我的入门教材

来源:互联网 发布:declare sql用法 编辑:程序博客网 时间:2024/05/04 11:34

using System;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web.UI.WebControls;


using MapInfo.Mapping;
using MapInfo.Styles;
using MapInfo.Data;
using MapInfo.Mapping.Thematics;
using MapInfo.Geometry;
using MapInfo.Mapping.Legends;
using MapInfo.Web.UI.WebControls;
using DataFactory;
//using CFunctions

namespace vlnmGIS2004
{
 /// <summary>
 /// Create By  : xiedengkevlnm.GIS
 /// Create Date:2005-11-12
 /// Discription:系统--业务层地图操作管理类
 /// Modified List
 /// The Map Functions Create By ZuoYi
 /// </summary>
 public class CMapFunctions:System.Web.UI.Page
 {
  CDataAccess dataAcc=new CDataAccess();
  SysCommon sysComm=new SysCommon();
  DataSet dsMap=new DataSet();

  private MapControl mapControl;

  public CMapFunctions(MapControl MapControl1)
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
   this.mapControl = MapControl1;
  }

  /// <summary>
  /// 选择图层上的区域对象
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  /// <param name="layName">可用于选择的图层名称</param>
  public void SelectedArea(string layName)
  {
   /*
   foreach (MapInfo.Mapping.IMapLayer layer in mapControl.Map.Layers)
   {
    if (layer==mapControl.Map.Layers[layName])
    {
     MapInfo.Mapping.LayerHelper.SetSelectable(layer,true);
     mapControl.SelectableLayers.Add(layName);
    }
    else
    {
     MapInfo.Mapping.LayerHelper.SetSelectable(layer,false);
     mapControl.SelectableLayers.Remove(layer);
    }
   }*/
   foreach (MapInfo.Mapping.IMapLayer layer in mapControl.Map.Layers)
   {
    MapInfo.Mapping.LayerHelper.SetSelectable(layer,false);
   }

   mapControl.SelectableLayers.Clear();

   MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers[layName],true);
  }
  public void UnSelectedAll()
  {
   foreach (MapInfo.Mapping.IMapLayer layer in mapControl.Map.Layers)
   {
    MapInfo.Mapping.LayerHelper.SetSelectable(layer,false);
   }

   mapControl.SelectableLayers.Clear();
  }

  /// <summary>
  /// 显示/隐藏指定的图层标注
  /// </summary>
  /// <param name="layName">可用于选择的图层名称</param>
  public void ShowLayerLabel(string layName,bool bShow)
  {
   MapInfo.Mapping.LabelLayer lly=null;
   foreach (MapInfo.Mapping.IMapLayer ly in mapControl.Map.Layers)
   {

    if(ly.Name == "Labels")
     lly = ly as MapInfo.Mapping.LabelLayer;
  
   }
   lly.Sources[layName].Enabled = bShow;
  }
  /// <summary>
  /// 隐藏所有标注
  /// </summary>
  public void HideAllLabel()
  {
   MapInfo.Mapping.LabelLayer lly=null;
   foreach (MapInfo.Mapping.IMapLayer ly in mapControl.Map.Layers)
   {

    if(ly.Name == "Labels")
     lly = ly as MapInfo.Mapping.LabelLayer;
  
   }
   for(int i=0 ;i<lly.Sources.Count;i++)
   {
    lly.Sources[i].Enabled = false;
   }
  }
  /// <summary>
  /// 隐藏所有图层
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  /// <param name="layName">可用于选择的图层名称</param>
  public void HideAllLayer()
  {
   foreach (MapInfo.Mapping.IMapLayer layer in mapControl.Map.Layers)
   {
    if (layer.Name!="Labels")
    {
     layer.Enabled=false;
     //ShowLayerLabel(mapControl,layer.Name,false);
    }
   }
  }
  private void AddBmpPointLayer(string layerName,string bmpName,DataTable dataTable)
  {
   AddBmpPointLayer( layerName, bmpName, dataTable,Color.Red);
  }

  /// <summary>
  /// 创建一个用图标表示数据库中点的图层
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  /// <param name="layerName">所要创建的图层名称</param>
  /// <param name="bmpName">用于表示数据点的图片</param>
  /// <param name="dataTable">绑定于图层的数据表</param>
  private void AddBmpPointLayer(string layerName,string bmpName,DataTable dataTable,System.Drawing.Color color)
  {
   foreach (MapInfo.Mapping.IMapLayer ly in mapControl.Map.Layers)
   {
    if (ly.Name==layerName)
    {
     mapControl.Map.Layers.Remove(layerName);
    }
   }

   if (dataTable.Rows.Count>0)
   {

    MapInfo.Data.TableInfoAdoNet ti=new MapInfo.Data.TableInfoAdoNet(layerName,dataTable);
                 
    MapInfo.Data.SpatialSchemaXY xy=new MapInfo.Data.SpatialSchemaXY();
    xy.CoordSys = mapControl.Map.GetDisplayCoordSys();
    //经纬度字段(特别指定lon,lat)
    xy.XColumn ="lon";
    xy.YColumn ="lat";
    ti.SpatialSchema = xy;
    MapInfo.Data.Table t = MapInfo.Engine.Session.Current.Catalog.GetTable(layerName);
    if(t!=null)
     t.Close();
    t =MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
    MapInfo.Mapping.FeatureLayer layer=new MapInfo.Mapping.FeatureLayer(t);
   
    mapControl.Map.Layers.Add(layer);
   
    MapInfo.Styles.BitmapPointStyle bitmappointstyle = new MapInfo.Styles.BitmapPointStyle(bmpName, MapInfo.Styles.BitmapStyles.None, new Color(),13);
    MapInfo.Mapping.FeatureLayer fl = (MapInfo.Mapping.FeatureLayer)mapControl.Map.Layers[layerName];// as FeatureLayer;
    MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,new MapInfo.Styles.CompositeStyle (bitmappointstyle));
    fl.Modifiers.Clear();
    fl.Modifiers.Append(fsm);

    mapControl.SelectableLayers.Add(layerName);

    //设定图层的标注
    MapInfo.Mapping.LabelLayer labelLayer = new MapInfo.Mapping.LabelLayer(layerName+ " Label", layerName+ " Label");
    labelLayer.Sources.Append(new MapInfo.Mapping.LabelSource(t));
   
    mapControl.Map.Layers.Add(labelLayer);

    MapInfo.Mapping.LabelSource source = labelLayer.Sources[0];
    source.DefaultLabelProperties.Layout.Offset = 3;
    source.DefaultLabelProperties.Layout.Alignment = MapInfo.Text.Alignment.BottomCenter;

    source.DefaultLabelProperties.Style.Font.Size = 9;
    source.DefaultLabelProperties.Style.Font.FontWeight = FontWeight.Bold;
    source.DefaultLabelProperties.Style.Font.ForeColor = color;
    source.DefaultLabelProperties.Style.Font.TextEffect = TextEffect.Halo;

    //SelectedArea(layerName);
    
    MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers[layerName],true);

   }
  }
  private void  DrawSector(MapInfo.Data.Table table,double x,double y,int middle,int angle,double radius)
  {
   string[] colorGIS=DataFactory.SysCommon.strGisSectorColor.Split(',');
   System.Drawing.Color color =Color.FromArgb(Convert.ToInt32(colorGIS[0]),Convert.ToInt32(colorGIS[1]),Convert.ToInt32(colorGIS[2]));
   DrawSector(table, x, y, middle, angle, radius,color);
  }
  /// <summary>
  /// 绘制小区的覆盖扇区
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  /// <param name="table"></param>
  /// <param name="x">原点横坐标</param>
  /// <param name="y">原点纵坐标</param>
  /// <param name="middle">方向角</param>
  /// <param name="angle">水平瓣宽</param>
  /// <param name="radius">扇形半径</param>
  private void  DrawSector(MapInfo.Data.Table table,double x,double y,int middle,int angle,double radius,System.Drawing.Color color)
  {
   if((angle == 0) ||(radius == 0))
    return;
   MapInfo.Geometry.DPoint center = new MapInfo.Geometry.DPoint(x, y);

   MapInfo.Geometry.LegacyArc sector =new LegacyArc(mapControl.Map.GetDisplayCoordSys(),center,radius,radius,
    MapInfo.Geometry.DistanceUnit.Kilometer, MapInfo.Geometry.DistanceType.Spherical,middle-angle/2,middle+angle/2);
   
   MultiCurve mc = sector.CreateMultiCurve(100);

   MapInfo.Geometry.DPoint[] tmpPoints = mc[0][0].SamplePoints();
   
   MapInfo.Geometry.DPoint[] dPoints = new MapInfo.Geometry.DPoint[3] ;
   dPoints[0] = mc[0].EndPoint;
   dPoints[1] = new MapInfo.Geometry.DPoint(x,y);
   dPoints[2] = mc[0].StartPoint;

   MapInfo.Geometry.DPoint[] mPoints = new MapInfo.Geometry.DPoint[tmpPoints.Length - 1+3] ;
   for(int i=0,j=0;i<tmpPoints.Length - 1+3;i++)
   {
    if(i<tmpPoints.Length - 1)
     mPoints[i]=tmpPoints[i];
    else
     mPoints[i]=dPoints[j++];
   }
   

   MapInfo.Geometry.MultiPolygon  mp = new MultiPolygon(mapControl.Map.GetDisplayCoordSys(),CurveSegmentType.Linear,mPoints);
   mp.EditingComplete();

   MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle();

   cs.GridStyle.DisplayHillshade=true;
   (cs.LineStyle as MapInfo.Styles.SimpleLineStyle).Color=Color.FromArgb(255,0,0);
   
   (cs.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Pattern=2;
   //(cs.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor =Color.FromArgb(176,255,176);
   string[] colorGIS=DataFactory.SysCommon.strGisSectorColor.Split(',');
   (cs.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor =color;

   MapInfo.Data.Feature f = new MapInfo.Data.Feature(mp, cs);

   table.InsertFeature(f);

  }
  private void ShowCell(String cellName)
  {
   ShowCell(cellName,true);
  }
  private void ShowCell(String cellName,bool bSetView)
  {
   string[] colorGIS=DataFactory.SysCommon.strGisSectorColor.Split(',');
   System.Drawing.Color color =Color.FromArgb(Convert.ToInt32(colorGIS[0]),Convert.ToInt32(colorGIS[1]),Convert.ToInt32(colorGIS[2]));
   ShowCell(cellName,true,bSetView,color);
  }
  /// <summary>
  /// 显示小区的覆盖范围
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  /// <param name="CELLNAME">小区名</param>
  private void ShowCell(String cellName,bool bNew,bool bSetView,System.Drawing.Color color)
  {
   System.Data.DataTable sourceDataTable = new System.Data.DataTable("SourceData");
   string sql = "select CELL_DIR 方向角,SECTOR_ANGLE 水平瓣宽,MAX_CELL_RADIUS Distince,LONGITUDE_GIS LONGITUDE,LATITUDE_GIS LATITUDE from ptnmc.V_CELL_AREA where CELL_CHN = '"+cellName+"' or CELL_CHN in (select CELL_CHN from ptnmc.CELL_CONFIG where RSITE_CHN = '"+cellName+"')";
   sourceDataTable=dataAcc.DataCollect(sql,sysComm.SysDBConnStr()).Tables[0];
   int middle,angle;
   double x,y,radius;

   if (sourceDataTable != null)
   {
    if (sourceDataTable.Rows.Count > 0)
    {
     MapInfo.Data.TableInfo ti;
     MapInfo.Data.Table table;

   
     table = MapInfo.Engine.Session.Current.Catalog.GetTable("TEMP");

     if(table!=null)
     {
      if(bNew)
      {
       table.Close();
       ti = MapInfo.Data.TableInfoFactory.CreateTemp("TEMP");
       table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
      }
     }
     else
     {
      bNew = true;
      ti = MapInfo.Data.TableInfoFactory.CreateTemp("TEMP");
      table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
     }
   


     for (int i=0;i<sourceDataTable.Rows.Count;i++)
     {
      middle = int.Parse(sourceDataTable.Rows[i]["方向角"].ToString());
      angle = int.Parse(sourceDataTable.Rows[i]["水平瓣宽"].ToString());
      radius = double.Parse(sourceDataTable.Rows[i]["Distince"].ToString());
      x = double.Parse(sourceDataTable.Rows[i]["LONGITUDE"].ToString());
      y = double.Parse(sourceDataTable.Rows[i]["LATITUDE"].ToString());
      DrawSector(table,x, y, middle, angle, radius,color);
     }

     //mapControl.Map.Clear();
     FeatureLayer fl = new FeatureLayer(table);

     if(!mapControl.Map.Layers.Contains(fl))
      mapControl.Map.Layers.Insert(2,fl);
     if(bSetView)
     {
      mapControl.Map.SetView(fl);
     }
    }
   }
   
   sourceDataTable = null;
   

  }

  public void MoveTop(string strLayerName)
  {
   int nFrom = 0;
   for(int i = 0;i< mapControl.Map.Layers.Count;i++)
   {
    if(mapControl.Map.Layers[i] == mapControl.Map.Layers[strLayerName])
    {
     nFrom = i;
     break;
    }
   }
   mapControl.Map.Layers.Move(nFrom, 0);
  }

  public void MoveBottom(string strLayerName)
  {
   int nFrom = 0;
   for(int i = 0;i< mapControl.Map.Layers.Count;i++)
   {
    if(mapControl.Map.Layers[i] == mapControl.Map.Layers[strLayerName])
    {
     nFrom = i;
     break;
    }
   }
   mapControl.Map.Layers.Move(nFrom, mapControl.Map.Layers.Count-1 );
  }

  

  /**////
  /// 设置层的透明与否
  ///
  /// 层名
  /// 不透明类型 ALL 全部不透明 BORDER 只有边界不透明(内部透明)NONE 全部透明
   /// 如果是边界不透明,此处设置边界颜色
   public void LayerTransparent(string layerName,System.Drawing.Color borderColor)
   {

    MapInfo.Styles.SimpleInterior simpleInterior = new MapInfo.Styles.SimpleInterior(1); //0是线透明,1是面透明
    MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
    MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth,2,borderColor);
    MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle,simpleInterior);
    MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle,null,null,null);

    MapInfo.Mapping.FeatureLayer fl = (MapInfo.Mapping.FeatureLayer)mapControl.Map.Layers[layerName];// as FeatureLayer;
    MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle);
    fl.Modifiers.Clear();
    fl.Modifiers.Append(fsm);

/*
    //创建连接和命令来更新table中的数据
    MapInfo.Data.MIConnection connection=new MapInfo.Data.MIConnection();
    connection.Open();
    MapInfo.Data.MICommand command=connection.CreateCommand();
    //command.CommandText = "update " + layerName + " set obj=obj,MI_Style=@style";
    command.CommandText = "update " + layerName + " set MI_Style=@style";
    command.Parameters.Add("@style",compositeStyle);
    command.Prepare();
    command.ExecuteNonQuery();

    //关闭连接
    command.Cancel();
    command.Dispose();
    connection.Close();
    connection.Dispose();
    */
   }
  
  public void ShowArea()
  {
   
    mapControl.Map.Layers["AREA"].Enabled = true;
    LayerTransparent("AREA",Color.DarkTurquoise);
    this.ShowLayerLabel("AREA",true);
    MoveBottom("AREA");
   
  }

  /// <summary>
  /// 韶关基站拨侧系统
  /// </summary>
  public void GEO_SG_CELL_BC(string BSNAME,System.Web.UI.WebControls.DropDownList ddlSite)
  {
   String sqlstr;
   //sqlstr ="select distinct CELL_CHN as name,convert(decimal(9,6),LONGITUDE_GIS) AS lon,convert(decimal(9,6),LATITUDE_GIS) as lat ,1 AlarmLevel from ptnmc.CELL_CONFIG WHERE CELL_CHN in (select stationname_c from ptnmc.MYSQL_groupstation) and ISNULL(LONGITUDE_GIS,'')<>'' ";
   sqlstr = "select distinct RSITE_CHN as name,convert(decimal(9,6),LONGITUDE_GIS) AS lon,convert(decimal(9,6),LATITUDE_GIS) as lat , "+
"b.MOS AlarmLevel from ptnmc.CELL_CONFIG a,ptnmc.V_MYSQL_dialup_result b "+
"WHERE a.RSITE_CHN like '%'+rtrim(ltrim(b.groupstationname)) + '%' and ISNULL(LONGITUDE_GIS,'')<>'' and rtrim(ltrim(b.groupstationname)) <> ''";
   
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   
   AddBmpPointLayer("MySGCELL","TOWE1-bg.bmp",dsMap.Tables[0]);


   

   for(int i=0;i<dsMap.Tables[0].Rows.Count;i++)
   {
    string strCELLNAME = dsMap.Tables[0].Rows[i]["name"].ToString();
    string strMOS = dsMap.Tables[0].Rows[i]["AlarmLevel"].ToString();

    System.Drawing.Color color = Color.FromArgb(0,130,0);
    if(strMOS == "0")
     color = Color.FromArgb(255,0,0);
    if(strMOS == "1")
     color = Color.FromArgb(255,148,40);
    if(strMOS == "2")
     color = Color.FromArgb(255,255,0);
    if(strMOS == "3")
     color = Color.FromArgb(229,255,0);
    if(strMOS == "4")
     color = Color.FromArgb(30,225,0);
    

    ShowCell(strCELLNAME,false,false,color);
   }

   if(BSNAME != "") //小区定位
   {
    //ShowCell(Name);
    string sef = "name = '"+BSNAME+"'";
    QueryFilter filter = new SqlExpressionFilter(sef);
    QueryDefinition qd = new QueryDefinition(filter, "*");
    SearchInfo si = new SearchInfo(null, qd);

    MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable("MySGCELL");
   
    IResultSetFeatureCollection fc = null;
    if(table!=null)
    {
     fc = MapInfo.Engine.Session.Current.Catalog.Search(table, si);
    }
    if(fc.Count>0)
    {
     mapControl.Map.SetView(fc[0].Geometry.GeometricCentroid,mapControl.Map.GetDisplayCoordSys(),new MapInfo.Geometry.Distance(3,DistanceUnit.Kilometer));
     MapInfo.Data.Table table1 = MapInfo.Engine.Session.Current.Catalog.GetTable("TEMP");
     FeatureLayer fl = new FeatureLayer(table1);
     mapControl.Map.Layers.Insert(2,fl);
    }

   }


   //sqlstr = "select distinct CELL_CHN as name from ptnmc.CELL_CONFIG a,ptnmc.V_MYSQL_dialup_result b WHERE a.CELL_CHN = b.groupstationname and ISNULL(LONGITUDE_GIS,'')<>'' ";
   sqlstr = "select distinct RSITE_CHN as name from ptnmc.CELL_CONFIG a,ptnmc.V_MYSQL_dialup_result b "+
    "WHERE a.RSITE_CHN like '%'+rtrim(ltrim(b.groupstationname)) + '%' and ISNULL(LONGITUDE_GIS,'')<>'' and rtrim(ltrim(b.groupstationname)) <> ''";

   DataSet ds = dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   CFunctions.setItems(ddlSite,ds,"name");
   ddlSite.Items.Insert(0,new ListItem("",""));
   if (BSNAME.Length>0)
    CFunctions.FindDropdownIndex(ddlSite,BSNAME,true);

   
  }

  /// <summary>
  /// 资源呈现-交换-BSC
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  public void GEO_BSC()
  {
   HideAllLayer();
   HideAllLabel();
   UnSelectedAll();
   mapControl.Map.Layers["BSC"].Enabled = true;
   //MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["BSC"],true);
   SelectedArea("BSC");
   ShowLayerLabel("BSC",true);

   if(SysCommon.strAddr == "DG")
   {
    //ShowArea();
    mapControl.Map.Layers["AREA"].Enabled = true;
    ShowLayerLabel("AREA",true);

    MapInfo.Styles.SimpleInterior simpleInterior = new MapInfo.Styles.SimpleInterior(1); //0是线透明,1是面透明
    MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
    MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth,2,Color.Black);
    MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle,simpleInterior);
    MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle,null,null,null);

    MapInfo.Mapping.FeatureLayer fl = (MapInfo.Mapping.FeatureLayer)mapControl.Map.Layers["BSC"];// as FeatureLayer;
    MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle);
    fl.Modifiers.Clear();
    fl.Modifiers.Append(fsm);

    MapInfo.Mapping.LabelLayer lly=null;
    foreach (MapInfo.Mapping.IMapLayer ly in mapControl.Map.Layers)
    {

     if(ly.Name == "Labels")
      lly = ly as MapInfo.Mapping.LabelLayer;
  
    }
    lly.Sources["BSC"].DefaultLabelProperties.Visibility.AllowOverlap = true;
    lly.Sources["AREA"].DefaultLabelProperties.Visibility.AllowOverlap = true;


   }
   if(SysCommon.strAddr == "ZS")
   {
    //ShowArea();
    mapControl.Map.Layers["Area"].Enabled = true;
   }
  }
  /// <summary>
  /// 资源呈现-交换-MSC
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  public void GEO_MSC()
  {
   HideAllLabel();
   HideAllLayer();
   UnSelectedAll();
   //mapControl.Map.Layers.Remove("BSC");

   /*
   
   */
   mapControl.Map.Layers["MSC"].Enabled = true;
   //MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["MSC"],true);
   SelectedArea("MSC");
   ShowLayerLabel("MSC",true);

   if(SysCommon.strAddr == "DG")
   {
    //ShowArea();
    mapControl.Map.Layers["AREA"].Enabled = true;

    mapControl.Map.Layers["AREA"].Enabled = true;
    ShowLayerLabel("AREA",true);

    MapInfo.Styles.SimpleInterior simpleInterior = new MapInfo.Styles.SimpleInterior(1); //0是线透明,1是面透明
    MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
    MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth,2,Color.Black);
    MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle,simpleInterior);
    MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle,null,null,null);

    MapInfo.Mapping.FeatureLayer fl = (MapInfo.Mapping.FeatureLayer)mapControl.Map.Layers["MSC"];// as FeatureLayer;
    MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle);
    fl.Modifiers.Clear();
    fl.Modifiers.Append(fsm);

    MapInfo.Mapping.LabelLayer lly=null;
    foreach (MapInfo.Mapping.IMapLayer ly in mapControl.Map.Layers)
    {

     if(ly.Name == "Labels")
      lly = ly as MapInfo.Mapping.LabelLayer;
  
    }
    lly.Sources["MSC"].DefaultLabelProperties.Visibility.AllowOverlap = true;
    lly.Sources["AREA"].DefaultLabelProperties.Visibility.AllowOverlap = true;
   }
   if(SysCommon.strAddr == "ZS")
   {
    //ShowArea();
    mapControl.Map.Layers["Area"].Enabled = true;
   }
  }

  /// <summary>
  /// 资源呈现-无线-VIP小区
  /// </summary>
  /// <param name="Name" >要定位的小区名,传入空值表示查所有</param>
  public void GEO_CELL_VIP(string Name)
  {
   String sqlstr;

   if(SysCommon.strAddr == "HZ")
   {
    sqlstr ="select distinct CELL_CHN as name,convert(decimal(9,6),LONGITUDE_GIS) AS lon,convert(decimal(9,6),LATITUDE_GIS) as lat ,PROSP AlarmLevel from ptnmc.CELL_CONFIG WHERE (PROSP = 1) and ISNULL(LONGITUDE_GIS,'')<>'' ";
   }
   else
   {
    //sqlstr ="select distinct CELL_CHN as name,convert(decimal(9,6),LONGITUDE_GIS) AS lon,convert(decimal(9,6),LATITUDE_GIS) as lat ,PROSP AlarmLevel from ptnmc.CELL_CONFIG WHERE (PROSP is not NULL or CELL_CHN = '"+Name+"') and ISNULL(LONGITUDE_GIS,'')<>'' ";
    //sqlstr ="select distinct CELL_CHN as name,convert(decimal(9,6),LONGITUDE_GIS) AS lon,convert(decimal(9,6),LATITUDE_GIS) as lat ,PROSP AlarmLevel from ptnmc.CELL_CONFIG WHERE (PROSP is not NULL) and ISNULL(LONGITUDE_GIS,'')<>'' ";
    sqlstr="select distinct CELL_CHN as name,convert(decimal(9,6),LONGITUDE_GIS) AS lon,convert(decimal(9,6),LATITUDE_GIS) as lat ,PROSP AlarmLevel from ptnmc.CELL_CONFIG WHERE (PROSP is not NULL) and ISNULL(LONGITUDE_GIS,'')<>''";
   }
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   
   AddBmpPointLayer("MyVIP","TOWE1-bg.bmp",dsMap.Tables[0]);

   if(Name != "") //小区定位
   {

    //ShowCell(Name);
    
    string sef = "name = '"+Name+"'";

    QueryFilter filter = new SqlExpressionFilter(sef);
    QueryDefinition qd = new QueryDefinition(filter, "*");
    SearchInfo si = new SearchInfo(null, qd);

    MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable("MyVIP");
   
    if(table!=null)
    {
     IResultSetFeatureCollection fc = MapInfo.Engine.Session.Current.Catalog.Search(table, si);
    
     if(fc.Count>0)
      ShowCell(Name);
    }
    /*
    if(fc.Envelope!=null)
    {
     mapControl.Map.SetView(fc.Envelope);
     mapControl.Map.Zoom=new MapInfo.Geometry.Distance(2,DistanceUnit.Kilometer);
    }*/

   }
   
   //ShowDetial(mapControl);
  }

  /// <summary>
  /// 告警呈现-交换-BSC
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  public void GEO_BSC_ERROR()
  {
   HideAllLabel();
   HideAllLayer();
   UnSelectedAll();
   mapControl.Map.Layers["BSC"].Enabled = true;
   MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["BSC"],true);
   ShowLayerLabel("BSC",true);

   SelectedArea("BSC");

   String sqlstr;
   sqlstr ="select distinct CONVERT(int,ALARM_LEVEL) from ptnmc.V_COVER where NAME like '%BSC%'";
   DataSet ds = dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   //无需绑定图层
   if(ds.Tables[0].Rows.Count==1)
   {
    if(SysCommon.strAddr == "DG")
    {
     //ShowArea();
     mapControl.Map.Layers["AREA"].Enabled = true;

     mapControl.Map.Layers["AREA"].Enabled = true;
     ShowLayerLabel("AREA",true);

     MapInfo.Styles.SimpleInterior simpleInterior = new MapInfo.Styles.SimpleInterior(1); //0是线透明,1是面透明
     MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
     MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth,2,Color.Black);
     MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle,simpleInterior);
     MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle,null,null,null);

     MapInfo.Mapping.FeatureLayer flbsc = (MapInfo.Mapping.FeatureLayer)mapControl.Map.Layers["BSC"];// as FeatureLayer;
     MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle);
     flbsc.Modifiers.Clear();
     flbsc.Modifiers.Append(fsm);

     MapInfo.Mapping.LabelLayer lly=null;
     foreach (MapInfo.Mapping.IMapLayer ly in mapControl.Map.Layers)
     {

      if(ly.Name == "Labels")
       lly = ly as MapInfo.Mapping.LabelLayer;
  
     }
     lly.Sources["BSC"].DefaultLabelProperties.Visibility.AllowOverlap = true;
     lly.Sources["AREA"].DefaultLabelProperties.Visibility.AllowOverlap = true;
    }
    return;
   }
   
   
 
   //数据绑定
   
   sqlstr ="select name,CONVERT(int,ALARM_LEVEL) as  VALUE from ptnmc.V_COVER where NAME like '%BSC%' order by CONVERT(int,ALARM_LEVEL)";

   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   MapInfo.Mapping.FeatureLayer fl = mapControl.Map.Layers["BSC"] as MapInfo.Mapping.FeatureLayer;
   //fl.Modifiers.Clear();

   MapInfo.Data.Table bindTable = MapInfo.Engine.Session.Current.Catalog.GetTable("BSC");

   MapInfo.Data.TableInfoAdoNet ti = new MapInfo.Data.TableInfoAdoNet("SourceData", dsMap.Tables[0]);
   MapInfo.Data.Table sourceTable  = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
    
   MapInfo.Data.Columns columns = new MapInfo.Data.Columns();
   columns.Add(new MapInfo.Data.Column("TCH", MapInfo.Data.MIDbType.Double, "VALUE"));
  
   bindTable.AddColumns(columns, MapInfo.Data.BindType.Static, sourceTable, "UPPER(NAME)", MapInfo.Data.Operator.Equal, "UPPER(NAME)");
   
   sourceTable.Close();

   //MapInfo.Mapping.FeatureLayer lyr = (MapInfo.Mapping.FeatureLayer) mapControl.MapExport.Map.Layers["BSC"]; 
   MapInfo.Mapping.FeatureLayer lyr = (MapInfo.Mapping.FeatureLayer) mapControl.Map.Layers["BSC"]; 
   MapInfo.Mapping.Thematics.IndividualValueTheme itheme = new IndividualValueTheme(lyr,"TCH","thmValue");
           
   lyr.Modifiers.Clear();
   lyr.Modifiers.Append(itheme);
   
   (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
   (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;


   if(SysCommon.strAddr == "DG")
   {
   
    //(itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
    (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
    (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Pattern =1;


    (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
    (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Pattern  = 2;

   
    for(int i=0;i<itheme.Bins.Count;i++)
    {
     (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).BackColor = Color.Transparent;
     (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
     (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Transparent = true;
    }

    MapInfo.Styles.SimpleInterior simpleInterior = new MapInfo.Styles.SimpleInterior(1,Color.Red,Color.Transparent,true);
    MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
    MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth);
    MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle,simpleInterior);
    MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle,null,null,null);
    MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle);
 
    lyr.Modifiers.Append(fsm);


    mapControl.Map.Layers["AREA"].Enabled = true;
    ShowLayerLabel("AREA",true);

    MapInfo.Mapping.LabelLayer lly=null;
    foreach (MapInfo.Mapping.IMapLayer ly in mapControl.Map.Layers)
    {

     if(ly.Name == "Labels")
      lly = ly as MapInfo.Mapping.LabelLayer;
  
    }
    lly.Sources["BSC"].DefaultLabelProperties.Visibility.AllowOverlap = true;
    lly.Sources["AREA"].DefaultLabelProperties.Visibility.AllowOverlap = true;


   }
  }
  /// <summary>
  /// 告警呈现-交换-MSC
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  public void GEO_MSC_ERROR()
  {
   HideAllLayer();
   HideAllLabel();
   //UnSelectedAll();
   mapControl.Map.Layers["MSC"].Enabled = true;
   MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["MSC"],true);
   ShowLayerLabel("MSC",true);
   SelectedArea("MSC");

   if(SysCommon.strAddr == "DG")
   {
    //ShowArea();
    mapControl.Map.Layers["AREA"].Enabled = true;
   }

   String sqlstr;
   sqlstr ="select distinct CONVERT(int,ALARM_LEVEL) from ptnmc.V_COVER where NAME like '%MSC%'";
   DataSet ds = dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   //无需绑定图层
   if(ds.Tables[0].Rows.Count==1)
   {
    if(SysCommon.strAddr == "DG")
    {
     //ShowArea();
     mapControl.Map.Layers["AREA"].Enabled = true;

     mapControl.Map.Layers["AREA"].Enabled = true;
     ShowLayerLabel("AREA",true);

     MapInfo.Styles.SimpleInterior simpleInterior = new MapInfo.Styles.SimpleInterior(1); //0是线透明,1是面透明
     MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
     MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth,2,Color.Black);
     MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle,simpleInterior);
     MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle,null,null,null);

     MapInfo.Mapping.FeatureLayer flmsc = (MapInfo.Mapping.FeatureLayer)mapControl.Map.Layers["MSC"];// as FeatureLayer;
     MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle);
     flmsc.Modifiers.Clear();
     flmsc.Modifiers.Append(fsm);

     MapInfo.Mapping.LabelLayer lly=null;
     foreach (MapInfo.Mapping.IMapLayer ly in mapControl.Map.Layers)
     {

      if(ly.Name == "Labels")
       lly = ly as MapInfo.Mapping.LabelLayer;
  
     }
     lly.Sources["MSC"].DefaultLabelProperties.Visibility.AllowOverlap = true;
     lly.Sources["AREA"].DefaultLabelProperties.Visibility.AllowOverlap = true;
    }
    return;
   }

   MapInfo.Mapping.FeatureLayer fl = mapControl.Map.Layers["MSC"] as MapInfo.Mapping.FeatureLayer;
   fl.Modifiers.Clear();
   
   //数据绑定
   sqlstr ="select name,CONVERT(int,ALARM_LEVEL) as  VALUE from ptnmc.V_COVER where NAME like '%MSC%' union select 'TEMP',1 order by CONVERT(int,ALARM_LEVEL)";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   MapInfo.Data.Table bindTable = MapInfo.Engine.Session.Current.Catalog.GetTable("MSC");

   MapInfo.Data.TableInfoAdoNet ti = new MapInfo.Data.TableInfoAdoNet("SourceData", dsMap.Tables[0]);
   MapInfo.Data.Table sourceTable  = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
    
   MapInfo.Data.Columns columns = new MapInfo.Data.Columns();
   columns.Add(new MapInfo.Data.Column("TCH", MapInfo.Data.MIDbType.Int, "VALUE"));

   bool rlt = bindTable.AddColumns(columns, MapInfo.Data.BindType.Static, sourceTable, "UPPER(NAME)", MapInfo.Data.Operator.Equal, "UPPER(NAME)");
   sourceTable.Close();

   MapInfo.Mapping.Thematics.IndividualValueTheme itheme;
   MapInfo.Mapping.FeatureLayer lyr;
   if(rlt)
   {
    lyr = (MapInfo.Mapping.FeatureLayer) mapControl.MapExport.Map.Layers["MSC"]; 
    //MapInfo.Mapping.Thematics.RangedTheme itheme = new MapInfo.Mapping.Thematics.RangedTheme(lyr, "TCH","thmscValue", 3, MapInfo.Mapping.Thematics.DistributionMethod.EqualRangeSize);
    itheme = new IndividualValueTheme(lyr,"TCH","thmmscValue");
           
    lyr.Modifiers.Clear();
    lyr.Modifiers.Append(itheme);
   
    //itheme.Bins[0].Style.SymbolStyle.Color = Color.Green;
    //itheme.Bins[itheme.Bins.Count-1].Style.SymbolStyle.Color = Color.DarkGreen;
    (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
    (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
    /*
    itheme.SpreadBy = MapInfo.Mapping.Thematics.SpreadByPart.Color;
    itheme.ColorSpreadBy =  MapInfo.Mapping.Thematics.ColorSpreadMethod.Rgb;
    itheme.RecomputeStyles();
    */

    if(SysCommon.strAddr == "DG")
    {
   
     //(itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
     (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
     (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Pattern =1;


     (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
     (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Pattern  = 2;

   
     for(int i=0;i<itheme.Bins.Count;i++)
     {
      (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).BackColor = Color.Transparent;
      (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
      (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Transparent = true;
     }

     MapInfo.Styles.SimpleInterior simpleInterior = new MapInfo.Styles.SimpleInterior(1,Color.Red,Color.Transparent,true);
     MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
     MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth);
     MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle,simpleInterior);
     MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle,null,null,null);
     MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle);
 
     lyr.Modifiers.Append(fsm);


     mapControl.Map.Layers["AREA"].Enabled = true;
     ShowLayerLabel("AREA",true);

     MapInfo.Mapping.LabelLayer lly=null;
     foreach (MapInfo.Mapping.IMapLayer ly in mapControl.Map.Layers)
     {

      if(ly.Name == "Labels")
       lly = ly as MapInfo.Mapping.LabelLayer;
  
     }
     lly.Sources["MSC"].DefaultLabelProperties.Visibility.AllowOverlap = true;
     lly.Sources["AREA"].DefaultLabelProperties.Visibility.AllowOverlap = true;


    }
   }

   
  }

  private void GEO_EXT_ALARM_HELPER(string LayerName,string AlarmTitle,string BMP,bool isOnlyHandle)
  {
   string sqlstr = "";
   if (!isOnlyHandle)
       sqlstr="select distinct a.RSITE_CHN AS name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,a.TITLE_NAME1 as AlarmLevel " +
     "from ptnmc.V_APP_ALARM_RSITE_EXTERNAL a,ptnmc.CELL_CONFIG b where a.RSITE_CHN=b.RSITE_CHN " +
     "and ISNULL(LONGITUDE_GIS,'')<>'' and TITLE_NAME1='"+AlarmTitle+"'"; 
   else
    sqlstr="select distinct a.RSITE_CHN AS name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,a.TITLE_NAME1 as AlarmLevel " +
     "from ptnmc.V_APP_ALARM_RSITE_EXTERNAL a,ptnmc.CELL_CONFIG b where a.RSITE_CHN=b.RSITE_CHN " +
     "and ISNULL(LONGITUDE_GIS,'')<>'' and a.TROUBLE_SIGN = 3 and TITLE_NAME1='"+AlarmTitle+"'";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer(LayerName,BMP,dsMap.Tables[0],Color.Blue);
  }

  private void GEO_EXT_ALARM_HELPER(string LayerName,string AlarmTitle,string BMP)
  {
   string sqlstr="select distinct a.RSITE_CHN AS name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,a.TITLE_NAME1 as AlarmLevel from ptnmc.V_APP_ALARM_RSITE_EXTERNAL a,ptnmc.CELL_CONFIG b where a.RSITE_CHN=b.RSITE_CHN and ISNULL(LONGITUDE_GIS,'')<>'' and TITLE_NAME1='"+AlarmTitle+"'"; 
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer(LayerName,BMP,dsMap.Tables[0],Color.Blue);
  }

  private void GEO_PER_ALARM_HELPER(string LayerName,string AlarmTitle,string BMP,Color color)
  {
   string sqlstr="select a.rsite_chn as name,a.longitude_gis as lon,a.latitude_gis as lat,b.type_name AlarmLevel from  ptnmc.CELL_CONFIG as a,ptnmc.V_APP_ALARM_PF as b where a.cell =b.cell and b.cell <>'' and longitude_gis<>'' and TYPE_NAME='"+AlarmTitle+"'";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer(LayerName,BMP,dsMap.Tables[0],color);
  }
  private void GEO_PER_ALARM_HELPER(string LayerName,string AlarmTitle,string BMP)
  {
   GEO_PER_ALARM_HELPER( LayerName ,AlarmTitle, BMP,Color.Purple);
  }

  private void GEO_CUT_HELPER(string LayerName,string AlarmTitle,string BMP)
  {
   //string sqlstr="select a.rsite_chn as name,a.longitude_gis as lon,a.latitude_gis as lat,b.type_name AlarmLevel from ptnmc.CELL_CONFIG as a,ptnmc.V_APP_ALARM_PF as b where a.cell =b.cell and b.cell <>'' and longitude_gis<>'' and TYPE_NAME='"+AlarmTitle+"'";
   string sqlstr="select basename as name,lon,lat,TROUBLE_SIGN AlarmLevel  from ptnmc.V_APP_ALARM_OTHER_FAIL where TROUBLE_SIGN='"+AlarmTitle+"'";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer(LayerName,BMP,dsMap.Tables[0]);
  }
  /// <summary>
  /// 告警呈现-无线-基站外告
  /// </summary>
  /// <param name="Name" >要定位的小区名,传入空值表示查所有</param>
  public string GEO_EXT_ALARM(string Name,System.Web.UI.WebControls.DropDownList ddlSite)
  {
   UnSelectedAll();
   GEO_EXT_ALARM_HELPER("MyBaseSite_POWER","电源告警",  "主电.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_HAND","手工上载",  "湿度高.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_HUMIDITY","湿度告警",  "湿度高.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_LOW","电压告警",  "低压.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_GATE","门禁告警",  "门碰.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_WATER","水浸告警",  "水浸.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_FIRE","防火告警",  "火警.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_CB_OPEN","CB_OPEN",  "湿度高.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_TINE_FAILURE", "TUNE FAILURE", "整流器.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_LIGHT","灯光告警",  "低压.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_HOT","高温告警",  "温度高.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_LEIJI","雷击告警",  "CAUT1-32.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_WEIHU","维护告警",  "CAUT1-32.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_NTMONITOR","小区逻辑信道可用性监视告警","CAUT1-32.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_CITYPOWER","市电告警",  "CAUT1-32.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_EXTERNAL","EXTERNAL ALARM",  "主电.bmp");

   string strAlarmTitles = "'电源告警','手工上载','湿度告警','电压告警','门禁告警','水浸告警','防火告警','CB_OPEN','TUNE FAILURE',"+
         "'灯光告警','高温告警','雷击告警','维护告警','小区逻辑信道可用性监视告警','市电告警','EXTERNAL ALARM'";


   if(Name != "") //小区定位
   {
    string sef = "name = '"+Name+"'";

    MapInfo.Data.QueryFilter filter = new MapInfo.Data.SqlExpressionFilter(sef);
    MapInfo.Data.QueryDefinition qd = new MapInfo.Data.QueryDefinition(filter, "*");
    MapInfo.Data.SearchInfo si = new MapInfo.Data.SearchInfo(null, qd);

    IResultSetFeatureCollection fc=null;
    string[] arrLayer=new string[] {"MyBaseSite_POWER","MyBaseSite_HAND","MyBaseSite_HUMIDITY","MyBaseSite_LOW","MyBaseSite_GATE","MyBaseSite_WATER","MyBaseSite_FIRE","MyBaseSite_CB_OPEN","MyBaseSite_TINE_FAILURE","MyBaseSite_LIGHT","MyBaseSite_HOT","MyBaseSite_LEIJI","MyBaseSite_WEIHU","MyBaseSite_NTMONITOR","MyBaseSite_CITYPOWER","MyBaseSite_EXTERNAL"};
    for (int i=0;i<arrLayer.Length;i++)
    {
     if (MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i])!=null)
     {
      fc=MapInfo.Engine.Session.Current.Catalog.Search(MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i]), si);
     }
     if (fc!=null)
     {
      if (fc.Count!=0)
       break;
     }
    }
    if(fc.Envelope!=null)
    {
     mapControl.Map.SetView(fc.Envelope);
     mapControl.Map.Zoom=new MapInfo.Geometry.Distance(3,DistanceUnit.Kilometer);
    }
   }
   
   //ShowDetial(mapControl);

   //string sqlstr = "select distinct a.RSITE_CHN from ptnmc.V_APP_ALARM_RSITE_EXTERNAL a,ptnmc.CELL_CONFIG b where a.RSITE_CHN=b.RSITE_CHN and ISNULL(LONGITUDE_GIS,'')<>'' and a.TITLE_NAME in(select distinct TITLE_NAME1 from ptnmc.CONFIG_ALARM_TITLE1)";
   string sqlstr = "select distinct a.RSITE_CHN from ptnmc.V_APP_ALARM_RSITE_EXTERNAL a,ptnmc.CELL_CONFIG b where a.RSITE_CHN=b.RSITE_CHN and ISNULL(LONGITUDE_GIS,'')<>'' and a.TITLE_NAME1 in("+strAlarmTitles+")";
   
   if(dsMap!=null)
    dsMap.Clear();
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   CFunctions.setItems(ddlSite,dsMap,"RSITE_CHN");
   ddlSite.Items.Insert(0,new ListItem("",""));
   if (Name.Length>0)
    CFunctions.FindDropdownIndex(ddlSite,Name,true);
   
   /*
   sqlstr = "select count(distinct RSITE_CHN) as cn from ptnmc.V_APP_ALARM_RSITE_EXTERNAL where TITLE_NAME1 in("+strAlarmTitles+")";
   dsMap.Clear();
   dsMap = new DataSet();
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   int total = (int)dsMap.Tables[0].Rows[0][0];
   */
   int total = dsMap.Tables[0].Rows.Count;
   string msg = "目前全网共有"+total+"个基站有外告";
   /*
   dsMap.Clear();
   dsMap = new DataSet();
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   total = (int)dsMap.Tables[0].Rows[0][0];
   */

//   if(total>0)
//    msg = msg + ",有"+total+"个基站出现电源告警";


   //msg = "";
   return msg;
   
  }
  public void GEO_HIDE_ALL_CELL()
  {
   if(this.mapControl.Map.Layers["ALL_CELL"]!=null)
   {
    this.mapControl.Map.Layers["ALL_CELL"].Enabled = false;
   }
  }
  public void GEO_SHOW_ALL_CELL()
  {
   if(this.mapControl.Map.Layers["ALL_CELL"]!=null)
   {
    this.mapControl.Map.Layers["ALL_CELL"].Enabled = true;
    return;
   }

   string sqlstr="select distinct a.CELL_CHN as name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,'小区全阻' as AlarmLevel from ptnmc.V_APP_ALARM_CELL_FAIL a,ptnmc.Cell_Config b where a.CELL_CHN=b.CELL_CHN AND ISNULL(LONGITUDE_GIS,'')<>''";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());


   MapInfo.Data.TableInfo ti;
   MapInfo.Data.Table table;

   table = MapInfo.Engine.Session.Current.Catalog.GetTable("ALL_CELL");
   if(table!=null)
   {
    table.Close();
   }
   ti = MapInfo.Data.TableInfoFactory.CreateTemp("ALL_CELL");
   table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);


   System.Data.DataTable sourceDataTable = new System.Data.DataTable("SourceData");

   for(int j=0;j<dsMap.Tables[0].Rows.Count;j++)
   {
    string cellName = dsMap.Tables[0].Rows[j][0].ToString();
    
    
    string sql = "select CELL_DIR 方向角,SECTOR_ANGLE 水平瓣宽,MAX_CELL_RADIUS Distince,LONGITUDE_GIS LONGITUDE,LATITUDE_GIS LATITUDE from ptnmc.V_CELL_AREA where CELL_CHN = '"+cellName+"' or CELL_CHN in (select CELL_CHN from ptnmc.CELL_CONFIG where RSITE_CHN = '"+cellName+"')";
    sourceDataTable=dataAcc.DataCollect(sql,sysComm.SysDBConnStr()).Tables[0];
    int middle,angle;
    double x,y,radius;

    
    
    for (int i=0;i<sourceDataTable.Rows.Count;i++)
    {
     middle = int.Parse(sourceDataTable.Rows[i]["方向角"].ToString());
     angle = int.Parse(sourceDataTable.Rows[i]["水平瓣宽"].ToString());
     radius = double.Parse(sourceDataTable.Rows[i]["Distince"].ToString());
     x = double.Parse(sourceDataTable.Rows[i]["LONGITUDE"].ToString());
     y = double.Parse(sourceDataTable.Rows[i]["LATITUDE"].ToString());
     DrawSector(table,x, y, middle, angle, radius);
    }
    
    if (sourceDataTable.Rows.Count>0)
    {
     FeatureLayer fl = new FeatureLayer(table);
     mapControl.Map.Layers.Insert(mapControl.Map.Layers.Count-1,fl);
     mapControl.Map.SetView(fl);
    }
    else
    {
    
    
    }
    sourceDataTable = null;
   }

   /*
   FeatureLayer fl = new FeatureLayer(table);

   int n;
   if(mapControl.Map.Layers.Count>1)
    n = mapControl.Map.Layers.Count;
   else
    n = 1;
   mapControl.Map.Layers.Insert(mapControl.Map.Layers.Count-1,fl);

   sourceDataTable = null;
   */


  }

  /// <summary>
  /// 告警呈现-无线-小区全阻
  /// </summary>
  /// <param name="Name" >要定位的小区名,传入空值表示查所有</param>
  public string GEO_CELL_ALARM(string Name,System.Web.UI.WebControls.DropDownList ddlSite)
  {
   String sqlstr;
   sqlstr="select distinct a.CELL_CHN as name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,'小区全阻' as AlarmLevel from ptnmc.V_APP_ALARM_CELL_FAIL a,ptnmc.Cell_Config b where a.CELL_CHN=b.CELL_CHN AND ISNULL(LONGITUDE_GIS,'')<>''";
   if(Name != "")
   {
    sqlstr="select distinct a.CELL_CHN as name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,'小区全阻' as AlarmLevel "+
"from ptnmc.V_APP_ALARM_CELL_FAIL a "+
"join ptnmc.Cell_Config b on a.CELL_CHN=b.CELL_CHN AND ISNULL(LONGITUDE_GIS,'')<>'' "+
"and LONGITUDE_GIS <>(select LONGITUDE_GIS from ptnmc.Cell_Config where CELL_CHN = '"+Name+"') "+
"and LATITUDE_GIS <>(select LATITUDE_GIS from ptnmc.Cell_Config where CELL_CHN = '"+Name+"') "+
"union "+
"select distinct a.CELL_CHN as name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,'小区全阻' as AlarmLevel  "+
"from ptnmc.V_APP_ALARM_CELL_FAIL a,ptnmc.Cell_Config b where a.CELL_CHN=b.CELL_CHN AND ISNULL(LONGITUDE_GIS,'')<>'' "+
"and a.CELL_CHN = '"+Name+"' ";
   }
   try
   {
    dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   
    UnSelectedAll();
    AddBmpPointLayer("MyBaseSiteDown","TOWE1-bg.bmp",dsMap.Tables[0]);

    //计算当前缩放比例
    MapInfo.Geometry.Distance zoomDistance=this.mapControl.Map.Zoom;
    double zoom=Convert.ToDouble(Convert.ToInt32(zoomDistance.Value*16.09))/10;


    if(Name != "") //小区定位
    {
     
     ShowCell(Name);
     mapControl.Map.Zoom=new MapInfo.Geometry.Distance(mapControl.Map.Zoom.Value*9,DistanceUnit.Kilometer);
     

     string sef = "name = '"+Name+"'";

     MapInfo.Data.QueryFilter filter = new MapInfo.Data.SqlExpressionFilter(sef);
     MapInfo.Data.QueryDefinition qd = new MapInfo.Data.QueryDefinition(filter, "*");
     MapInfo.Data.SearchInfo si = new MapInfo.Data.SearchInfo(null, qd);


     IResultSetFeatureCollection fc=null;
     fc=MapInfo.Engine.Session.Current.Catalog.Search(MapInfo.Engine.Session.Current.Catalog.GetTable("MyBaseSiteDown"), si);
     if(fc.Envelope!=null)
     {
      mapControl.Map.SetView(fc.Envelope);
      mapControl.Map.Zoom=new MapInfo.Geometry.Distance(3,DistanceUnit.Kilometer);
     }

 


    }
     /*
    else if(zoom<1.0)
    {
     for(int i=0;i<dsMap.Tables[0].Rows.Count;i++)
     {
      string strCell = dsMap.Tables[0].Rows[0][0].ToString();
      ShowCell(Name);
     }
    }*/
   
    //ShowDetial(mapControl);
  
    sqlstr = "select distinct a.CELL_CHN from ptnmc.V_APP_ALARM_CELL_FAIL a,ptnmc.Cell_Config b where a.CELL_CHN=b.CELL_CHN AND ISNULL(LONGITUDE_GIS,'')<>''";
    dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
    CFunctions.setItems(ddlSite,dsMap,"CELL_CHN");
    ddlSite.Items.Insert(0,new ListItem("",""));
    if (Name.Length>0)
     CFunctions.FindDropdownIndex(ddlSite,Name,true);

    /*
    sqlstr = "select count(distinct RSITE_CHN) as cn from ptnmc.V_APP_ALARM_CELL_FAIL";
    dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
    string msg = "目前全网共有"+dsMap.Tables[0].Rows[0][0]+"个基站有故障,";
    */
    string msg = "";
   
    dsMap.Clear();
    dsMap = new DataSet();
    sqlstr = "select count(distinct a.CELL_CHN) as cn from ptnmc.V_APP_ALARM_CELL_FAIL a,ptnmc.Cell_Config b where a.CELL_CHN=b.CELL_CHN AND ISNULL(LONGITUDE_GIS,'')<>''";
    dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   
    msg = msg + "目前全网共有"+dsMap.Tables[0].Rows[0][0]+"个小区全阻";
    return msg;
   }
   catch
   {
    throw;
   }
   finally
   {
    dsMap.Clear();
   }
  }

  /// <summary>
  /// 告警呈现-性能告警-小区性能告警
  /// </summary>
  /// <param name="Name" >要定位的小区名,传入空值表示查所有</param>
  public void GEO_CELL_PER(string Name,System.Web.UI.WebControls.DropDownList ddlSite)
  {
   GEO_PER_ALARM_HELPER( "MyCELLPER01","小区TCH掉话数","TCH掉话数.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER02","小区TCH真实拥塞率","TCH真实拥塞率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER03","小区TCH考核拥塞率","TCH考核拥塞率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER04","小区SDCCH考核拥塞率","SPCCH考核拥塞率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER05","小区强上行干扰比例","强上行干扰比例.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER06","小区GPRS流量","GPRS流量.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER07","小区SDCCH无线接通率","SPCCH无线接通率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER08","小区TCH无线接通率","TCH无线接通率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER09","BSC无线接通率","BSC无线接通率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER10","BSC TCH拥塞数","BSC TCH拥塞数.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER11","BSC TCH掉话数","BSC TCH掉话数.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER12","BSC PCU拥塞率","BSC PCU拥塞率.bmp");


   //string[] types  = {"小区TCH掉话数","小区TCH真实拥塞率","小区TCH考核拥塞率","小区SDCCH考核拥塞率","小区强上行干扰比例","小区GPRS流量","小区SDCCH无线接通率","小区TCH无线接通率","BSC无线接通率","BSC TCH拥塞数","BSC TCH掉话数","BSC PCU拥塞率"};
   string types  = "'小区TCH掉话数','小区TCH真实拥塞率','小区TCH考核拥塞率','小区SDCCH考核拥塞率','小区强上行干扰比例','小区GPRS流量','小区SDCCH无线接通率','小区TCH无线接通率','BSC无线接通率','BSC TCH拥塞数','BSC TCH掉话数','BSC PCU拥塞率'";
   string sqlstr = "select a.rsite_chn as name from  ptnmc.CELL_CONFIG as a,ptnmc.V_APP_ALARM_PF as b where a.cell =b.cell and b.cell <>'' and longitude_gis<>'' and TYPE_NAME in ("+types+")";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   CFunctions.setItems(ddlSite,dsMap,"name");
   ddlSite.Items.Insert(0,new ListItem("",""));
   if (Name.Length>0)
    CFunctions.FindDropdownIndex(ddlSite,Name,true);

   if(Name != "") //小区定位
   {
    string sef = "name = '"+Name+"'";

    MapInfo.Data.QueryFilter filter = new MapInfo.Data.SqlExpressionFilter(sef);
    MapInfo.Data.QueryDefinition qd = new MapInfo.Data.QueryDefinition(filter, "*");
    MapInfo.Data.SearchInfo si = new MapInfo.Data.SearchInfo(null, qd);

    IResultSetFeatureCollection fc=null;
    string[] arrLayer=new string[] {"MyCELLPER01","MyCELLPER02","MyCELLPER03","MyCELLPER04","MyCELLPER05","MyCELLPER06","MyCELLPER07","MyCELLPER08","MyCELLPER09","MyCELLPER10","MyCELLPER11","MyCELLPER12"};
    for (int i=0;i<arrLayer.Length;i++)
    {
     if (MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i])!=null)
     {
      fc=MapInfo.Engine.Session.Current.Catalog.Search(MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i]), si);
     }
     if (fc!=null)
     {
      if (fc.Count!=0)
       break;
     }
    }
    if(fc.Envelope!=null)
    {
     mapControl.Map.SetView(fc.Envelope);
     mapControl.Map.Zoom=new MapInfo.Geometry.Distance(1,DistanceUnit.Kilometer);
    }
   }
   
   //ShowDetial(mapControl);
  }

  /// <summary>
  /// 告警呈现-工程割接-工程割接
  /// </summary>
  /// <param name="Name" >要定位的小区名,传入空值表示查所有</param>
  public void GEO_NETCUT(string Name)
  {
   GEO_CUT_HELPER( "MYNetCutAlarm1","4","软件升级.bmp");
   GEO_CUT_HELPER ( "MYNetCutAlarm2","5","扩容割接.bmp");
   GEO_CUT_HELPER(  "MYNetCutAlarm3","6","临时调整.bmp");
   GEO_CUT_HELPER(  "MYNetCutAlarm4","7","工程建设.bmp");
   GEO_CUT_HELPER(  "MYNetCutAlarm5","","其他.bmp");

   if(Name != "") //小区定位
   {
    string sef = "name = '"+Name+"'";

    MapInfo.Data.QueryFilter filter = new MapInfo.Data.SqlExpressionFilter(sef);
    MapInfo.Data.QueryDefinition qd = new MapInfo.Data.QueryDefinition(filter, "*");
    MapInfo.Data.SearchInfo si = new MapInfo.Data.SearchInfo(null, qd);

    IResultSetFeatureCollection fc=null;
    string[] arrLayer=new string[] {"MYNetCutAlarm1","MYNetCutAlarm2","MYNetCutAlarm3","MYNetCutAlarm4","MYNetCutAlarm5"};
    for (int i=0;i<arrLayer.Length;i++)
    {
     if (MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i])!=null)
     {
      fc=MapInfo.Engine.Session.Current.Catalog.Search(MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i]), si);
     }
     if (fc!=null)
     {
      if (fc.Count!=0)
       break;
     }
    }
    if(fc.Envelope!=null)
    {
     mapControl.Map.SetView(fc.Envelope);
     mapControl.Map.Zoom=new MapInfo.Geometry.Distance(1,DistanceUnit.Kilometer);
    }
   }
   
   //ShowDetial(mapControl);
  }

  /// <summary>
  /// 性能呈现-无线统计-BSC话务量
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  public void GEO_BSC_TCH()
  {
   HideAllLayer();
   HideAllLabel();
   UnSelectedAll();
   mapControl.Map.Layers["BSC"].Enabled = true;
   MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["BSC"],true);
   SelectedArea("BSC");
   ShowLayerLabel("BSC",true);

   if(SysCommon.strAddr == "DG")
   {
    //ShowArea();
   }

   String sqlstr;
   sqlstr ="select NE as name,Convert(numeric(10,2),TRA) as VALUE from ptnmc.APP_PER_BSC_CU";
   DataSet ds = dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   //无需绑定图层
   if(ds.Tables[0].Rows.Count<1)
    return;


   MapInfo.Mapping.FeatureLayer fl = mapControl.Map.Layers["BSC"] as MapInfo.Mapping.FeatureLayer;
   fl.Modifiers.Clear();
   
   //数据绑定
   //sqlstr="select NE as name,convert(Decimal(6,2),TRA*100) as VALUE from ptnmc.APP_PER_BSC_CU order by convert(Decimal(6,2),TRA*100)";
   //sqlstr="select NE as name,TRA as VALUE from ptnmc.APP_PER_BSC_CU order by TRA";
   //sqlstr = "select NE as name,TRA as VALUE from ptnmc.APP_PER_BSC_CU union select NAME,0 from ptnmc.PMC_CONFIG where TYPE_SIGN = 2 and NAME not in (select NE from ptnmc.APP_PER_BSC_CU) order by TRA";
   sqlstr = "select NE as name,Convert(numeric(10,2),TRA) as VALUE from ptnmc.APP_PER_BSC_CU order by TRA";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   MapInfo.Data.Table bindTable = MapInfo.Engine.Session.Current.Catalog.GetTable("BSC");

   MapInfo.Data.TableInfoAdoNet ti = new MapInfo.Data.TableInfoAdoNet("SourceData", dsMap.Tables[0]);
   MapInfo.Data.Table sourceTable  = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
    
   MapInfo.Data.Columns columns = new MapInfo.Data.Columns();
   columns.Add(new MapInfo.Data.Column("TCH", MapInfo.Data.MIDbType.Double, "VALUE"));

   bindTable.AddColumns(columns, MapInfo.Data.BindType.Static, sourceTable, "UPPER(NAME)", MapInfo.Data.Operator.Equal, "UPPER(NAME)");
   sourceTable.Close();

   MapInfo.Mapping.FeatureLayer lyr = (MapInfo.Mapping.FeatureLayer) mapControl.MapExport.Map.Layers["BSC"]; 
   MapInfo.Mapping.Thematics.RangedTheme itheme = new MapInfo.Mapping.Thematics.RangedTheme(lyr, "TCH","thmValue", 5, MapInfo.Mapping.Thematics.DistributionMethod.EqualRangeSize);
           
   while(lyr.Modifiers.Count>0)
    lyr.Modifiers.RemoveAt(0);

   lyr.Modifiers.Append(itheme);
   
   //itheme.Bins[0].Style.SymbolStyle.Color = Color.Green;
   //itheme.Bins[itheme.Bins.Count-1].Style.SymbolStyle.Color = Color.DarkGreen;
   (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
   (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.DarkGreen;
   
   itheme.SpreadBy = MapInfo.Mapping.Thematics.SpreadByPart.Color;
   itheme.ColorSpreadBy =  MapInfo.Mapping.Thematics.ColorSpreadMethod.Rgb;
   itheme.RecomputeStyles();


   MapInfo.Mapping.Legends.Legend legend= mapControl.Map.Legends.CreateLegend(new Size(3, 3));
   legend.Border = true;

   MapInfo.Mapping.Legends.ThemeLegendFrame frame= MapInfo.Mapping.Legends.LegendFrameFactory.CreateThemeLegendFrame("TCH", "TCH",itheme );
   legend.Frames.Append(frame);
   frame.Title = "BSC 话务量(爱尔兰)";
   for(int i=0;i<frame.Rows.Count;i++)
   {
    string x=frame.Rows[i].Text;
    string [] Mid=x.Split(new char[] {'t','o'});
    for(int j=0;j<Mid.Length;j++)
    {
     int Locate=Mid[j].IndexOf(".");
     if(Mid[j].Length-Locate>=3)
     {
      Mid[j]=Mid[j].Substring(0,Locate+3);
     }
     else
     {
      
     }
    }
    frame.Rows[i].Text=Mid[0].ToString()+"to"+Mid[2].ToString();
    }
   


   //LegendControl1.Map = mapControl.Map;
   
   //LegendControl1.Width = frame.Width;
   //LegendControl1.Height = frame.Height;

   //LegendControl1.Legend = legend;
   
   mapControl.Map.Adornments.Clear();
   mapControl.Map.Adornments.Append(legend);
   System.Drawing.Point p = new System.Drawing.Point(500,330);
   mapControl.Map.Adornments[0].Location = p;
/*
   if(SysCommon.strAddr == "DG")
   {
   
    //(itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
    (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
    (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Pattern =1;


    (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
    (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Pattern  = 2;

   
    for(int i=0;i<itheme.Bins.Count;i++)
    {
     (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).BackColor = Color.Transparent;
     (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
     (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Transparent = true;
    }

    MapInfo.Styles.SimpleInterior simpleInterior = new MapInfo.Styles.SimpleInterior(1,Color.Red,Color.Transparent,true);
    MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
    MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth);
    MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle,simpleInterior);
    MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle,null,null,null);
    MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle);
 
    lyr.Modifiers.Append(fsm);


    mapControl.Map.Layers["AREA"].Enabled = true;
    ShowLayerLabel("AREA",true);


   }*/

  }

  /// <summary>
  /// 性能呈现-无线统计-BSC掉话率
  /// </summary>
  /// <param name="mapControl">地图容器名</param>
  public void GEO_BSC_DROP()
  {
   HideAllLayer();
   HideAllLabel();
   UnSelectedAll();
   mapControl.Map.Layers["BSC"].Enabled = true;
   MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["BSC"],true);

   SelectedArea("BSC");
   ShowLayerLabel("BSC",true);

   if(SysCommon.strAddr == "DG")
   {
    //ShowArea();
   }

   String sqlstr;
   sqlstr ="select NE as name,T_DROP_RATE as VALUE from ptnmc.APP_PER_BSC_CU";
   DataSet ds = dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   //无需绑定图层
   if(ds.Tables[0].Rows.Count<1)
    return;

   MapInfo.Mapping.FeatureLayer fl = mapControl.Map.Layers["BSC"] as MapInfo.Mapping.FeatureLayer;
   fl.Modifiers.Clear();
   
   //数据绑定
   //sqlstr="select NE as name,convert(Decimal(6,2),TRA*100) as VALUE from ptnmc.APP_PER_BSC_CU order by convert(Decimal(6,2),TRA*100)";
   sqlstr="select NE as name,T_DROP_RATE*100 as VALUE from ptnmc.APP_PER_BSC_CU order by T_DROP_RATE";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   MapInfo.Data.Table bindTable = MapInfo.Engine.Session.Current.Catalog.GetTable("BSC");

   MapInfo.Data.TableInfoAdoNet ti = new MapInfo.Data.TableInfoAdoNet("SourceData", dsMap.Tables[0]);
   MapInfo.Data.Table sourceTable  = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
    
   MapInfo.Data.Columns columns = new MapInfo.Data.Columns();
   columns.Add(new MapInfo.Data.Column("DROP", MapInfo.Data.MIDbType.Double, "VALUE"));

   bindTable.AddColumns(columns, MapInfo.Data.BindType.Static, sourceTable, "UPPER(NAME)", MapInfo.Data.Operator.Equal, "UPPER(NAME)");
   sourceTable.Close();

   MapInfo.Mapping.FeatureLayer lyr = (MapInfo.Mapping.FeatureLayer) mapControl.MapExport.Map.Layers["BSC"]; 
   MapInfo.Mapping.Thematics.RangedTheme itheme = new MapInfo.Mapping.Thematics.RangedTheme(lyr, "DROP","thmValue", 5, MapInfo.Mapping.Thematics.DistributionMethod.EqualRangeSize);
           
   while(lyr.Modifiers.Count>0)
    lyr.Modifiers.RemoveAt(0);

   lyr.Modifiers.Append(itheme);
   
   //itheme.Bins[0].Style.SymbolStyle.Color = Color.Green;
   //itheme.Bins[itheme.Bins.Count-1].Style.SymbolStyle.Color = Color.DarkGreen;
   (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
   (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.DarkGreen;
   
   itheme.SpreadBy = MapInfo.Mapping.Thematics.SpreadByPart.Color;
   itheme.ColorSpreadBy =  MapInfo.Mapping.Thematics.ColorSpreadMethod.Rgb;
   itheme.RecomputeStyles();

   MapInfo.Mapping.Legends.Legend legend= mapControl.Map.Legends.CreateLegend(new Size(3, 3));
   legend.Border = true;

   MapInfo.Mapping.Legends.ThemeLegendFrame frame= MapInfo.Mapping.Legends.LegendFrameFactory.CreateThemeLegendFrame("DROP", "DROP",itheme );
   legend.Frames.Append(frame);
   frame.Title = "BSC 掉话率";
   //frame.Rows[3].Text = "my 0 range";


   //LegendControl1.Map = mapControl.Map;
   
   //LegendControl1.Width = frame.Width;
   //LegendControl1.Height = frame.Height;

   //LegendControl1.Legend = legend;
   
   mapControl.Map.Adornments.Clear();
   mapControl.Map.Adornments.Append(legend);
   System.Drawing.Point p = new System.Drawing.Point(500,330);
   mapControl.Map.Adornments[0].Location = p;

  }

  /// <summary>
  /// 话务呈现-小区话务量
  /// </summary>
  /// <param name="Name" >要定位的小区名,传入空值表示查所有</param>
  public void GEO_CELL_TCH(string Name)
  {
   String sqlstr;
   sqlstr = "select distinct CELL_CHN as name,LONGITUDE_GIS AS lon,LATITUDE_GIS as lat ,3 AlarmLevel from ptnmc.CELL_CONFIG WHERE ISNULL(LONGITUDE_GIS,'')<>''  and CELL in(select CELL from  ptnmc.APP_PER_CELL_CU_TRA10)";

   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   
   UnSelectedAll();
   AddBmpPointLayer("MyCELLTCH","TOWE1-bg.bmp",dsMap.Tables[0]);

   if(Name != "") //小区定位
   {

    ShowCell(Name);
   }
   
   //ShowDetial(mapControl);
  }

  /// <summary>
  /// 用户行为分析-VLR
  /// </summary>
  /// <param name="Name" >要定位的小区名,传入空值表示查所有</param>
  public void GEO_VLR()
  {
   HideAllLayer();
   HideAllLabel();
   UnSelectedAll();
   mapControl.Map.Layers["MSC"].Enabled = true;
   MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["MSC"],true);

   SelectedArea("MSC");
   ShowLayerLabel("MSC",true);

   MapInfo.Mapping.FeatureLayer fl = mapControl.Map.Layers["MSC"] as MapInfo.Mapping.FeatureLayer;
   fl.Modifiers.Clear();
   
   //数据绑定
   String sqlstr;
   sqlstr = "select NE as name,SUM(USR_REG) as VALUE from ptnmc.APP_PER_VLR_CU where NE in (select NAME from ptnmc.PMC_CONFIG where TYPE_SIGN = 1) group by NE order by SUM(USR_REG)";
 
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   MapInfo.Data.Table bindTable = MapInfo.Engine.Session.Current.Catalog.GetTable("MSC");

   MapInfo.Data.TableInfoAdoNet ti = new MapInfo.Data.TableInfoAdoNet("SourceData", dsMap.Tables[0]);
   MapInfo.Data.Table sourceTable  = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
    
   MapInfo.Data.Columns columns = new MapInfo.Data.Columns();
   columns.Add(new MapInfo.Data.Column("TCH", MapInfo.Data.MIDbType.Double, "VALUE"));

   bindTable.AddColumns(columns, MapInfo.Data.BindType.Static, sourceTable, "UPPER(NAME)", MapInfo.Data.Operator.Equal, "UPPER(NAME)");
   sourceTable.Close();

   MapInfo.Mapping.FeatureLayer lyr = (MapInfo.Mapping.FeatureLayer) mapControl.MapExport.Map.Layers["MSC"]; 
   MapInfo.Mapping.Thematics.RangedTheme itheme = new MapInfo.Mapping.Thematics.RangedTheme(lyr, "TCH","thmValue", 5, MapInfo.Mapping.Thematics.DistributionMethod.EqualRangeSize);
           
   lyr.Modifiers.Append(itheme);
   
   //itheme.Bins[0].Style.SymbolStyle.Color = Color.Green;
   //itheme.Bins[itheme.Bins.Count-1].Style.SymbolStyle.Color = Color.DarkGreen;
   (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
   (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.DarkGreen;
   
   itheme.SpreadBy = MapInfo.Mapping.Thematics.SpreadByPart.Color;
   itheme.ColorSpreadBy =  MapInfo.Mapping.Thematics.ColorSpreadMethod.Rgb;
   itheme.RecomputeStyles();
  }


  internal class SelectedAreaModifier : MapInfo.Mapping.FeatureStyleModifier
  {
   private System.Collections.Hashtable features;

   public SelectedAreaModifier(string name, string alias, IResultSetFeatureCollection fc, string layerAlias): base(name, alias)
   {
    features = new System.Collections.Hashtable();
    string[] exp = new string[]{"MI_Key"};
    this.Expressions = exp;

    foreach(MapInfo.Data.Feature f in fc)
    {
     features.Add(f.Key.Value, f.Key.Value);
    }
   }

   protected override bool Modify(MapInfo.Styles.FeatureStyleStack styles, object[] values)
   {
    MapInfo.Styles.CompositeStyle cs = styles.Current;

    if (features.Contains((values[0] as MapInfo.Data.Key).Value))
    {
     // Set the style for region features because the modifier is being applied to a region layer.

     //(cs.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = System.Drawing.Color.Orange;
     (cs.AreaStyle.Border as MapInfo.Styles.SimpleLineStyle).Color = System.Drawing.Color.RoyalBlue;
     (cs.AreaStyle.Border as MapInfo.Styles.SimpleLineStyle).Width = new MapInfo.Styles.LineWidth(3, MapInfo.Styles.LineWidthUnit.Pixel);

     return true;
    }
    return false;
   }
  }

  /// <summary>
  /// 创建街道的临时表
  /// </summary>
  public MapInfo.Data.Table CreateTempLayer(string tableName)
  {
   MapInfo.Data.Table retTable = MapInfo.Engine.Session.Current.Catalog[tableName];
   if(retTable != null)
   {
    MapInfo.Engine.Session.Current.Catalog.CloseTable(tableName);
    //return retTable;
   }

   MapInfo.Data.Table tbStreet = MapInfo.Engine.Session.Current.Catalog.GetTable("street");
   MapInfo.Data.TableInfoMemTable newTableInfo = new MapInfo.Data.TableInfoMemTable(tableName);
   //MapInfo.Data.TableInfo newTableInfo;// = new MapInfo.Data.TableInfo("NewTable");
   //newTableInfo = MapInfo.Data.TableInfoFactory.CreateTemp(layerName);
   foreach (MapInfo.Data.Column Col in tbStreet.TableInfo.Columns)
   {
    newTableInfo.Columns.Add(Col.Clone());
   }

   retTable = MapInfo.Engine.Session.Current.Catalog.CreateTable(newTableInfo);
   
   
   MapInfo.Mapping.FeatureLayer layer=new MapInfo.Mapping.FeatureLayer(retTable);
   mapControl.Map.Layers.Add(layer);

   return retTable;
   
  }


  public void AllAlarm(string Name)
  {

   //UnSelectedAll();
   mapControl.Map.Layers["BSC"].Enabled = true;
   MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["BSC"],true);
   ShowLayerLabel("BSC",true);

   //SelectedArea("BSC");

   String sqlstr;
   sqlstr ="select distinct CONVERT(int,ALARM_LEVEL) from ptnmc.V_COVER where NAME like '%BSC%'";
   DataSet ds = dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());


   //无需绑定图层
   if(ds.Tables[0].Rows.Count==1)
   {
    //更改BSC图层的基本样式
    MapInfo.Mapping.FeatureLayer flBSC = (MapInfo.Mapping.FeatureLayer) mapControl.MapExport.Map.Layers["BSC"]; 
    MapInfo.Styles.SimpleInterior simpleInteriorBSC = new MapInfo.Styles.SimpleInterior(5,Color.DarkGreen,Color.Transparent,true);
    MapInfo.Styles.LineWidth lineWidthBSC = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
    MapInfo.Styles.SimpleLineStyle simpleLineStyleBSC = new MapInfo.Styles.SimpleLineStyle(lineWidthBSC);
    MapInfo.Styles.AreaStyle areaStyleBSC = new MapInfo.Styles.AreaStyle(simpleLineStyleBSC,simpleInteriorBSC);
    MapInfo.Styles.CompositeStyle compositeStyleBSC = new MapInfo.Styles.CompositeStyle(areaStyleBSC,null,null,null);
    MapInfo.Mapping.FeatureOverrideStyleModifier fsmBSC = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyleBSC);
 
    flBSC.Modifiers.Append(fsmBSC);
    return;
   }
   
   
   
 
   //数据绑定
   
   sqlstr ="select name,CONVERT(int,ALARM_LEVEL) as  VALUE from ptnmc.V_COVER where NAME like '%BSC%' union select '',1  order by CONVERT(int,ALARM_LEVEL)";

   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());


   
   MapInfo.Data.Table bindTable = MapInfo.Engine.Session.Current.Catalog.GetTable("BSC");

   MapInfo.Data.TableInfoAdoNet ti = new MapInfo.Data.TableInfoAdoNet("SourceData", dsMap.Tables[0]);
   MapInfo.Data.Table sourceTable  = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
    
   MapInfo.Data.Columns columns = new MapInfo.Data.Columns();
   columns.Add(new MapInfo.Data.Column("TCH", MapInfo.Data.MIDbType.Double, "VALUE"));
  
   bindTable.AddColumns(columns, MapInfo.Data.BindType.Static, sourceTable, "UPPER(NAME)", MapInfo.Data.Operator.Equal, "UPPER(NAME)");
   
   sourceTable.Close();

   MapInfo.Mapping.FeatureLayer lyr = (MapInfo.Mapping.FeatureLayer) mapControl.MapExport.Map.Layers["BSC"]; 
   MapInfo.Mapping.Thematics.IndividualValueTheme itheme = new IndividualValueTheme(lyr,"TCH","thmValue");
           
   
   //修改呈现样式
   lyr.Modifiers.Clear();
   lyr.Modifiers.Append(itheme);
   

   (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
   (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Pattern =5;


   (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
   (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Pattern  = 7;

   
   for(int i=0;i<itheme.Bins.Count;i++)
   {
    (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).BackColor = Color.Transparent;
    (itheme.Bins[i].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).Transparent = true;
   }

   MapInfo.Styles.SimpleInterior simpleInterior = new MapInfo.Styles.SimpleInterior(5,Color.DarkGreen,Color.Transparent,true);
   MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Point);
   MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth);
   MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle,simpleInterior);
   MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle,null,null,null);
   MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle);
 
   lyr.Modifiers.Append(fsm);
   

   
   //小区站倒
   sqlstr="select distinct a.CELL_CHN as name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,'小区全阻' as AlarmLevel from ptnmc.V_APP_ALARM_CELL_FAIL a,ptnmc.Cell_Config b where a.CELL_CHN=b.CELL_CHN AND ISNULL(LONGITUDE_GIS,'')<>''";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer("MyBaseSiteDown","TOWE1-bg.bmp",dsMap.Tables[0]);
   
   //基站外告
   GEO_EXT_ALARM_HELPER("MyBaseSite_POWER","电源告警",  "主电.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_HAND","手工上载",  "湿度高.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_HUMIDITY","湿度告警",  "湿度高.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_LOW","电压告警",  "低压.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_GATE","门禁告警",  "门碰.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_WATER","水浸告警",  "水浸.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_FIRE","防火告警",  "火警.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_CB_OPEN","CB_OPEN",  "湿度高.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_TINE_FAILURE", "TUNE FAILURE", "整流器.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_LIGHT","灯光告警",  "低压.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_HOT","高温告警",  "温度高.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_LEIJI","雷击告警",  "CAUT1-32.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_WEIHU","维护告警",  "CAUT1-32.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_NTMONITOR","小区逻辑信道可用性监视告警","CAUT1-32.bmp");
   GEO_EXT_ALARM_HELPER( "MyBaseSite_CITYPOWER","市电告警",  "CAUT1-32.bmp");


   //性能告警
   GEO_PER_ALARM_HELPER( "MyCELLPER01","小区TCH掉话数","TCH掉话数.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER02","小区TCH真实拥塞率","TCH真实拥塞率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER03","小区TCH考核拥塞率","TCH考核拥塞率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER04","小区SDCCH考核拥塞率","SPCCH考核拥塞率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER05","小区强上行干扰比例","强上行干扰比例.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER06","小区GPRS流量","GPRS流量.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER07","小区SDCCH无线接通率","SPCCH无线接通率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER08","小区TCH无线接通率","TCH无线接通率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER09","BSC无线接通率","BSC无线接通率.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER10","BSC TCH拥塞数","BSC TCH拥塞数.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER11","BSC TCH掉话数","BSC TCH掉话数.bmp");
   GEO_PER_ALARM_HELPER( "MyCELLPER12","BSC PCU拥塞率","BSC PCU拥塞率.bmp");
   

  

   if(Name != "") //小区定位
   {
    string sef = "名称 = '"+Name+"'";

    MapInfo.Data.QueryFilter filter = new MapInfo.Data.SqlExpressionFilter(sef);
    MapInfo.Data.QueryDefinition qd = new MapInfo.Data.QueryDefinition(filter, "*");
    MapInfo.Data.SearchInfo si = new MapInfo.Data.SearchInfo(null, qd);

    IResultSetFeatureCollection fc=null;
    Feature ftr = null;
    string[] arrLayer=new string[] {"street"};
    for (int i=0;i<arrLayer.Length;i++)
    {
     if (MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i])!=null)
     {
      fc=MapInfo.Engine.Session.Current.Catalog.Search(MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i]), si);
      ftr = MapInfo.Engine.Session.Current.Catalog.SearchForFeature(MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i]), si);
     }
     
     if (fc!=null)
     {
      if (fc.Count!=0)
       break;
     }
     if(ftr!=null)
      break;
    }
    
    if(fc.Envelope!=null)
    {
     //Feature ftr = fc[0];
     int n = fc.Count;

     MapInfo.Styles.SimpleInterior sis = new MapInfo.Styles.SimpleInterior(9,System.Drawing.Color.Purple );
     MapInfo.Styles.LineWidth lw = new MapInfo.Styles.LineWidth(10,MapInfo.Styles.LineWidthUnit.Point );
     MapInfo.Styles.SimpleLineStyle sl = new MapInfo.Styles.SimpleLineStyle (lw,3,Color.Red);
     MapInfo.Styles.AreaStyle ar = new MapInfo.Styles.AreaStyle (sl,sis);

     MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(ar);
     cs.LineStyle = sl;


     string tempLayerName = "tempStreet";
     MapInfo.Data.Table newTable = CreateTempLayer(tempLayerName);

     //MapInfo.Data.Table newTable = MapInfo.Engine.Session.Current.Catalog.OpenTable(tempLayerName);

     MapInfo.Data.MIConnection connection = new MapInfo.Data.MIConnection();
     connection.Open();

     MapInfo.Data.MICommand command = connection.CreateCommand();
    
     command.CommandText = "delete "+tempLayerName ;
     command.Prepare();
     command.ExecuteNonQuery();

     command.CommandText = "Insert into "+tempLayerName + " Select * from street where MI_Key = @MIKEY";
     command.Parameters.Add("@MIKEY", ftr.Key);
     command.Prepare();
     command.ExecuteNonQuery();

     command.Dispose();
     connection.Close();

     (mapControl.Map.Layers[tempLayerName] as FeatureLayer).Modifiers.Clear();
     MapInfo.Mapping.FeatureOverrideStyleModifier fsmtemp = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,cs);
     (mapControl.Map.Layers[tempLayerName] as FeatureLayer).Modifiers.Append(fsmtemp);
     
     //newTable.UpdateFeature();
     

     /*
     (mapControl.Map.Layers["street"] as FeatureLayer).Modifiers.Clear();

     ftr.Style = cs;
     ftr.Update();
     */


     /*
     foreach(Feature ftr in fc)
     {
      MapInfo.Data.MIConnection connection = new MapInfo.Data.MIConnection();
      connection.Open();

      MapInfo.Data.MICommand command = connection.CreateCommand();
      command.CommandText = "update " + ftr.Table.Alias + " set obj = @obj,MI_Style=@style where MI_Key = @MIKEY";
      command.Parameters.Add("@obj", ftr.Geometry );
      command.Parameters.Add("@MIKEY", ftr.Key);
      command.Parameters.Add("@style",cs);
      command.ExecuteNonQuery();

      command.Dispose();
      connection.Close();
      connection.Dispose();

      ftr.Update();
     }
     */

     //fc[0].Update();

     //FeatureLayer fl = this.mapControl.Map.Layers["street"] as FeatureLayer;

     /*
     MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable("street");
     table
     Feature ff = new Feature(table,new Key());

     table.UpdateFeature(fc[0],true);
     
     
     */
     
     /*
     
     SelectedAreaModifier scm = new SelectedAreaModifier("SelectedAreaModifier","SelectedAreaModifier",fc,fl.Alias);
     fl.Modifiers.Clear();
     fl.Modifiers.Append(scm);
     */

     //MapInfo.Styles.CompositeStyle compositeStyle1 = new MapInfo.Styles.CompositeStyle(new MapInfo.Styles.AreaStyle(new MapInfo.Styles.SimpleLineStyle(new MapInfo.Styles.LineWidth(3, MapInfo.Styles.LineWidthUnit.Pixel), 2, System.Drawing.Color.Purple), new MapInfo.Styles.SimpleInterior(2, System.Drawing.Color.Yellow)));
     //MapInfo.Mapping.FeatureOverrideStyleModifier fsm1 = new MapInfo.Mapping.FeatureOverrideStyleModifier(null,compositeStyle1);
     //fl.Modifiers.Append(fsm1);

     //fl.Style  = new MapInfo.Styles.SimpleLineStyle(new MapInfo.Styles.LineWidth(3, MapInfo.Styles.LineWidthUnit.Pixel), 2, System.Drawing.Color.Purple);

     mapControl.Map.SetView(fc.Envelope);

     if((this.mapControl.Map.Zoom.Value <3) || (this.mapControl.Map.Zoom.Value >100))
      mapControl.Map.Zoom=new MapInfo.Geometry.Distance(3,DistanceUnit.Kilometer);

    }
   }
   
  }

  public void ZSCutMsc()
  {
   HideAllLayer();
   HideAllLabel();
   //UnSelectedAll();
   mapControl.Map.Layers["MSC"].Enabled = true;
   MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["MSC"],true);
   ShowLayerLabel("MSC",true);
   SelectedArea("MSC");

   String sqlstr;
   sqlstr ="select ADDRESS from ptnmc.PROJECT_NETCUT where ADDRESS_TYPE = '网元' and ADDRESS like '%MSC%'";
   DataSet ds = dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   //无需绑定图层
   if(ds.Tables[0].Rows.Count==0)
   {
    
    return;
   }

   MapInfo.Mapping.FeatureLayer fl = mapControl.Map.Layers["MSC"] as MapInfo.Mapping.FeatureLayer;
   fl.Modifiers.Clear();
   
   //数据绑定
   sqlstr ="select ADDRESS NAME,1 VALUE from ptnmc.PROJECT_NETCUT where ADDRESS_TYPE = '网元' and ADDRESS like '%MSC%'";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   MapInfo.Data.Table bindTable = MapInfo.Engine.Session.Current.Catalog.GetTable("MSC");

   MapInfo.Data.TableInfoAdoNet ti = new MapInfo.Data.TableInfoAdoNet("SourceData", dsMap.Tables[0]);
   MapInfo.Data.Table sourceTable  = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
    
   MapInfo.Data.Columns columns = new MapInfo.Data.Columns();
   columns.Add(new MapInfo.Data.Column("TCH", MapInfo.Data.MIDbType.Int, "VALUE"));

   bool rlt = bindTable.AddColumns(columns, MapInfo.Data.BindType.Static, sourceTable, "UPPER(NAME)", MapInfo.Data.Operator.Equal, "UPPER(NAME)");
   sourceTable.Close();

   MapInfo.Mapping.Thematics.IndividualValueTheme itheme;
   MapInfo.Mapping.FeatureLayer lyr;
   if(rlt)
   {
    lyr = (MapInfo.Mapping.FeatureLayer) mapControl.MapExport.Map.Layers["MSC"]; 
    //MapInfo.Mapping.Thematics.RangedTheme itheme = new MapInfo.Mapping.Thematics.RangedTheme(lyr, "TCH","thmscValue", 3, MapInfo.Mapping.Thematics.DistributionMethod.EqualRangeSize);
    itheme = new IndividualValueTheme(lyr,"TCH","thmmscValue");
           
    lyr.Modifiers.Clear();
    lyr.Modifiers.Append(itheme);
   
    //itheme.Bins[0].Style.SymbolStyle.Color = Color.Green;
    //itheme.Bins[itheme.Bins.Count-1].Style.SymbolStyle.Color = Color.DarkGreen;
    (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
    (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;
    /*
    itheme.SpreadBy = MapInfo.Mapping.Thematics.SpreadByPart.Color;
    itheme.ColorSpreadBy =  MapInfo.Mapping.Thematics.ColorSpreadMethod.Rgb;
    itheme.RecomputeStyles();
    */

    
   }
  }

  public void ZSCutBsc()
  {
   HideAllLabel();
   HideAllLayer();
   UnSelectedAll();
   mapControl.Map.Layers["BSC"].Enabled = true;
   MapInfo.Mapping.LayerHelper.SetSelectable(mapControl.Map.Layers["BSC"],true);
   ShowLayerLabel("BSC",true);

   SelectedArea("BSC");

   String sqlstr;
   sqlstr ="select ADDRESS from ptnmc.PROJECT_NETCUT where ADDRESS_TYPE = '网元' and ADDRESS like '%BSC%'";
   DataSet ds = dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   //无需绑定图层
   if(ds.Tables[0].Rows.Count==0)
   {
    return;
   }
   
   
 
   //数据绑定
   
   sqlstr ="select ADDRESS NAME,1 VALUE from ptnmc.PROJECT_NETCUT where ADDRESS_TYPE = '网元' and ADDRESS like '%BSC%'";

   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   MapInfo.Mapping.FeatureLayer fl = mapControl.Map.Layers["BSC"] as MapInfo.Mapping.FeatureLayer;
   //fl.Modifiers.Clear();

   MapInfo.Data.Table bindTable = MapInfo.Engine.Session.Current.Catalog.GetTable("BSC");

   MapInfo.Data.TableInfoAdoNet ti = new MapInfo.Data.TableInfoAdoNet("SourceData", dsMap.Tables[0]);
   MapInfo.Data.Table sourceTable  = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
    
   MapInfo.Data.Columns columns = new MapInfo.Data.Columns();
   columns.Add(new MapInfo.Data.Column("TCH", MapInfo.Data.MIDbType.Double, "VALUE"));
  
   bindTable.AddColumns(columns, MapInfo.Data.BindType.Static, sourceTable, "UPPER(NAME)", MapInfo.Data.Operator.Equal, "UPPER(NAME)");
   
   sourceTable.Close();

   //MapInfo.Mapping.FeatureLayer lyr = (MapInfo.Mapping.FeatureLayer) mapControl.MapExport.Map.Layers["BSC"]; 
   MapInfo.Mapping.FeatureLayer lyr = (MapInfo.Mapping.FeatureLayer) mapControl.Map.Layers["BSC"]; 
   MapInfo.Mapping.Thematics.IndividualValueTheme itheme = new IndividualValueTheme(lyr,"TCH","thmValue");
           
   lyr.Modifiers.Clear();
   lyr.Modifiers.Append(itheme);
   
   (itheme.Bins[0].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.LimeGreen;
   (itheme.Bins[itheme.Bins.Count-1].Style.AreaStyle.Interior as MapInfo.Styles.SimpleInterior).ForeColor = Color.Red;


   
  }

  public void ZSService(string Name,System.Web.UI.WebControls.DropDownList ddlSite)
  {
   
 
   //数据绑定

   //覆盖盲点
   //sqlstr="select CELL_CHN as name,LONGITUDE_GIS AS lon,LATITUDE_GIS AS lat,'小区割接' as AlarmLevel from ptnmc.CELL_CONFIG where CELL_CHN in (select ADDRESS from ptnmc.PROJECT_NETCUT where ADDRESS_TYPE = '小区') and ISNULL(LONGITUDE_GIS,'')<>''";
   string sqlstr="select BlindName as name,LONGITUDE_GIS AS lon,LATITUDE_GIS AS lat,'覆盖盲点' as AlarmLevel from ptnmc.ALARM_SITE_BLIND where ISNULL(LONGITUDE_GIS,'')<>''";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer("MyBlindSite","TARG1-32.bmp",dsMap.Tables[0]);
   

   //Halt站
   //sqlstr="select distinct a.CELL AS name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,a.STATE as AlarmLevel from ptnmc.ALARM_CELL_HALTED a,ptnmc.CELL_CONFIG b where a.CELL=b.CELL and ISNULL(LONGITUDE_GIS,'')<>''";
   sqlstr = "select CELL_CHN as name,LONGITUDE_GIS AS lon,LATITUDE_GIS AS lat,'Halted 站' as AlarmLevel from ptnmc.CELL_CONFIG where CELL in (select distinct CELL from ptnmc.V_ALARM_CELL_HALTED) and ISNULL(LONGITUDE_GIS,'')<>''";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer("MyHalt","halt.bmp",dsMap.Tables[0],Color.Blue);
   
   //小区站倒(手工)
   sqlstr="select distinct a.CELL_CHN as name,b.LONGITUDE_GIS AS lon,b.LATITUDE_GIS AS lat,'小区全阻' as AlarmLevel " +
    "from ptnmc.V_APP_ALARM_CELL_FAIL a,ptnmc.Cell_Config b " +
    "where a.CELL_CHN=b.CELL_CHN AND a.TROUBLE_SIGN = 2 AND ISNULL(LONGITUDE_GIS,'')<>''";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer("MyBaseSiteDown","TOWE1-bg.bmp",dsMap.Tables[0]);


   //全阻基站
   sqlstr="select CELL_CHN as name,LONGITUDE_GIS AS lon,LATITUDE_GIS AS lat,'全阻基站' as AlarmLevel from ptnmc.CELL_CONFIG where CELL in (select CELL from ptnmc.ALARM_SITE_BREAK where STATE = 'BreakSite') and ISNULL(LONGITUDE_GIS,'')<>''";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer("MyBreakSite","qzjz_1.bmp",dsMap.Tables[0]);


   //拥塞基站
   sqlstr="select CELL_CHN as name,LONGITUDE_GIS AS lon,LATITUDE_GIS AS lat,'拥塞基站' as AlarmLevel from ptnmc.CELL_CONFIG where CELL in (select CELL from ptnmc.ALARM_SITE_BREAK where STATE = 'BusySite') and ISNULL(LONGITUDE_GIS,'')<>''";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer("MyBusySite","ysjz_1.bmp",dsMap.Tables[0]);

   //小区割接
   sqlstr="select CELL_CHN as name,LONGITUDE_GIS AS lon,LATITUDE_GIS AS lat,'小区割接' as AlarmLevel from ptnmc.CELL_CONFIG where CELL_CHN in (select ADDRESS from ptnmc.PROJECT_NETCUT where ADDRESS_TYPE = '小区') and ISNULL(LONGITUDE_GIS,'')<>''";
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());
   AddBmpPointLayer("MyCELLCUT","gj.bmp",dsMap.Tables[0]);

   
   
   //基站外告
   GEO_EXT_ALARM_HELPER("MyBaseSite_POWER","电源告警",  "主电.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_HAND","手工上载",  "湿度高.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_HUMIDITY","湿度告警",  "湿度高.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_LOW","电压告警",  "低压.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_GATE","门禁告警",  "门碰.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_WATER","水浸告警",  "水浸.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_FIRE","防火告警",  "火警.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_CB_OPEN","CB_OPEN",  "湿度高.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_TINE_FAILURE", "TUNE FAILURE", "整流器.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_LIGHT","灯光告警",  "低压.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_HOT","高温告警",  "温度高.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_LEIJI","雷击告警",  "CAUT1-32.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_WEIHU","维护告警",  "CAUT1-32.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_NTMONITOR","小区逻辑信道可用性监视告警","CAUT1-32.bmp",true);
   GEO_EXT_ALARM_HELPER( "MyBaseSite_CITYPOWER","市电告警",  "CAUT1-32.bmp",true);

   

   

   if(Name != "") //小区定位
   {
    string sef = "name = '"+Name+"'";

    MapInfo.Data.QueryFilter filter = new MapInfo.Data.SqlExpressionFilter(sef);
    MapInfo.Data.QueryDefinition qd = new MapInfo.Data.QueryDefinition(filter, "*");
    MapInfo.Data.SearchInfo si = new MapInfo.Data.SearchInfo(null, qd);

    IResultSetFeatureCollection fc=null;
    string[] arrLayer=new string[] {"MyCELLCUT","MyBreakSite","MyBusySite","MyBaseSiteDown","MyHalt","MyBaseSite_POWER","MyBaseSite_HAND","MyBaseSite_HUMIDITY","MyBaseSite_LOW","MyBaseSite_GATE","MyBaseSite_WATER","MyBaseSite_FIRE","MyBaseSite_CB_OPEN","MyBaseSite_TINE_FAILURE","MyBaseSite_LIGHT","MyBaseSite_HOT","MyBaseSite_LEIJI","MyBaseSite_WEIHU","MyBaseSite_NTMONITOR","MyBaseSite_CITYPOWER","MyBaseSite_EXTERNAL","MyBlindSite"};
    for (int i=0;i<arrLayer.Length;i++)
    {
     if (MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i])!=null)
     {
      fc=MapInfo.Engine.Session.Current.Catalog.Search(MapInfo.Engine.Session.Current.Catalog.GetTable(arrLayer[i]), si);
     }
     if (fc!=null)
     {
      if (fc.Count!=0)
       break;
     }
    }
    if(fc.Envelope!=null)
    {
     
     string sql = "select CELL_DIR 方向角,SECTOR_ANGLE 水平瓣宽,MAX_CELL_RADIUS Distince,LONGITUDE_GIS LONGITUDE,LATITUDE_GIS LATITUDE from ptnmc.V_CELL_AREA where CELL_CHN = '"+Name+"' or CELL_CHN in (select CELL_CHN from ptnmc.CELL_CONFIG where RSITE_CHN = '"+Name+"')";
     DataTable sourceDataTable=dataAcc.DataCollect(sql,sysComm.SysDBConnStr()).Tables[0];
     if (sourceDataTable != null)
     {
      if (sourceDataTable.Rows.Count > 0)
      {
       ShowCell(Name);
       mapControl.Map.Zoom=new MapInfo.Geometry.Distance(3,DistanceUnit.Kilometer);
      }
      else
      {
       mapControl.Map.SetView(fc.Envelope);
       mapControl.Map.Zoom=new MapInfo.Geometry.Distance(3,DistanceUnit.Kilometer);
      }
     }
    }
   }
   
   //ShowDetial(mapControl);

   string strAlarmTitles = "'电源告警','手工上载','湿度告警','电压告警','门禁告警','水浸告警','防火告警','CB_OPEN','TUNE FAILURE',"+
    "'灯光告警','高温告警','雷击告警','维护告警','小区逻辑信道可用性监视告警','市电告警','EXTERNAL ALARM'";


   //string sqlstr = "select distinct a.RSITE_CHN from ptnmc.V_APP_ALARM_RSITE_EXTERNAL a,ptnmc.CELL_CONFIG b where a.RSITE_CHN=b.RSITE_CHN and ISNULL(LONGITUDE_GIS,'')<>'' and a.TITLE_NAME in(select distinct TITLE_NAME1 from ptnmc.CONFIG_ALARM_TITLE1)";
   sqlstr = "select distinct a.RSITE_CHN from ptnmc.V_APP_ALARM_RSITE_EXTERNAL a,ptnmc.CELL_CONFIG b where a.RSITE_CHN=b.RSITE_CHN and ISNULL(LONGITUDE_GIS,'')<>'' and a.TITLE_NAME1 in("+strAlarmTitles+")";
   
   if(dsMap!=null)
    dsMap.Clear();
   dsMap=dataAcc.DataCollect(sqlstr,sysComm.SysDBConnStr());

   CFunctions.setItems(ddlSite,dsMap,"RSITE_CHN");
   ddlSite.Items.Insert(0,new ListItem("",""));
   if (Name.Length>0)
    CFunctions.FindDropdownIndex(ddlSite,Name,true);
   
  }

 }
  
}