Example #1
0
        private void btnLink_Click(object sender, EventArgs e)
        {
            listViewEx.Items.Clear();

            Exception err = null;

            SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet();
            switch (comBoxType.Text)
            {
            case "SDE":
                sysGisDataSet.SetWorkspace(txtServer.Text, txtInstance.Text, txtDB.Text, txtUser.Text, txtPassword.Text, txtVersion.Text, out err);
                break;

            case "GDB":
                sysGisDataSet.SetWorkspace(txtDB.Text, SysCommon.enumWSType.GDB, out err);
                break;

            case "PDB":
                sysGisDataSet.SetWorkspace(txtDB.Text, SysCommon.enumWSType.PDB, out err);
                break;

            default:
                break;
            }

            if (err != null || sysGisDataSet.WorkSpace == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未设置用户数据库连接或连接失败,请检查!");
                return;
            }

            List <string> lstNames = sysGisDataSet.GetAllFeatureDatasetNames();

            foreach (string name in lstNames)
            {
                ListViewItem aItem = listViewEx.Items.Add(name);
                aItem.Tag     = "FD";
                aItem.Checked = true;
            }
            lstNames = sysGisDataSet.GetFeatureClassNames();
            foreach (string name in lstNames)
            {
                ListViewItem aItem = listViewEx.Items.Add(name);
                aItem.Tag     = "FC";
                aItem.Checked = true;
            }

            sysGisDataSet.Dispose();
        }
Example #2
0
        /// <summary>
        /// 初始化数据库连接
        /// </summary>
        private void InitialDB(out Exception err)
        {
            err = null;
            //cyf 20110625 modify
            List <IDataset> lstDataset = new List <IDataset>();
            XmlDocument     xml        = new XmlDocument();

            if (!File.Exists(ModData.v_projectDetalXML))
            {
                err = new Exception(ModData.v_projectDetalXML + "不存在");
                return;
            }
            xml.Load(ModData.v_projectDetalXML);
            XmlElement elementTemp = xml.SelectSingleNode("//现势库/连接信息[@类型!='']") as XmlElement;//取得矢量数据
            //end
            IWorkspace TempWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;

            if (TempWorkSpace == null)
            {
                err = new Exception("连接数据库失败!");
                return;
            }
            XmlElement elementTemp2 = xml.SelectSingleNode("//现势库/数据集[@名称!='']") as XmlElement;
            string     datasetname  = elementTemp2.GetAttribute("名称");

            SysCommon.Gis.SysGisDataSet sysGisDataset = new SysCommon.Gis.SysGisDataSet(TempWorkSpace);
            //cyf 20110625 modify:
            IFeatureDataset dataset = sysGisDataset.GetFeatureDataset(datasetname, out err);

            //end
            if (err != null)
            {
                err = new Exception("获取数据失败!");
                return;
            }

            lstDataset = sysGisDataset.GetFeatureClass(dataset);
            if (lstDataset == null || lstDataset.Count == 0)
            {
                err = new Exception("库体要素类为空!");
            }
            m_LstDataset = lstDataset;
        }
Example #3
0
        private void cmbTmpDB_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = cmbTmpDB.SelectedIndex;

            if (index >= 0)
            {
                try
                {
                    DevComponents.AdvTree.Node pNode = _ListTmpDBList[index];
                    if (pNode.DataKeyString == "FD")
                    {
                        Exception err = null;
                        SysCommon.Gis.SysGisDataSet sysGisDataset  = new SysCommon.Gis.SysGisDataSet(Plugin.ModuleCommon.TmpWorkSpace);
                        IFeatureDataset             featureDataset = null; //数据集
                        featureDataset     = sysGisDataset.GetFeatureDataset(pNode.Text, out err);
                        sysGisDataset      = null;
                        _CurFeatureDataset = featureDataset;
                        InitFeatureClassList(featureDataset);
                    }
                }
                catch
                { }
            }
        }
        public void OnDataCheck()
        {
            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }

            //获取所有数据集
            SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <IDataset>             lstDT         = sysGisDataSet.GetAllFeatureClass();
            string path = dataCheckParaSet.Workspace.PathName;

            ExcuteCheck(lstDT, path);
        }
Example #5
0
        public void OnDataCheck()
        {
            Exception eError = null;

            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }

            //实现代码
            SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable();
            pSysTable.DbConn    = dataCheckParaSet.DbConnPara;
            pSysTable.DBConType = SysCommon.enumDBConType.OLEDB;
            pSysTable.DBType    = SysCommon.enumDBType.ACCESS;

            //高程点图层,参数ID为19(还需要改进)
            string pointFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 19, out eError);

            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }
            //等高线图层,参数ID为20
            string lineFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 20, out eError);

            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }
            //高程点高程字段名,参数ID为22
            string pointFieldsname = TopologyCheckClass.GetParaValue(pSysTable, 22, out eError);

            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }
            //等高线高程字段名,参数ID为23
            string lineFieldname = TopologyCheckClass.GetParaValue(pSysTable, 23, out eError);

            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }
            //等高线间距值,参数ID为21
            string intervalValue = TopologyCheckClass.GetParaValue(pSysTable, 21, out eError);

            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }
            //高程点搜索半径,参数ID为38
            string radiu = TopologyCheckClass.GetParaValue(pSysTable, 38, out eError);

            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }

            SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <IDataset>             LstFeaClass   = sysGisDataSet.GetAllFeatureClass();

            if (LstFeaClass.Count == 0)
            {
                return;
            }

            //执行等高线点线矛盾检查
            PointLineElevCheck(Hook, LstFeaClass, lineFeaclsname, lineFieldname, pointFeaclsname, pointFieldsname, Convert.ToDouble(intervalValue), out eError);
            if (eError != null)
            {
                eError = new Exception("等高线点线矛盾检查失败!" + eError.Message);
                return;
            }
            #region
            ////获取所有数据集
            //SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            //List<string> featureDatasetNames = sysGisDataSet.GetAllFeatureDatasetNames();
            //if (featureDatasetNames.Count == 0) return;
            //foreach (string name in featureDatasetNames)
            //{
            //    IFeatureDataset featureDataset = sysGisDataSet.GetFeatureDataset(name, out eError);
            //    if (eError != null) continue;

            //    //高程点图层,参数ID为19(还需要改进)
            //    string pointFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 19, out eError);
            //    if (eError != null)
            //    {
            //        eError=new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    //等高线图层,参数ID为20
            //    string lineFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 20, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    //高程点高程字段名,参数ID为22
            //    string pointFieldsname = TopologyCheckClass.GetParaValue(pSysTable, 22, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    //等高线高程字段名,参数ID为23
            //    string lineFieldname = TopologyCheckClass.GetParaValue(pSysTable, 23, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    //等高线间距值,参数ID为21
            //    string intervalValue = TopologyCheckClass.GetParaValue(pSysTable, 21, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    //高程点搜索半径,参数ID为38
            //    string radiu = TopologyCheckClass.GetParaValue(pSysTable, 38, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    //执行等高线点线矛盾检查
            //    PointLineElevCheck(Hook,featureDataset, lineFeaclsname, lineFieldname, pointFeaclsname, pointFieldsname, Convert.ToDouble(intervalValue), out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("等高线点线矛盾检查失败!" + eError.Message);
            //        return;
            //    }
            //}

            #endregion
        }
Example #6
0
        public void OnDataCheck()
        {
            Exception eError = null;

            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }

            //实现代码
            SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable();
            pSysTable.DbConn    = dataCheckParaSet.DbConnPara;
            pSysTable.DBConType = SysCommon.enumDBConType.OLEDB;
            pSysTable.DBType    = SysCommon.enumDBType.ACCESS;

            //分类代码字段名
            string codeName = TopologyCheckClass.GetCodeName(pSysTable, out eError);

            if (eError != null)
            {
                //eError=new Exception(eError.Message);
                return;
            }

            //等高线注记检查,参数ID为31
            DataTable mTable = TopologyCheckClass.GetParaValueTable(pSysTable, 31, out eError);

            if (eError != null)
            {
                //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
                return;
            }
            if (mTable.Rows.Count == 0)
            {
                //eError = new Exception("未进行等高线注记一致性检查参数配置!");
                return;
            }
            //等高线注记检查搜索半径,参数ID为34
            string paraValue3 = TopologyCheckClass.GetParaValue(pSysTable, 34, out eError);

            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }
            double serchRadiu3 = Convert.ToDouble(paraValue3);

            //等高线注记检查精度控制,参数ID为37
            paraValue3 = TopologyCheckClass.GetParaValue(pSysTable, 37, out eError);
            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }
            long precision3 = Convert.ToInt64(paraValue3);

            SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <IDataset>             LstFeaClass   = sysGisDataSet.GetAllFeatureClass();

            if (LstFeaClass.Count == 0)
            {
                return;
            }

            //执行等高线注记检查
            PointAnnoCheck(Hook, LstFeaClass, mTable, codeName, serchRadiu3, precision3, out eError);
            if (eError != null)
            {
                eError = new Exception("等高线注记检查失败。" + eError.Message);
                return;
            }

            #region 分类代码字段名
            //string codeName = TopologyCheckClass.GetCodeName(pSysTable, out eError);
            //if (eError != null)
            //{
            //    //eError=new Exception(eError.Message);
            //    return;
            //}

            ////获取所有数据集
            //SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            //List<string> featureDatasetNames = sysGisDataSet.GetAllFeatureDatasetNames();
            //if (featureDatasetNames.Count == 0) return;
            //foreach (string name in featureDatasetNames)
            //{
            //    IFeatureDataset featureDataset = sysGisDataSet.GetFeatureDataset(name, out eError);
            //    if (eError != null) continue;


            //    //等高线注记检查,参数ID为31
            //    DataTable mTable = TopologyCheckClass.GetParaValueTable(featureDataset, pSysTable, 31, out eError);
            //    if (eError != null)
            //    {
            //        //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
            //        return;
            //    }
            //    if (mTable.Rows.Count == 0)
            //    {
            //        continue;
            //    }
            //    //等高线注记检查搜索半径,参数ID为34
            //    string paraValue3 = TopologyCheckClass.GetParaValue(pSysTable, 34, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    double serchRadiu3 = Convert.ToDouble(paraValue3);
            //    //等高线注记检查精度控制,参数ID为37
            //    paraValue3 = TopologyCheckClass.GetParaValue(pSysTable, 37, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    long precision3 = Convert.ToInt64(paraValue3);
            //    //执行等高线注记检查
            //    PointAnnoCheck(Hook, featureDataset, mTable, codeName, serchRadiu3, precision3, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("等高线注记检查失败。" + eError.Message);
            //        return;
            //    }
            //}
            #endregion
        }
Example #7
0
//added by chulili 20110719 根据数据集加载历史数据
        public void AddHistoryDataByFD(string[] strTemp, string strType)
        {
            Mapcontrol.ClearLayers();
            Toccontrol.Update();
            Application.DoEvents();

            //加载历史数据
            Exception err = null;

            SysCommon.Gis.SysGisDataSet sourceSysGisDataSet = new SysCommon.Gis.SysGisDataSet();
            switch (strType)
            {
            case "SDE":
                sourceSysGisDataSet.SetWorkspace(strTemp[0], strTemp[1], strTemp[2], strTemp[3], strTemp[4], strTemp[5], out err);
                break;

            case "PDB":
                sourceSysGisDataSet.SetWorkspace(strTemp[2], SysCommon.enumWSType.PDB, out err);
                break;

            case "GDB":
                sourceSysGisDataSet.SetWorkspace(strTemp[2], SysCommon.enumWSType.GDB, out err);
                break;
            }

            if (err != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("连接数据库失败", "原因:" + err.Message);
                return;
            }
            //cyf 20110706 add
            DevComponents.AdvTree.Node ProjectNode = new DevComponents.AdvTree.Node();
            ProjectNode = m_ProTree.SelectedNode;
            while (ProjectNode.Parent != null)
            {
                ProjectNode = ProjectNode.Parent;
            }
            //cyf 20110625 add:
            DevComponents.AdvTree.Node DBNode = new DevComponents.AdvTree.Node(); //数据库树节点
            //获取数据库节点
            DBNode = m_ProTree.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(); //数据集树节点
            if (DBNode.Text == "现势库" || DBNode.Text == "历史库")                        //.DataKeyString == "现势库"
            {
                //获取数据集节点
                DtSetNode = m_ProTree.SelectedNode;
                while (DtSetNode.Parent != null && DtSetNode.DataKeyString != "FD")
                {
                    DtSetNode = DtSetNode.Parent;
                }
                if (DtSetNode.DataKeyString != "FD")
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集节点失败!");
                    return;
                }
            }
            //end
            //added by chulili 20110719
            XmlElement elementTemp   = (DBNode.Tag as XmlElement).SelectSingleNode(".//连接信息") as XmlElement;
            IWorkspace TempWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;

            SysCommon.Gis.SysGisDataSet sysGisDataset  = new SysCommon.Gis.SysGisDataSet(TempWorkSpace);
            IFeatureDataset             featureDataset = null; //数据集
            IGroupLayer pGroupLayer = new GroupLayerClass();

            if (m_ProTree.SelectedNode.DataKeyString == "FD")
            {
                featureDataset = sysGisDataset.GetFeatureDataset(m_ProTree.SelectedNode.Text, out err);
                if (err != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集失败,请检查该数据集是否存在!");
                    return;
                }
                pGroupLayer.Name = m_ProTree.SelectedNode.Text + "_" + ProjectNode.Text;
            }
            else if (m_ProTree.SelectedNode.DataKeyString == "FC")
            {
                featureDataset = sysGisDataset.GetFeatureDataset(DtSetNode.Text, out err);
                if (err != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集失败!");
                    return;
                }
                pGroupLayer.Name = DtSetNode.Text + "_" + ProjectNode.Text;
            }
            List <IDataset> lstDataset = sysGisDataset.GetFeatureClass(featureDataset);
            //end added by chulili
            //List<string> lstNames = sourceSysGisDataSet.GetFeatureClassNames();
            XmlElement feaclsElem = null;

            try { feaclsElem = (m_ProTree.SelectedNode.Tag as XmlElement).SelectSingleNode(".//图层名") as XmlElement; }
            catch { }

            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;

                pFeatureLayer.Name = dataset.Name;
                if (m_ProTree.SelectedNode.DataKeyString == "FC")
                {
                    //加载指定的图层
                    if (m_ProTree.SelectedNode.Text != pFeatureLayer.Name)
                    {
                        continue;
                    }
                }
                else if (m_ProTree.SelectedNode.DataKeyString == "FD")
                {
                    if (feaclsElem != null)
                    {
                        if (!feaclsElem.GetAttribute("名称").Contains(pFeatureLayer.Name))
                        {
                            //若不具备数据权限,则不进行加载
                            continue;
                        }
                    }
                }
                pGroupLayer.Add(pFeatureLayer as ILayer);
            }
            Mapcontrol.Map.AddLayer(pGroupLayer);
            SysCommon.Gis.ModGisPub.LayersCompose(Mapcontrol);

            InitialSliderItem(Mapcontrol);
        }
        public override void OnClick()
        {
            Exception           eError = null;
            FolderBrowserDialog pFolderBrowserDialog = new FolderBrowserDialog();

            if (pFolderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                ///获得树图上选择的工程节点
                #region 获得工程树图上的参数信息
                ///获得树图上选择的工程节点
                //cyf 20110626 modify
                DevComponents.AdvTree.Node pCurNode   = m_Hook.ProjectTree.SelectedNode;   //当前树节点,栅格数据节点
                DevComponents.AdvTree.Node pDBProNode = m_Hook.ProjectTree.SelectedNode;   //获得工程树图节点
                while (pDBProNode.Parent != null)
                {
                    pDBProNode = pDBProNode.Parent;
                }
                if (pDBProNode.DataKeyString != "project")
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取工程树图节点失败!");
                    return;
                }
                //end
                //cyf  20110609 modify:
                //string pProjectname = pCurNode.Name;
                string pProjectname = pDBProNode.Text;
                //end
                System.Xml.XmlNode Projectnode = m_Hook.DBXmlDocument.SelectSingleNode("工程管理/工程[@名称='" + pProjectname + "']");
                //cyf
                if (Projectnode == null)
                {
                    return;
                }
                //end
                //cyf 20110626 modify:获取栅格数据图层的存储类型
                //获得栅格数据库类型
                //System.Xml.XmlElement DbTypeElem = Projectnode.SelectSingleNode(".//内容//栅格数据库") as System.Xml.XmlElement;
                //string dbType = DbTypeElem.GetAttribute("存储类型");   //栅格编目、栅格数据集
                XmlElement pCurElem = null;  //图层xml节点
                try { pCurElem = pCurNode.Tag as XmlElement; }
                catch { }
                if (pCurElem == null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取图层xml节点失败!");
                    return;
                }
                string dbType             = pCurElem.GetAttribute("存储类型").Trim(); //栅格数据存储类型
                string pDesRasterCollName = pCurElem.GetAttribute("名称").Trim();   //栅格数据名称

                //获得栅格目录,栅格数据集名称
                //System.Xml.XmlElement DbcataLogNameElem = Projectnode.SelectSingleNode(".//栅格数据库/连接信息/库体") as System.Xml.XmlElement;
                //if (DbcataLogNameElem == null) return;
                //string pDesRasterCollName = DbcataLogNameElem.GetAttribute("名称");    //栅格数据名称
                //if (pDesRasterCollName == "") return;
                //end

                //获得连接信息
                System.Xml.XmlElement DbConnElem = Projectnode.SelectSingleNode(".//栅格数据库/连接信息") as System.Xml.XmlElement;
                string pType     = DbConnElem.GetAttribute("类型");
                string pServer   = DbConnElem.GetAttribute("服务器");
                string pInstance = DbConnElem.GetAttribute("服务名");
                string pDataBase = DbConnElem.GetAttribute("数据库");
                string pUser     = DbConnElem.GetAttribute("用户");
                string pPassword = DbConnElem.GetAttribute("密码");
                string pVersion  = DbConnElem.GetAttribute("版本");
                //cyf 20110609 add
                string pConnectInfo = "";         //连接信息字符串
                pConnectInfo = pType + "," + pServer + "," + pInstance + "," + pDataBase + "," + pUser + "," + pPassword + "," + pVersion;
                //end
                #endregion
                #region 设置数据库连接信息
                SysCommon.Gis.SysGisDataSet pSysDt = new SysCommon.Gis.SysGisDataSet();
                if (pType.ToUpper() == "PDB")
                {
                    pSysDt.SetWorkspace(pDataBase, SysCommon.enumWSType.PDB, out eError);
                }
                else if (pType.ToUpper() == "GDB")
                {
                    pSysDt.SetWorkspace(pDataBase, SysCommon.enumWSType.GDB, out eError);
                }
                else if (pType.ToUpper() == "SDE")
                {
                    pSysDt.SetWorkspace(pServer, pInstance, "", pUser, pPassword, pVersion, out eError);
                    pDesRasterCollName = pUser + "." + pDesRasterCollName;
                }
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                    return;
                }
                #endregion

                //cyf 20110609 add:读取栅格数据入库日志,
                #region 检查是否存在已经入库的数据
                SysCommon.DataBase.SysTable pSysTable = null;
                Dictionary <string, string> DicbeInDb = new Dictionary <string, string>();  //用来已经入库的栅格数据的源路径和目标连接信息
                if (File.Exists(ModData.RasterInDBLog))
                {
                    //若存在栅格数据入库日志,则将入库过的数据的路径保存起来
                    pSysTable = new SysCommon.DataBase.SysTable();
                    pSysTable.SetDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ModData.RasterInDBLog + ";Persist Security Info=True", SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out eError);
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接栅格入库日志表失败!");
                        return;
                    }
                    //获得栅格入库日志表
                    DataTable pTable = pSysTable.GetTable("rasterfileinfo", out eError);
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取栅格入库日志表失败!");
                        pSysTable.CloseDbConnection();
                        return;
                    }
                    for (int i = 0; i < pTable.Rows.Count; i++)
                    {
                        string pFileName = pTable.Rows[i][0].ToString();
                        string pDesPath  = pTable.Rows[i][2].ToString();
                        if (!DicbeInDb.ContainsKey(pFileName))
                        {
                            DicbeInDb.Add(pFileName, pDesPath);
                        }
                    }
                    //关闭连接
                    pSysTable.CloseDbConnection();
                    //cyf 20110610 modify
                    if (pTable.Rows.Count > 0)
                    {
                        //存在已经入库的数据
                        RasterErrInfoFrm pRasterErrInfoFrm = new RasterErrInfoFrm(pTable);
                        if (pRasterErrInfoFrm.ShowDialog() != DialogResult.OK)
                        {
                            //若不继续入库,则返回
                            return;
                        }
                    }
                    //end
                }

                #endregion
                //end
                //cyf 20110609
                //连接栅格数据入库日志表
                if (!File.Exists(ModData.RasterInDBLog))
                {
                    if (File.Exists(ModData.RasterInDBTemp))
                    {
                        File.Copy(ModData.RasterInDBTemp, ModData.RasterInDBLog);
                    }
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "没有找到日志表模板:" + ModData.RasterInDBTemp);
                    return;
                }
                pSysTable = new SysCommon.DataBase.SysTable();
                pSysTable.SetDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ModData.RasterInDBLog + ";Persist Security Info=True", SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接栅格入库日志表失败!");
                    return;
                }
                //获得文件夹下面所有的子文件
                string        pRootFile      = pFolderBrowserDialog.SelectedPath;// 选择的文件夹路径
                DirectoryInfo pDirectoryInfo = new DirectoryInfo(pRootFile);
                //FileInfo[] pFileInfoArr = pDirectoryInfo.GetFiles("*.tif", SearchOption.AllDirectories);
                FileInfo[] pFileInfoArr = pDirectoryInfo.GetFiles("*.*", SearchOption.AllDirectories);
                //添加进度条
                if (pAppFormRef.ProgressBar != null)
                {
                    pAppFormRef.ProgressBar.Visible = true;
                    pAppFormRef.ProgressBar.Maximum = pFileInfoArr.Length;
                    pAppFormRef.ProgressBar.Minimum = 0;
                    pAppFormRef.ProgressBar.Value   = 0;
                    Application.DoEvents();
                }
                //end
                for (int i = 0; i < pFileInfoArr.Length; i++)
                {
                    FileInfo pFileInfo = pFileInfoArr[i];
                    string   pFileName = pFileInfo.FullName; //文件名

                    if (!pFileName.ToLower().EndsWith("tif") && !pFileName.ToLower().EndsWith("img"))
                    {
                        //如果不是TIF文件和IMG文件则不参与检查
                        //进度条加1
                        if (pAppFormRef.ProgressBar != null)
                        {
                            pAppFormRef.ProgressBar.Value++;
                            Application.DoEvents();
                        }
                        continue;
                    }
                    //cyf 20110609 add:对入库过的数据进行判断和筛选
                    if (DicbeInDb.ContainsKey(pFileName))
                    {
                        //已经进行入库
                        if (DicbeInDb[pFileName] == pConnectInfo)
                        {
                            //如果源的路径与目标的路径都相同,则说明已经入库了
                            //进度条加1
                            if (pAppFormRef.ProgressBar != null)
                            {
                                pAppFormRef.ProgressBar.Value++;
                                Application.DoEvents();
                            }
                            continue;
                        }
                    }
                    //end
                    //cyf 20110610 add:文字提示
                    if (pAppFormRef != null)
                    {
                        pAppFormRef.OperatorTips = "正在进行数据" + pFileName + "入库...";
                        Application.DoEvents();
                    }
                    //end
                    //cyf 20110610 adds
                    string Starime = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();  //开始时间
                    //end
                    //进行数据入库
                    string fileFullName = pFileName;
                    if (dbType == "栅格数据集")
                    {
                        //栅格数据集入库
                        InputRasterDataset(pDesRasterCollName, fileFullName, pSysDt.WorkSpace, out eError);
                    }
                    else if (dbType == "栅格编目")
                    {
                        //栅格编目数据入库
                        InputRasterCatalogData(pDesRasterCollName, fileFullName, pSysDt.WorkSpace, out eError);
                    }
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "栅格数据入库出错!\n" + eError.Message);
                        return;
                    }
                    //若入库成功,则将入库成功的数据添加到栅格数据日志表中
                    //cyf 20110609 插入栅格数据日志表中
                    string insertStr = "insert into rasterfileinfo values('" + pFileName + "','" + Starime + "','" + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "','" + pConnectInfo + "')";
                    pSysTable.UpdateTable(insertStr, out eError);
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "插入栅格入库日志表失败!");
                        continue;
                    }
                    //进度条加1
                    if (pAppFormRef.ProgressBar != null)
                    {
                        pAppFormRef.ProgressBar.Value++;
                        Application.DoEvents();
                    }
                    //end
                }
                //cyf  20110609 add:
                //关闭连接
                pSysTable.CloseDbConnection();
                //end
                //if (dbType == "栅格编目")
                //{
                //    InputRasterCatalogData(pDesRasterCollName, fileList, pSysDt.WorkSpace, out eError);
                //}
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "栅格数据入库完成!");

                //cyf 20110609 add
                if (pAppFormRef.ProgressBar != null)
                {
                    pAppFormRef.ProgressBar.Visible = false;
                    //cyf 20110610 add:清空文字提示
                    pAppFormRef.OperatorTips = "";
                    //end
                }
                //end

                //cyf 20110610 add:栅格正常结束的日志
                if (File.Exists(ModData.RasterInDBLog))
                {
                    File.Delete(ModData.RasterInDBLog);
                }
                //end
            }
        }
Example #9
0
        /// <summary>
        /// 单击开始检查时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_enter_Click(object sender, EventArgs e)
        {
            Exception eError = null;

            if (txtRange.Text == "")
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请选择接边范围数据库!");
                return;
            }
            SysCommon.Gis.SysGisDataSet pRangeGisDB = new SysCommon.Gis.SysGisDataSet();
            pRangeGisDB.SetWorkspace(txtRange.Text.ToString().Trim(), SysCommon.enumWSType.PDB, out eError);
            if (eError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "接边范围数据库连接失败!");
                return;
            }

            if (ShowException())
            {
                #region 错误日志连接信息
                string logPath = txtLog.Text;
                if (logPath.Trim() == string.Empty)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请选择日志输出路径!");
                    return;
                }
                if (File.Exists(logPath))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据文件已存在!\n" + logPath);
                }

                //生成日志信息EXCEL格式
                SysCommon.DataBase.SysDataBase pSysLog = new SysCommon.DataBase.SysDataBase();
                pSysLog.SetDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + logPath + "; Extended Properties=Excel 8.0;", SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "日志信息表连接失败!");
                    return;
                }
                string strCreateTableSQL = @" CREATE TABLE ";
                strCreateTableSQL += @" 错误日志 ";
                strCreateTableSQL += @" ( ";
                strCreateTableSQL += @" 检查功能名 VARCHAR, ";
                strCreateTableSQL += @" 错误类型 VARCHAR, ";
                strCreateTableSQL += @" 错误描述 VARCHAR, ";
                strCreateTableSQL += @" 数据图层1 VARCHAR, ";
                strCreateTableSQL += @" 数据OID1 VARCHAR, ";
                strCreateTableSQL += @" 数据图层2 VARCHAR, ";
                strCreateTableSQL += @" 数据OID2 VARCHAR, ";
                strCreateTableSQL += @" 定位点X VARCHAR , ";
                strCreateTableSQL += @" 定位点Y VARCHAR , ";
                strCreateTableSQL += @" 检查时间 VARCHAR ,";
                strCreateTableSQL += @" 数据文件路径 VARCHAR ";
                strCreateTableSQL += @" ) ";

                pSysLog.UpdateTable(strCreateTableSQL, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "插入表头出错!");
                    return;
                }

                #endregion

                double         AreaValue   = Convert.ToDouble(txt_area.Text);   //范围容差
                double         SearchValue = Convert.ToDouble(txt_search.Text); //搜索容差
                DataCheckClass JoinChecks  = new DataCheckClass(_AppHk);
                //将日志表连接信息和表名保存起来
                JoinChecks.ErrDbCon     = pSysLog.DbConn;
                JoinChecks.ErrTableName = "错误日志";
                JoinChecks.AREAValue    = AreaValue;
                JoinChecks.SEARCHValue  = SearchValue;

                SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable();
                string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + TopologyCheckClass.GeoDataCheckParaPath;
                pSysTable.SetDbConnection(conStr, SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "GIS数据检查配置表连接失败!");
                    return;
                }
                //获得接边范围的图层名和字段名
                DataTable mTable = GetParaValueTable(pSysTable, 39, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询GIS数据检察配置表失败!");
                    return;
                }
                if (mTable.Rows.Count == 0)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未进行接边检查参数的配置!");
                    return;
                }
                string rangeLayerName = mTable.Rows[0]["图层"].ToString().Trim();
                string rangeFieldName = mTable.Rows[0]["字段项"].ToString().Trim();
                if (rangeFieldName == "" || rangeLayerName == "")
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "接边检查参数配置不完整!");
                    return;
                }

                //设置界面上初始显示的属性表
                TreeLayer.Nodes[Convert.ToInt32(dataGridViewX1.Tag)].Name = "";
                for (int d = 0; d < dataGridViewX1.Rows.Count; d++)
                {
                    if (Convert.ToBoolean(dataGridViewX1.Rows[d].Cells[0].Value) == true)
                    {
                        string temp = dataGridViewX1.Rows[d].Cells[1].Value.ToString();
                        TreeLayer.Nodes[Convert.ToInt32(dataGridViewX1.Tag)].Name += temp + " ";
                    }
                }

                if (!JoinChecks.Initialize_Tree(pRangeGisDB, rangeLayerName, rangeFieldName, _AppHk.DataTree, TreeLayer, _AppHk, out eError))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "初始化树图失败!");
                    return;
                }
                //int Pur = PurviewState();//验证是管理员还是作业员

                ///说明:作业员以图幅去进行接边处理,管理员以任务区范围去接边处理
                //if (Pur == 1)
                //{
                ////管理员
                ////初始化数据处理树图
                //if (!JoinChecks.Initialize_Tree("任务区范围", "CASE_NAME", _AppHk.DataTree, TreeLayer, _AppHk))
                //{
                //    return;
                //}
                //}
                //else if(Pur == 0)
                //{
                //    //作业员
                //    //初始化数据处理树图
                //    if (!JoinChecks.Initialize_Tree("图幅范围", "MAP_ID", _AppHk.DataTree, TreeLayer, _AppHk))
                //    {
                //        return;
                //    }
                //}
                this.Close();
                //数据接边检查
                //用线程做速度会很慢主要体现在要素空间查询时
                //System.Threading.ParameterizedThreadStart parstart = new System.Threading.ParameterizedThreadStart(JoinChecks.DoJoinCheck);
                //Thread aThread = new Thread(parstart);
                //_AppHk.CurrentThread = aThread;
                //aThread.Priority = ThreadPriority.Highest;
                //aThread.Start(_AppHk as object);, Pur
                int Pur = 0;        //以图幅进行接边
                JoinChecks.DoJoinCheck(_AppHk as object, Pur);
            }
        }
Example #10
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();
        }
Example #11
0
        public bool CreateFeatureClassUnderDS(string FCName, string DSName, bool IncludeFeature, bool CreateDS, string TempDBID, bool AddFID)
        {
            IFeatureWorkspace pDesFeatureWorkspace = this._Workspace as IFeatureWorkspace;
            IFeatureClass     pDesFeatureClass     = null;

            if (pDesFeatureWorkspace == null)
            {
                return(false);
            }

            IFeatureWorkspace pSourFeatureWorkspace = this._TempleteWorkspace as IFeatureWorkspace;

            if (pSourFeatureWorkspace == null)
            {
                return(false);
            }

            IFeatureDataset pDesFeatureDataset = null;
            IFeatureDataset pSrcFeatureDataset = null;

            if (CreateDS)
            {
                //创建数据集

                pSrcFeatureDataset = pSourFeatureWorkspace.OpenFeatureDataset(DSName);
                IGeoDataset pGeoDataset = pSrcFeatureDataset as IGeoDataset;
                pDesFeatureDataset = pDesFeatureWorkspace.CreateFeatureDataset(DSName + TempDBID, pGeoDataset.SpatialReference);
            }
            else
            {
                pDesFeatureDataset = pDesFeatureWorkspace.OpenFeatureDataset(DSName + TempDBID);
            }

            #region 创建目标图层
            //获取源要素类
            IFeatureClass pSourFeatureClass = pSourFeatureWorkspace.OpenFeatureClass(FCName);
            if (pSourFeatureClass == null)
            {
                return(false);
            }

            //获取源要素类后判断要素类的类型

            if (pSourFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)   //如果是注记层
            {
                IFeatureWorkspaceAnno pFWSAnno   = pDesFeatureWorkspace as IFeatureWorkspaceAnno;
                IAnnoClass            pAnnoClass = pSourFeatureClass.Extension as IAnnoClass;
                IGraphicsLayerScale   pGLS       = new GraphicsLayerScaleClass();
                pGLS.ReferenceScale = pAnnoClass.ReferenceScale;
                pGLS.Units          = pAnnoClass.ReferenceScaleUnits;

                ///添加特殊字段
                ///
                IField     pField     = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;

                pFieldEdit.Editable_2 = true;
                pFieldEdit.Name_2     = "GOFID";
                pFieldEdit.Type_2     = esriFieldType.esriFieldTypeInteger;



                IField     pField2     = new FieldClass();
                IFieldEdit pFieldEdit2 = pField2 as IFieldEdit;

                pFieldEdit2.Editable_2 = true;
                pFieldEdit2.Name_2     = "pro_id"; //项目ID
                pFieldEdit2.Type_2     = esriFieldType.esriFieldTypeInteger;

                IFields pFields = pSourFeatureClass.Fields;

                if (AddFID)
                {
                    IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
                    pFieldsEdit.AddField(pField);
                    pFieldsEdit.AddField(pField2);
                    pDesFeatureClass = pFWSAnno.CreateAnnotationClass(FCName + TempDBID, pFields, pSourFeatureClass.CLSID, pSourFeatureClass.EXTCLSID, pSourFeatureClass.ShapeFieldName, "", pDesFeatureDataset, null, pAnnoClass.AnnoProperties, pGLS, pAnnoClass.SymbolCollection, true);
                    pFieldsEdit.DeleteField(pField);
                    pFieldsEdit.DeleteField(pField2);
                }
                else
                {
                    pDesFeatureClass = pFWSAnno.CreateAnnotationClass(FCName + TempDBID, pFields, pSourFeatureClass.CLSID, pSourFeatureClass.EXTCLSID, pSourFeatureClass.ShapeFieldName, "", pDesFeatureDataset, null, pAnnoClass.AnnoProperties, pGLS, pAnnoClass.SymbolCollection, true);
                }
            }
            else    //如果是普通要素类
            {
                ///添加特殊字段
                ///
                IField     pField     = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;

                pFieldEdit.Editable_2 = true;
                pFieldEdit.Name_2     = "GOFID";
                pFieldEdit.Type_2     = esriFieldType.esriFieldTypeInteger;


                IField     pField2     = new FieldClass();
                IFieldEdit pFieldEdit2 = pField2 as IFieldEdit;

                pFieldEdit2.Editable_2 = true;
                pFieldEdit2.Name_2     = "pro_id"; //项目ID
                pFieldEdit2.Type_2     = esriFieldType.esriFieldTypeInteger;

                IFields pFields = pSourFeatureClass.Fields;

                if (AddFID)
                {
                    IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
                    pFieldsEdit.AddField(pField);
                    pFieldsEdit.AddField(pField2);
                    pDesFeatureClass = pDesFeatureDataset.CreateFeatureClass(FCName + TempDBID, pFields, pSourFeatureClass.CLSID, pSourFeatureClass.EXTCLSID, pSourFeatureClass.FeatureType, pSourFeatureClass.ShapeFieldName, "");
                    pFieldsEdit.DeleteField(pField);
                    pFieldsEdit.DeleteField(pField2);
                }
                else
                {
                    pDesFeatureClass = pDesFeatureDataset.CreateFeatureClass(FCName + TempDBID, pFields, pSourFeatureClass.CLSID, pSourFeatureClass.EXTCLSID, pSourFeatureClass.FeatureType, pSourFeatureClass.ShapeFieldName, "");
                }
            }

            #endregion

            if (pDesFeatureClass == null)
            {
                return(false);
            }

            //导入要素
            if (IncludeFeature)  //如果需要复制要素
            {
                Exception eError = null;

                Dictionary <string, string> pDic = new Dictionary <string, string>();
                IFeatureCursor pFeatureCursor    = pSourFeatureClass.Search(null, false);

                IFields pFields = pSourFeatureClass.Fields;

                for (int i = 0; i < pFields.FieldCount; i++)
                {
                    IField pField = pFields.get_Field(i);
                    if (pField.Editable)
                    {
                        pDic.Add(pField.Name, pField.Name);
                    }
                }

                SysCommon.Gis.SysGisDataSet pSysGisDataSet = new SysCommon.Gis.SysGisDataSet();
                pSysGisDataSet.WorkSpace = this._Workspace;

                pSysGisDataSet.NewFeatures(FCName, pFeatureCursor, pDic, null, true, true, out eError);

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
            }
            return(true);
        }
Example #12
0
        /// <summary>
        /// 根据模板创建指定的要素类(从模板中复制要素类)

        /// </summary>
        /// <param name="FCName">要素类名称</param>
        /// <param name="IncludeFeature">是否导入源要素类中的要素</param>
        /// <returns>是否创建成功</returns>
        public bool CreateDefaultFeatureClass(string FCName, bool IncludeFeature)
        {
            IFeatureWorkspace pDesFeatureWorkspace = this._Workspace as IFeatureWorkspace;
            IFeatureClass     pDesFeatureClass     = null;

            if (pDesFeatureWorkspace == null)
            {
                return(false);
            }

            IFeatureWorkspace pSourFeatureWorkspace = this._TempleteWorkspace as IFeatureWorkspace;

            if (pSourFeatureWorkspace == null)
            {
                return(false);
            }

            #region 创建目标图层
            //获取源要素类
            IFeatureClass pSourFeatureClass = pSourFeatureWorkspace.OpenFeatureClass(FCName);
            if (pSourFeatureClass == null)
            {
                return(false);
            }

            //获取源要素类后判断要素类的类型

            if (pSourFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)   //如果是注记层
            {
                IFeatureWorkspaceAnno pFWSAnno   = pDesFeatureWorkspace as IFeatureWorkspaceAnno;
                IAnnoClass            pAnnoClass = pSourFeatureClass.Extension as IAnnoClass;
                IGraphicsLayerScale   pGLS       = new GraphicsLayerScaleClass();
                pGLS.ReferenceScale = pAnnoClass.ReferenceScale;
                pGLS.Units          = pAnnoClass.ReferenceScaleUnits;

                pDesFeatureClass = pFWSAnno.CreateAnnotationClass(pSourFeatureClass.AliasName, pSourFeatureClass.Fields, pSourFeatureClass.CLSID, pSourFeatureClass.EXTCLSID, pSourFeatureClass.ShapeFieldName, "", null, null, pAnnoClass.AnnoProperties, pGLS, pAnnoClass.SymbolCollection, true);
            }
            else    //如果是普通要素类
            {
                pDesFeatureClass = pDesFeatureWorkspace.CreateFeatureClass(FCName, pSourFeatureClass.Fields, pSourFeatureClass.CLSID, pSourFeatureClass.EXTCLSID, pSourFeatureClass.FeatureType, pSourFeatureClass.ShapeFieldName, "");
            }

            #endregion

            if (pDesFeatureClass == null)
            {
                return(false);
            }

            //导入要素
            if (IncludeFeature)  //如果需要复制要素
            {
                Exception eError = null;

                Dictionary <string, string> pDic = new Dictionary <string, string>();
                IFeatureCursor pFeatureCursor    = pSourFeatureClass.Search(null, false);

                IFields pFields = pSourFeatureClass.Fields;

                for (int i = 0; i < pFields.FieldCount; i++)
                {
                    IField pField = pFields.get_Field(i);
                    if (pField.Editable)
                    {
                        pDic.Add(pField.Name, pField.Name);
                    }
                }

                SysCommon.Gis.SysGisDataSet pSysGisDataSet = new SysCommon.Gis.SysGisDataSet();
                pSysGisDataSet.WorkSpace = this._Workspace;

                pSysGisDataSet.NewFeatures(FCName, pFeatureCursor, pDic, null, true, true, out eError);

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
            }
            return(true);
        }
Example #13
0
        /////////该类实现将各种ArcGis图层加载至数据库集成管理界面的图层控件当中来////////
        /// <summary>
        /// 加载矢量库体
        /// </summary>
        /// <param name="DbEleInfo">矢量库体对应的库体信息XmlElement</param>
        /// <param name="in_MXDFile">符号化mxd文件路径</param>
        /// <param name="ex">输出错误信息</param>
        public static void AddFeaLayer(Plugin.Application.IAppDBIntegraRef m_Hook, XmlElement DbEleInfo, string in_MXDFile, out Exception ex)
        {
            ex = null;
            try
            {
                XmlElement elementTemp   = DbEleInfo.SelectSingleNode(".//现势库/连接信息") as XmlElement;
                IWorkspace TempWorkSpace = ModDBOperate.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;
                if (TempWorkSpace == null)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                    ex = new Exception("连接数据库失败!");
                    return;
                }
                ILayer player = ModDBOperate.GetGroupLayer(m_Hook.MapControl, m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + m_Hook.ProjectTree.SelectedNode.Text);
                if (player != null)
                {
                    m_Hook.MapControl.Map.DeleteLayer(player);
                    m_Hook.TOCControl.Update();
                }

                IGroupLayer pGroupLayer = new GroupLayerClass();
                SysCommon.Gis.SysGisDataSet sysGisDataset  = new SysCommon.Gis.SysGisDataSet(TempWorkSpace);
                IFeatureDataset             featureDataset = sysGisDataset.GetFeatureDataset((elementTemp.FirstChild as XmlElement).GetAttribute("名称"), out ex);
                if (ex != null)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据失败!");
                    ex = new Exception("获取数据发生异常:" + ex.Message);
                    return;
                }

                pGroupLayer.Name = m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + m_Hook.ProjectTree.SelectedNode.Text;
                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")
                    {
                        if (dataset.Name.ToUpper().Contains(userName.Trim().ToUpper()))
                        {
                            //SDE用户图层名去掉用户名
                            pFeatureLayer.Name = dataset.Name.Substring(userName.Trim().Length + 1);
                        }
                        else
                        {
                            pFeatureLayer.Name = dataset.Name;
                        }
                    }
                    else
                    {
                        pFeatureLayer.Name = dataset.Name;
                    }
                    pFeatureLayer.Visible = false;
                    pGroupLayer.Add(pFeatureLayer as ILayer);
                }
                m_Hook.MapControl.Map.AddLayer(pGroupLayer);
                SysCommon.Gis.ModGisPub.LayersCompose(m_Hook.MapControl);
            }
            catch (Exception eError)
            {
                ex = eError;
                return;
            }
        }
Example #14
0
        public override void OnClick()
        {
            Exception      eError   = null;
            OpenFileDialog OpenFile = new OpenFileDialog();

            OpenFile.CheckFileExists = true;
            OpenFile.CheckPathExists = true;
            OpenFile.Title           = "选择栅格数据";
            OpenFile.Filter          = "tif数据(*.tif)|*.tif|img数据(*.img)|*.img";
            OpenFile.Multiselect     = true;
            if (OpenFile.ShowDialog() == DialogResult.OK)
            {
                string[] fileArr = OpenFile.FileNames;

                ///获得树图上选择的工程节点
                //cyf 20110626 modify
                DevComponents.AdvTree.Node pCurNode   = m_Hook.ProjectTree.SelectedNode;   //当前树节点,栅格数据节点
                DevComponents.AdvTree.Node pDBProNode = m_Hook.ProjectTree.SelectedNode;   //获得工程树图节点
                while (pDBProNode.Parent != null)
                {
                    pDBProNode = pDBProNode.Parent;
                }
                if (pDBProNode.DataKeyString != "project")
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取工程树图节点失败!");
                    return;
                }
                //end
                //cyf  20110609 modify:
                //string pProjectname = pCurNode.Name;
                string pProjectname = pDBProNode.Text;
                //end
                System.Xml.XmlNode Projectnode = m_Hook.DBXmlDocument.SelectSingleNode("工程管理/工程[@名称='" + pProjectname + "']");
                //cyf
                if (Projectnode == null)
                {
                    return;
                }
                //end
                //cyf 20110626 modify:获取栅格数据图层的存储类型
                //获得栅格数据库类型
                //System.Xml.XmlElement DbTypeElem = Projectnode.SelectSingleNode(".//内容//栅格数据库") as System.Xml.XmlElement;
                //string dbType = DbTypeElem.GetAttribute("存储类型");   //栅格编目、栅格数据集
                XmlElement pCurElem = null;  //图层xml节点
                try { pCurElem = pCurNode.Tag as XmlElement; }
                catch { }
                if (pCurElem == null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取图层xml节点失败!");
                    return;
                }
                string dbType             = pCurElem.GetAttribute("存储类型").Trim(); //栅格数据存储类型
                string pDesRasterCollName = pCurElem.GetAttribute("名称").Trim();   //栅格数据名称

                //获得栅格目录,栅格数据集名称
                //System.Xml.XmlElement DbcataLogNameElem = Projectnode.SelectSingleNode(".//栅格数据库/连接信息/库体") as System.Xml.XmlElement;
                //if (DbcataLogNameElem == null) return;
                //string pDesRasterCollName = DbcataLogNameElem.GetAttribute("名称");    //栅格数据名称
                //if (pDesRasterCollName == "") return;
                //end

                //获得连接信息
                System.Xml.XmlElement DbConnElem = Projectnode.SelectSingleNode(".//栅格数据库/连接信息") as System.Xml.XmlElement;
                string pType     = DbConnElem.GetAttribute("类型");
                string pServer   = DbConnElem.GetAttribute("服务器");
                string pInstance = DbConnElem.GetAttribute("服务名");
                string pDataBase = DbConnElem.GetAttribute("数据库");
                string pUser     = DbConnElem.GetAttribute("用户");
                string pPassword = DbConnElem.GetAttribute("密码");
                string pVersion  = DbConnElem.GetAttribute("版本");
                //cyf 20110609 add
                string pConnectInfo = "";         //连接信息字符串
                pConnectInfo = pType + "|" + pServer + "|" + pInstance + "|" + pDataBase + "|" + pUser + "|" + pPassword + "|" + pVersion;
                //end
                //获得目标数据库的参数
                //System.Xml.XmlElement DbParaElem = Projectnode.SelectSingleNode(".//栅格数据库/参数设置") as System.Xml.XmlElement;
                //string resampleTypeStr = DbParaElem.GetAttribute("重采样类型");
                //string compressionTypeStr = DbParaElem.GetAttribute("压缩类型");
                //string pyramid = DbParaElem.GetAttribute("金字塔");
                //string tileH = DbParaElem.GetAttribute("瓦片高度");
                //string tileW = DbParaElem.GetAttribute("瓦片宽度");
                //string bandNum = DbParaElem.GetAttribute("波段");
                //rstResamplingTypes resampleType = GetResampleTpe(resampleTypeStr);
                //esriRasterCompressionType compressionType = GetCompression(compressionTypeStr);
                //if (tileH == "")
                //{
                //    tileH = "128";
                //}
                //if (tileW == "")
                //{
                //    tileW = "128";
                //}
                //if (pyramid == "")
                //{
                //    pyramid = "6";
                //}

                //设置数据库连接信息
                SysCommon.Gis.SysGisDataSet pSysDt = new SysCommon.Gis.SysGisDataSet();
                if (pType.ToUpper() == "PDB")
                {
                    pSysDt.SetWorkspace(pDataBase, SysCommon.enumWSType.PDB, out eError);
                }
                else if (pType.ToUpper() == "GDB")
                {
                    pSysDt.SetWorkspace(pDataBase, SysCommon.enumWSType.GDB, out eError);
                }
                else if (pType.ToUpper() == "SDE")
                {
                    pSysDt.SetWorkspace(pServer, pInstance, "", pUser, pPassword, pVersion, out eError);
                    pDesRasterCollName = pUser + "." + pDesRasterCollName;
                }
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                    return;
                }

                //Thread aThread = null;
                //cyf 20110609 add:读取栅格数据入库日志,检查是否存在已经入库的数据
                SysCommon.DataBase.SysTable pSysTable = null;
                Dictionary <string, string> DicbeInDb = new Dictionary <string, string>();  //用来已经入库的栅格数据的源路径和目标连接信息
                if (File.Exists(ModData.RasterInDBLog))
                {
                    //若存在栅格数据入库日志,则将入库过的数据的路径保存起来
                    pSysTable = new SysCommon.DataBase.SysTable();
                    pSysTable.SetDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ModData.RasterInDBLog + ";Persist Security Info=True", SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out eError);
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接栅格入库日志表失败!");
                        return;
                    }
                    //获得栅格入库日志表
                    DataTable pTable = pSysTable.GetTable("rasterfileinfo", out eError);
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取栅格入库日志表失败!");
                        pSysTable.CloseDbConnection();
                        return;
                    }
                    for (int i = 0; i < pTable.Rows.Count; i++)
                    {
                        string pFileName = pTable.Rows[i][0].ToString();
                        string pDesPath  = pTable.Rows[i][3].ToString();
                        if (!DicbeInDb.ContainsKey(pFileName))
                        {
                            DicbeInDb.Add(pFileName, pDesPath);
                        }
                    }
                    //关闭连接
                    pSysTable.CloseDbConnection();
                    //cyf 20110610 modify
                    if (pTable.Rows.Count > 0)
                    {
                        //存在已经入库的数据
                        RasterErrInfoFrm pRasterErrInfoFrm = new RasterErrInfoFrm(pTable);
                        if (pRasterErrInfoFrm.ShowDialog() != DialogResult.OK)
                        {
                            //若不继续入库,则返回
                            return;
                        }
                    }
                    //end
                }
                //end

                ///进行数据入库
                //cyf 20110609
                //连接栅格数据入库日志表
                if (!File.Exists(ModData.RasterInDBLog))
                {
                    if (File.Exists(ModData.RasterInDBTemp))
                    {
                        File.Copy(ModData.RasterInDBTemp, ModData.RasterInDBLog);
                    }
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "没有找到日志表模板:" + ModData.RasterInDBTemp);

                    return;
                }
                pSysTable = new SysCommon.DataBase.SysTable();
                pSysTable.SetDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ModData.RasterInDBLog + ";Persist Security Info=True", SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接栅格入库日志表失败!");
                    return;
                }
                //添加进度条
                if (pAppFormRef.ProgressBar != null)
                {
                    pAppFormRef.ProgressBar.Visible = true;
                    pAppFormRef.ProgressBar.Maximum = fileArr.Length;
                    pAppFormRef.ProgressBar.Minimum = 0;
                    pAppFormRef.ProgressBar.Value   = 0;
                    Application.DoEvents();
                }
                //end
                //List<string> fileList = new List<string>();   //要进行入库的文件名
                for (int i = 0; i < fileArr.Length; i++)
                {
                    //if (!fileList.Contains(fileArr[i]))
                    //{
                    //    fileList.Add(fileArr[i]);
                    //}
                    //cyf 20110609 add:对入库过的数据进行判断和筛选
                    if (DicbeInDb.ContainsKey(fileArr[i]))
                    {
                        //已经进行入库
                        if (DicbeInDb[fileArr[i]] == pConnectInfo)
                        {
                            //如果源的路径与目标的路径都相同,则说明已经入库了
                            //进度条加1
                            if (pAppFormRef.ProgressBar != null)
                            {
                                pAppFormRef.ProgressBar.Value++;
                                Application.DoEvents();
                            }
                            continue;
                        }
                    }
                    //end
                    //cyf 20110610 add:文字提示
                    if (pAppFormRef != null)
                    {
                        pAppFormRef.OperatorTips = "正在进行数据" + fileArr[i] + "入库...";
                        Application.DoEvents();
                    }
                    //end
                    //cyf 20110610 adds
                    string Starime = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();  //开始时间
                    //end
                    string fileFullName = fileArr[i];
                    if (dbType == "栅格数据集")
                    {
                        //栅格数据集入库
                        InputRasterDataset(pDesRasterCollName, fileFullName, pSysDt.WorkSpace, out eError);
                    }
                    else if (dbType == "栅格编目")
                    {
                        //栅格编目数据入库
                        InputRasterCatalogData(pDesRasterCollName, fileFullName, pSysDt.WorkSpace, out eError);
                    }
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "栅格数据入库出错!\n" + eError.Message);
                        return;
                    }
                    //若入库成功后,更新则将入库成功的数据添加到栅格数据日志表中
                    //cyf 20110609 插入栅格数据日志表中
                    string insertStr = "insert into rasterfileinfo values('" + fileArr[i] + "','" + Starime + "','" + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "','" + pConnectInfo + "')";
                    pSysTable.UpdateTable(insertStr, out eError);
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "插入栅格入库日志表失败!");
                        continue;
                    }
                    //进度条加1
                    if (pAppFormRef.ProgressBar != null)
                    {
                        pAppFormRef.ProgressBar.Value++;
                        Application.DoEvents();
                    }
                    //end
                }
                //cyf  20110609 add:
                //关闭连接
                pSysTable.CloseDbConnection();
                //end
                //if (dbType == "栅格编目")
                //{
                //    InputRasterCatalogData(pDesRasterCollName, fileList, pSysDt.WorkSpace, out eError);
                //}
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "栅格数据入库完成!");

                //cyf 20110609 add
                if (pAppFormRef.ProgressBar != null)
                {
                    pAppFormRef.ProgressBar.Visible = false;
                    //cyf 20110610 add:清空文字提示
                    pAppFormRef.OperatorTips = "";
                    //end
                }
                //end
                //cyf 20110610 add:栅格正常结束的日志
                if (File.Exists(ModData.RasterInDBLog))
                {
                    //File.Delete(ModData.RasterInDBLog);
                }
                //end
            }
        }
Example #15
0
        //cyf 2011065 modify
        public override void OnClick()
        {
            Exception err = null;

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

            DevComponents.AdvTree.Node DtSetNode = vSelectedNode; //数据集树节点
            if (DBNode.Text != "现势库")
            {
                return;
            }
            //XmlElement elementTemp = (DBNode.Tag as XmlElement).SelectSingleNode(".//连接信息") as XmlElement;
            // IWorkspace TempWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;
            //ygc 2013-01-19修改临时库创建的位置
            frmXZDBPropertySet frm = new frmXZDBPropertySet();
            //frm.GetPropertySetStr = textSource.Text;
            IWorkspace TempWorkSpace = null;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                //textSource.Text = frm.GetPropertySetStr;
                TempWorkSpace = frm.m_pworkspace;
            }

            if (TempWorkSpace == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                return;
            }

            SysCommon.Gis.SysGisDataSet sysGisDataset = new SysCommon.Gis.SysGisDataSet(TempWorkSpace);
            //cyf 20110625 modify
            IFeatureDataset featureDataset = null;        //数据集

            if (vSelectedNode.DataKeyString == "FD")
            {
                featureDataset = sysGisDataset.GetFeatureDataset(vSelectedNode.Text, out err);
                if (err != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集失败,请检查该数据集是否存在!");
                    return;
                }
            }
            Exception pError = null;

            if (featureDataset != null)
            {
                bool bRes = InitialTmpDBstructure(featureDataset);
                if (bRes)
                {
                    MessageBox.Show("初始化临时库结构成功!");
                    //根据工程树图xml刷新工程树图界面
                    if (File.Exists(ModData.v_projectDetalXML))
                    {
                        XmlDocument xml = new XmlDocument();
                        xml.Load(ModData.v_projectDetalXML);
                        ModData.v_AppGIS.DBXmlDocument = xml;
                        ModData.v_AppGIS.ProjectTree.Nodes.Clear();
                        ModDBOperator.RefreshProjectTree(ModData.v_AppGIS.DBXmlDocument, ModData.v_AppGIS.ProjectTree, out pError);
                    }
                }
            }
        }
Example #16
0
        public override void OnClick()
        {
            Exception eError = null;

            DevComponents.AdvTree.Node SelNode = m_Hook.ProjectTree.SelectedNode;

            long dataID = long.Parse(SelNode.Tag.ToString());    //数据ID

            //获得项目节点
            DevComponents.AdvTree.Node proNode = SelNode;
            while (proNode.DataKey.ToString() != EnumTreeNodeType.PROJECT.ToString())
            {
                proNode = proNode.Parent;
            }
            long projectID = long.Parse(proNode.Tag.ToString());  //项目ID

            //获得根节点,数据库节点

            DevComponents.AdvTree.Node mDBNode = SelNode;
            while (mDBNode.Parent != null)
            {
                mDBNode = mDBNode.Parent;
            }
            //若不是数据库节点,就返回
            if (mDBNode == null)
            {
                return;
            }
            if (mDBNode.DataKey == null)
            {
                return;
            }
            if (mDBNode.DataKey.ToString() == "")
            {
                return;
            }
            if (mDBNode.DataKey.ToString() != EnumTreeNodeType.DATABASE.ToString())
            {
                return;
            }
            if (mDBNode.Name == "文件连接")
            {
                //进行定位操作

                //连接数据库

                XmlElement dbElem = mDBNode.Tag as XmlElement;
                if (dbElem == null)
                {
                    return;
                }
                string ipStr = dbElem.GetAttribute("MetaDBConn");

                // string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ipStr + ";Persist Security Info=True";//元数据连接字符串
                string ConnStr = ipStr;
                //设置元数据库连接
                SysCommon.DataBase.SysTable pSysDB = new SysCommon.DataBase.SysTable();
                pSysDB.SetDbConnection(ConnStr, SysCommon.enumDBConType.ORACLE, SysCommon.enumDBType.ORACLE, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "连接元数据库失败!连接地址为:" + ipStr);
                    return;
                }
                string    str = "select * from ProjectMDTable where ID=" + projectID;
                DataTable dt  = pSysDB.GetSQLTable(str, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "查找项目元信息表出错!");
                    pSysDB.CloseDbConnection();
                    return;
                }
                if (dt.Rows.Count == 0)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "找不到ID为:" + projectID + "的项目元信息!");
                    pSysDB.CloseDbConnection();
                    return;
                }
                string RangeDBPath = dt.Rows[0]["图幅结合表"].ToString().Trim();   //图幅结合表

                //查找数据对应的图幅的比例尺和图幅号

                string str1  = "";
                string mapNO = "";      //图幅号

                long mapSale = 0;       //图幅比例尺

                string feaClsName = ""; //范围图层名

                if (m_DataTypeID == 0)
                {
                    //标准图幅
                    str1       = "select 图幅号,图幅比例尺 from StandardMapMDTable where ID=" + dataID;
                    feaClsName = "MapFrame_";
                }
                else if (m_DataTypeID == 1)
                {
                    //非标准图幅

                    str1       = "select 块图号,块图比例尺 from NonstandardMapMDTable where ID=" + dataID;
                    feaClsName = "Range_";
                }
                DataTable tempDT = pSysDB.GetSQLTable(str1, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "查询数据表格出错!");
                    pSysDB.CloseDbConnection();
                    return;
                }
                if (tempDT.Rows.Count == 0)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "找不到数据ID为:" + dataID + "的数据元信息!");
                    pSysDB.CloseDbConnection();
                    return;
                }
                mapNO = tempDT.Rows[0][0].ToString().Trim();
                if (tempDT.Rows[0][1].ToString().Trim() != "")
                {
                    mapSale = long.Parse(tempDT.Rows[0][1].ToString().Trim());
                }
                if (mapSale == 0)
                {
                    return;                 //若没有填写比例尺信息则返回
                }
                feaClsName += mapSale.ToString();
                pSysDB.CloseDbConnection();

                SysCommon.Gis.SysGisDataSet pSysDT = new SysCommon.Gis.SysGisDataSet();
                pSysDT.SetWorkspace(RangeDBPath, SysCommon.enumWSType.PDB, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "连接范围库出错,连接地址为:\n" + RangeDBPath);
                    return;
                }
                IFeatureClass rangeFeaCls = pSysDT.GetFeatureClass(feaClsName, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "查找范围图层出错,图层名为:\n" + feaClsName);
                    return;
                }
                try
                {
                    string       whereStr = "MAP_NEWNO='" + mapNO + "'";
                    IQueryFilter pFilter  = new QueryFilterClass();
                    pFilter.WhereClause = whereStr;
                    IFeatureCursor pCursor = rangeFeaCls.Search(pFilter, false);
                    if (pCursor == null)
                    {
                        return;
                    }
                    IFeature pFea = pCursor.NextFeature();
                    if (pFea != null)
                    {
                        //进行定位
                        ZoomToFeature(m_Hook.MapControl, pFea);
                    }
                    else
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "范围要素不存在!");
                        return;
                    }

                    //释放CURSOR
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
                }
                catch (Exception ex)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", ex.Message);
                    return;
                }
            }
        }
Example #17
0
        public void OnDataCheck()
        {
            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }

            //获取所有数据集
            SysCommon.Gis.SysGisDataSet sysGisDataSet   = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <IDataset>             featureDatasets = sysGisDataSet.GetAllFeatureClass();

            ISchemeProject m_pProject = null;                                                        //数据库结构文件对象
            int            m_DBScale  = 0;                                                           //默认比例尺
            int            m_DSScale  = 0;                                                           //数据集比例尺

            Dictionary <string, IFeatureClass> pLayerDic = new Dictionary <string, IFeatureClass>(); //记录加载到map上的图层对象

            foreach (IDataset var in featureDatasets)
            {
                string FCName = var.Name;
                if (FCName.Contains("."))
                {
                    FCName = FCName.Substring(FCName.IndexOf('.') + 1);
                }
                IFeatureClass FC = var as IFeatureClass;
                if (FC != null && !pLayerDic.ContainsKey(FCName))
                {
                    pLayerDic.Add(FCName, FC);
                }
            }

            ///读取配置方案到对象
            ///
            m_pProject = new SchemeProjectClass();                                          //创建实例
            m_pProject.Load(GeoDataChecker.DBSchemaPath, e_FileType.GO_SCHEMEFILETYPE_MDB); //加载schema文件

            if (m_pProject != null)
            {
                #region 获得比例尺信息
                string   DBScale       = m_pProject.get_MetaDataValue("Scale") as string; //获取比例尺信息(总工程中的默认比例尺)
                string[] DBPScaleArayy = DBScale.Split(':');
                m_DBScale = Convert.ToInt32(DBPScaleArayy[1]);
                #endregion

                IChildItemList pProjects = m_pProject as IChildItemList;
                //获取属性库集合信息
                ISchemeItem    pDBList  = pProjects.get_ItemByName("ATTRDB");
                IChildItemList pDBLists = pDBList as IChildItemList;
                //遍历属性库集合
                long DBNum = pDBLists.GetCount();
                for (int i = 0; i < DBNum; i++)
                {
                    m_DSScale = 0;    //比例尺信息

                    //取得属性库信息
                    ISchemeItem pDB = pDBLists.get_ItemByIndex(i);
                    ///获取数据集的比例尺信息,如果获取失败则,取默认比例尺信息
                    IAttribute pa = pDB.AttributeList.get_AttributeByName("Scale") as IAttribute;
                    if (pa == null)
                    {
                        m_DSScale = m_DBScale;
                    }
                    else
                    {
                        string[] DBScaleArayy = pa.Value.ToString().Split(':');
                        m_DSScale = Convert.ToInt32(DBScaleArayy[1]);
                    }

                    IChildItemList pDBs         = pDB as IChildItemList;
                    string         pDatasetName = pDB.Name;

                    ////遍历属性表
                    int TabNum = pDBs.GetCount();
                    for (int j = 0; j < TabNum; j++)
                    {
                        //获取属性表信息
                        ISchemeItem pTable            = pDBs.get_ItemByIndex(j); //获取属性表对象
                        string      pFeatureClassName = pTable.Name;             //要素类名称

                        ///检查图层是否存在
                        if (!pLayerDic.ContainsKey(pFeatureClassName))
                        {
                            //传递错误日志
                            IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.目标要素类缺失.GetHashCode(), "要素类在标准中存在,却在目标数据集中未找到", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                            DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                            DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                            continue;
                        }

                        #region 检查要素类类型是否与配置方案一致
                        string pFeatureClassType = pTable.Value as string;   //要素类类型
                        ///检查图层类型是否一致
                        ///
                        IFeatureClass pfeatureclass;

                        bool GetlyrSeccess = pLayerDic.TryGetValue(pFeatureClassName, out pfeatureclass);

                        if (GetlyrSeccess)
                        {
                            //IFeatureLayer pFeatureLayer = player as IFeatureLayer;

                            switch (pFeatureClassType)
                            {
                            case "ANNO":
                                if (pfeatureclass.FeatureType != esriFeatureType.esriFTAnnotation)
                                {
                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.要素类类型不一致.GetHashCode(), "目标要素类应为 注记 类型", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                break;

                            case "POINT":
                                if (pfeatureclass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
                                {
                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.要素类类型不一致.GetHashCode(), "目标要素类应为 点 类型", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                break;

                            case "LINE":
                                if (pfeatureclass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                                {
                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.要素类类型不一致.GetHashCode(), "目标要素类应为 线 类型", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                break;

                            case "AREA":
                                if (pfeatureclass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
                                {
                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.要素类类型不一致.GetHashCode(), "目标要素类应为 面 类型", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            continue;
                        }
                        #endregion

                        //遍历字段
                        IAttributeList pAttrs = pTable.AttributeList;
                        long           FNum   = pAttrs.GetCount();

                        //检查非GIS平台定义的字段
                        IFields fields = pfeatureclass.Fields;

                        //循环属性表中的字段,添加到arcgis的字段对象中
                        for (int k = 0; k < FNum; k++)
                        {
                            //添加自定义属性字段
                            CheckFields(pAttrs, k, fields, pFeatureClassName, dataCheckParaSet);
                        }
                    }
                }
            }
            else
            {
                return;
            }
        }
Example #18
0
        //added by chulili 2012-01-12 modify
        public override void OnClick()
        {
            Exception err = null;

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

            DevComponents.AdvTree.Node DtSetNode = vSelectedNode; //数据集树节点
            if (DBNode.Text != "现势库")
            {
                return;
            }
            XmlElement elementTemp   = (DBNode.Tag as XmlElement).SelectSingleNode(".//连接信息") as XmlElement;
            IWorkspace TempWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;

            if (TempWorkSpace == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                return;
            }

            SysCommon.Gis.SysGisDataSet sysGisDataset = new SysCommon.Gis.SysGisDataSet(TempWorkSpace);
            //cyf 20110625 modify
            IFeatureDataset featureDataset = null;        //数据集

            if (vSelectedNode.DataKeyString == "FD")
            {
                featureDataset = sysGisDataset.GetFeatureDataset(vSelectedNode.Text, out err);
                if (err != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集失败,请检查该数据集是否存在!");
                    return;
                }
            }
            if (featureDataset != null)
            {
                bool bRes = InitialHisDBstructure(featureDataset);
                if (bRes)
                {
                    MessageBox.Show("初始化历史库结构成功!");
                }
            }
        }
Example #19
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (listViewEx.CheckedItems.Count == 0)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未选择对象,无法生成历史!");
                return;
            }

            Exception err = null;

            //获取现势库连接信息

            SysCommon.Gis.SysGisDataSet sourceSysGisDataSet = new SysCommon.Gis.SysGisDataSet();
            switch (comBoxType.Text)
            {
            case "SDE":
                sourceSysGisDataSet.SetWorkspace(txtServer.Text, txtInstance.Text, txtDB.Text, txtUser.Text, txtPassword.Text, txtVersion.Text, out err);
                break;

            case "GDB":
                sourceSysGisDataSet.SetWorkspace(txtDB.Text, SysCommon.enumWSType.GDB, out err);
                break;

            case "PDB":
                sourceSysGisDataSet.SetWorkspace(txtDB.Text, SysCommon.enumWSType.PDB, out err);
                break;

            default:
                break;
            }

            if (err != null || sourceSysGisDataSet.WorkSpace == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未设置用户数据库连接或连接失败,请检查!");
                return;
            }

            //获取历史库连接信息

            IPropertySet pPropSet        = new PropertySetClass();
            IWorkspace   pTagetWorkspace = null;

            try
            {
                switch (comboBoxTypeHistory.Text)
                {
                case "PDB":
                    AccessWorkspaceFactory pAccessFact = new AccessWorkspaceFactoryClass();
                    if (!File.Exists(txtDBHistory.Text))
                    {
                        FileInfo filePDB = new FileInfo(txtDBHistory.Text);
                        pAccessFact.Create(filePDB.DirectoryName, filePDB.Name, null, 0);
                    }
                    pPropSet.SetProperty("DATABASE", txtDBHistory.Text);
                    pTagetWorkspace = pAccessFact.Open(pPropSet, 0);

                    break;

                case "GDB":
                    FileGDBWorkspaceFactoryClass pFileGDBFact = new FileGDBWorkspaceFactoryClass();
                    DirectoryInfo dirGDB = new DirectoryInfo(txtDBHistory.Text);
                    pFileGDBFact.Create(dirGDB.Parent.FullName, dirGDB.Name.Substring(0, dirGDB.Name.Length - 4), null, 0);
                    pPropSet.SetProperty("DATABASE", txtDBHistory.Text);
                    pTagetWorkspace = pFileGDBFact.Open(pPropSet, 0);

                    break;

                case "SDE":
                    IWorkspaceFactory pSdeFact = new SdeWorkspaceFactoryClass();
                    pPropSet.SetProperty("SERVER", txtServerHistory.Text);
                    pPropSet.SetProperty("INSTANCE", txtInstanceHistory.Text);
                    pPropSet.SetProperty("DATABASE", txtDBHistory.Text);
                    pPropSet.SetProperty("USER", txtUserHistory.Text);
                    pPropSet.SetProperty("PASSWORD", txtPasswordHistory.Text);
                    pPropSet.SetProperty("VERSION", txtVersionHistory.Text);
                    pTagetWorkspace = pSdeFact.Open(pPropSet, 0);

                    break;

                default:
                    break;
                }
            }
            catch (Exception er)
            {
                //*******************************************************************
                //guozheng added
                if (ModData.SysLog != null)
                {
                    ModData.SysLog.Write(er, null, DateTime.Now);
                }
                else
                {
                    ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                    ModData.SysLog.Write(er, null, DateTime.Now);
                }
                //********************************************************************
            }

            if (pTagetWorkspace == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未设置历史库连接或连接失败,请检查!");
                return;
            }

            this.Cursor = System.Windows.Forms.Cursors.AppStarting;

            List <string> lstData = new List <string>();

            try
            {
                //根据用户数据库结构创建历史库
                foreach (ListViewItem aItem in listViewEx.CheckedItems)
                {
                    if (aItem.Tag.ToString() == "FD")
                    {
                        IFeatureDataset tagetFeatureDataset = null;
                        IFeatureDataset pFeatureDataset     = sourceSysGisDataSet.GetFeatureDataset(aItem.Text, out err);
                        if (!(pTagetWorkspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureDataset, aItem.Text + "_GOH"))
                        {
                            tagetFeatureDataset = (pTagetWorkspace as IFeatureWorkspace).CreateFeatureDataset(aItem.Text + "_GOH", (pFeatureDataset as IGeoDataset).SpatialReference);
                        }
                        else
                        {
                            tagetFeatureDataset = (pTagetWorkspace as IFeatureWorkspace).OpenFeatureDataset(aItem.Text + "_GOH");
                        }

                        IEnumDataset pEnumDs = pFeatureDataset.Subsets;
                        pEnumDs.Reset();
                        IDataset pDs = pEnumDs.Next();
                        while (pDs != null)
                        {
                            IFeatureClass pFeatureClass = pDs as IFeatureClass;
                            if (pFeatureClass != null)
                            {
                                if (!(pTagetWorkspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureClass, pDs.Name + "_GOH"))
                                {
                                    CreateFeatCls(tagetFeatureDataset, pFeatureClass, pDs.Name + "_GOH", out err);
                                }
                                lstData.Add(pDs.Name);
                            }
                            pDs = pEnumDs.Next();
                        }
                    }
                    else if (aItem.Tag.ToString() == "FC")
                    {
                        IFeatureClass pFeatureClass = sourceSysGisDataSet.GetFeatureClass(aItem.Text, out err);
                        if (!(pTagetWorkspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureClass, aItem.Text + "_GOH"))
                        {
                            CreateFeatCls(pTagetWorkspace as IFeatureWorkspace, pFeatureClass, aItem.Text + "_GOH", out err);
                        }
                        lstData.Add(aItem.Text);
                    }
                }
            }
            catch (Exception er)
            {
                //*******************************************************************
                //guozheng added
                if (ModData.SysLog != null)
                {
                    ModData.SysLog.Write(er, null, DateTime.Now);
                }
                else
                {
                    ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                    ModData.SysLog.Write(er, null, DateTime.Now);
                }
                //********************************************************************
                this.Cursor = System.Windows.Forms.Cursors.Default;
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "创建历史库结构失败!");
                return;
            }

            //遍历现势库数据FC进行数据移植
            Dictionary <string, string> dicFieldsPair = new Dictionary <string, string>();

            dicFieldsPair.Add("OBJECTID", "SourceOID");
            Dictionary <string, object> dicValue = new Dictionary <string, object>();

            dicValue.Add("FromDate", DateTime.Now.ToString("u"));
            dicValue.Add("ToDate", DateTime.MaxValue.ToString("u"));//.ToString("YYYY-MM-DD HH:MI:SS"));
            dicValue.Add("State", 0);
            (pTagetWorkspace as IWorkspaceEdit).StartEditing(false);
            bool res = true;

            progressBarXLay.Maximum = lstData.Count;
            progressBarXLay.Minimum = 0;
            progressBarXLay.Value   = 0;
            foreach (string aFeatClsName in lstData)
            {
                labelXMemo.Text = "正在进行图层" + aFeatClsName + "...";
                Application.DoEvents();
                int            cnt           = 0;
                int            allcnt        = 0;
                IFeatureCursor featureCursor = null;
                IFeatureClass  tagetFeatCls  = null;
                try
                {
                    featureCursor = sourceSysGisDataSet.GetFeatureCursor(aFeatClsName, "", null, "", out err, out cnt, out allcnt);
                    tagetFeatCls  = (pTagetWorkspace as IFeatureWorkspace).OpenFeatureClass(aFeatClsName + "_GOH");
                }
                catch (Exception ex)
                {
                    //*******************************************************************
                    //guozheng added
                    if (ModData.SysLog != null)
                    {
                        ModData.SysLog.Write(ex, null, DateTime.Now);
                    }
                    else
                    {
                        ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                        ModData.SysLog.Write(ex, null, DateTime.Now);
                    }
                    //********************************************************************
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
                    return;
                }

                progressBarXFeat.Maximum = cnt;
                progressBarXFeat.Minimum = 0;
                progressBarXFeat.Value   = 0;
                ModDBOperator.NewFeatures(tagetFeatCls, featureCursor, dicFieldsPair, dicValue, true, false, progressBarXFeat, out err);
                Marshal.ReleaseComObject(featureCursor);
                progressBarXLay.Value++;

                labelXMemo.Text = "";
                Application.DoEvents();
                if (err != null)
                {
                    res = false;
                    break;
                }
            }
            (pTagetWorkspace as IWorkspaceEdit).StopEditing(res);

            this.Cursor = System.Windows.Forms.Cursors.Default;
            if (res)
            {
                if (m_DbProjectElement != null)
                {
                    try
                    {
                        XmlElement aElement = m_DbProjectElement.SelectSingleNode(".//内容//历史库//连接信息") as XmlElement;
                        SaveObjDB(aElement, listViewEx.Items[0].Text + "_GOH");
                    }
                    catch (Exception er)
                    {
                        //*******************************************************************
                        //guozheng added
                        if (ModData.SysLog != null)
                        {
                            ModData.SysLog.Write(er, null, DateTime.Now);
                        }
                        else
                        {
                            ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                            ModData.SysLog.Write(er, null, DateTime.Now);
                        }
                        //********************************************************************
                        return;
                    }
                }
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "生成历史库成功!");
                this.Close();
            }
            else
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "生成历史库失败!");
            }
        }
Example #20
0
        public void OnDataCheck()
        {
            Exception eError = null;

            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }
            string path = dataCheckParaSet.Workspace.PathName;

            //实现代码
            SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable();
            pSysTable.DbConn    = dataCheckParaSet.DbConnPara;
            pSysTable.DBConType = SysCommon.enumDBConType.OLEDB;
            pSysTable.DBType    = SysCommon.enumDBType.ACCESS;

            DataTable mTable = TopologyCheckClass.GetParaValueTable(pSysTable, 2, out eError);

            if (eError != null)
            {
                //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
                return;
            }
            if (mTable.Rows.Count == 0)
            {
                //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未进行空值检查配置!");
                return;
            }

            SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <IDataset>             LstFeaClass   = sysGisDataSet.GetAllFeatureClass();

            if (LstFeaClass.Count == 0)
            {
                return;
            }

            //执行空值检查
            IsNullCheck(Hook, LstFeaClass, mTable, path, out eError);
            if (eError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "空值检查失败。" + eError.Message);
                return;
            }

            #region
            ////获取所有数据集
            //SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            //List<string> featureDatasetNames = sysGisDataSet.GetAllFeatureDatasetNames();
            //if (featureDatasetNames.Count == 0) return;
            //foreach (string name in featureDatasetNames)
            //{
            //    IFeatureDataset featureDataset = sysGisDataSet.GetFeatureDataset(name, out eError);
            //    if (eError != null) continue;


            //    //空值检查参数ID为2
            //    DataTable mTable = TopologyCheckClass.GetParaValueTable(featureDataset, pSysTable, 2, out eError);
            //    if (eError != null)
            //    {
            //        //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
            //        return;
            //    }
            //    if (mTable.Rows.Count == 0)
            //    {
            //        continue;
            //    }
            //    //执行空值检查
            //    IsNullCheck(Hook, featureDataset, mTable, out eError);
            //    if (eError != null)
            //    {
            //        eError=new Exception("空值检查失败。" + eError.Message);
            //        return;
            //    }
            //}
            #endregion
        }
        public override void OnClick()
        {
            //当前所有范围面,用来设置数据显示范围
            IFeatureLayer pRangeFeatLay = null;
            IFeatureLayer pFeatureLayer = null;
            IFeatureClass pFeatureClass = null;
            Exception     exError       = null;

            //如果工作库数据group图层已经存在 就不让再加了
            for (int i = 0; i < _AppHk.MapControl.LayerCount; i++)
            {
                ILayer mLayer = _AppHk.MapControl.get_Layer(i);
                if (mLayer is IGroupLayer)
                {
                    if (mLayer.Name == "现势库数据")
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "现势库数据图层已经存在。");
                        return;
                    }
                }
            }

            Plugin.Application.IAppFormRef pArrForm = _AppHk as Plugin.Application.IAppFormRef;
            pArrForm.MainForm.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            //获取更新库体数据集
            if (_AppHk.DBXmlDocument == null)
            {
                pArrForm.MainForm.Cursor = System.Windows.Forms.Cursors.Default;
                return;
            }
            XmlNode DBNode = _AppHk.DBXmlDocument.SelectSingleNode(".//项目工程");

            if (DBNode == null)
            {
                return;
            }
            XmlElement DBElement = DBNode as XmlElement;
            XmlElement objNode   = DBNode.SelectSingleNode(".//目标数据连接") as XmlElement;

            SysCommon.Gis.SysGisDataSet pObjSysGisDataSet = new SysCommon.Gis.SysGisDataSet();
            pObjSysGisDataSet.SetWorkspace(objNode.GetAttribute("服务器"), objNode.GetAttribute("服务名"), objNode.GetAttribute("数据库"), objNode.GetAttribute("用户"), objNode.GetAttribute("密码"), objNode.GetAttribute("版本"), out exError);
            if (exError != null)
            {
                pArrForm.MainForm.Cursor = System.Windows.Forms.Cursors.Default;
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "现势库数据连接失败,请确认");
                return;
            }
            //获取数据显示范围
            IGeometry pGeometry = null;

            pRangeFeatLay = ModDBOperator.GetMapFrameLayer("zone", _AppHk.MapControl, "示意图") as IFeatureLayer;
            if (pRangeFeatLay == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "无法获取数据显示范围!");
                return;
            }
            //判断当前是否有示提交的范围面
            IFeatureCursor pFeatureCursor = pRangeFeatLay.Search(null, false);

            if (pFeatureCursor != null)
            {
                IFeature pFeature = pFeatureCursor.NextFeature();
                while (pFeature != null)
                {
                    if (pGeometry == null)
                    {
                        pGeometry = pFeature.Shape;
                    }
                    else
                    {
                        pGeometry = (pGeometry as ITopologicalOperator).Union(pFeature.Shape);
                    }
                    pFeature = pFeatureCursor.NextFeature();
                }
            }
            if (pGeometry == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "无法获取数据显示范围!");
                return;
            }
            //获取所有更新数据的FeatureClass
            IFeatureDataset pFeaDataset = pObjSysGisDataSet.GetFeatureDataset("c_njtdt", out exError);// 这个地方要素集的名称是写死的 暂时没有办法获得工作库的信息 需要修改 陈新伟 20091211

            if (pFeaDataset == null)
            {
                pArrForm.MainForm.Cursor = System.Windows.Forms.Cursors.Default;
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "无法获得指定的现势库数据【C_NJTDT】。");//yjl20120503
                return;
            }

            //符号化类
            //SymbolLyr symLyr = new SymbolLyr();   //@@@

            List <IDataset> listFC = pObjSysGisDataSet.GetFeatureClass(pFeaDataset);
            IGroupLayer     pLayer = new GroupLayerClass();

            pLayer.Name = "现势库数据";

            foreach (IDataset pDataset in listFC)
            {
                pFeatureClass = pDataset as IFeatureClass;
                if (pFeatureClass == null)
                {
                    continue;
                }
                pFeatureLayer = new FeatureLayerClass();
                if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    pFeatureLayer = new FDOGraphicsLayerClass();
                }

                pFeatureLayer.FeatureClass = pFeatureClass;
                pFeatureLayer.Name         = pDataset.Name;
                pFeatureLayer.ScaleSymbols = false;
                //pFeatureLayer = ModDBOperator.GetSelectionLayer(pTempFeatureLayer, pGeometry);
                //if (pFeatureLayer == null) return;

                //符号化图层
                //symLyr.SymbolFeatrueLayer(pFeatureLayer);     //@@@

                //收缩图例
                if (pFeatureClass.FeatureType == esriFeatureType.esriFTSimple)
                {
                    ModDBOperator.ExpandLegend(pFeatureLayer as ILayer, false);
                }
                pLayer.Add(pFeatureLayer as ILayer);
            }
            _AppHk.MapControl.Map.AddLayer(pLayer);
            pObjSysGisDataSet.CloseWorkspace(true);

            //对图层进行排序
            SysCommon.Gis.ModGisPub.LayersCompose(pLayer);

            //将图幅结合表置于底层
            //ModDBOperator.MoveMapFrameLayer(_AppHk.MapControl);
            _AppHk.TOCControl.Update();
            _AppHk.MapControl.Map.ClipGeometry = pGeometry;
            _AppHk.MapControl.ActiveView.Refresh();

            pArrForm.MainForm.Cursor = System.Windows.Forms.Cursors.Default;
        }
Example #22
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            Exception eError = null;

            SysCommon.Gis.SysGisDataSet pHistoSysGisDT = new SysCommon.Gis.SysGisDataSet();//历史库连接
            //判断源数据是否连接
            if (comboBoxOrgType.Text == "ESRI文件数据库(*.gdb)")
            {
                if (this.textBoxX1.Text == "")
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请设置源数据连接");
                    return;
                }
            }

            else if (comBoxType.Text == "ArcSDE(For Oracle)")
            {
                if (txtServer.Text == "" || txtInstance.Text == "" || txtDB.Text == "" || txtVersion.Text == "" || txtUser.Text == "" || txtPassword.Text == "")
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请设置目标数据连接!");
                    return;
                }
            }
            else
            {
                if (txtDB.Text == "")
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请设置目标数据连接!");
                    return;
                }
            }

            string fileXml = "";

            if (v_OpeType == EnumOperateType.Submit)
            {
                //图幅数据提交
                fileXml = ModData.DBTufuInputXml;
            }
            if (!File.Exists(fileXml))
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "对照关系文件不存在!\n" + fileXml);
                return;
            }

            //判断历史库是否连接成功
            bool isConSucc = true;

            if (cmbHistoType.Text == "ArcSDE(For Oracle)")
            {
                if (txtHistoServer.Text.Trim() == "" || txtHistoUser.Text.Trim() == "" || txtHistoPassword.Text.Trim() == "")
                {
                    isConSucc = false;
                }
                else
                {
                    pHistoSysGisDT.SetWorkspace(txtHistoServer.Text.Trim(), txtHistoInstance.Text.Trim(), txtHistoDB.Text.Trim(), txtHistoUser.Text.Trim(), txtHistoPassword.Text.Trim(), txtHistoVersion.Text.Trim(), out eError);
                    if (eError != null)
                    {
                        isConSucc = false;
                    }
                }
            }
            else if (cmbHistoType.Text.Trim() == "ESRI文件数据库(*.gdb)")
            {
                if (txtHistoDB.Text.Trim() == "")
                {
                    isConSucc = false;
                }
                else
                {
                    pHistoSysGisDT.SetWorkspace(txtHistoDB.Text.Trim(), SysCommon.enumWSType.GDB, out eError);
                    if (eError != null)
                    {
                        isConSucc = false;
                    }
                }
            }
            else
            {
                if (txtHistoDB.Text.Trim() == "")
                {
                    isConSucc = false;
                }
                else
                {
                    pHistoSysGisDT.SetWorkspace(txtHistoDB.Text.Trim(), SysCommon.enumWSType.PDB, out eError);
                    if (eError != null)
                    {
                        isConSucc = false;
                    }
                }
            }
            if (!isConSucc)
            {
                //若历史库连接不成功
                SysCommon.Error.frmInformation InfoDial = new SysCommon.Error.frmInformation("是", "否", "是否将数据置为历史?");
                if (InfoDial.ShowDialog() == DialogResult.OK)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "历史库连接失败,请重新选择历史库!");
                    return;
                }
            }
            #region FID记录表是否连接成功
            //SysCommon.DataBase.SysDataBase pSysDB = new SysCommon.DataBase.SysDataBase();
            //string connectionStr = "";
            //switch (cmbFIDType.Text.ToUpper())
            //{
            //    case "ORACLE":
            //        connectionStr = "Data Source=" + txtFIDInstance.Text + ";Persist Security Info=True;User ID=" + txtFIDUser.Text + ";Password="******";Unicode=True";
            //        pSysDB.SetDbConnection(connectionStr, SysCommon.enumDBConType.ORACLE, SysCommon.enumDBType.ORACLE, out eError);
            //        break;
            //    case "ACCESS":
            //        connectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +txtFIDInstance.Text + ";Mode=Share Deny None;Persist Security Info=False";
            //        pSysDB.SetDbConnection(connectionStr, SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out eError);
            //        break;
            //    case "SQL":
            //        connectionStr = "Data Source=" + txtFIDInstance.Text + ";Initial Catalog=" + txtFIDServer.Text + ";User ID=" + txtFIDUser.Text + ";Password="******"提示", "FID记录表库连接失败!");
            //    return;
            //}
            #endregion

            //获得图幅总范围
            XmlNode    ProNode    = v_AppGIS.ProjectTree.SelectedNode.Tag as XmlNode;
            XmlElement workDBElem = ProNode.SelectSingleNode(".//内容//图幅工作库//范围信息") as XmlElement;
            string     rangeStr   = workDBElem.GetAttribute("范围").Trim();
            byte[]     xmlByte    = Convert.FromBase64String(rangeStr);
            object     pGeo       = new PolygonClass();
            if (XmlDeSerializer(xmlByte, pGeo) == false)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "几何范围解析出错!");
                return;
            }
            m_Geometry = pGeo as IGeometry;
            if (m_Geometry == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "图幅范围为空!");
                return;
            }

            string pDateTimeStr = DateTime.Now.ToString("u");

            Plugin.Application.IAppFormRef pAppFormRef = v_AppGIS as Plugin.Application.IAppFormRef;
            pAppFormRef.OperatorTips = "获取数据信息...";

            //根据窗体设置形成数据操作xml内容
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml("<数据移植></数据移植>");
            XmlNode sourceNode = ModDBOperator.SelectNode(xmlDoc.DocumentElement as XmlNode, "源数据连接");

            XmlElement dataElement = xmlDoc.CreateElement("源数据");
            dataElement.SetAttribute("类型", comboBoxOrgType.Tag.ToString().Trim());
            if (comboBoxOrgType.Text.Trim() == "ESRI文件数据库(*.gdb)")
            {
                dataElement.SetAttribute("服务器", "");
                dataElement.SetAttribute("服务名", "");
                dataElement.SetAttribute("数据库", this.textBoxX1.Text);
                dataElement.SetAttribute("用户", "");
                dataElement.SetAttribute("密码", "");
                dataElement.SetAttribute("版本", "");
            }
            sourceNode.AppendChild((XmlNode)dataElement);

            XmlElement objElementTemp = ModDBOperator.SelectNode(xmlDoc.DocumentElement as XmlNode, "目标数据连接") as XmlElement;
            objElementTemp.SetAttribute("类型", comBoxType.Tag.ToString().Trim());
            objElementTemp.SetAttribute("服务器", txtServer.Text.Trim());
            objElementTemp.SetAttribute("服务名", txtInstance.Text.Trim());
            objElementTemp.SetAttribute("数据库", txtDB.Text.Trim());
            objElementTemp.SetAttribute("用户", txtUser.Text.Trim());
            objElementTemp.SetAttribute("密码", txtPassword.Text.Trim());
            objElementTemp.SetAttribute("版本", txtVersion.Text.Trim());

            XmlElement RuleElement = ModDBOperator.SelectNode(xmlDoc.DocumentElement as XmlNode, "规则") as XmlElement;
            RuleElement.SetAttribute("路径", fileXml);

            pAppFormRef.OperatorTips = "初始化数据处理树图...";
            //初始化数据处理树图
            InitialDBTree newInitialDBTree = new InitialDBTree();
            newInitialDBTree.OnCreateDataTree(v_AppGIS.DataTree, xmlDoc);
            if ((bool)v_AppGIS.DataTree.Tag == false)
            {
                return;
            }

            //进行数据移植
            this.Hide();
            pAppFormRef.OperatorTips = "进行图幅数据提交...";
            esriSpatialRelEnum RelEnum = esriSpatialRelEnum.esriSpatialRelIntersects;
            if (m_DataThread == null)
            {
                m_DataThread = new clsDataThread(v_AppGIS, m_Geometry, RelEnum, true, null, null, v_OpeType, pHistoSysGisDT, pDateTimeStr);
            }
            Thread aThread = new Thread(new ThreadStart(m_DataThread.DoBatchWorks));
            m_DataThread.CurrentThread = aThread;
            m_DataThread.UserName      = txtHistoUser.Text; //历史库用户名  xisheng 2011.07.15
            m_DataThread.UserNameNow   = txtUser.Text;      //现实库用户名  xisheng 2011.07.15
            v_AppGIS.CurrentThread     = aThread;
            aThread.Start();

            //利用计时器刷新mapcontrol
            if (_timer == null)
            {
                _timer = new System.Windows.Forms.Timer();
            }
            _timer.Interval = 800;
            _timer.Enabled  = true;
            _timer.Tick    += new EventHandler(Timer_Tick);
        }
Example #23
0
        private void btnCon_Click(object sender, EventArgs e)
        {
            Exception eError = null;

            //连接数据库
            pGisDT = new SysCommon.Gis.SysGisDataSet();
            if (comBoxType.Text.Trim() == "SDE")
            {
                pGisDT.SetWorkspace(txtServer.Text, txtInstance.Text, txtDB.Text, txtUser.Text, txtPassword.Text, txtVersion.Text, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库连接失败!");
                    return;
                }
            }
            else if (comBoxType.Text.Trim() == "GDB")
            {
                pGisDT.SetWorkspace(txtDB.Text.Trim(), SysCommon.enumWSType.GDB, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库连接失败!");
                    return;
                }
            }
            else
            {
                pGisDT.SetWorkspace(txtDB.Text.Trim(), SysCommon.enumWSType.PDB, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库连接失败!");
                    return;
                }
            }

            //获得数据库中的所有要素类
            List <IDataset> LstDT = pGisDT.GetAllFeatureClass();
            //要进行检查的要素类
            List <ILayer> LstLayer = new List <ILayer>();

            for (int i = 0; i < LstDT.Count; i++)
            {
                IFeatureClass pFeaCls = LstDT[i] as IFeatureClass;
                if (pFeaCls.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    continue;
                }
                if (pFeaCls.ShapeType == esriGeometryType.esriGeometryPolyline || pFeaCls.ShapeType == esriGeometryType.esriGeometryPolygon)
                {
                    //对线要素和面要素进行接边检查
                    IFeatureLayer pFeaLayer = new FeatureLayerClass();
                    pFeaLayer.FeatureClass = pFeaCls;
                    ILayer pLayer = pFeaLayer as ILayer;
                    if (!LstLayer.Contains(pLayer))
                    {
                        LstLayer.Add(pLayer);
                    }
                }
            }
            if (LstLayer.Count == 0)
            {
                return;
            }

            //初始化接边检查界面
            BindDataGrid(LstLayer[0]);
            for (int j = 0; j < LstLayer.Count; j++)
            {
                DevComponents.AdvTree.Node node = new DevComponents.AdvTree.Node();
                node.Text            = ((LstLayer[j] as IFeatureLayer).FeatureClass as IDataset).Name; //树的节点名称
                node.Tag             = LstLayer[j];                                                    //将层放在节点的TAG上,用来后面的操作
                node.CheckBoxVisible = true;
                TreeLayer.Nodes.Add(node);
            }
        }
Example #24
0
        public void OnDataCheck()
        {
            Exception eError = null;

            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }

            //实现代码
            SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable();
            pSysTable.DbConn    = dataCheckParaSet.DbConnPara;
            pSysTable.DBConType = SysCommon.enumDBConType.OLEDB;
            pSysTable.DBType    = SysCommon.enumDBType.ACCESS;

            //获取所有数据集
            SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <string> featureDatasetNames         = sysGisDataSet.GetAllFeatureDatasetNames();

            if (featureDatasetNames.Count == 0)
            {
                return;
            }
            foreach (string name in featureDatasetNames)
            {
                IFeatureDataset featureDataset = sysGisDataSet.GetFeatureDataset(name, out eError);
                if (eError != null)
                {
                    continue;
                }


                //线穿面检查,参数ID为17
                DataTable mTable = TopologyCheckClass.GetParaValueTable(featureDataset, pSysTable, 17, out eError);
                if (eError != null)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
                    return;
                }
                if (mTable.Rows.Count == 0)
                {
                    continue;
                }
                LineCrossAreaCheck(Hook, featureDataset, mTable, out eError);
                if (eError != null)
                {
                    eError = new Exception("线穿面检查失败!" + eError.Message);
                    return;
                }
            }
        }
        public void OnDataCheck()
        {
            Exception eError = null;

            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }

            //实现代码
            SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable();
            pSysTable.DbConn    = dataCheckParaSet.DbConnPara;
            pSysTable.DBConType = SysCommon.enumDBConType.OLEDB;
            pSysTable.DBType    = SysCommon.enumDBType.ACCESS;

            //获取所有数据集
            SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <string> featureDatasetNames         = sysGisDataSet.GetAllFeatureDatasetNames();

            if (featureDatasetNames.Count == 0)
            {
                return;
            }

            //设置进度条
            ProgressChangeEvent eInfo = new ProgressChangeEvent();

            eInfo.Max = featureDatasetNames.Count;
            int pValue = 0;

            //遍历数据集,并进行检查
            foreach (string name in featureDatasetNames)
            {
                IFeatureDataset featureDataset = sysGisDataSet.GetFeatureDataset(name, out eError);
                if (eError != null)
                {
                    continue;
                }

                //线线重合检查,参数为45
                DataTable mTable = TopologyCheckClass.GetParaValueTable(featureDataset, pSysTable, 45, out eError);
                if (eError != null)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
                    return;
                }
                if (mTable.Rows.Count == 0)
                {
                    continue;
                }
                AreaTopoCheck2(Hook, featureDataset, mTable, esriTopologyRuleType.esriTRTLineCoveredByLineClass, out eError);
                if (eError != null)
                {
                    eError = new Exception("线线重合检查失败!" + eError.Message);
                    return;
                }

                //进度条加1
                pValue++;
                eInfo.Value = pValue;
                GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
            }
        }
Example #26
0
        public void AddHistoryData(string[] strTemp, string strType)
        {
            Mapcontrol.ClearLayers();
            Toccontrol.Update();
            Application.DoEvents();

            //加载历史数据
            Exception err = null;

            SysCommon.Gis.SysGisDataSet sourceSysGisDataSet = new SysCommon.Gis.SysGisDataSet();
            switch (strType)
            {
            case "SDE":
                sourceSysGisDataSet.SetWorkspace(strTemp[0], strTemp[1], strTemp[2], strTemp[3], strTemp[4], strTemp[5], out err);
                break;

            case "PDB":
                sourceSysGisDataSet.SetWorkspace(strTemp[2], SysCommon.enumWSType.PDB, out err);
                break;

            case "GDB":
                sourceSysGisDataSet.SetWorkspace(strTemp[2], SysCommon.enumWSType.GDB, out err);
                break;
            }
            string WsUsername = strTemp[3];//记录用户名 席胜20111020

            if (err != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("连接数据库失败", "原因:" + err.Message);
                return;
            }
            //cyf 20110706 add
            DevComponents.AdvTree.Node ProjectNode = new DevComponents.AdvTree.Node();
            ProjectNode = m_ProTree.SelectedNode;
            while (ProjectNode.Parent != null)
            {
                ProjectNode = ProjectNode.Parent;
            }
            //cyf 20110625 add:
            DevComponents.AdvTree.Node DBNode = new DevComponents.AdvTree.Node(); //数据库树节点
            //获取数据库节点
            DBNode = m_ProTree.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(); //数据集树节点
            if (DBNode.Text == "现势库" || DBNode.Text == "历史库")                        //.DataKeyString == "现势库"
            {
                //获取数据集节点
                DtSetNode = m_ProTree.SelectedNode;
                while (DtSetNode.Parent != null && DtSetNode.DataKeyString != "FD")
                {
                    DtSetNode = DtSetNode.Parent;
                }
                if (DtSetNode.DataKeyString != "FD")
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集节点失败!");
                    return;
                }
            }
            //end

            //List<string> lstNames = sourceSysGisDataSet.GetFeatureClassNames();
            //if (lstNames == null) return;
            //foreach (string name in lstNames)
            //{
            //    if (name.EndsWith("_GOH"))
            //    {
            //        IFeatureClass featCls = sourceSysGisDataSet.GetFeatureClass(name, out err);
            //        IFeatureLayer pFeatureLayer = new FeatureLayerClass();
            //        if (featCls.FeatureType == esriFeatureType.esriFTAnnotation)
            //        {
            //            pFeatureLayer = new FDOGraphicsLayerClass();
            //        }

            //        pFeatureLayer.FeatureClass = featCls;
            //        //cyf 20110706 modify:不去掉图层名
            //        //if (strTemp[3].Trim() != "")
            //        //{
            //        //    if ((featCls as IDataset).Name.ToUpper().Contains(strTemp[3].Trim().ToUpper()))
            //        //    {
            //        //        //SDE,图层名带用户名,应该去掉
            //        //        pFeatureLayer.Name = (featCls as IDataset).Name.Substring(strTemp[3].Trim().Length+1);
            //        //    }
            //        //}
            //        //else
            //        //{
            //            pFeatureLayer.Name = (featCls as IDataset).Name;
            //        //}
            //        //end
            //        //cyf 20110705 add
            //        //加载具备权限的图层
            //        XmlElement feaclsElem = null;
            //        try { feaclsElem = (m_ProTree.SelectedNode.Tag as XmlElement).SelectSingleNode(".//图层名") as XmlElement; } catch { }

            //        if (feaclsElem != null)
            //        {
            //            if (!feaclsElem.GetAttribute("名称").Contains(pFeatureLayer.Name))
            //            {
            //                //若不具备数据权限,则不进行加载
            //                continue;
            //            }
            //        }
            //        //end
            //        Mapcontrol.Map.AddLayer(pFeatureLayer as ILayer);
            //    }
            //}

            //lstNames = sourceSysGisDataSet.GetAllFeatureDatasetNames();
            //foreach (string name in lstNames)
            //{
            //    if (!name.EndsWith("_GOH"))
            //    {
            //        continue;
            //    }
            //    //cyf 20110706 modify
            //    IGroupLayer pGroupLayer = new GroupLayerClass();
            //    IFeatureDataset featureDataset = null;        //数据集
            //    if (m_ProTree.SelectedNode.DataKeyString == "FD")
            //    {
            //        featureDataset = sourceSysGisDataSet.GetFeatureDataset(m_ProTree.SelectedNode.Text, out err);
            //        if (err != null)
            //        {
            //            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集失败,请检查历史库是否存在!");
            //            return;
            //        }
            //        pGroupLayer.Name = m_ProTree.SelectedNode.Text + "_" + ProjectNode.Text;
            //    }
            //    else if (m_ProTree.SelectedNode.DataKeyString == "FC")
            //    {
            //        featureDataset = sourceSysGisDataSet.GetFeatureDataset(DtSetNode.Text, out err);
            //        if (err != null)
            //        {
            //            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据集失败!");
            //            return;
            //        }
            //        pGroupLayer.Name = DtSetNode.Text + "_" + ProjectNode.Text;
            //    }
            //    //end
            IGroupLayer pGroupLayer = new GroupLayerClass();

            pGroupLayer.Name = m_ProTree.SelectedNode.Text + "_" + ProjectNode.Text;
            IFeatureDataset pFeatureDataset = sourceSysGisDataSet.GetFeatureDataset(DtSetNode.Text, out err);
            IEnumDataset    pEnumDs         = pFeatureDataset.Subsets;

            pEnumDs.Reset();
            IDataset pDs = pEnumDs.Next();

            //ModDBOperator.WriteLog("while start");
            while (pDs != null)
            {
                IFeatureClass featCls       = pDs as IFeatureClass;
                IFeatureLayer pFeatureLayer = new FeatureLayerClass();
                if (featCls.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    pFeatureLayer = new FDOGraphicsLayerClass();
                }
                pFeatureLayer.FeatureClass = featCls;
                //去用户名 xisheng 0906
                if (strTemp[3].Trim() != "")
                {
                    if (pDs.Name.ToUpper().Contains(strTemp[3].Trim().ToUpper()))
                    {
                        //SDE,图层名带用户名,应该去掉
                        pFeatureLayer.Name = pDs.Name.Substring(strTemp[3].Trim().Length + 1);
                    }
                }
                else
                {
                    pFeatureLayer.Name = pDs.Name;
                }
                //end
                //pFeatureLayer.Name = pDs.Name;
                //cyf 20110705 add
                //加载具备权限的图层
                XmlElement feaclsElem = null;
                if (m_ProTree.SelectedNode.DataKeyString == "FC")
                {
                    //加载指定的图层
                    if (m_ProTree.SelectedNode.Text != pFeatureLayer.Name)
                    {
                        pDs = pEnumDs.Next();
                        continue;
                    }
                    else
                    {
                        pGroupLayer.Add(pFeatureLayer as ILayer);
                        break;
                    }
                }
                else if (m_ProTree.SelectedNode.DataKeyString == "FD")
                {
                    //数据集节点
                    try { feaclsElem = (m_ProTree.SelectedNode.Tag as XmlElement).SelectSingleNode(".//图层名") as XmlElement; }
                    catch { }

                    if (feaclsElem != null)
                    {
                        if (!feaclsElem.GetAttribute("名称").Contains(pFeatureLayer.Name))
                        {
                            //若不具备数据权限,则不进行加载
                            pDs = pEnumDs.Next();
                            continue;
                        }
                    }
                }
                //end
                //cyf 20110706 modify
                pGroupLayer.Add(pFeatureLayer as ILayer);
                //Mapcontrol.Map.AddLayer(pFeatureLayer as ILayer);
                //end
                pDs = pEnumDs.Next();
            }
            //ModDBOperator.WriteLog("while end");
            Mapcontrol.Map.AddLayer(pGroupLayer as ILayer);
            Mapcontrol.ActiveView.Refresh();

            //ModDBOperator.WriteLog("LayersCompose start");
            SysCommon.Gis.ModGisPub.LayersCompose(Mapcontrol);
            //写日志
            //ModDBOperator.WriteLog("InitialSliderItem start");
            InitialSliderItem(Mapcontrol);
            //写日志
            //ModDBOperator.WriteLog("InitialSliderItem end");
        }