Ejemplo n.º 1
0
        /// <summary>
        /// 加载栅格库体
        /// </summary>
        /// <param name="m_Hook">主程序hook</param>
        /// <param name="DbEleInfo">矢量库体对应的库体信息XmlElement</param>
        /// <param name="ex">输出错误信息</param>
        public static void AddRasterLayer(Plugin.Application.IAppDBIntegraRef m_Hook, XmlElement DbEleInfo, out Exception ex)
        {
            ex = null;
            try
            {
                IGroupLayer pGroupLayer = new GroupLayerClass();
                pGroupLayer.Name = m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + m_Hook.ProjectTree.SelectedNode.Text;
                // string rasterDBType = (m_Hook.ProjectTree.SelectedNode.Tag as XmlElement).GetAttribute("存储类型");
                // string rasterDBType = DbEleInfo.GetAttribute("存储类型");
                string     rasterDBType = string.Empty;
                XmlElement RasterEle    = DbEleInfo.SelectSingleNode(".//栅格数据库") as XmlElement;
                rasterDBType = RasterEle.GetAttribute("存储类型").Trim();
                XmlElement elementTemp   = DbEleInfo.SelectSingleNode(".//栅格数据库/连接信息") as XmlElement;
                IWorkspace TempWorkSpace = ModDBOperate.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;
                if (TempWorkSpace == null)
                {
                    // SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                    ex = new Exception("连接数据库失发生异常");
                    return;
                }
                IRasterWorkspaceEx pRasterWS = TempWorkSpace as IRasterWorkspaceEx;
                if (pRasterWS == null)
                {
                    return;
                }
                string feaclsName = (elementTemp.FirstChild as XmlElement).GetAttribute("名称");
                if (rasterDBType.Trim() == "栅格编目")
                {
                    //栅格编目数据加载
                    IRasterCatalog         pRasterCatalog = pRasterWS.OpenRasterCatalog(feaclsName);
                    IGdbRasterCatalogLayer pGDBRCLayer    = new GdbRasterCatalogLayerClass();
                    if (!pGDBRCLayer.Setup(pRasterCatalog as ITable))
                    {
                        return;
                    }
                    IFeatureLayer mFeaLayer = pGDBRCLayer as IFeatureLayer;
                    pGroupLayer.Add(mFeaLayer as ILayer);
                }
                else if (rasterDBType.Trim() == "栅格数据集")
                {
                    //栅格数据集加载

                    IRasterDataset pRasterDataset = pRasterWS.OpenRasterDataset(feaclsName);
                    IRasterLayer   pRasterLayer   = new RasterLayerClass();
                    pRasterLayer.CreateFromDataset(pRasterDataset);
                    if (pRasterLayer == null)
                    {
                        return;
                    }
                    pGroupLayer.Add(pRasterLayer as ILayer);
                }
                m_Hook.MapControl.Map.AddLayer(pGroupLayer);
            }
            catch (Exception eError)
            {
                ex = eError;
                return;
            }
        }
Ejemplo n.º 2
0
        public static void OpenFeatureClassFunction(AxMapControl MapControl, IFeatureClassName pFcName, DataTable dt = null)
        {
            try
            {
                MapControl.Map.ClearLayers();
                MapControl.SpatialReference = null;
                IName         pName = pFcName as IName;
                IFeatureClass pFc   = pName.Open() as IFeatureClass;

                if (null != dt)
                {
                    InitDataTable(pFc, dt);

                    IFeatureCursor pCursor = pFc.Search(null, true);
                    IFeature       pfea    = pCursor.NextFeature();
                    int            j       = 0;
                    while (pfea != null)
                    {
                        DataRow dataRow = dt.NewRow();

                        for (int i = 0; i < pfea.Fields.FieldCount; i++)
                        {
                            dataRow[i] = pfea.get_Value(i).ToString();
                        }

                        dt.Rows.Add(dataRow);
                        pfea = pCursor.NextFeature();
                        j++;
                    }
                    ComReleaser.ReleaseCOMObject(pCursor);
                }

                if (pFcName.FeatureType == esriFeatureType.esriFTRasterCatalogItem)
                {
                    IGdbRasterCatalogLayer pGdbRCLayer = new GdbRasterCatalogLayerClass();
                    pGdbRCLayer.Setup(pFc as ITable);
                    MapControl.Map.AddLayer(pGdbRCLayer as ILayer);
                }
                else if ((pFcName.FeatureType == esriFeatureType.esriFTSimple) ||
                         (pFcName.FeatureType == esriFeatureType.esriFTComplexEdge) ||
                         (pFcName.FeatureType == esriFeatureType.esriFTComplexJunction) ||
                         (pFcName.FeatureType == esriFeatureType.esriFTSimpleEdge) ||
                         (pFcName.FeatureType == esriFeatureType.esriFTSimpleJunction))
                {
                    IFeatureLayer pLayer = new FeatureLayerClass
                    {
                        FeatureClass = pFc,
                        Name         = (pFc as IDataset).Name
                    };
                    MapControl.Map.AddLayer(pLayer as ILayer);
                }
                else if (pFcName.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    ILayer pLayer = OpenAnnotationLayer(pFc);
                    pLayer.Name = (pFc as IDataset).Name;
                    MapControl.Map.AddLayer(pLayer as ILayer);
                }

                MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
            catch (Exception ex)
            { }
        }
Ejemplo n.º 3
0
        //cyf 2011065 modify
        public override void OnClick()
        {
            Exception err = null;

            /////获取工程项目名称
            DevComponents.AdvTree.Node ProjectNode = new DevComponents.AdvTree.Node();
            ProjectNode = m_Hook.ProjectTree.SelectedNode;
            while (ProjectNode.Parent != null)
            {
                ProjectNode = ProjectNode.Parent;
            }
            //cyf 20110625 add:
            DevComponents.AdvTree.Node DBNode = new DevComponents.AdvTree.Node(); //数据库树节点
            //获取数据库节点
            DBNode = m_Hook.ProjectTree.SelectedNode;
            while (DBNode.Parent != null && DBNode.DataKeyString != "DB")
            {
                DBNode = DBNode.Parent;
            }
            if (DBNode.DataKeyString != "DB")
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据库节点失败!");
                return;
            }

            DevComponents.AdvTree.Node DtSetNode = new DevComponents.AdvTree.Node();  //数据集树节点
            #region 获取数据集节点
            if (DBNode.Text == "现势库" || DBNode.Text == "历史库" || DBNode.Text == "临时库") //.DataKeyString == "现势库"
            {
                //获取数据集节点
                DtSetNode = m_Hook.ProjectTree.SelectedNode;
                while (DtSetNode.Parent != null && DtSetNode.DataKeyString != "FD")
                {
                    DtSetNode = DtSetNode.Parent;
                }
                if (DtSetNode.DataKeyString != "FD")
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集节点失败!");
                    return;
                }
            }
            else if (DBNode.Text == "栅格数据库")
            {
                //cyf 20110626 add:获取栅格数据库图层节点
                DtSetNode = m_Hook.ProjectTree.SelectedNode;
                if (m_Hook.ProjectTree.SelectedNode.DataKeyString == "RC")
                {
                    while (DtSetNode.Parent != null && DtSetNode.DataKeyString != "RC")
                    {
                        DtSetNode = DtSetNode.Parent;
                    }
                    if (DtSetNode.DataKeyString != "RC")
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集节点失败!");
                        return;
                    }
                }
                else if (m_Hook.ProjectTree.SelectedNode.DataKeyString == "RD")
                {
                    while (DtSetNode.Parent != null && DtSetNode.DataKeyString != "RD")
                    {
                        DtSetNode = DtSetNode.Parent;
                    }
                    if (DtSetNode.DataKeyString != "RD")
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集节点失败!");
                        return;
                    }
                }
                //end
            }
            #endregion


            XmlElement elementTemp   = (DBNode.Tag as XmlElement).SelectSingleNode(".//连接信息") as XmlElement;
            IWorkspace TempWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;
            if (TempWorkSpace == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                return;
            }
            //cyf 20110625 modify
            ILayer player = null;
            //ILayer player = ModDBOperator.GetGroupLayer(m_Hook.MapControl, m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + ProjectNode.Text);
            if (m_Hook.ProjectTree.SelectedNode.DataKeyString == "FD")
            {
                player = ModDBOperator.GetGroupLayer(m_Hook.MapControl, m_Hook.ProjectTree.SelectedNode.Text + "_" + ProjectNode.Text);
            }
            else if (m_Hook.ProjectTree.SelectedNode.DataKeyString == "FC")
            {
                player = ModDBOperator.GetGroupLayer(m_Hook.MapControl, DtSetNode.Text + "_" + ProjectNode.Text);
            }
            //cyf 20110626 add:添加获取栅格数据图层
            else if (m_Hook.ProjectTree.SelectedNode.DataKeyString == "RC" || m_Hook.ProjectTree.SelectedNode.DataKeyString == "RD")
            {
                //获取栅格数据图层
                player = ModDBOperator.GetGroupLayer(m_Hook.MapControl, DtSetNode.Text + "_" + ProjectNode.Text);
            }
            //end
            if (player != null)
            {
                m_Hook.MapControl.Map.DeleteLayer(player);
                m_Hook.TOCControl.Update();
            }
            //end

            IGroupLayer pGroupLayer = new GroupLayerClass();

            //cyf 20110625

            if (DBNode.Text == "现势库" || DBNode.Text == "历史库" || DBNode.Text == "临时库") //.DataKeyString == "现势库"
            {
                /////////若为历史库管理状态退出该状态,加载现势库
                m_Hook.MapControl.Map.ClearLayers();
                Plugin.Interface.ICommandRef HisBaseCommand = null;
                bool GetSeccess = Plugin.ModuleCommon.DicCommands.TryGetValue("GeoDBATool.ControlsDBHistoryManage", out HisBaseCommand);
                if (GetSeccess)
                {
                    HisCommand = HisBaseCommand as ControlsDBHistoryManage;
                    if (HisCommand.Checked)
                    {
                        HisCommand.IsHistory = false;//判断是不是历史库点的加载,若是现势库就卸载掉历史库,若是历史库就不操作
                        HisCommand.OnClick();
                    }
                }
                #region 加载数据
                SysCommon.Gis.SysGisDataSet sysGisDataset = new SysCommon.Gis.SysGisDataSet(TempWorkSpace);
                //cyf 20110625 modify
                IFeatureDataset featureDataset = null;        //数据集
                if (m_Hook.ProjectTree.SelectedNode.DataKeyString == "FD")
                {
                    featureDataset = sysGisDataset.GetFeatureDataset(m_Hook.ProjectTree.SelectedNode.Text, out err);
                    if (err != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集失败,请检查该数据集是否存在!");
                        return;
                    }
                    pGroupLayer.Name = m_Hook.ProjectTree.SelectedNode.Text + "_" + ProjectNode.Text;
                }
                else if (m_Hook.ProjectTree.SelectedNode.DataKeyString == "FC")
                {
                    featureDataset = sysGisDataset.GetFeatureDataset(DtSetNode.Text, out err);
                    if (err != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集失败!");
                        return;
                    }
                    pGroupLayer.Name = DtSetNode.Text + "_" + ProjectNode.Text;
                }
                //end

                List <IDataset> lstDataset = sysGisDataset.GetFeatureClass(featureDataset);
                //遍历要素类,加载图层
                string dbType   = "";
                string userName = "";//用户名

                userName = elementTemp.GetAttribute("用户");
                dbType   = elementTemp.GetAttribute("类型");
                foreach (IDataset dataset in lstDataset)
                {
                    IFeatureClass pFeatureClass = dataset as IFeatureClass;
                    if (pFeatureClass == null)
                    {
                        continue;
                    }
                    IFeatureLayer pFeatureLayer = new FeatureLayerClass();
                    if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        pFeatureLayer = new FDOGraphicsLayerClass();
                    }
                    pFeatureLayer.FeatureClass = pFeatureClass;
                    if (dbType.Trim().ToUpper() == "SDE")
                    {
                        //cyf 20110706 modify:修改为不去掉用户名 changed by xisheng 0906 去掉用户名
                        if (dataset.Name.ToUpper().Contains(userName.Trim().ToUpper()))
                        {
                            //SDE用户图层名去掉用户名
                            pFeatureLayer.Name = dataset.Name.Substring(userName.Trim().Length + 1);
                        }
                        else
                        {
                            pFeatureLayer.Name = dataset.Name;
                        }
                        //end
                    }
                    else
                    {
                        pFeatureLayer.Name = dataset.Name;
                    }
                    //cyf 20110625 modify
                    if (m_Hook.ProjectTree.SelectedNode.DataKeyString == "FC")
                    {
                        //加载指定的图层
                        if (m_Hook.ProjectTree.SelectedNode.Text != pFeatureLayer.Name)
                        {
                            continue;
                        }
                    }
                    else if (m_Hook.ProjectTree.SelectedNode.DataKeyString == "FD")
                    {
                        //加载具备权限的图层
                        XmlElement feaclsElem = null;
                        try { feaclsElem = (m_Hook.ProjectTree.SelectedNode.Tag as XmlElement).SelectSingleNode(".//图层名") as XmlElement; } catch { }
                        if (feaclsElem != null)
                        {
                            if (!feaclsElem.GetAttribute("名称").Contains(pFeatureLayer.Name))
                            {
                                //若不具备数据权限,则不进行加载
                                continue;
                            }
                        }
                    }
                    //end
                    pGroupLayer.Add(pFeatureLayer as ILayer);
                }

                m_Hook.MapControl.Map.AddLayer(pGroupLayer);
                #endregion
            }
            //else if (DBNode.Text == "历史库")
            //{
            //    //历史库加载
            //    //ModDBOperator.WriteLog("GetCommand");
            //    Plugin.Interface.ICommandRef HisBaseCommand = null;
            //    bool GetSeccess = Plugin.ModuleCommon.DicCommands.TryGetValue("GeoDBATool.ControlsDBHistoryManage", out HisBaseCommand);
            //    if (GetSeccess)
            //    {
            //        HisCommand = HisBaseCommand as ControlsDBHistoryManage;
            //        //判断是不是历史库点的加载,若是现势库就卸载掉历史库,若是历史库就不操作
            //        HisCommand.IsHistory = true;
            //        HisCommand.OnClick();
            //        if (HisCommand.MyControlHistoryBar != null)
            //        {
            //            string HisDBType = elementTemp.GetAttribute("类型");
            //            string[] strTemp = new string[] { elementTemp.GetAttribute("服务器"), elementTemp.GetAttribute("服务名"), elementTemp.GetAttribute("数据库"), elementTemp.GetAttribute("用户"), elementTemp.GetAttribute("密码"), elementTemp.GetAttribute("版本") };

            //            HisCommand.MyControlHistoryBar.AddHistoryData(strTemp, HisDBType);
            //        }
            //    }
            //}
            //加载sde数据后,注册版本
            //if (dbType.Trim().ToUpper() == "SDE")
            //{
            //    IDataset pFeaDt = featureDataset as IDataset;
            //    if (pFeaDt != null)
            //    {
            //        IVersionedObject pVerObj = pFeaDt as IVersionedObject;
            //        if (!pVerObj.IsRegisteredAsVersioned)
            //        {
            //            //注册版本
            //            pVerObj.RegisterAsVersioned(true);
            //        }
            //        else
            //        {
            //            pVerObj.RegisterAsVersioned(false);
            //        }
            //    }

            //}

            else if (DBNode.Text == "栅格数据库")
            {
                //栅格数据加载,分为两种情况:栅格数据集、栅格编目
                //cyf 20110625 modify
                pGroupLayer.Name = m_Hook.ProjectTree.SelectedNode.Text + "_" + ProjectNode.Text;
                //end
                string rasterDBType = (m_Hook.ProjectTree.SelectedNode.Tag as XmlElement).GetAttribute("存储类型");

                elementTemp   = (DBNode.Tag as XmlElement).SelectSingleNode(".//连接信息") as XmlElement; //cyf 20110626
                TempWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;
                if (TempWorkSpace == null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                    return;
                }
                IRasterWorkspaceEx pRasterWS = TempWorkSpace as IRasterWorkspaceEx;
                if (pRasterWS == null)
                {
                    return;
                }
                //string feaclsName = (elementTemp.FirstChild as XmlElement).GetAttribute("名称");
                string feaclsName = m_Hook.ProjectTree.SelectedNode.Text;
                try
                {
                    if (rasterDBType.Trim() == "栅格编目")
                    {
                        //栅格编目数据加载
                        IRasterCatalog         pRasterCatalog = pRasterWS.OpenRasterCatalog(feaclsName);
                        IGdbRasterCatalogLayer pGDBRCLayer    = new GdbRasterCatalogLayerClass();
                        if (!pGDBRCLayer.Setup(pRasterCatalog as ITable))
                        {
                            return;
                        }
                        IFeatureLayer mFeaLayer = pGDBRCLayer as IFeatureLayer;
                        pGroupLayer.Add(mFeaLayer as ILayer);
                        //IFeatureClass pFeaCls = pRasterCatalog as IFeatureClass;
                        //if (pFeaCls == null) return;
                        //IFeatureCursor pFeaCursor=pFeaCls.Search(null,false);
                        //if(pFeaCursor==null) return;
                        //IFeature pFea=pFeaCursor.NextFeature();
                        //while (pFea != null)
                        //{
                        //    IRasterCatalogItem pRCItem = pFea as IRasterCatalogItem;
                        //    IRasterDataset pRasterDt = pRCItem.RasterDataset;
                        //    IRasterLayer mRasterLayer = new RasterLayerClass();
                        //    mRasterLayer.CreateFromDataset(pRasterDt);
                        //    if (mRasterLayer == null) return;
                        //    pGroupLayer.Add(mRasterLayer as ILayer);

                        //    pFea = pFeaCursor.NextFeature();

                        //    //IFeatureLayer pFeaLayer = new FeatureLayerClass();
                        //    //pFeaLayer.FeatureClass = pFeaCls as IFeatureClass;
                        //    //pFeaLayer.Name = feaclsName;
                        //    //pGroupLayer.Add(pFeaLayer as ILayer);
                        //}
                    }
                    else if (rasterDBType.Trim() == "栅格数据集")
                    {
                        //栅格数据集加载

                        IRasterDataset pRasterDataset = pRasterWS.OpenRasterDataset(feaclsName);
                        //IRasterPyramid pRasterPyramid = pRasterDataset as IRasterPyramid;
                        //if(!pRasterPyramid.Present)
                        //{
                        //    if (SysCommon.Error.ErrorHandle.ShowFrmInformation("是", "否", "未构建金字塔,是否构建金字塔?"))
                        //    {
                        //        pRasterPyramid.Create();
                        //    }
                        //}
                        IRasterLayer pRasterLayer = new RasterLayerClass();
                        pRasterLayer.CreateFromDataset(pRasterDataset);
                        if (pRasterLayer == null)
                        {
                            return;
                        }
                        pGroupLayer.Add(pRasterLayer as ILayer);
                    }
                    m_Hook.MapControl.Map.AddLayer(pGroupLayer);
                } catch (Exception e)
                {
                    //*******************************************************************
                    //guozheng added
                    if (ModData.SysLog != null)
                    {
                        ModData.SysLog.Write(e, null, DateTime.Now);
                    }
                    else
                    {
                        ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                        ModData.SysLog.Write(e, null, DateTime.Now);
                    }
                    //********************************************************************

                    return;
                }
            }
            //对图层进行排序

            SysCommon.Gis.ModGisPub.LayersCompose(m_Hook.MapControl);

            //符号化 去掉加载的符号化 20111025 席胜

            //GeoUtilities.ControlsRenderLayerByMxd RenderLayerByMxd = new GeoUtilities.ControlsRenderLayerByMxd();
            //RenderLayerByMxd.OnCreate(m_Hook);
            //RenderLayerByMxd.OnClick();
        }
Ejemplo n.º 4
0
        public void LoadData(IList ilist_0)
        {
            IEnumDataset      subsets;
            IDataset          j;
            string            str;
            IFeatureClass     dataset;
            IFeatureLayer     cadFeatureLayerClass;
            ITopologyLayer    topologyLayerClass;
            IEnumFeatureClass classes;
            IFeatureClass     m;
            IFeatureClass     n;
            IFeatureLayer     featureLayerClass;
            List <object>     objs = new List <object>();

            foreach (object ilist0 in ilist_0)
            {
                if (ilist0 is IGxDataset)
                {
                    if ((ilist0 as IGxDataset).Type != esriDatasetType.esriDTFeatureDataset)
                    {
                        objs.Add(ilist0);
                    }
                    else
                    {
                        IEnumGxObject children = (ilist0 as IGxObjectContainer).Children;
                        children.Reset();
                        for (IGxObject i = children.Next(); i != null; i = children.Next())
                        {
                            objs.Add(i);
                        }
                    }
                }
                else if (!(ilist0 is IDataset))
                {
                    objs.Add(ilist0);
                }
                else
                {
                    if ((ilist0 as IDataset).Type != esriDatasetType.esriDTFeatureDataset)
                    {
                        continue;
                    }
                    subsets = (ilist0 as IDataset).Subsets;
                    subsets.Reset();
                    for (j = subsets.Next(); j != null; j = subsets.Next())
                    {
                        objs.Add(j);
                    }
                }
            }
            ProcessAssist processAssist = new ProcessAssist();

            processAssist.InitProgress();
            processAssist.SetMaxValue(objs.Count);
            processAssist.SetMessage("正在加载数据,请稍候...");
            processAssist.Start();
            try
            {
                ILayer layer = null;
                IMap   map   = this.GetMap();
                this.list_0 = new List <ILayer>();
                List <string> strs      = new List <string>();
                IEnvelope     envelope  = null;
                IDataset      item      = null;
                IGxDataset    gxDataset = null;
                for (int k = 0; k < objs.Count; k++)
                {
                    string name = "";
                    if (objs[k] is IGxObject)
                    {
                        name = (objs[k] as IGxObject).Name;
                    }
                    else if (objs[k] is IDataset)
                    {
                        name = (objs[k] as IDataset).Name;
                    }
                    bool flag = true;
                    str = string.Format("加载图层[{0}],第{1}/{2}个", name, k + 1, objs.Count);
                    processAssist.Increment(1);
                    processAssist.SetMessage(str);
                    if (objs[k] is IGxLayer)
                    {
                        layer = (objs[k] as IGxLayer).Layer;
                        if (layer is IGeoDataset && !SpatialReferenctOperator.ValideFeatureClass(layer as IGeoDataset))
                        {
                            strs.Add(layer.Name);
                            flag = false;
                        }
                        this.AddLayer(map, layer, ref envelope, flag);
                    }
                    else if (!(objs[k] is IGxAGSObject))
                    {
                        if (objs[k] is IGxDataset)
                        {
                            gxDataset = objs[k] as IGxDataset;
                            item      = gxDataset.Dataset;
                        }
                        else if (ilist_0[k] is IDataset)
                        {
                            item = objs[k] as IDataset;
                        }
                        if (item != null)
                        {
                            if (item is IGeoDataset)
                            {
                                flag = SpatialReferenctOperator.ValideFeatureClass(item as IGeoDataset);
                            }
                            if (item.Type == esriDatasetType.esriDTFeatureClass)
                            {
                                dataset = (IFeatureClass)item;
                                if ((gxDataset as IGxObject).Category.IndexOf("CAD") != -1)
                                {
                                    if (dataset.FeatureType != esriFeatureType.esriFTCoverageAnnotation)
                                    {
                                        cadFeatureLayerClass = new CadFeatureLayerClass();
                                    }
                                    else
                                    {
                                        cadFeatureLayerClass = new CadAnnotationLayerClass();
                                    }
                                    cadFeatureLayerClass.FeatureClass = dataset;
                                    cadFeatureLayerClass.Name         = dataset.AliasName;
                                }
                                else if (dataset.FeatureType == esriFeatureType.esriFTAnnotation)
                                {
                                    cadFeatureLayerClass = new FDOGraphicsLayerClass()
                                    {
                                        FeatureClass = dataset,
                                        Name         = dataset.AliasName
                                    };
                                }
                                else if (dataset.FeatureType != esriFeatureType.esriFTDimension)
                                {
                                    cadFeatureLayerClass = new FeatureLayerClass()
                                    {
                                        FeatureClass = dataset,
                                        Name         = dataset.AliasName
                                    };
                                }
                                else
                                {
                                    cadFeatureLayerClass = new DimensionLayerClass()
                                    {
                                        FeatureClass = dataset,
                                        Name         = dataset.AliasName
                                    };
                                }
                                if (!flag)
                                {
                                    strs.Add(cadFeatureLayerClass.Name);
                                }
                                this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                            }
                            else if (item.Type == esriDatasetType.esriDTCadDrawing)
                            {
                                if ((gxDataset as IGxObject).Category != "CAD绘图")
                                {
                                    IEnumGxObject enumGxObject = (gxDataset as IGxObjectContainer).Children;
                                    enumGxObject.Reset();
                                    for (IGxDataset l = enumGxObject.Next() as IGxDataset; l != null; l = enumGxObject.Next() as IGxDataset)
                                    {
                                        dataset = l.Dataset as IFeatureClass;
                                        if (dataset != null)
                                        {
                                            if (dataset.FeatureType != esriFeatureType.esriFTAnnotation)
                                            {
                                                cadFeatureLayerClass = new CadFeatureLayerClass()
                                                {
                                                    FeatureClass = dataset,
                                                    Name         = dataset.AliasName
                                                };
                                            }
                                            else
                                            {
                                                cadFeatureLayerClass = new FDOGraphicsLayerClass()
                                                {
                                                    FeatureClass = dataset,
                                                    Name         = dataset.AliasName
                                                };
                                            }
                                            flag = true;
                                            if (cadFeatureLayerClass is IGeoDataset)
                                            {
                                                bool flag1 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                                flag = flag1;
                                                if (!flag1)
                                                {
                                                    strs.Add(cadFeatureLayerClass.Name);
                                                }
                                            }
                                            this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                        }
                                    }
                                }
                                else
                                {
                                    ICadLayer cadLayerClass = new CadLayerClass()
                                    {
                                        CadDrawingDataset = gxDataset.Dataset as ICadDrawingDataset,
                                        Name = gxDataset.Dataset.Name
                                    };
                                    if (!flag)
                                    {
                                        strs.Add(cadLayerClass.Name);
                                    }
                                    this.AddLayer(map, cadLayerClass, ref envelope, flag);
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTFeatureDataset)
                            {
                                subsets = item.Subsets;
                                subsets.Reset();
                                for (j = subsets.Next(); j != null; j = subsets.Next())
                                {
                                    if (j.Type == esriDatasetType.esriDTFeatureClass)
                                    {
                                        dataset = j as IFeatureClass;
                                        if (dataset.FeatureType != esriFeatureType.esriFTAnnotation)
                                        {
                                            cadFeatureLayerClass = new FeatureLayerClass()
                                            {
                                                FeatureClass = dataset,
                                                Name         = dataset.AliasName
                                            };
                                            flag = true;
                                            if (cadFeatureLayerClass is IGeoDataset)
                                            {
                                                bool flag2 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                                flag = flag2;
                                                if (!flag2)
                                                {
                                                    strs.Add(cadFeatureLayerClass.Name);
                                                }
                                            }
                                            this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                        }
                                        else
                                        {
                                            cadFeatureLayerClass = new FDOGraphicsLayerClass()
                                            {
                                                FeatureClass = dataset,
                                                Name         = dataset.AliasName
                                            };
                                            flag = true;
                                            if (cadFeatureLayerClass is IGeoDataset)
                                            {
                                                bool flag3 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                                flag = flag3;
                                                if (!flag3)
                                                {
                                                    strs.Add(cadFeatureLayerClass.Name);
                                                }
                                            }
                                            this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                        }
                                    }
                                    else if (j.Type == esriDatasetType.esriDTTopology)
                                    {
                                        topologyLayerClass = new TopologyLayerClass()
                                        {
                                            Topology = j as ITopology
                                        };
                                        (topologyLayerClass as ILayer).Name = j.Name;
                                        this.AddLayer(map, topologyLayerClass as ILayer, ref envelope, true);
                                    }
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTTopology)
                            {
                                if (MessageBox.Show(string.Concat("是否将参加拓扑-", item.Name, "-的所有要素添加到地图中"), "添加拓扑层", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                                {
                                    classes = (item as IFeatureClassContainer).Classes;
                                    classes.Reset();
                                    for (m = classes.Next(); m != null; m = classes.Next())
                                    {
                                        cadFeatureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = m,
                                            Name         = m.AliasName
                                        };
                                        flag = true;
                                        if (cadFeatureLayerClass is IGeoDataset)
                                        {
                                            bool flag4 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                            flag = flag4;
                                            if (!flag4)
                                            {
                                                strs.Add(cadFeatureLayerClass.Name);
                                            }
                                        }
                                        this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                    }
                                }
                                topologyLayerClass = new TopologyLayerClass()
                                {
                                    Topology = item as ITopology
                                };
                                (topologyLayerClass as ILayer).Name = item.Name;
                                this.AddLayer(map, topologyLayerClass as ILayer, ref envelope, true);
                            }
                            else if (item.Type == esriDatasetType.esriDTTin)
                            {
                                ITinLayer tinLayerClass = new TinLayerClass()
                                {
                                    Dataset = (ITin)item,
                                    Name    = item.Name
                                };
                                flag = true;
                                if (tinLayerClass is IGeoDataset)
                                {
                                    bool flag5 = SpatialReferenctOperator.ValideFeatureClass(tinLayerClass as IGeoDataset);
                                    flag = flag5;
                                    if (!flag5)
                                    {
                                        strs.Add(tinLayerClass.Name);
                                    }
                                }
                                this.AddLayer(map, tinLayerClass, ref envelope, flag);
                            }
                            else if (item.Type == esriDatasetType.esriDTRasterCatalog)
                            {
                                IGdbRasterCatalogLayer gdbRasterCatalogLayerClass = null;
                                gdbRasterCatalogLayerClass = new GdbRasterCatalogLayerClass();
                                if (gdbRasterCatalogLayerClass.Setup((ITable)(item as IRasterCatalog)))
                                {
                                    bool flag6 = SpatialReferenctOperator.ValideFeatureClass(gdbRasterCatalogLayerClass as IGeoDataset);
                                    flag = flag6;
                                    if (!flag6)
                                    {
                                        strs.Add((gdbRasterCatalogLayerClass as ILayer).Name);
                                    }
                                    this.AddLayer(map, gdbRasterCatalogLayerClass as ILayer, ref envelope, flag);
                                }
                            }
                            else if (!(item.Type == esriDatasetType.esriDTRasterDataset ? false : item.Type != esriDatasetType.esriDTRasterBand))
                            {
                                bool flag7 = true;
                                if (!((IRasterPyramid)item).Present)
                                {
                                    if (this.m_pApp.PyramidPromptType == PyramidPromptType.AlwaysBuildNoPrompt)
                                    {
                                        ((IRasterPyramid)item).Create();
                                    }
                                    else if (this.m_pApp.PyramidPromptType == PyramidPromptType.AlwaysPrompt)
                                    {
                                        DialogResult dialogResult = BuildPyramidSet.Show();
                                        if (dialogResult == DialogResult.Yes)
                                        {
                                            ((IRasterPyramid)item).Create();
                                        }
                                        else if (dialogResult == DialogResult.Cancel)
                                        {
                                            flag7 = false;
                                        }
                                    }
                                }
                                if (flag7)
                                {
                                    IRasterLayer rasterLayerClass = new RasterLayerClass()
                                    {
                                        Cached = true
                                    };
                                    rasterLayerClass.CreateFromDataset((IRasterDataset)item);
                                    rasterLayerClass.Name = item.Name;
                                    bool flag8 = SpatialReferenctOperator.ValideFeatureClass(rasterLayerClass as IGeoDataset);
                                    flag = flag8;
                                    if (!flag8)
                                    {
                                        strs.Add(rasterLayerClass.Name);
                                    }
                                    this.AddLayer(map, rasterLayerClass, ref envelope, flag);
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTTable)
                            {
                                try
                                {
                                    IStandaloneTableCollection standaloneTableCollection = this.GetMap() as IStandaloneTableCollection;
                                    IPropertySet connectionProperties = item.Workspace.ConnectionProperties;
                                    bool         flag9 = false;
                                    int          num   = 0;
                                    while (true)
                                    {
                                        if (num < standaloneTableCollection.StandaloneTableCount)
                                        {
                                            ITable table = standaloneTableCollection.StandaloneTable[num].Table;
                                            if (!connectionProperties.IsEqual((table as IDataset).Workspace.ConnectionProperties) || !((table as IDataset).Name == item.Name))
                                            {
                                                num++;
                                            }
                                            else
                                            {
                                                flag9 = true;
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    if (!flag9)
                                    {
                                        standaloneTableCollection.AddStandaloneTable(new StandaloneTableClass()
                                        {
                                            Table = item as ITable
                                        });
                                    }
                                }
                                catch (Exception exception)
                                {
                                    CErrorLog.writeErrorLog(this, exception, "");
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTGeometricNetwork)
                            {
                                IGeometricNetwork geometricNetwork = item as IGeometricNetwork;
                                if (geometricNetwork != null)
                                {
                                    IEnumFeatureClass classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTSimpleJunction];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                    classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTComplexJunction];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                    classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTSimpleEdge];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                    classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTComplexEdge];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTNetworkDataset)
                            {
                                INetworkLayer networkLayerClass = new NetworkLayerClass()
                                {
                                    NetworkDataset = item as INetworkDataset
                                };
                                this.AddLayer(map, networkLayerClass as ILayer, ref envelope, true);
                                if (MessageBox.Show(string.Concat("是否将参加网络要素集-", item.Name, "-的所有要素添加到地图中"), "添加拓扑层", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                                {
                                    classes = (item as IFeatureClassContainer).Classes;
                                    classes.Reset();
                                    for (m = classes.Next(); m != null; m = classes.Next())
                                    {
                                        cadFeatureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = m,
                                            Name         = m.AliasName
                                        };
                                        this.AddLayer(map, cadFeatureLayerClass, ref envelope, true);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        IMapServerLayer mapServerLayerClass = new MapServerLayerClass();
                        mapServerLayerClass.ServerConnect((objs[k] as IGxAGSObject).AGSServerObjectName, (objs[k] as IGxAGSObject).DefaultMapName);
                        this.AddLayer(map, mapServerLayerClass as ILayer, ref envelope, false);
                    }
                }
                processAssist.End();
                bool layerCount = this.GetMap().LayerCount > 0;
                if (strs.Count > 0)
                {
                    MessageBox.Show("警告:数据范围不一致。\r\n 一个或多个添加的图层范围与关联的空间坐标系范围不一致。请检查数据问题。存在问题图层信息请查看错误日志!", "管理平台", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (string str1 in strs)
                    {
                        if (stringBuilder.Length > 0)
                        {
                            stringBuilder.Append(",");
                        }
                        stringBuilder.Append(str1);
                    }
                    CErrorLog.writeErrorLog(stringBuilder, null, "图层范围不一致!");
                }
                foreach (ILayer list0 in this.list_0)
                {
                    list0.Visible = true;
                }
                if (layerCount && envelope != null)
                {
                    IMap map1 = this.GetMap();
                    ISpatialReference spatialReference = map1.SpatialReference;
                    if ((spatialReference is IUnknownCoordinateSystem || envelope.SpatialReference is IUnknownCoordinateSystem || envelope.SpatialReference == null ? false : spatialReference != null))
                    {
                        envelope.Project(spatialReference);
                    }
                    (map1 as IActiveView).Extent = envelope;
                    (map1 as IActiveView).Refresh();
                }
                if (this.m_pApp != null)
                {
                    this.m_pApp.MapDocumentChanged();
                }
                else if (ApplicationRef.Application != null)
                {
                    ApplicationRef.Application.MapDocumentChanged();
                }
            }
            catch (Exception exception1)
            {
                str = exception1.ToString();
            }
            if (this.onLoadCompleteHand_0 != null)
            {
                this.onLoadCompleteHand_0();
            }
        }