private void btnAddData_Click(object sender, EventArgs e) { Exception eError = null; SysCommon.Gis.SysGisDataSet pSysGISDT = new SysCommon.Gis.SysGisDataSet(); axMapControl1.ClearLayers(); //加载范围数据 OpenFileDialog OpenFile = new OpenFileDialog(); OpenFile.CheckFileExists = true; OpenFile.CheckPathExists = true; OpenFile.Title = "选择图形范围"; OpenFile.Filter = "图幅范围数据(*.mdb)|*.mdb"; if (OpenFile.ShowDialog() == DialogResult.OK) { pSysGISDT.SetWorkspace(OpenFile.FileName, SysCommon.enumWSType.PDB, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据刻录出错!"); return; } IList <IDataset> LstDT = pSysGISDT.GetAllFeatureClass(); List = LstDT; FeaturecomboBox.Items.Clear(); FeaturecomboBox.Enabled = true; this.DataLoad.Enabled = true; foreach (IDataset pDT in LstDT) { IFeatureClass pFeatureCls = pDT as IFeatureClass; if (pFeatureCls.ShapeType == esriGeometryType.esriGeometryPolygon) { IFeatureLayer pFeaLayer = new FeatureLayerClass(); ILayer pLayer = null; pFeaLayer.FeatureClass = pFeatureCls; pLayer = pFeaLayer as ILayer; FeaturecomboBox.Items.Add(pFeatureCls.AliasName); } } if (FeaturecomboBox.Items.Count > 0) { FeaturecomboBox.SelectedIndex = 0; } axMapControl1.ActiveView.Refresh(); } //ICommand _cmd = new ControlsAddDataCommandClass(); //if (_cmd == null) return; //_cmd.OnCreate(axMapControl1.Object as IMapControlDefault); //_cmd.OnClick(); //axMapControl1.ActiveView.Refresh(); }
private void btnOK_Click(object sender, EventArgs e) { Exception eError = null; //判断源数据是否连接 if (this.textBoxUptRange.Text == "") { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请设置更新范围数据连接"); return; } if (this.textBoxUptData.Text == "") { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请设置更新数据连接"); return; } ClsBatchUpdate pClsBatchUpdate = new ClsBatchUpdate(); //从数据树图中获取现势库和历史库节点 DevComponents.AdvTree.Node pCurNode = pClsBatchUpdate.GetNodeOfProjectTree(v_AppGIS.ProjectTree, "DB", "现势库"); DevComponents.AdvTree.Node pHisNode = pClsBatchUpdate.GetNodeOfProjectTree(v_AppGIS.ProjectTree, "DB", "历史库"); if (pCurNode == null || pHisNode == null) { return; } //获取现势库连接 XmlElement elementTemp = (pCurNode.Tag as XmlElement).SelectSingleNode(".//连接信息") as XmlElement; IWorkspace pCurWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace; if (pCurWorkSpace == null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接现势库失败!"); return; } //获取历史库连接 elementTemp = (pHisNode.Tag as XmlElement).SelectSingleNode(".//连接信息") as XmlElement; IWorkspace pHisWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace; if (pHisWorkSpace == null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接历史库失败!"); return; } //获取更新数据库连接 SysCommon.Gis.SysGisDataSet pUptSysGisDT = new SysCommon.Gis.SysGisDataSet();//更新库连接 SysCommon.enumWSType pUptType = SysCommon.enumWSType.PDB; if (this.textBoxUptData.Tag == "PDB") { pUptType = SysCommon.enumWSType.PDB; } else if (this.textBoxUptData.Tag == "GDB") { pUptType = SysCommon.enumWSType.GDB; } Exception ERR0 = null; pUptSysGisDT.SetWorkspace(this.textBoxUptData.Text, pUptType, out ERR0); IWorkspace pUptWorkSpace = pUptSysGisDT.WorkSpace; //获取更新范围 IGeometry pUptGeometry = null; pUptGeometry = SysCommon.ModPublicFun.GetPolyGonFromFile(this.textBoxUptRange.Text); this.Hide(); FrmProcessBar frmbar = new FrmProcessBar(); frmbar.Show(); if (pUptGeometry != null) { pClsBatchUpdate.DoBatchUpdate(pCurWorkSpace, pHisWorkSpace, pUptWorkSpace, pUptGeometry, pCurNode, pHisNode, frmbar); } frmbar.Close(); this.Close(); }
//获取数据集 public bool GetAllDataSets(string strServer, string strServerName, string strDataBase, string strUser, string strPassWord, string strVersion, string strDataType, out List <string> listDatasets) { //cyf 20110609 测试数据库连接 包括SDE、PDB、gdb SysCommon.Gis.SysGisDataSet pSysDt = new SysCommon.Gis.SysGisDataSet(); Exception pError = null; listDatasets = null; pSysDt.SetWorkspace(strServer, strServerName, strDataBase, strUser, strPassWord, strVersion, out pError); ESRI.ArcGIS.Geodatabase.IWorkspace pWs = pSysDt.WorkSpace; if (pWs == null) { return(false); } //连接成功后,将数据集加载到下拉列表框中 if (strDataType.Equals("DLG")) { //框架要素库中数据集名称 List <string> LstDtName = pSysDt.GetAllFeatureDatasetNames(); if (LstDtName.Count == 0) { //pError = new Exception("该数据库下不存在数据集,请检查!"); return(false); } //遍历数据集名称,将数据集加载在下拉列表框中 if (listDatasets == null) { listDatasets = new List <string>(); } foreach (string item in LstDtName) { //历史数据集,不添加 if (item.ToLower().EndsWith("_GOH")) { continue; } string GetDataSetName = item;//数据集名称 //添加 listDatasets.Add(GetDataSetName); } } // else if (strDataBase.Equals("DOM") || strDataBase.Equals("DEM")) else if (strDataType.Equals("DOM") || strDataType.Equals("DEM")) { IEnumDataset pEnumDataset = null; pEnumDataset = pWs.get_Datasets(esriDatasetType.esriDTRasterDataset); if (pEnumDataset == null) { pError = new Exception("获取栅格数据名称出错!"); return(false); } pEnumDataset.Reset(); IDataset pDt = pEnumDataset.Next(); if (listDatasets == null) { listDatasets = new List <string>(); } //遍历栅格数据集 while (pDt != null) { string rasteName = ""; //栅格数据名称 rasteName = pDt.Name; //添加 listDatasets.Add(rasteName); pDt = pEnumDataset.Next(); } pEnumDataset = pWs.get_Datasets(esriDatasetType.esriDTRasterCatalog); if (pEnumDataset == null) { pError = new Exception("获取栅格数据名称出错!"); return(false); } pEnumDataset.Reset(); pDt = pEnumDataset.Next(); if (pDt == null) { pError = new Exception("获取栅格数据名称出错!"); return(false); } //遍历栅格编目 while (pDt != null) { string rasteName = ""; //栅格数据名称 rasteName = pDt.Name; //added by chulili 20110715过滤掉原本存在的历史库 if (!rasteName.ToLower().EndsWith("_GOH")) { //将栅格数据名称添加到数组中 listDatasets.Add(rasteName); } pDt = pEnumDataset.Next(); } } return(true); }