using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.DataSourcesGDB; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Geometry; using KGIS.Framework.AE; using KGIS.Framework.AE.Enum; using KGIS.Framework.AE.ExtensionMethod; using KGIS.Framework.AE.GPHelper; using KGIS.Framework.DBOperator; using KGIS.Framework.Maps; using KGIS.Framework.Platform; using KGIS.Framework.Platform.Helper; using KGIS.Framework.ThreadManager; using KGIS.Framework.Utils; using KGIS.Framework.Utils.ExtensionMethod; using KGIS.Framework.Utils.Helper; using Kingo.Plugin.DataCheck.Helper; using Kingo.PluginServiceInterface; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Windows; namespace Kingo.Plugin.BGResultManager.View { /// /// FrmCZCBG.xaml 的交互逻辑 /// public partial class FrmCZCBG : BaseWindow { private IFeatureClass _DLTBGXFc = null; private IFeatureClass _CZCFc = null; private IFeatureLayer _DLTBFc = null; private List _ComList { get; set; } private ThreadManager threadMag = null; public FrmCZCBG() { InitializeComponent(); _ComList = new List(); //_DLTBGXFc = Platform.Instance.MapsService.GetFeatureClassByName("DLTBGX"); } private void BtnSelectCZCLayer_Click(object sender, RoutedEventArgs e) { //OpenDataDialog pDialog = new OpenDataDialog(); //ISpatialDataObjectFilter pOFilter; //pOFilter = new FilterDatasetsAndLayers(); //pDialog.AddFilter(pOFilter, true); //pDialog.Title = "选择导入的数据"; //pDialog.AllowMultiSelect = false; //pDialog.RestoreLocation = true; //pDialog.StartLocation = pDialog.FinalLocation; //System.Windows.Forms.DialogResult dialogResult = pDialog.ShowDialog(); //if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0) //{ // foreach (ISpatialDataObject distObj in pDialog.Selection) // { // if (distObj.DatasetType == esriDatasetType.esriDTFeatureClass) // { // if (_ComList == null) // _ComList = new List(); // if (!_ComList.Contains(pDialog.FinalLocation)) // _ComList.Add(pDialog.FinalLocation); // combCZCFW.ItemsSource = _ComList; // combCZCFW.SelectedItem = pDialog.FinalLocation; // //combCZCFW.Text = pDialog.FinalLocation; // _CZCFc = (distObj.DatasetName as IName).Open() as IFeatureClass; // } // } //} } IFeatureLayer _DLTBGXLayer_Mem = null; IFeatureLayer _DLTBGX201Layer_Mem = null; IFeatureLayer _DLTBGX202Layer_Mem = null; IFeatureLayer _DLTBGX203Layer_Mem = null; IFeatureLayer _DLTBGX204Layer_Mem = null; IFeatureLayer _DLTBGX205Layer_Mem = null; IFeatureLayer _CZC20XLayer_Mem = null; IFeatureLayer _CZC201Layer_Mem = null; IFeatureLayer _CZC202Layer_Mem = null; IFeatureLayer _CZC203Layer_Mem = null; IFeatureLayer _CZC204Layer_Mem = null; IFeatureLayer _CZC205Layer_Mem = null; string MaxBSM = string.Empty; private static IFeatureLayer GetLayerFromPath(string filePath, string fileName) { ESRI.ArcGIS.Geodatabase.IWorkspaceFactory workspcFac = new FileGDBWorkspaceFactoryClass(); IFeatureWorkspace featureWorkspace; IFeatureLayer featureLayer = new FeatureLayerClass(); //打开路径 featureWorkspace = workspcFac.OpenFromFile(filePath, 0) as IFeatureWorkspace; //打开类要素 featureLayer.FeatureClass = featureWorkspace.OpenFeatureClass(fileName); return featureLayer; } private void BtnOK_Click(object sender, RoutedEventArgs e) { try { ProjectInfo projectInfo = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo); _CZCFc = GetLayerFromPath(projectInfo.ProjDir + "\\PrjDB.gdb", "JC_CZCDYD").FeatureClass; //MapsManager.Instance.MapService.GetFeatureClassByName("JC_CZCDYD"); if (_CZCFc == null) { MessageHelper.Show("未获取到工程下的基础城镇村等用地(JC_CZCDYD)图层"); return; } CZCDYDHelper helper = new CZCDYDHelper(); helper.ExtractExe(_CZCFc, ckbDelMinMJ.IsChecked == true); string time = new DateTime(DateTime.Now.Year - 1, 12, 31).ToShortDateString(); string dbPath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjDBPath()) + @"\BGTJ.sqlite"; IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite); DataTable bhxxbDt = rdbHelper.ExecuteDatatable("BHXXB", "select * from BHXXB where BZ='ZLBG' and BGXW='1'", true); Dictionary dicZLBG = new Dictionary(); Dictionary dicXZQDM = new Dictionary(); List BGQTBBSM = new List(); foreach (DataRow dr in bhxxbDt.Rows) { string bgqzldwdm = dr["BGQZLDWDM"].ToTrim(); string bghzldwdm = dr["BGHZLDWDM"].ToTrim(); string bgqzldwmc = dr["BGQZLDWMC"].ToTrim(); string bghzldwmc = dr["BGHZLDWMC"].ToTrim(); string bgqtbbsm = dr["BGQTBBSM"].ToTrim(); string bgq = bgqzldwdm + "_" + bgqzldwmc; string bgh = bghzldwdm + "_" + bghzldwmc; if (bgq != bgh && !dicZLBG.ContainsKey(bgq)) { dicZLBG.Add(bgq, bgh); if (!dicXZQDM.ContainsKey(bgqzldwdm.Substring(0, 9))) dicXZQDM.Add(bgqzldwdm.Substring(0, 9), 0); } if (bgq != bgh) { if (!BGQTBBSM.Contains(bgqtbbsm)) { BGQTBBSM.Add(bgqtbbsm); } } } IGeometry BGQDLTBUnion = null; _DLTBFc = GetLayerFromPath(projectInfo.ProjDir + "\\PrjDB.gdb", "JC_DLTB"); //MapsManager.Instance.MapService.GetFeatureLayerByName("JC_DLTB"); int jcbsmIndex = _DLTBFc.FeatureClass.FindField("BSM"); IFeature f = null; #region 融合 string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\CZCDYDBGTempFile"; if (!Directory.Exists(gdbFolder)) { Directory.CreateDirectory(gdbFolder); } try { DelectDir(gdbFolder);//能删除就删除 删除报错不处理 } catch { } IWorkspaceFactory pFtWsFct = new FileGDBWorkspaceFactory(); string gdbFileName = Guid.NewGuid().ToString(); string path = System.IO.Path.Combine(gdbFolder, gdbFileName); pFtWsFct.Create(path, "TempGDB", null, 0); string TempfilePath = System.IO.Path.Combine(path, "TempGDB.gdb");//临时数据存放路径 IWorkspaceAPI wsAPI = new WorkspaceAPI(TempfilePath, WorkspaceTypeEnum.GDBFile); IFeatureClassAPI CZCDYDBGTempFeatureclassAPI = wsAPI.CreateFeatureClass("CZCDYDBGTemp", (_DLTBFc.FeatureClass as IGeoDataset).SpatialReference, _DLTBFc.FeatureClass.Fields); IFeatureCursor t_cursor = CZCDYDBGTempFeatureclassAPI.FeatureClass.Insert(true); IFeatureCursor bgqcursor = _DLTBFc.Search(new QueryFilterClass() { SubFields = "BSM,Shape" }, true); while ((f = bgqcursor.NextFeature()) != null) { string bsm = f.Value[jcbsmIndex].ToTrim(); if (!BGQTBBSM.Contains(bsm)) continue; IFeatureBuffer buf = CZCDYDBGTempFeatureclassAPI.FeatureClass.CreateFeatureBuffer(); buf.Shape = f.ShapeCopy; t_cursor.InsertFeature(buf); } t_cursor.Flush(); GPParamClass gPParamClass = new GPParamClass() { FirstFeatureClass = CZCDYDBGTempFeatureclassAPI.FeatureClass, OutFeatureClassPath = TempfilePath + "\\" + "NewCZCDYD", IsGetOutPutFeature = true, }; IFeatureLayer featureLayer = null; GeoprocessorHelper.DissolveAnalysis(gPParamClass, ref featureLayer, true); bgqcursor = featureLayer.FeatureClass.Search(null, true); IFeature bgqF = bgqcursor.NextFeature(); if (bgqF == null) { MessageHelper.Show("完成"); return; } BGQDLTBUnion = bgqF.ShapeCopy; #endregion IFeatureClass czcgxgc = MapsManager.Instance.MapService.GetFeatureClassByName("CZCDYDGXGC"); ITable czcgxgcTable = czcgxgc as ITable; ICursor cur = czcgxgcTable.Search(new QueryFilterClass() { SubFields = "BGQBSM" }, true); int bgqbsmIdx = czcgxgcTable.FindField("BGQBSM"); IRow row = null; Dictionary dicBSM = new Dictionary(); while ((row = cur.NextRow()) != null) { string bgqbsm = row.Value[bgqbsmIdx].ToTrim(); if (!dicBSM.ContainsKey(bgqbsm)) { dicBSM.Add(bgqbsm, 0); } } IFeatureClass jcCZC = GetLayerFromPath(projectInfo.ProjDir + "\\PrjDB.gdb", "JC_CZCDYD").FeatureClass; //MapsManager.Instance.MapService.GetFeatureClassByName("JC_CZCDYD"); IFeatureClass czcgx = MapsManager.Instance.MapService.GetFeatureClassByName("CZCDYDGX"); IFeatureCursor gxgcInsCur = czcgxgc.Insert(true); IFeatureCursor gxInsCur = czcgx.Insert(true); IFeatureBuffer gxgcBuf = null; IFeatureBuffer gxBuf = null; Dictionary gcFieldMapp = new Dictionary(); for (int i = 0; i < czcgxgc.Fields.FieldCount; i++) { IField field = czcgxgc.Fields.Field[i]; if (field.Name.ToUpper().Contains("SHAPE") || !field.Editable) continue; int idx = jcCZC.FindField(field.Name.ToUpper().Replace("BGQ", "").Replace("BGH", "")); if (idx == -1) continue; gcFieldMapp.Add(i, idx); } Dictionary gxFieldMapp = new Dictionary(); for (int i = 0; i < czcgx.Fields.FieldCount; i++) { IField field = czcgx.Fields.Field[i]; if (field.Name.ToUpper().Contains("SHAPE") || !field.Editable) continue; int idx = jcCZC.FindField(field.Name); if (idx == -1) continue; gxFieldMapp.Add(i, idx); } //IFeatureCursor cursor = jcCZC.Search(new QueryFilterClass() { WhereClause = "CZCLX<>'201'" }, true); IFeatureCursor cursor = jcCZC.Search(new SpatialFilterClass() { WhereClause = "CZCLX<>'201'", Geometry = BGQDLTBUnion, SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects }, true); f = null; int bsmIdx = jcCZC.FindField("BSM"); int bgxwIdx = czcgxgc.FindField("BGXW"); int bghbsmIdx = czcgxgc.FindField("BGHBSM"); int bghczclxIdx = czcgxgc.FindField("BGHCZCLX"); int bghczcdmIdx = czcgxgc.FindField("BGHCZCDM"); int bghczcmcIdx = czcgxgc.FindField("BGHCZCMC"); //变更前 int bgqczclxIdx = czcgxgc.FindField("BGQCZCLX"); int bgqczcdmIdx = czcgxgc.FindField("BGQCZCDM"); int bgqczcmcIdx = czcgxgc.FindField("BGQCZCMC"); int bgmjIdx = czcgxgc.FindField("BGMJ"); int GXSJIdx = czcgxgc.FindField("GXSJ"); int czcmjIdx = jcCZC.FindField("CZCMJ"); int gxBSMIdx = jcCZC.FindField("BSM"); int czcdmIdx = jcCZC.FindField("CZCDM"); int czcmcIdx = jcCZC.FindField("CZCMC"); int CZCGXSJIdx = czcgx.FindField("GXSJ"); List qsDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM); int JC_DLTBBSM = _DLTBFc.FeatureClass.FindField("BSM"); string PrjCode = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE; while ((f = cursor.NextFeature()) != null) { string bsm = f.Value[bsmIdx].ToTrim(); if (dicBSM.ContainsKey(bsm)) continue; if (ckbXDM.IsChecked == false) { if (!FeatureAPI.IsInterSect(f.ShapeCopy, BGQDLTBUnion)) continue; } if (gxgcBuf == null) gxgcBuf = czcgxgc.CreateFeatureBuffer(); gxgcBuf.Shape = f.ShapeCopy; foreach (KeyValuePair idx in gcFieldMapp) { gxgcBuf.Value[idx.Key] = f.Value[idx.Value]; } string bghczclx = gxgcBuf.Value[bghczclxIdx].ToTrim(); string bghczcdm = gxgcBuf.Value[bghczcdmIdx].ToTrim(); string bghczcmc = gxgcBuf.Value[bghczcmcIdx].ToTrim(); //变更前 string bgqczclx = gxgcBuf.Value[bgqczclxIdx].ToTrim(); string bgqczcdm = gxgcBuf.Value[bgqczcdmIdx].ToTrim(); string bgqczcmc = gxgcBuf.Value[bgqczcmcIdx].ToTrim(); string bgh = bghczcdm + "_" + bghczcmc; string strCZCDM = bghczcdm; string strCZCMC = bghczcmc; if (bghczclx == "203" || bghczclx == "203A" || bghczclx == "204" || bghczclx == "205") { if (dicZLBG.ContainsKey(bgh)) { //#region 判断是否与变更图斑相交 //ITopologicalOperator topo = f.ShapeCopy as ITopologicalOperator; //IGeometry tempGeo = topo.Buffer(-0.00015); //List features = new List(); //if (tempGeo.IsEmpty) // features = FeatureAPI.Identify2(f.ShapeCopy, JC_DLTB_Layer); //else // features = FeatureAPI.Identify(tempGeo, JC_DLTB_Layer); //List bsms = new List(); //string sbsm = string.Empty; //if (features.Count > 0) //{ // foreach (var item in features) // { // bsms.Add($"'{item.Value[JC_DLTBBSM].ToTrim()}'"); // } // if (bsms.Count > 0) // { // sbsm = string.Join(",", bsms); // } //} //bhxxbDt.Select($"BGQTBBSM in({sbsm})"); //DataRow[] bhxxbDR = bhxxbDt.Select($"BGQTBBSM in({sbsm})"); //if (bhxxbDR != null && bhxxbDR.Length == 0) //{ // continue; //} //#endregion string[] zlArr = dicZLBG[bgh].Split('_'); strCZCDM = zlArr[0]; strCZCMC = zlArr[1]; gxgcBuf.Value[bghczcdmIdx] = zlArr[0]; gxgcBuf.Value[bghczcmcIdx] = zlArr[1]; } } else if (bghczclx == "202") { //bool isBG = true; foreach (KeyValuePair kvp in dicZLBG) { if (kvp.Key.StartsWith(bgh.Substring(0, 9))) { //#region 判断是否与变更图斑相交 //ITopologicalOperator topo = f.ShapeCopy as ITopologicalOperator; //IGeometry tempGeo = topo.Buffer(-0.00015); //List features = new List(); //if (tempGeo.IsEmpty) // features = FeatureAPI.Identify2(f.ShapeCopy, JC_DLTB_Layer); //else // features = FeatureAPI.Identify(tempGeo, JC_DLTB_Layer); //List bsms = new List(); //string sbsm = string.Empty; //if (features.Count > 0) //{ // foreach (var item in features) // { // bsms.Add($"'{item.Value[JC_DLTBBSM].ToTrim()}'"); // } // if (bsms.Count > 0) // { // sbsm = string.Join(",", bsms); // } //} //DataRow[] bhxxbDR = bhxxbDt.Select($"BGQTBBSM in({sbsm})"); //if (bhxxbDR != null && bhxxbDR.Length == 0) //{ // isBG = false; // break; //} //#endregion strCZCDM = kvp.Value.Substring(0, 9).PadRight(19, '0'); gxgcBuf.Value[bghczcdmIdx] = strCZCDM; if (qsDic != null) { DataDicTionary dic = qsDic.FirstOrDefault(qs => qs.CODE == strCZCDM || qs.CODE.StartsWith(strCZCDM.Substring(0, 9))); if (dic != null) { strCZCMC = dic.NAME; gxgcBuf.Value[bghczcmcIdx] = strCZCMC; } } break; } } //if (!isBG) continue; } bghczcdm = gxgcBuf.Value[bghczcdmIdx].ToTrim(); bghczcmc = gxgcBuf.Value[bghczcmcIdx].ToTrim(); if (bghczclx.Trim() == bgqczclx.Trim() && bghczcdm.Trim() == bgqczcdm.Trim() && bghczcmc.Trim() == bgqczcmc.Trim()) continue;//前后这三个字段没有前后变化则不插入 //gxgcBuf.Value[] = ""; string bghbsm = gxgcBuf.Value[bghbsmIdx].ToTrim(); if (!bghbsm.StartsWith(PrjCode)) { string strR = bghbsm.Substring(0, 6); gxgcBuf.Value[bghbsmIdx] = bghbsm.Replace(strR, PrjCode); } gxgcBuf.Value[bgxwIdx] = "1"; gxgcBuf.Value[bgmjIdx] = f.Value[czcmjIdx]; gxgcBuf.Value[GXSJIdx] = time; gxgcInsCur.InsertFeature(gxgcBuf); if (gxBuf == null) gxBuf = czcgx.CreateFeatureBuffer(); gxBuf.Shape = f.ShapeCopy; foreach (KeyValuePair idx in gxFieldMapp) { gxBuf.Value[idx.Key] = f.Value[idx.Value]; } string gxbsm = gxBuf.Value[gxBSMIdx].ToTrim(); if (!gxbsm.StartsWith(PrjCode)) { string strR = gxbsm.Substring(0, 6); gxBuf.Value[gxBSMIdx] = gxbsm.Replace(strR, PrjCode); } gxBuf.Value[czcdmIdx] = strCZCDM; gxBuf.Value[czcmcIdx] = strCZCMC; gxBuf.Value[CZCGXSJIdx] = time; gxInsCur.InsertFeature(gxBuf); } gxgcInsCur.Flush(); gxInsCur.Flush(); if (ckbXDM.IsChecked == true) { cur = czcgxgcTable.Search(new QueryFilterClass() { SubFields = "BGQBSM" }, true); bgqbsmIdx = czcgxgcTable.FindField("BGQBSM"); row = null; dicBSM = new Dictionary(); while ((row = cur.NextRow()) != null) { string bgqbsm = row.Value[bgqbsmIdx].ToTrim(); if (!dicBSM.ContainsKey(bgqbsm)) { dicBSM.Add(bgqbsm, 0); } } cursor = jcCZC.Search(null, true); f = null; while ((f = cursor.NextFeature()) != null) { string bsm = f.Value[bsmIdx].ToTrim(); if (dicBSM.ContainsKey(bsm)) continue; if (gxgcBuf == null) gxgcBuf = czcgxgc.CreateFeatureBuffer(); gxgcBuf.Shape = f.ShapeCopy; foreach (KeyValuePair idx in gcFieldMapp) { gxgcBuf.Value[idx.Key] = f.Value[idx.Value]; } string bghbsm = gxgcBuf.Value[bghbsmIdx].ToTrim(); string bghczclx = gxgcBuf.Value[bghczclxIdx].ToTrim(); string bghczcdm = gxgcBuf.Value[bghczcdmIdx].ToTrim(); string bghczcmc = gxgcBuf.Value[bghczcmcIdx].ToTrim(); //变更前 string bgqbsm = gxgcBuf.Value[bgqbsmIdx].ToTrim(); string bgqczclx = gxgcBuf.Value[bgqczclxIdx].ToTrim(); string bgqczcdm = gxgcBuf.Value[bgqczcdmIdx].ToTrim(); string bgqczcmc = gxgcBuf.Value[bgqczcmcIdx].ToTrim(); bghbsm = gxgcBuf.Value[bghbsmIdx].ToTrim(); if (!bghbsm.StartsWith(PrjCode)) { string strR = bghbsm.Substring(0, 6); gxgcBuf.Value[bghbsmIdx] = bghbsm.Replace(strR, PrjCode); } if (!bghczcdm.StartsWith(PrjCode)) { string strR = bghczcdm.Substring(0, 6); gxgcBuf.Value[bghczcdmIdx] = bghczcdm.Replace(strR, PrjCode); } gxgcBuf.Value[bgxwIdx] = "1"; gxgcBuf.Value[bgmjIdx] = f.Value[czcmjIdx]; gxgcBuf.Value[GXSJIdx] = time; gxgcInsCur.InsertFeature(gxgcBuf); if (gxBuf == null) gxBuf = czcgx.CreateFeatureBuffer(); gxBuf.Shape = f.ShapeCopy; foreach (KeyValuePair idx in gxFieldMapp) { gxBuf.Value[idx.Key] = f.Value[idx.Value]; } string gxbsm = gxBuf.Value[gxBSMIdx].ToTrim(); if (!gxbsm.StartsWith(PrjCode)) { string strR = gxbsm.Substring(0, 6); gxBuf.Value[gxBSMIdx] = gxbsm.Replace(strR, PrjCode); } string gxCZCDM = gxBuf.Value[czcdmIdx].ToTrim(); if (!gxCZCDM.StartsWith(PrjCode)) { string strR = gxCZCDM.Substring(0, 6); gxBuf.Value[czcdmIdx] = gxCZCDM.Replace(strR, PrjCode); } //gxBuf.Value[czcdmIdx] = strCZCDM; //gxBuf.Value[czcmcIdx] = strCZCMC; gxBuf.Value[CZCGXSJIdx] = time; gxInsCur.InsertFeature(gxBuf); } gxgcInsCur.Flush(); gxInsCur.Flush(); } MessageHelper.Show("完成"); } catch (Exception ex) { ProgressHelper.CloseProcessBar(); MessageHelper.Show("城镇村范围变更失败!"); LogAPI.Debug("城镇村范围变更失败:"); LogAPI.Debug(ex); } finally { loading.Visibility = Visibility.Collapsed; } } private void CZCGXExe2(object param = null) { try { string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\CZCGX"; if (!System.IO.Directory.Exists(gdbFolder)) { System.IO.Directory.CreateDirectory(gdbFolder); } try { DelectDir(gdbFolder);//能删除就删除 删除报错不处理 } catch { } BasicDataModel[] dicXZQ = Platform.Instance.DicHelper.GetXZQDic(1); if (dicXZQ == null) dicXZQ = new BasicDataModel[] { }; List dicQS = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM); if (dicQS == null) dicQS = new List(); IWorkspaceFactory pFtWsFct = null; IWorkspaceName workspaceName = null; IWorkspaceAPI wsAPI = null; IWorkspace pWorkspace = null; pFtWsFct = new FileGDBWorkspaceFactory(); string gdbFileName = Guid.NewGuid().ToString() + ".gdb"; string path = System.IO.Path.Combine(gdbFolder, gdbFileName); workspaceName = pFtWsFct.Create(gdbFolder, gdbFileName, null, 0); string gdbpath = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetSchemeDBPath(); wsAPI = new WorkspaceAPI(gdbpath, WorkspaceTypeEnum.GDBFile); GPParamClass gPParamClass = new GPParamClass(); IFeatureLayer new20Layer = null; gPParamClass.FirstFeatureClass = _DLTBGX201Layer_Mem.FeatureClass; gPParamClass.SecondFeatureClass = _CZC201Layer_Mem.FeatureClass; gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX201"; gPParamClass.IsGetOutPutFeature = true; GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); Marshal.ReleaseComObject(new20Layer.FeatureClass); Marshal.ReleaseComObject(new20Layer); gPParamClass.FirstFeatureClass = _DLTBGX202Layer_Mem.FeatureClass; gPParamClass.SecondFeatureClass = _CZC202Layer_Mem.FeatureClass; gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX202"; gPParamClass.IsGetOutPutFeature = true; GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); Marshal.ReleaseComObject(new20Layer.FeatureClass); Marshal.ReleaseComObject(new20Layer); gPParamClass.FirstFeatureClass = _DLTBGX203Layer_Mem.FeatureClass; gPParamClass.SecondFeatureClass = _CZC203Layer_Mem.FeatureClass; gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX203"; gPParamClass.IsGetOutPutFeature = true; GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); Marshal.ReleaseComObject(new20Layer.FeatureClass); Marshal.ReleaseComObject(new20Layer); gPParamClass.FirstFeatureClass = _DLTBGX204Layer_Mem.FeatureClass; gPParamClass.SecondFeatureClass = _CZC204Layer_Mem.FeatureClass; gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX204"; gPParamClass.IsGetOutPutFeature = true; GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); Marshal.ReleaseComObject(new20Layer.FeatureClass); Marshal.ReleaseComObject(new20Layer); gPParamClass.FirstFeatureClass = _DLTBGX205Layer_Mem.FeatureClass; gPParamClass.SecondFeatureClass = _CZC205Layer_Mem.FeatureClass; gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX205"; gPParamClass.IsGetOutPutFeature = true; GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); Marshal.ReleaseComObject(new20Layer.FeatureClass); Marshal.ReleaseComObject(new20Layer); IQueryFilter filter = new QueryFilterClass(); filter.SubFields = "ZLDWDM,ZLDWMC,CZCSXM"; ICursor cur = (_DLTBGXLayer_Mem.FeatureClass as ITable).Update(filter, true); IRow _Row = null; int idxZLDWDM = _DLTBGXLayer_Mem.FeatureClass.FindField("ZLDWDM"); int idxZLDWMC = _DLTBGXLayer_Mem.FeatureClass.FindField("ZLDWMC"); int idxCZCSXM = _DLTBGXLayer_Mem.FeatureClass.FindField("CZCSXM"); while ((_Row = cur.NextRow()) != null) { string strZLDWDM = _Row.Value[idxZLDWDM].ToTrim(); string strZLDWMC = _Row.Value[idxZLDWMC].ToTrim(); string strCZCSXM = _Row.Value[idxCZCSXM].ToTrim(); string newCZCDM = string.Empty; string newCZCMC = string.Empty; #region 获取城镇村代码与名称 if (!string.IsNullOrWhiteSpace(strZLDWDM)) { if ("201,201A".Contains(strCZCSXM)) { newCZCDM = strZLDWDM.Substring(0, 6).PadRight(19, '0'); var xzq = dicXZQ.ToList().Find(p => p.Code == newCZCDM.Substring(0, 6)); if (xzq != null) { newCZCMC = xzq.Name; } _Row.Value[idxZLDWDM] = newCZCDM; _Row.Value[idxZLDWMC] = newCZCMC; } else if ("202,202A".Contains(strCZCSXM)) { newCZCDM = strZLDWDM.Substring(0, 9).PadRight(19, '0'); var xzq = dicQS.Find(p => p.CODE == newCZCDM || p.CODE == newCZCDM.Substring(0, 9)); if (xzq != null) { newCZCMC = xzq.NAME; } _Row.Value[idxZLDWDM] = newCZCDM; _Row.Value[idxZLDWMC] = newCZCMC; } cur.UpdateRow(_Row); } #endregion } IFeatureLayer newCZCLayer = null; gPParamClass.FirstFeatureClass = _DLTBGXLayer_Mem.FeatureClass; gPParamClass.OutFeatureClassPath = path + "\\" + "NewCZC"; gPParamClass.ListDissolveFiledName = new List() { "ZLDWDM", "ZLDWMC", "CZCSXM" }; gPParamClass.IsGetOutPutFeature = true; GeoprocessorHelper.DissolveAnalysis(gPParamClass, ref newCZCLayer); IFeatureLayer czcUnionLayer = null; gPParamClass.FirstFeatureClass = newCZCLayer.FeatureClass; gPParamClass.SecondFeatureClass = _CZC20XLayer_Mem.FeatureClass; gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX_Diss"; gPParamClass.IsGetOutPutFeature = true; GeoprocessorHelper.UnionAnalysis(gPParamClass, ref czcUnionLayer); IFeatureLayer czcUnionMToSLayer = null; gPParamClass.FirstFeatureClass = czcUnionLayer.FeatureClass; gPParamClass.OutFeatureClassPath = path + "\\" + "CZCUnionMToS"; gPParamClass.IsGetOutPutFeature = true; GeoprocessorHelper.MultipartToSinglePath(gPParamClass, ref czcUnionMToSLayer); //删除更新前后非20范围数据 (czcUnionMToSLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("DELETE from CZCUnionMToS where (CZCSXM is NULL or CZCSXM = '') and FID_CZC20X = -1")); //删除未变化数据 //(czcUnionMToSLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Delete from CZCUnionMToS where FID_NewCZC = -1")); filter.WhereClause = " FID_NewCZC = -1"; filter.SubFields = "OBJECTID,FID_CZC20X"; ITable itb = czcUnionMToSLayer.FeatureClass as ITable; ICursor TbCursor = itb.Search(filter, true); IRow row = null; Dictionary TempDic = new Dictionary(); Dictionary TempDelOids = new Dictionary(); //List delOids = new List(); int idx = itb.FindField("FID_CZC20X"); while ((row = TbCursor.NextRow()) != null) { int key = Convert.ToInt32(row.Value[idx]); if (TempDic.ContainsKey(key)) { TempDic[key]++; } else { TempDic.Add(key, 1); } TempDelOids.Add(row.OID, key); } foreach (var item in TempDelOids.Keys) { if (TempDic[TempDelOids[item]] == 1) itb.GetRow(item).Delete(); } IFeatureClassAPI tempFcAPI = new FeatureClassAPI(czcUnionMToSLayer.FeatureClass); tempFcAPI.AddField("BGXW", esriFieldType.esriFieldTypeInteger, "变更行为"); (czcUnionMToSLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Update CZCUnionMToS set BGXW=3 where FID_NewCZC <>-1 and FID_CZC20X = -1 ")); (czcUnionMToSLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Update CZCUnionMToS set BGXW=0 where CZCSXM is null")); //IFeatureLayer newJCCZCLayer = null; //gPParamClass.FirstFeatureClass = _CZC20XLayer_Mem.FeatureClass; //gPParamClass.SecondFeatureClass = czcUnionMToSLayer.FeatureClass; //gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX205"; //gPParamClass.IsGetOutPutFeature = true; //GeoprocessorHelper.EraseAnalysis(gPParamClass, ref newJCCZCLayer); //(_CZC20XLayer_Mem.FeatureClass as ITable).DeleteSearchedRows(null); //InsertDataToMemeoryLayer(newJCCZCLayer.FeatureClass, _CZC20XLayer_Mem.FeatureClass); //Marshal.ReleaseComObject(newJCCZCLayer.FeatureClass); //Marshal.ReleaseComObject(newJCCZCLayer); IFeatureLayer tempCZC203Layer = GeoDBAPI.CreateFeatureLayerInmemeory("CZC203", "城镇村203范围", (_CZCFc as IGeoDataset).SpatialReference, _CZCFc.ShapeType, _CZCFc.Fields); IFeatureClassAPI temp203FcAPI = new FeatureClassAPI(tempCZC203Layer.FeatureClass); temp203FcAPI.AddField("BGXW", esriFieldType.esriFieldTypeInteger, "变更行为"); filter.WhereClause = "BGXW = 3 or BGXW = 0"; IFeatureCursor cursor = czcUnionMToSLayer.FeatureClass.Search(null, true); IFeature feature = null; int idx_FID_NewCZC = czcUnionMToSLayer.FeatureClass.FindField("FID_NewCZC"); int idx_FID_CZC20X = czcUnionMToSLayer.FeatureClass.FindField("FID_CZC20X"); int idx_CZCSXM = czcUnionMToSLayer.FeatureClass.FindField("CZCSXM"); int idx_ZLDWDM = czcUnionMToSLayer.FeatureClass.FindField("ZLDWDM"); int idx_ZLDWMC = czcUnionMToSLayer.FeatureClass.FindField("ZLDWMC"); int idx_CZCLX = czcUnionMToSLayer.FeatureClass.FindField("CZCLX"); int idx_CZCDM = czcUnionMToSLayer.FeatureClass.FindField("CZCDM"); int idx_CZCMC = czcUnionMToSLayer.FeatureClass.FindField("CZCMC"); int idx_CZCMJ = czcUnionMToSLayer.FeatureClass.FindField("CZCMJ"); int idx_BGXW = czcUnionMToSLayer.FeatureClass.FindField("BGXW"); int idx_BSM = czcUnionMToSLayer.FeatureClass.FindField("BSM"); List ListGX = new List(); List unionOldOIDs = new List(); while ((feature = cursor.NextFeature()) != null) { if (feature.OID == 12183)//|| feature.OID == 10432|| feature.OID == 10433 { } //IFeatureBuffer buff = tempCZC203Layer.FeatureClass.CreateFeatureBuffer(); int FID_NewCZC = Convert.ToInt32(feature.Value[idx_FID_NewCZC]); int FID_CZC20X = Convert.ToInt32(feature.Value[idx_FID_CZC20X]); string CZCSXM = feature.Value[idx_CZCSXM].ToTrim(); string ZLDWDM = feature.Value[idx_ZLDWDM].ToTrim(); string ZLDWMC = feature.Value[idx_ZLDWMC].ToTrim(); string CZCLX = feature.Value[idx_CZCLX].ToTrim(); string CZCDM = feature.Value[idx_CZCDM].ToTrim(); string CZCMC = feature.Value[idx_CZCMC].ToTrim(); string CZCMJ = feature.Value[idx_CZCMJ].ToTrim(); string bgxw = feature.Value[idx_BGXW].ToTrim(); string bsm = feature.Value[idx_BSM].ToTrim(); string newCZCDM = ZLDWDM; string newCZCMC = ZLDWMC; CZCGX gx = new CZCGX(); if (bgxw == "3") { ListGX.Add(gx); gx.CZCLX = CZCSXM; gx.CZCDM = newCZCDM; gx.CZCMC = newCZCMC; gx.Shape = feature.ShapeCopy; gx.GCList.Add(new CZCGXGC() { Shape = feature.ShapeCopy, BGXW = bgxw, BGMJ = feature.ShapeCopy.GetEllipseArea(), BGHCZCDM = newCZCDM, BGHCZCMC = newCZCMC, BGHCZCLX = CZCSXM }); gx.BSM = "AddNew"; if (gx.CZCLX == "203" || gx.CZCLX == "203A") continue; List tempCzcs = FeatureAPI.Identify(gx.Shape, czcUnionMToSLayer); //int idxOldCzcOID = czcUnionMToSLayer; foreach (var item in tempCzcs) { if (item.OID == feature.OID) continue; int tempBGHOID = Convert.ToInt32(item.Value[idx_FID_NewCZC]); string tempCZCLX = item.Value[idx_CZCLX].ToTrim(); string tempCZCDM = item.Value[idx_CZCDM].ToTrim(); string tempCZCMC = item.Value[idx_CZCMC].ToTrim(); if (tempBGHOID != -1) { tempCZCLX = item.Value[idx_CZCSXM].ToTrim(); tempCZCDM = item.Value[idx_ZLDWDM].ToTrim(); tempCZCMC = item.Value[idx_ZLDWMC].ToTrim(); } string tempBGXW = item.Value[idx_BGXW].ToTrim(); if (tempCZCLX == gx.CZCLX && tempCZCDM == gx.CZCDM && tempCZCMC == gx.CZCMC && tempBGXW != "0" && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) { int oldOID = Convert.ToInt32(item.Value[idx_FID_CZC20X]); if (oldOID == 25682) { } if (oldOID != -1) { unionOldOIDs.Add(oldOID); } gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); gx.GCList.Add(new CZCGXGC() { Shape = item.ShapeCopy, BGXW = "2", BGMJ = item.ShapeCopy.GetEllipseArea(), BGQCZCLX = item.Value[idx_CZCLX].ToTrim(), BGQCZCDM = item.Value[idx_CZCDM].ToTrim(), BGQCZCMC = item.Value[idx_CZCMC].ToTrim(), BGQBSM = item.Value[idx_BSM].ToTrim(), BGHCZCDM = newCZCDM, BGHCZCMC = newCZCMC, BGHCZCLX = CZCSXM }); item.Delete(); } } List jcCzcs = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); foreach (var item in jcCzcs) { string jcCZCLX = item.Value[idx_JCCZCLX].ToTrim(); string jcCZCDM = item.Value[idx_JCCZCDM].ToTrim(); string jcCZCMC = item.Value[idx_JCCZCMC].ToTrim(); //string tempCZCLX = item.Value[idx_CZCLX].ToTrim(); string tempBSM = item.Value[idx_JCBSM].ToTrim(); if (jcCZCLX == gx.CZCLX && jcCZCDM == gx.CZCDM && jcCZCMC == gx.CZCMC && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) { IGeometry tmpGeo = feature.ShapeCopy; CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); if (gx1 != null) { gx1.Shape = FeatureAPI.Union(gx1.Shape, gx.Shape); gx1.GCList.AddRange(gx.GCList); ListGX.Remove(gx); gx = gx1; continue; } else { gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); } //if (oldOID != -1) //{ // unionOldOIDs.Add(oldOID); //} gx.UpdateOID.Add(item.OID); //if (unionOldOIDs.Contains(item.OID)) continue; gx.GCList.Add(new CZCGXGC() { Shape = item.ShapeCopy, BGXW = "2", BGMJ = item.ShapeCopy.GetEllipseArea(), BGQBSM = tempBSM, BGQCZCLX = jcCZCLX, BGQCZCDM = jcCZCDM, BGQCZCMC = jcCZCMC, BGHCZCDM = jcCZCDM, BGHCZCMC = jcCZCMC, BGHCZCLX = jcCZCLX }); } else if (unionOldOIDs.Contains(item.OID)) { CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); if (gx1 != null) { gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); gx1.GCList.ForEach(f => f.Shape = gx1.Shape); //gx1.GCList.AddRange(gx.GCList); //ListGX.Remove(gx); //gx = gx1; continue; } else { gx1 = new CZCGX(); gx1.BSM = "AddNew"; gx1.CZCLX = item.Value[idx_JCCZCLX].ToTrim(); gx1.CZCDM = item.Value[idx_JCCZCDM].ToTrim(); gx1.CZCMC = item.Value[idx_JCCZCMC].ToTrim(); gx1.Shape = FeatureAPI.Difference(item.ShapeCopy, gx.Shape); gx1.UpdateOID.Add(item.OID); gx1.GCList.Add(new CZCGXGC() { Shape = gx1.Shape, BGQBSM = tempBSM, BGQCZCLX = gx1.CZCLX, BGQCZCDM = gx1.CZCDM, BGQCZCMC = gx1.CZCMC, BGHCZCLX = gx1.CZCLX, BGHCZCDM = gx1.CZCDM, BGHCZCMC = gx1.CZCMC, BGMJ = item.ShapeCopy.GetEllipseArea(), BGXW = "2" }); ListGX.Add(gx1); continue; //gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); } //if (oldOID != -1) //{ // unionOldOIDs.Add(oldOID); //} gx.UpdateOID.Add(item.OID); //if (unionOldOIDs.Contains(item.OID)) continue; gx.GCList.Add(new CZCGXGC() { Shape = item.ShapeCopy, BGXW = "2", BGMJ = item.ShapeCopy.GetEllipseArea(), BGQBSM = tempBSM, BGQCZCLX = jcCZCLX, BGQCZCDM = jcCZCDM, BGQCZCMC = jcCZCMC, BGHCZCDM = jcCZCDM, BGHCZCMC = jcCZCMC, BGHCZCLX = jcCZCLX }); } } } else if (bgxw == "0") { ListGX.Add(gx); gx.Shape = feature.ShapeCopy; List jcCzcs = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); foreach (var item in jcCzcs) { CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); if (gx1 != null) { if (FeatureAPI.IsInterSect(gx1.Shape, gx.Shape)) { gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); foreach (var gc in gx1.GCList) { if (FeatureAPI.IsInterSect(gc.Shape, gx.Shape)) gc.Shape = FeatureAPI.Difference(gc.Shape, gx.Shape); } } } else { IGeometry upGeo = FeatureAPI.Difference(item.ShapeCopy, feature.ShapeCopy); if (upGeo == null || upGeo.IsEmpty) continue; int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); string bgqbsm = item.Value[idx_JCBSM].ToTrim(); if (bgqbsm != bsm) { continue; } gx1 = new CZCGX(); gx1.BSM = "AddNew"; gx1.CZCLX = item.Value[idx_JCCZCLX].ToTrim(); gx1.CZCDM = item.Value[idx_JCCZCDM].ToTrim(); gx1.CZCMC = item.Value[idx_JCCZCMC].ToTrim(); gx1.Shape = upGeo; gx1.UpdateOID.Add(item.OID); gx1.GCList.Add(new CZCGXGC() { Shape = upGeo, BGQBSM = bsm, BGQCZCLX = CZCLX, BGQCZCDM = CZCDM, BGQCZCMC = CZCMC, BGHCZCLX = gx1.CZCLX, BGHCZCDM = gx1.CZCDM, BGHCZCMC = gx1.CZCMC, BGMJ = item.ShapeCopy.GetEllipseArea(), BGXW = "2" }); ListGX.Add(gx1); } } gx.CZCLX = ""; gx.CZCDM = ""; gx.CZCMC = ""; gx.Shape = null; gx.GCList.Add(new CZCGXGC() { Shape = feature.ShapeCopy, BGQBSM = bsm, BGQCZCLX = CZCLX, BGQCZCDM = CZCDM, BGQCZCMC = CZCMC, BGMJ = feature.ShapeCopy.GetEllipseArea(), BGXW = bgxw }); } else { ListGX.Add(gx); if (string.IsNullOrWhiteSpace(CZCSXM)) { gx.CZCLX = CZCLX; gx.CZCDM = CZCDM; gx.CZCMC = CZCMC; gx.Shape = feature.ShapeCopy; bgxw = "2"; gx.BSM = "AddNew"; gx.GCList.Add(new CZCGXGC() { Shape = feature.ShapeCopy, BGXW = bgxw, BGMJ = feature.ShapeCopy.GetEllipseArea(), BGQBSM = bsm, BGQCZCLX = CZCLX, BGQCZCDM = CZCDM, BGQCZCMC = CZCMC, BGHCZCDM = CZCDM, BGHCZCMC = CZCMC, BGHCZCLX = CZCLX }); gx.BSM = "AddNew"; if (gx.CZCLX == "203" || gx.CZCLX == "203A") { ListGX.Remove(gx); continue; } List jcCzcs = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); foreach (var item in jcCzcs) { string jcCZCLX = item.Value[idx_JCCZCLX].ToTrim(); string jcCZCDM = item.Value[idx_JCCZCDM].ToTrim(); string jcCZCMC = item.Value[idx_JCCZCMC].ToTrim(); //string tempCZCLX = item.Value[idx_CZCLX].ToTrim(); string tempBSM = item.Value[idx_JCBSM].ToTrim(); if (jcCZCLX == CZCLX && jcCZCDM == CZCDM && jcCZCMC == CZCMC && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) { gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); gx.GCList.Add(new CZCGXGC() { Shape = item.ShapeCopy, BGXW = "2", BGMJ = item.ShapeCopy.GetEllipseArea(), BGQBSM = tempBSM, BGQCZCLX = jcCZCLX, BGQCZCDM = jcCZCDM, BGQCZCMC = jcCZCMC, BGHCZCDM = CZCDM, BGHCZCMC = CZCMC, BGHCZCLX = CZCLX }); } else if (FeatureAPI.IsInterSect(item.ShapeCopy, gx.Shape)) { CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); if (gx1 != null) { gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); gx1.GCList.ForEach(f => f.Shape = gx1.Shape); //gx1.GCList.AddRange(gx.GCList); //ListGX.Remove(gx); //gx = gx1; continue; } else { gx1 = new CZCGX(); gx1.BSM = "AddNew"; gx1.CZCLX = item.Value[idx_JCCZCLX].ToTrim(); gx1.CZCDM = item.Value[idx_JCCZCDM].ToTrim(); gx1.CZCMC = item.Value[idx_JCCZCMC].ToTrim(); gx1.Shape = FeatureAPI.Difference(item.ShapeCopy, gx.Shape); gx1.UpdateOID.Add(item.OID); gx1.GCList.Add(new CZCGXGC() { Shape = gx1.Shape, BGQBSM = tempBSM, BGQCZCLX = gx1.CZCLX, BGQCZCDM = gx1.CZCDM, BGQCZCMC = gx1.CZCMC, BGHCZCLX = gx1.CZCLX, BGHCZCDM = gx1.CZCDM, BGHCZCMC = gx1.CZCMC, BGMJ = feature.ShapeCopy.GetEllipseArea(), BGXW = "2" }); ListGX.Add(gx1); continue; //gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); } } } } else { bgxw = "2"; gx.CZCLX = CZCSXM; gx.CZCDM = newCZCDM; gx.CZCMC = newCZCMC; gx.Shape = feature.ShapeCopy; gx.GCList.Add(new CZCGXGC() { Shape = feature.ShapeCopy, BGXW = bgxw, BGMJ = feature.ShapeCopy.GetEllipseArea(), BGQBSM = bsm, BGQCZCLX = CZCLX, BGQCZCDM = CZCDM, BGQCZCMC = CZCMC, BGHCZCDM = gx.CZCDM, BGHCZCMC = gx.CZCMC, BGHCZCLX = gx.CZCLX }); gx.BSM = "AddNew"; int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); if (gx.CZCLX == "203" || gx.CZCLX == "203A") { List jcCzcs2 = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); foreach (var item in jcCzcs2) { string jcCZCLX = item.Value[idx_JCCZCLX].ToTrim(); string jcCZCDM = item.Value[idx_JCCZCDM].ToTrim(); string jcCZCMC = item.Value[idx_JCCZCMC].ToTrim(); //string tempCZCLX = item.Value[idx_CZCLX].ToTrim(); string tempBSM = item.Value[idx_JCBSM].ToTrim(); CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); if (gx1 != null) { gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); foreach (var tempGC in gx1.GCList) { tempGC.Shape = FeatureAPI.Difference(tempGC.Shape, gx.Shape); } } } continue; } List tempCzcs = FeatureAPI.Identify(gx.Shape, czcUnionMToSLayer); //int idxOldCzcOID = czcUnionMToSLayer; foreach (var item in tempCzcs) { if (item.OID == feature.OID) continue; string tempBGXW = item.Value[idx_BGXW].ToTrim(); string tempCZCLX = tempBGXW == "3" ? item.Value[idx_CZCSXM].ToTrim() : item.Value[idx_CZCLX].ToTrim(); string tempCZCDM = tempBGXW == "3" ? item.Value[idx_ZLDWDM].ToTrim() : item.Value[idx_CZCDM].ToTrim(); string tempCZCMC = tempBGXW == "3" ? item.Value[idx_ZLDWMC].ToTrim() : item.Value[idx_CZCMC].ToTrim(); if (tempCZCLX == gx.CZCLX && tempCZCDM == gx.CZCDM && tempCZCMC == gx.CZCMC && tempBGXW != "0" && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) { int oldOID = item.OID;// Convert.ToInt32(item.Value[idx_FID_CZC20X]); CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(oldOID)); if (gx1 != null) { ListGX.Remove(gx); gx = gx1; } if (oldOID != -1) { unionOldOIDs.Add(oldOID); } gx.UpdateOID.Add(oldOID); gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); gx.GCList.Add(new CZCGXGC() { Shape = item.ShapeCopy, BGXW = "2", BGMJ = item.ShapeCopy.GetEllipseArea(), BGQCZCLX = CZCLX, BGQCZCDM = CZCDM, BGQCZCMC = CZCMC, BGHCZCDM = newCZCDM, BGHCZCMC = newCZCMC, BGHCZCLX = CZCSXM }); item.Delete(); } } List jcCzcs = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); //int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); //int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); //int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); //int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); foreach (var item in jcCzcs) { if (item.OID == 15) { } string jcCZCLX = item.Value[idx_JCCZCLX].ToTrim(); string jcCZCDM = item.Value[idx_JCCZCDM].ToTrim(); string jcCZCMC = item.Value[idx_JCCZCMC].ToTrim(); string tempBSM = item.Value[idx_JCBSM].ToTrim(); if (jcCZCLX == gx.CZCLX && jcCZCDM == gx.CZCDM && jcCZCMC == gx.CZCMC && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) { IGeometry tmpGeo = feature.ShapeCopy; CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); if (gx1 != null && gx1.CZCLX == gx.CZCLX && gx1.CZCDM == gx.CZCDM) { if (FeatureAPI.IsContains(gx1.Shape, gx.Shape)) { ListGX.Remove(gx); gx = gx1; } else { gx1.Shape = FeatureAPI.Union(gx1.Shape, gx.Shape); gx1.GCList.AddRange(gx.GCList); ListGX.Remove(gx); gx = gx1; } continue; } else { gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); } gx.UpdateOID.Add(item.OID); gx.GCList.Add(new CZCGXGC() { Shape = item.ShapeCopy, BGXW = "2", BGMJ = item.ShapeCopy.GetEllipseArea(), BGQBSM = tempBSM, BGQCZCLX = jcCZCLX, BGQCZCDM = jcCZCDM, BGQCZCMC = jcCZCMC, BGHCZCDM = CZCDM, BGHCZCMC = CZCMC, BGHCZCLX = CZCLX }); } else { bool isUpdata = false; IGeometry tmpGeo = gx.Shape; foreach (var gc in gx.GCList) { if (gc.BGQBSM == tempBSM) { tmpGeo = gc.Shape; isUpdata = true; } } if (isUpdata) { //IGeometry tmpGeo = gx.Shape; CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); if (gx1 != null && gx1.CZCLX == gx.CZCLX && gx1.CZCDM == gx.CZCDM) { gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); if (gx1.CZCDM == gx.CZCDM && gx1.CZCLX == gx.CZCLX && gx1.CZCMC == gx.CZCMC) { ListGX.Remove(gx); gx1.GCList.AddRange(gx.GCList); gx = gx1; } else { ListGX.Remove(gx); gx1 = new CZCGX(); gx1.BSM = "AddNew"; gx1.CZCDM = jcCZCDM; gx1.CZCLX = jcCZCLX; gx1.CZCMC = jcCZCMC; gx1.Shape = gx.Shape;// FeatureAPI.Difference(item.ShapeCopy, gx.Shape); gx1.GCList.Add(new CZCGXGC() { Shape = gx.Shape, BGXW = "2", BGMJ = gx.Shape.GetEllipseArea(), BGQBSM = tempBSM, BGQCZCLX = jcCZCLX, BGQCZCDM = jcCZCDM, BGQCZCMC = jcCZCMC, BGHCZCDM = jcCZCDM, BGHCZCMC = jcCZCMC, BGHCZCLX = jcCZCLX }); ListGX.Add(gx1); } continue; //gx = gx1; } else { if (gx1 != null) { gx1.Shape = FeatureAPI.Difference(gx1.Shape, item.ShapeCopy); foreach (var tempGC in gx1.GCList) { tempGC.Shape = FeatureAPI.Difference(tempGC.Shape, item.ShapeCopy); } if (isUpdata) continue; } else { gx1 = new CZCGX(); gx1.BSM = "AddNew"; gx1.CZCDM = jcCZCDM; gx1.CZCLX = jcCZCLX; gx1.CZCMC = jcCZCMC; gx1.UpdateOID.Add(item.OID); gx1.Shape = FeatureAPI.Difference(item.ShapeCopy, gx.Shape); ListGX.Add(gx1); } } gx1.GCList.Add(new CZCGXGC() { Shape = gx1.Shape, BGXW = "2", BGMJ = gx1.Shape.GetEllipseArea(), BGQBSM = tempBSM, BGQCZCLX = jcCZCLX, BGQCZCDM = jcCZCDM, BGQCZCMC = jcCZCMC, BGHCZCDM = jcCZCDM, BGHCZCMC = jcCZCMC, BGHCZCLX = jcCZCLX }); } } } } } } List tempList = new List(); foreach (var item in ListGX) { if (item.Shape == null) continue; List geos = FeatureAPI.DissolveGeometryByRing(item.Shape); if (geos != null && geos.Count > 1) { item.Shape = geos[0]; for (int i = 1; i < geos.Count; i++) { CZCGX tempGx = new CZCGX() { BSM = "AddNew", CZCDM = item.CZCDM, CZCLX = item.CZCLX, CZCMC = item.CZCMC, Shape = geos[i] }; List gcList = new List(); foreach (var gc in item.GCList) { if (FeatureAPI.GetEqual(gc.Shape, geos[i])) { gcList.Add(gc); tempGx.GCList.Add(gc); } else if (FeatureAPI.IsContains(gc.Shape, geos[i])) { CZCGXGC tempgc1 = new CZCGXGC() { Shape = FeatureAPI.InterSect(gc.Shape, geos[i]), BGHBSM = gc.BGHBSM, BGHBZ = gc.BGHBZ, BGHCZCDM = gc.BGHCZCDM, BGHCZCLX = gc.BGHCZCLX, BGHCZCMC = gc.BGHCZCMC, BGMJ = 0, BGQBSM = gc.BGQBSM, BGQBZ = gc.BGQBZ, BGQCZCDM = gc.BGQCZCDM, BGQCZCLX = gc.BGQCZCLX, BGQCZCMC = gc.BGQCZCMC, BGXW = "2" }; gc.Shape = FeatureAPI.Difference(gc.Shape, geos[i]); tempgc1.BGMJ = tempgc1.Shape.GetEllipseArea(); tempGx.GCList.Add(tempgc1); } } foreach (var gc in gcList) { item.GCList.Remove(gc); } tempList.Add(tempGx); } } } ListGX.AddRange(tempList); InsertData(ListGX); } catch (Exception ex) { //MessageHelper.Show("城镇村范围变更失败!"); //LogAPI.Debug(ex); throw ex; } } public static void DelectDir(string srcPath) { try { DirectoryInfo dir = new DirectoryInfo(srcPath); FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录 foreach (FileSystemInfo i in fileinfo) { if (i is DirectoryInfo) //判断是否文件夹 { DirectoryInfo subdir = new DirectoryInfo(i.FullName); subdir.Delete(true); //删除子目录和文件 } else { File.Delete(i.FullName); //删除指定文件 } } } catch (Exception e) { throw; } } private void InsertData(List pData) { IFeatureClass _CZCGX_Fc = null; IFeatureClass _CZCGXGC_Fc = null; try { if (pData == null || pData.Count == 0) return; _CZCGX_Fc = MapsManager.Instance.MapService.GetFeatureClassByName("CZCDYDGX"); _CZCGXGC_Fc = MapsManager.Instance.MapService.GetFeatureClassByName("CZCDYDGXGC"); if (_CZCGX_Fc == null) { MessageHelper.Show("未找到城镇村更新层"); return; } if (_CZCGXGC_Fc == null) { MessageHelper.Show("未找到城镇村更新过程层"); return; } (_CZCGX_Fc as ITable).DeleteSearchedRows(null); (_CZCGXGC_Fc as ITable).DeleteSearchedRows(null); IFeatureCursor _GXInsertCursor = _CZCGX_Fc.Insert(true); IFeatureCursor _GCInsertCursor = _CZCGXGC_Fc.Insert(true); IFeatureBuffer _GxBuffer = _CZCGX_Fc.CreateFeatureBuffer(); IFeatureBuffer _GcBuffer = _CZCGXGC_Fc.CreateFeatureBuffer(); int idxBSM = _CZCGX_Fc.FindField("BSM"); int idxCZCLX = _CZCGX_Fc.FindField("CZCLX"); int idxCZCDM = _CZCGX_Fc.FindField("CZCDM"); int idxCZCMC = _CZCGX_Fc.FindField("CZCMC"); int idxGXSJ = _CZCGX_Fc.FindField("GXSJ"); int idxBGQBSM = _CZCGXGC_Fc.FindField("BGQBSM"); int idxBGHBSM = _CZCGXGC_Fc.FindField("BGHBSM"); int idxBGQCZCLX = _CZCGXGC_Fc.FindField("BGQCZCLX"); int idxBGHCZCLX = _CZCGXGC_Fc.FindField("BGHCZCLX"); int idxBGQCZCDM = _CZCGXGC_Fc.FindField("BGQCZCDM"); int idxBGHCZCDM = _CZCGXGC_Fc.FindField("BGHCZCDM"); int idxBGQCZCMC = _CZCGXGC_Fc.FindField("BGQCZCMC"); int idxBGHCZCMC = _CZCGXGC_Fc.FindField("BGHCZCMC"); int idxBGXW = _CZCGXGC_Fc.FindField("BGXW"); int idxBGMJ = _CZCGXGC_Fc.FindField("BGMJ"); int idxGCGXSJ = _CZCGXGC_Fc.FindField("GXSJ"); int i = 0; Dictionary> gcMJs = new Dictionary>(); Dictionary bghOIDs = new Dictionary(); Dictionary bghMJs = new Dictionary(); List ListBGXWModel = new List(); foreach (var gx in pData) { if (gx.GCList.Count == 0) { } i++; if (!string.IsNullOrWhiteSpace(gx.CZCLX)) { if (gx.Shape.IsEmpty) { continue; } IArea area = gx.Shape as IArea; if (area.Area < 0.01) { continue; } _GxBuffer.Shape = gx.Shape; if (idxBSM != -1) { if (gx.BSM == "AddNew") { string bsmPrefix = MaxBSM.Substring(0, 10); int MaxNum = Convert.ToInt32(MaxBSM.Substring(10)); if (MaxNum == 1171) { } MaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); gx.BSM = MaxBSM; } _GxBuffer.Value[idxBSM] = gx.BSM; } if (idxCZCLX != -1) _GxBuffer.Value[idxCZCLX] = gx.CZCLX; if (idxCZCDM != -1) _GxBuffer.Value[idxCZCDM] = gx.CZCDM; if (idxCZCMC != -1) _GxBuffer.Value[idxCZCMC] = gx.CZCMC; if (idxGXSJ != -1) _GxBuffer.Value[idxGXSJ] = new DateTime(DateTime.Now.Year - 1, 12, 31); object oid = _GXInsertCursor.InsertFeature(_GxBuffer); if (!bghOIDs.ContainsKey(gx.BSM)) { bghOIDs.Add(gx.BSM, Convert.ToInt32(oid)); } } foreach (var gc in gx.GCList) { gc.BGMJ = gc.Shape.GetEllipseArea().ToDouble(2); if (gc.Shape == null || gc.Shape.IsEmpty || gc.BGMJ == 0) { continue; } List gcList = FeatureAPI.DissolveGeometryByRing(gc.Shape); if (gcList == null) continue; foreach (var shp in gcList) { double bgmj = shp.GetEllipseArea(); if (bgmj == 0) { continue; } _GcBuffer.Shape = shp; if (idxBGXW != -1) _GcBuffer.Value[idxBGXW] = gc.BGXW; if (idxBGMJ != -1) _GcBuffer.Value[idxBGMJ] = bgmj.ToDouble(2); if (idxBGQBSM != -1) _GcBuffer.Value[idxBGQBSM] = gc.BGQBSM; if (idxBGHBSM != -1) _GcBuffer.Value[idxBGHBSM] = gx.BSM; if (idxBGQCZCLX != -1) _GcBuffer.Value[idxBGQCZCLX] = gc.BGQCZCLX; if (idxBGHCZCLX != -1) _GcBuffer.Value[idxBGHCZCLX] = gc.BGHCZCLX; if (idxBGQCZCDM != -1) _GcBuffer.Value[idxBGQCZCDM] = gc.BGQCZCDM; if (idxBGHCZCDM != -1) _GcBuffer.Value[idxBGHCZCDM] = gc.BGHCZCDM; if (idxBGQCZCMC != -1) _GcBuffer.Value[idxBGQCZCMC] = gc.BGQCZCMC; if (idxBGHCZCMC != -1) _GcBuffer.Value[idxBGHCZCMC] = gc.BGHCZCMC; if (idxGCGXSJ != -1) _GcBuffer.Value[idxGCGXSJ] = new DateTime(DateTime.Now.Year - 1, 12, 31); object oid = _GCInsertCursor.InsertFeature(_GcBuffer); if (!string.IsNullOrWhiteSpace(gc.BGQBSM)) { if (gcMJs.ContainsKey(gc.BGQBSM)) { gcMJs[gc.BGQBSM].Add(new PCModel() { OID = Convert.ToInt32(oid), MJ = gc.BGMJ }); } else { gcMJs.Add(gc.BGQBSM, new List()); gcMJs[gc.BGQBSM].Add(new PCModel() { OID = Convert.ToInt32(oid), MJ = gc.BGMJ }); } } ListBGXWModel.Add(new SetBGXWModel { OID = Convert.ToInt32(oid), BGQBSM = gc.BGQBSM, BGHBSM = gc.BGHBSM }); } } } _GXInsertCursor.Flush(); _GCInsertCursor.Flush(); ICursor curor = (_CZCFc as ITable).Search(null, true); IRow row = null; Dictionary jcMJs = new Dictionary(); int idxJCBSM = -1, idxJCMJ = -1; while ((row = curor.NextRow()) != null) { if (idxJCBSM == -1) idxJCBSM = row.Fields.FindField("BSM"); if (idxJCMJ == -1) idxJCMJ = row.Fields.FindField("CZCMJ"); jcMJs.Add(row.Value[idxJCBSM].ToTrim(), row.Value[idxJCMJ].ToDouble()); } foreach (var key in jcMJs.Keys) { if (!gcMJs.ContainsKey(key)) { continue; } List shpList = gcMJs[key]; double pKZMJ = jcMJs[key]; shpList = shpList.OrderByDescending(o => o.MJ).ToList(); double mjc = Math.Round(shpList.Sum(s => s.MJ) - pKZMJ, 2); if (Math.Round(mjc, 2) == 0) { continue; } int num = 0; //平差 while (Math.Round(mjc, 2) != 0 && num < 10) { num++; int tpsm = (int)(Math.Abs(Math.Round(mjc, 2)) / 0.01); int e = tpsm / shpList.Count; int f = tpsm % shpList.Count; if (f != 0) { double tpmj = (e + 1) * 0.01; for (int j = 0; j < f; j++) { if (mjc < 0) shpList[j].MJ = shpList[j].MJ + tpmj; else shpList[j].MJ = shpList[j].MJ - tpmj; } } if (e != 0) { double tpmj = e * 0.01; for (int j = f; j < shpList.Count; j++) { if (mjc < 0) shpList[j].MJ = shpList[j].MJ + tpmj; else shpList[j].MJ = shpList[j].MJ - tpmj; } } mjc = Math.Round(shpList.Sum(s => s.MJ), 2) - pKZMJ; } foreach (var item in shpList) { IFeature fet = _CZCGXGC_Fc.GetFeature(item.OID); fet.Value[idxBGMJ] = item.MJ; fet.Store(); Marshal.ReleaseComObject(fet); } } curor = (_CZCGXGC_Fc as ITable).Search(null, true); row = null; bghMJs.Clear(); List ListSXBG = new List(); while ((row = curor.NextRow()) != null) { string bgqBSM = row.Value[idxBGQBSM].ToTrim(); string bghBSM = row.Value[idxBGHBSM].ToTrim(); double bgmj = row.Value[idxBGMJ].ToDouble(); if (!string.IsNullOrWhiteSpace(bghBSM)) { if (!bghMJs.ContainsKey(bghBSM)) { bghMJs.Add(bghBSM, bgmj); } else { bghMJs[bghBSM] += bgmj; } } int bgqNum = ListBGXWModel.Count(c => c.BGQBSM == bgqBSM); int bghnum = ListBGXWModel.Count(c => c.BGHBSM == bghBSM); if (bgqNum == 1 && bghnum == 1) { ListSXBG.Add(row.OID); } } int idxCZCMJ = _CZCGX_Fc.FindField("CZCMJ"); foreach (var item in bghMJs.Keys) { if (bghOIDs.ContainsKey(item)) { if (bghOIDs[item] != -1) { IFeature fet = _CZCGX_Fc.GetFeature(bghOIDs[item]); fet.Value[idxCZCMJ] = bghMJs[item].ToDouble(2); fet.Store(); Marshal.ReleaseComObject(fet); } } } foreach (var gcoid in ListSXBG) { IFeature GCfeature = _CZCGXGC_Fc.GetFeature(gcoid); GCfeature.Value[idxBGXW] = "1"; string BGHBSM = GCfeature.Value[idxBGHBSM].ToTrim(); GCfeature.Value[idxBGHBSM] = GCfeature.Value[idxBGQBSM]; GCfeature.Store(); (_CZCGX_Fc as FeatureClass).Workspace.ExecuteSQL(string.Format("Update CZCDYDGX set BSM='{0}' where BSM='{1}'", GCfeature.Value[idxBGQBSM], BGHBSM)); } } catch (Exception ex) { MessageHelper.Show("写入数据失败!错误原因请查看系统日志"); LogAPI.Debug("城镇村范围变更失败:"); LogAPI.Debug(ex); } } private string GetMaxBSM(List fcList) { //System.Windows.Forms.Application.DoEvents(); int xh = 0; string MaxBSM = ""; string leftStr = string.Empty; foreach (var fc in fcList) { string BSM = string.Empty; int BSMIndex = fc.FindField("BSM"); if (BSMIndex == -1) return BSM; ITable table = (ITable)fc; // 创建一个ITableSort接口对象 ITableSort tableSort = new TableSortClass(); tableSort.Table = table; tableSort.Fields = "BSM"; tableSort.set_Ascending("BSM", false); tableSort.Sort(null); ICursor cursor = tableSort.Rows; IRow row = cursor.NextRow(); if (row != null) { int maxBSM = 0; int currBSM = 0; string BSMStr = row.Value[BSMIndex].ToString(); if (BSMStr.Length != 18) return BSM; string subBSMStr = BSMStr.Substring(9); try { currBSM = Convert.ToInt32(subBSMStr); } catch (Exception) { return BSM; } if (currBSM > maxBSM) maxBSM = currBSM; if (BSMStr.Length != 18) return BSM; string maxStr = maxBSM.ToString(); int zeroNum = 9 - maxStr.Length; for (int i = 0; i < zeroNum; i++) { maxStr = 0 + maxStr; } BSM = BSMStr.Substring(0, 9) + maxStr; } if (BSM.Length != 18) continue; int xh2 = Convert.ToInt32(BSM.Substring(10)); leftStr = BSM.Substring(0, 10); if (xh < xh2) { xh = xh2; MaxBSM = BSM; } } return MaxBSM; } private void InsertDataToMemeoryLayer(IFeatureClass pSource, IFeatureClass pTarget, IQueryFilter pFilter = null) { try { if (pSource == null || pTarget == null) return; IFeatureClassAPI fcAPI = new FeatureClassAPI(pSource); if (pTarget != null) fcAPI.FcToFc(pTarget, pFilter, false); } catch (Exception ex) { LogAPI.Debug("获取城镇村范围数据失败:"); LogAPI.Debug(ex); } } private void BtnCancel_Click(object sender, RoutedEventArgs e) { this.Close(); } } public class PCModel { public int OID { get; set; } public double MJ { get; set; } } public class SetBGXWModel { public int OID { get; set; } public string BGQBSM { get; set; } public int BGQBSMNum { get; set; } public string BGHBSM { get; set; } public int BGHBSMNum { get; set; } } public class CZCGXGC { public string BGXW { get; set; } public double BGMJ { get; set; } public string BGQBSM { get; set; } public string BGHBSM { get; set; } public string BGQCZCDM { get; set; } public string BGHCZCDM { get; set; } public string BGQCZCMC { get; set; } public string BGHCZCMC { get; set; } public string BGQBZ { get; set; } public string BGHBZ { get; set; } public string BGQCZCLX { get; set; } public string BGHCZCLX { get; set; } public IGeometry Shape { get; set; } } public class CZCGX { public bool IsNewAdd203 { get; set; } public List UpdateOID { get; set; } public int OID { get; set; } public string CZCLX { get; set; } public string BSM { get; set; } public string CZCDM { get; set; } public string CZCMC { get; set; } public double CZCMJ { get; set; } public List GCList { get; set; } = new List(); public IGeometry Shape { get; set; } public string BGXW { get; set; } public CZCGX() { UpdateOID = new List(); } } }