diff --git a/KGIS_DLTB/App.config b/KGIS_DLTB/App.config
deleted file mode 100644
index d6dbac9..0000000
--- a/KGIS_DLTB/App.config
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/KGIS_DLTB/GPHelper/ExeGPForProces.cs b/KGIS_DLTB/GPHelper/ExeGPForProces.cs
deleted file mode 100644
index 089dce8..0000000
--- a/KGIS_DLTB/GPHelper/ExeGPForProces.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-using ESRI.ArcGIS.Carto;
-using ESRI.ArcGIS.esriSystem;
-using KGIS.Framework.AE.GPHelper;
-using KGIS.Framework.Utils;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace KGIS_DLTB
-{
- public class GPHelper
- {
- public static GPHelper Instance { get; } = new GPHelper();
- public GPHelper()
- { }
- public string ExeGPForProces(string args1, string args2, string args3, string args4, string args5)
- {
- if (string.IsNullOrWhiteSpace(args1))
- args1 = "null";
- if (string.IsNullOrWhiteSpace(args2))
- args2 = "null";
- if (string.IsNullOrWhiteSpace(args3))
- args3 = "null";
- if (string.IsNullOrWhiteSpace(args4))
- args4 = "null";
- if (string.IsNullOrWhiteSpace(args5))
- args5 = "null";
- var psi = new ProcessStartInfo("GPHelper.exe", string.Format("{0} {1} {2} {3} {4}", args1, args2, args3, args4, args5));
- psi.UseShellExecute = false;
- psi.CreateNoWindow = true;
- psi.RedirectStandardError = true;
- psi.RedirectStandardInput = true;
- psi.RedirectStandardOutput = true;
-
- var pes = Process.Start(psi);
-
- var sbuffer = new StringBuilder();
- var sout = pes.StandardOutput;
- while (!sout.EndOfStream)
- {
- var line = sout.ReadLine();
- if (String.IsNullOrEmpty(line)) continue;
- sbuffer.AppendLine(line);
- }
- pes.WaitForExit();
- pes.Close();
- String res = sbuffer.ToString();
- sbuffer.Clear();
- return res;
- }
- public string ExeGPForProces(string arg)
- {
- string result = string.Empty;
- Byte[] toEncryptArray = Encoding.UTF8.GetBytes(arg);
- string strParm = Convert.ToBase64String(toEncryptArray);
- //Console.WriteLine(strParm);
- var psi = new ProcessStartInfo("GPHelper.exe", "GP调用");
- psi.EnvironmentVariables["MY_ARGS"] = strParm;
- psi.UseShellExecute = false;
- psi.CreateNoWindow = true;
- psi.RedirectStandardError = true;
- psi.RedirectStandardInput = true;
- psi.RedirectStandardOutput = true;
-
- var pes = Process.Start(psi);
- var sbuffer = new StringBuilder();
- var sout = pes.StandardOutput;
- while (!sout.EndOfStream)
- {
- result = sout.ReadLine();
- if (String.IsNullOrEmpty(result)) continue;
- sbuffer.AppendLine(result);
- }
- pes.WaitForExit();
- pes.Close();
- String res = sbuffer.ToString();
- sbuffer.Clear();
- //Console.WriteLine(res);
- return result;
- }
-
- public void ExeGPForProces(GPParamClass gPParam, ref IFeatureLayer result)
- {
- string outPath = string.Empty;
- try
- {
- string strParm = SerializeAPI.SerializeToXML(gPParam);
- outPath = ExeGPForProces(strParm);
- lock (this)
- {
- if (gPParam.GPType == EnumGPType.Default)
- {
- return;
- }
- if (outPath.ToLower() == "error")
- {
-
- }
- else
- {
- if (string.IsNullOrWhiteSpace(outPath))
- outPath = gPParam.OutFeatureClassPath;
- result = new FeatureLayer();
- FileInfo file = new FileInfo(outPath.Replace("\r\n", ""));
- string dbPath = file.DirectoryName;
- string fcName = file.Name;
- if (file.Name.ToLower().EndsWith(".gdb") && gPParam.FcName != null)
- {
- dbPath = file.FullName;
- fcName = gPParam.FcName;
- }
- else if (fcName.ToLower().EndsWith(".shp"))
- {
- KGIS.Framework.AE.IWorkspaceAPI wsAPI = new KGIS.Framework.AE.WorkspaceAPI(dbPath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.ShapeFile);
- KGIS.Framework.AE.IFeatureClassAPI fcAPI = wsAPI.OpenFeatureClass(fcName.Replace(".shp", ""));
- result.FeatureClass = fcAPI.FeatureClass;
- }
- {
- KGIS.Framework.AE.IWorkspaceAPI wsAPI = new KGIS.Framework.AE.WorkspaceAPI(dbPath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile, true);
- KGIS.Framework.AE.IFeatureClassAPI fcAPI = wsAPI.OpenFeatureClass(fcName);
- result.FeatureClass = fcAPI.FeatureClass;
- }
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(outPath);
- Console.WriteLine(ex.Message);
- }
- }
-
- public void ExeGp(IVariantArray pParam)
- {
- string outPath = string.Empty;
- try
- {
- string strParm = KGIS.Framework.AE.GeoDBAPI.SerialzedPersist(pParam);
- outPath = ExeGPForProces(strParm);
- }
- catch (Exception ex)
- {
- Console.WriteLine(outPath);
- Console.WriteLine(ex.Message);
- }
- }
-
- public bool ValidityLic()
- {
- try
- {
-#if DEBUG
- Console.WriteLine("Log:数据信息校验_False!");
- return true;
-#else
- string jkrjSQ = System.IO.Path.Combine(SysAppPath.GetCurrentAppPath(), "jkrj.lic");
- cvvOrpfAU3EHNwACbeT.WD3DgyfSL927cnSHeKI ProcessingValidity = new cvvOrpfAU3EHNwACbeT.WD3DgyfSL927cnSHeKI("KGIS_SJJK", "6x", jkrjSQ);
- bool v = ProcessingValidity.BbOJCFj78PyoadK1iYD();
- return v;
-#endif
- }
- catch (Exception ex)
- {
- Console.WriteLine("Err:数据信息校验异常_KGIS_DLTB:" + ex.StackTrace + ex.Message);
- Console.WriteLine("Err:数据信息校验异常_KGIS_DLTB!");
- return false;
- }
-
- }
-
- }
-}
diff --git a/KGIS_DLTB/GPHelper/GeoprocessorHelper.cs b/KGIS_DLTB/GPHelper/GeoprocessorHelper.cs
deleted file mode 100644
index 7c21595..0000000
--- a/KGIS_DLTB/GPHelper/GeoprocessorHelper.cs
+++ /dev/null
@@ -1,394 +0,0 @@
-using ESRI.ArcGIS.Carto;
-using ESRI.ArcGIS.DataManagementTools;
-using ESRI.ArcGIS.esriSystem;
-using ESRI.ArcGIS.Geodatabase;
-using ESRI.ArcGIS.Geoprocessing;
-using ESRI.ArcGIS.Geoprocessor;
-using KGIS.Framework.AE.GPHelper;
-//using KGIS.Framework.Utils;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading;
-
-namespace GPHelper
-{
- public class CustomGPHelper
- {
-
- public static void DLTBBGDissolve_Tool(IVariantArray pParam)
- {
- object sev = null;
- //1-定义GeoProcessor对象
- IGeoProcessor gp = new GeoProcessorClass();
- try
- {
- //2-设置参数
- gp.OverwriteOutput = true;
- string strPath = AppDomain.CurrentDomain.BaseDirectory;
- if (!strPath.EndsWith(@"\"))
- {
- strPath += @"\";
- }
- string toolPath = System.IO.Path.Combine(strPath, @"Resource\ZLDatabaseTool" + ".tbx");
- if (!System.IO.File.Exists(toolPath))
- {
- throw new Exception("未找到预变更工具!");
- }
- //3-设置工具箱所在的路径
- gp.AddToolbox(toolPath);
- //5-执行工具
- IGeoProcessorResult result = gp.Execute("DLTBBGDissolve", pParam, null);
- if (result != null && result.Status != esriJobStatus.esriJobSucceeded)
- {
- string ms = "";
- if (gp.MessageCount > 0)
- {
- for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
- {
- ms += "$" + gp.GetMessage(Count) + "\n\n";
- }
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (gp.MessageCount > 0)
- gp.GetMessages(ref sev).ToString();
- }
- }
-
- ///
- /// 地类图斑更新层数据变更
- ///
- ///
- public static void DLTBGXDissolve_Tool(IVariantArray pParam)
- {
- object sev = null;
- //1-定义GeoProcessor对象
- IGeoProcessor gp = new GeoProcessorClass();
- try
- {
- //2-设置参数
- gp.OverwriteOutput = true;
- string strPath = AppDomain.CurrentDomain.BaseDirectory;
- if (!strPath.EndsWith(@"\"))
- {
- strPath += @"\";
- }
- string toolPath = System.IO.Path.Combine(strPath, @"Resource\ZLDatabaseTool" + ".tbx");
- if (!System.IO.File.Exists(toolPath))
- {
- throw new Exception("未找到预变更工具!");
- }
- //3-设置工具箱所在的路径
- gp.AddToolbox(toolPath);
- //5-执行工具
- IGeoProcessorResult result = gp.Execute("DLTBGXDissolve", pParam, null);
- if (result != null && result.Status != esriJobStatus.esriJobSucceeded)
- {
- string ms = "";
- if (gp.MessageCount > 0)
- {
- for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
- {
- ms += "$" + gp.GetMessage(Count) + "\n\n";
- }
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (gp.MessageCount > 0)
- gp.GetMessages(ref sev).ToString();
- }
- }
-
- public static void SetGDPDJB_Tool(IVariantArray pParam)
- {
- object sev = null;
- //1-定义GeoProcessor对象
- IGeoProcessor gp = new GeoProcessorClass();
- try
- {
- //2-设置参数
- gp.OverwriteOutput = true;
- string strPath = AppDomain.CurrentDomain.BaseDirectory;
- if (!strPath.EndsWith(@"\"))
- {
- strPath += @"\";
- }
- string toolPath = System.IO.Path.Combine(strPath, @"Resource\ZLDatabaseTool" + ".tbx");
- if (!System.IO.File.Exists(toolPath))
- {
- throw new Exception("未找到预变更工具!");
- }
- //3-设置工具箱所在的路径
- gp.AddToolbox(toolPath);
- //5-执行工具
- IGeoProcessorResult result = gp.Execute("SetGDPDJBTool", pParam, null);
- if (result != null && result.Status != esriJobStatus.esriJobSucceeded)
- {
- string ms = "";
- if (gp.MessageCount > 0)
- {
- for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
- {
- ms += "$" + gp.GetMessage(Count) + "\n\n";
- }
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (gp.MessageCount > 0)
- gp.GetMessages(ref sev).ToString();
- }
- }
- public static void DLTBBG_Tool(IVariantArray pParam)
- {
- object sev = null;
- //1-定义GeoProcessor对象
- IGeoProcessor gp = new GeoProcessorClass();
- try
- {
- //2-设置参数
- gp.OverwriteOutput = true;
- string strPath = AppDomain.CurrentDomain.BaseDirectory;
- if (!strPath.EndsWith(@"\"))
- {
- strPath += @"\";
- }
- string toolPath = System.IO.Path.Combine(strPath, @"Resource\ZLDatabaseTool" + ".tbx");
- if (!System.IO.File.Exists(toolPath))
- {
- throw new Exception("未找到预变更工具!");
- }
- //3-设置工具箱所在的路径
- gp.AddToolbox(toolPath);
- //5-执行工具
- IGeoProcessorResult result = gp.Execute("DLTBBGTool", pParam, null);
- if (result != null && result.Status != esriJobStatus.esriJobSucceeded)
- {
- string ms = "";
- if (gp.MessageCount > 0)
- {
- for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
- {
- ms += "$" + gp.GetMessage(Count) + "\n\n";
- }
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (gp.MessageCount > 0)
- gp.GetMessages(ref sev).ToString();
- }
- }
- public static void GDTBBG_Tool(IVariantArray pParam)
- {
- object sev = null;
- //1-定义GeoProcessor对象
- IGeoProcessor gp = new GeoProcessorClass();
- try
- {
- //2-设置参数
- gp.OverwriteOutput = true;
- string strPath = AppDomain.CurrentDomain.BaseDirectory;
- if (!strPath.EndsWith(@"\"))
- {
- strPath += @"\";
- }
- string toolPath = System.IO.Path.Combine(strPath, @"Resource\ZLDatabaseTool" + ".tbx");
- if (!System.IO.File.Exists(toolPath))
- {
- throw new Exception("未找到预变更工具!");
- }
- //3-设置工具箱所在的路径
- gp.AddToolbox(toolPath);
- //5-执行工具
- IGeoProcessorResult result = gp.Execute("GDTBBGTool", pParam, null);
- if (result != null && result.Status != esriJobStatus.esriJobSucceeded)
- {
- string ms = "";
- if (gp.MessageCount > 0)
- {
- for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
- {
- ms += "$" + gp.GetMessage(Count) + "\n\n";
- }
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (gp.MessageCount > 0)
- gp.GetMessages(ref sev).ToString();
- }
- }
-
- public static void RepairGeo(GPParamClass gPParam)
- {
- Geoprocessor gp = new Geoprocessor();
- try
- {
- RepairGeometry repairgeo = new RepairGeometry();
- repairgeo.in_features = gPParam.FirstFeatureLayer.FeatureClass;
- //repairgeo.out_feature_class = outFC;
- repairgeo.delete_null = "TRUE";
- IGeoProcessorResult tGeoResult = (IGeoProcessorResult)gp.Execute(repairgeo, null);
- if (tGeoResult == null || tGeoResult.Status != esriJobStatus.esriJobSucceeded)
- {
- //LogAPI.Debug("检查图形失败:");
- throw new Exception(ReturnMessages(gp));
- }
- string msg = ReturnMessages(gp);
- }
- catch (Exception ex)
- {
- throw new Exception(ReturnMessages(gp));
- }
- }
- public static void RepairGeo(IFeatureClass pFc)
- {
- Geoprocessor gp = new Geoprocessor();
- try
- {
- RepairGeometry repairgeo = new RepairGeometry();
- repairgeo.in_features = pFc;
- //repairgeo.out_feature_class = outFC;
- repairgeo.delete_null = "TRUE";
- IGeoProcessorResult tGeoResult = (IGeoProcessorResult)gp.Execute(repairgeo, null);
- if (tGeoResult == null || tGeoResult.Status != esriJobStatus.esriJobSucceeded)
- {
- //LogAPI.Debug("检查图形失败:");
- throw new Exception(ReturnMessages(gp));
- }
- string msg = ReturnMessages(gp);
- }
- catch (Exception ex)
- {
- throw new Exception(ReturnMessages(gp));
- }
- }
-
-
- public static void DLTBGXGC_Tool(IVariantArray pParam)
- {
- object sev = null;
- //1-定义GeoProcessor对象
- IGeoProcessor gp = new GeoProcessorClass();
- try
- {
- //2-设置参数
- gp.OverwriteOutput = true;
- string strPath = AppDomain.CurrentDomain.BaseDirectory;
- if (!strPath.EndsWith(@"\"))
- {
- strPath += @"\";
- }
- string toolPath = System.IO.Path.Combine(strPath, @"Resource\ZLDatabaseTool" + ".tbx");
- if (!System.IO.File.Exists(toolPath))
- {
- throw new Exception("未找到预变更工具!");
- }
- //3-设置工具箱所在的路径
- gp.AddToolbox(toolPath);
- //5-执行工具
- IGeoProcessorResult result = gp.Execute("DLTBGXGCTool", pParam, null);
- if (result != null && result.Status != esriJobStatus.esriJobSucceeded)
- {
- string ms = "";
- if (gp.MessageCount > 0)
- {
- for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
- {
- ms += "$" + gp.GetMessage(Count) + "\n\n";
- }
- }
- }
- gp.RemoveToolbox(toolPath);
-
- Marshal.ReleaseComObject(gp);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- //if (gp.MessageCount > 0)
- // gp.GetMessages(ref sev).ToString();
- }
- }
-
- public static void TableToTable(IFeatureLayer pLayer, string pOutLocal, string pOutName)
- {
- try
- {
- //for (int i = 0; i < listFeatureClass.Count(); i++)
- //{
- ESRI.ArcGIS.Geoprocessor.Geoprocessor geoprocessor = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
- geoprocessor.OverwriteOutput = true;
- ESRI.ArcGIS.ConversionTools.TableToTable TbToTb = new ESRI.ArcGIS.ConversionTools.TableToTable();
- TbToTb.in_rows = pLayer.FeatureClass;
- TbToTb.out_path = pOutLocal;
- TbToTb.out_name = pOutName;
- IGeoProcessorResult tGeoResult = (IGeoProcessorResult)geoprocessor.Execute(TbToTb, null);
- if (tGeoResult == null || tGeoResult.Status != ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)
- {
- string msg = ReturnMessages(geoprocessor);
- throw new Exception(msg);
- }
- //}
-
- }
- catch (Exception ex)
- {
- //LogAPI.Debug("将一个或多个属性表导出excel 时失败,异常原因: " + ex + " ; ");
- throw ex;
- }
- }
- ///
- /// 获取GP任务执行信息
- ///
- ///
- ///
- private static string ReturnMessages(Geoprocessor gp)
- {
- string ms = "";
- if (gp.MessageCount > 0)
- {
- for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
- {
- ms += "$" + gp.GetMessage(Count) + "\n\n";
- }
- }
- return ms;
- }
- }
-
-}
diff --git a/KGIS_DLTB/Helper/BaseIDG.cs b/KGIS_DLTB/Helper/BaseIDG.cs
deleted file mode 100644
index cf47a94..0000000
--- a/KGIS_DLTB/Helper/BaseIDG.cs
+++ /dev/null
@@ -1,709 +0,0 @@
-using ESRI.ArcGIS.Carto;
-using ESRI.ArcGIS.esriSystem;
-using ESRI.ArcGIS.Geodatabase;
-using KGIS.Framework.AE;
-using KGIS.Framework.AE.Enum;
-using KGIS.Framework.AE.GPHelper;
-using KGIS.Framework.Utils;
-using KGIS.Framework.Utils.ExtensionMethod;
-using Kingo.PluginServiceInterface;
-using Kingo.PluginServiceInterface.Model;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Runtime.InteropServices;
-
-namespace KGIS_DLTB
-{
- public class BaseIDG : IDisposable
- {
- //private IFeatureLayer jCLayer;
- internal IFeatureLayer _jcTbLayer;
- internal IFeatureLayer _gxgcTBLayer;
- internal IFeatureLayer _gxTbLayer;
- internal IFeatureLayer _bgTbLayer;
- internal IFeatureLayer _cjqTbLayer;
- internal IFeatureLayer _jcCjdcqLayer;
- internal IFeatureLayer _jcCjdcqJxLayer;
- internal IFeatureLayer _gxCjdcqLayer;
- internal IFeatureLayer _gxgcCjdcqLayer;
- internal IFeatureLayer _gxCjdcqJxLayer;
- internal IFeatureLayer _jcXzqLayer;
- internal IFeatureLayer _jcXzqJxLayer;
- internal IFeatureLayer _gxXzqLayer;
- internal IFeatureLayer _gxgcXzqLayer;
- internal IFeatureLayer _gxXzqJxLayer;
- internal IFeatureLayer _jcCzcLayer;
- internal IFeatureLayer _gxCzcLayer;
- internal IFeatureLayer _gxgcCzcLayer;
- internal IFeatureLayer _jcGddbLayer;
- internal IFeatureLayer _gxGddbLayer;
- internal IFeatureLayer _jcPdtLayer;
- internal IFeatureLayer _gxPdtLayer;
- internal IFeatureLayer _nmTbLayer;
-
- public IWorkspaceAPI BgWsAPI { get; set; }
- public Dictionary DicWsAPI { get; set; }
- public IWorkspaceAPI ZlWsAPI { get; set; }
- public IWorkspaceAPI NmWsAPI { get; set; }
- public IWorkspaceAPI JCWsAPI { get; set; }
- //public IFeatureLayer JCLayer { get => jCLayer; set => jCLayer = value; }
- //public IFeatureLayer GXLayer { get => gXLayer; set => gXLayer = value; }
- public IFeatureLayer NmTbLayer { get => _nmTbLayer; set => _nmTbLayer = value; }
- #region 地类图斑
- public IFeatureLayer JcTbLayer { get => _jcTbLayer; }
- public IFeatureLayer JcPdtLayer { get => _jcPdtLayer; }
- public IFeatureLayer GxgcTBLayer { get => _gxgcTBLayer; }
- public IFeatureLayer GxTbLayer { get => _gxTbLayer; }
- public IFeatureLayer GxPdtLayer { get => _gxPdtLayer; }
-
- public IFeatureLayer BgTbLayer { get => _bgTbLayer; }
- public IFeatureLayer CJQTbLayer { get => _cjqTbLayer; }
- #endregion
-
- #region 村级调查区
- public IFeatureLayer JcCjdcqLayer { get => _jcCjdcqLayer; set => _jcCjdcqLayer = value; }
- public IFeatureLayer JcCjdcqJxLayer { get => _jcCjdcqJxLayer; }
- public IFeatureLayer GxCjdcqLayer { get => _gxCjdcqLayer; }
- public IFeatureLayer GxgcCjdcqLayer { get => _gxgcCjdcqLayer; }
- public IFeatureLayer GxCjdcqJxLayer { get => _gxCjdcqJxLayer; }
- #endregion
-
- #region 行政区
- public IFeatureLayer JcXzqLayer { get => _jcXzqLayer; set => _jcXzqLayer = value; }
- public IFeatureLayer JcXzqJxLayer { get => _jcXzqJxLayer; }
- public IFeatureLayer GxXzqLayer { get => _gxXzqLayer; }
- public IFeatureLayer GxgcXzqLayer { get => _gxgcXzqLayer; }
- public IFeatureLayer GxXzqJxLayer { get => _gxXzqJxLayer; }
- #endregion
-
- #region 城镇村
- public IFeatureLayer JcCzcLayer { get => _jcCzcLayer; }
- public IFeatureLayer GxCzcLayer { get => _gxCzcLayer; }
- public IFeatureLayer GxgcCzcLayer { get => _gxgcCzcLayer; }
- #endregion
-
- #region 耕地等别
- public IFeatureLayer JcGddbLayer { get => _jcGddbLayer; }
- public IFeatureLayer GxGddbLayer { get => _gxGddbLayer; }
- #endregion
- public virtual void CreateNMK2(IDGParameter parm)
- {
- try
- {
- IFeatureLayer TempNMKLayer = null;
- GPParamClass gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = JcTbLayer;//基础地类图斑要素类
- gPParamClass.SecondFeatureLayer = GxTbLayer;//地类图斑更新要素类
- gPParamClass.OutFeatureClassPath = parm.PrjInfo.NMDatabase + "\\" + "DLTB_NMK";//要添加的要素类图层
- gPParamClass.IsGetOutPutFeature = true;//是否获取GP工具生成后的图层
- gPParamClass.GPType = EnumGPType.Erase;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempNMKLayer);//擦除/相减分析
- IFeatureClassAPI fcAPI = new FeatureClassAPI(TempNMKLayer.FeatureClass);
- fcAPI.AddField("XZQDM", esriFieldType.esriFieldTypeString, "行政区代码");
- fcAPI.AddField("XZQTZLX", esriFieldType.esriFieldTypeInteger, "行政区调整类型");
- //fcAPI.FcToFc(NMKLayer.FeatureClass, null, false);
- fcAPI = new FeatureClassAPI(GxTbLayer.FeatureClass);
- fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false);
-
- ITable nmkTable = TempNMKLayer.FeatureClass as ITable;
- //更新后年末库
- ICursor nmkCur = nmkTable.Update(null, true);
- IRow nmkRow = null;
- int bsmIdx = nmkTable.FindField("BSM");
- int zldwIdx = nmkTable.FindField("ZLDWDM");
- int xzqdmIdx = nmkTable.FindField("XZQDM");
- int XZQTZLXmIdx = nmkTable.FindField("XZQTZLX");
- int HDMCIdx = nmkTable.FindField("HDMC");
- while ((nmkRow = nmkCur.NextRow()) != null)
- {
- //string bsm = nmkRow.Value[bsmIdx].ToTrim();
- //if (hcbghbsm.Contains(bsm))
- //{
- // nmkRow.Value[XZQTZLXmIdx] = 2;
- //}
- //else if (msbghbsm.Contains(bsm))
- //{
- // nmkRow.Value[XZQTZLXmIdx] = 4;
- //}
- //else if (msbgqbsm.Contains(bsm) && !bghbsmDic.ContainsKey(bsm))
- //{
- // nmkRow.Value[XZQTZLXmIdx] = 4;
- //}
- //if (bhxxDic.ContainsKey(bsm))
- //{
- // for (int i = 0; i < nmkRow.Fields.FieldCount; i++)
- // {
- // IField field = nmkRow.Fields.Field[i];
- // string bghField = "BGH" + field.Name;
- // DataRow dr = bhxxDic[bsm];
- // if (!dr.Table.Columns.Contains(bghField))
- // bghField = "BGHTB" + field.Name;
- // if (dr.Table.Columns.Contains(bghField))
- // {
- // if (field.Type == esriFieldType.esriFieldTypeString)
- // {
- // nmkRow.Value[i] = msbghbsm.Contains(bsm) ? "" : dr[bghField];
- // }
- // else if (field.Type == esriFieldType.esriFieldTypeDouble)
- // {
- // nmkRow.Value[i] = msbghbsm.Contains(bsm) ? 0 : dr[bghField].ToDouble();
- // }
- // }
- // }
- //}
- if (zldwIdx != -1 && xzqdmIdx != -1)
- {
- string zldwdm = nmkRow.Value[zldwIdx].ToTrim();
- if (!string.IsNullOrWhiteSpace(zldwdm) && zldwdm.Length > 9)
- {
- nmkRow.Value[xzqdmIdx] = zldwdm.Substring(0, 9);
- }
- }
- if (HDMCIdx != -1)
- nmkRow.Value[HDMCIdx] = nmkRow.Value[HDMCIdx].ToString().ToTrim() == "" ? "" : nmkRow.Value[HDMCIdx].ToString().ToTrim();
- nmkCur.UpdateRow(nmkRow);
- }
- nmkCur.Flush();
- nmkTable.DeleteSearchedRows(new QueryFilterClass() { WhereClause = "XZQTZLX=4 or XZQTZLX=2" });
- _nmTbLayer = TempNMKLayer;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
-
- ///
- /// 生成年末库图层-GP创建年末库图层
- ///
- ///
- public virtual void CreateNMK3(IDGParameter parm)
- {
- IFeatureCursor _cursor = null;
- try
- {
- IFeatureLayer TempNMKLayer = null;
- GPParamClass gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = JcTbLayer;//基础地类图斑要素类
- //gPParamClass.SecondFeatureLayer = GxTbLayer;//地类图斑更新要素类
- gPParamClass.OutFeatureClassPath = parm.PrjInfo.NMDatabase;// + "\\" + "DLTB_NMK";//要添加的要素类图层
- gPParamClass.IsGetOutPutFeature = true;//是否获取GP工具生成后的图层
- gPParamClass.GPType = EnumGPType.FcToFc;
- gPParamClass.FcName = "DLTB_NMK";
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempNMKLayer);//擦除/相减分析
-
- _cursor = GxgcTBLayer.FeatureClass.Search(new QueryFilterClass() { SubFields = "BGQTBBSM" }, true);
- Dictionary DicJcBSMs = new Dictionary();
- IFeature f = null;
- int idx = GxgcTBLayer.FeatureClass.FindField("BGQTBBSM");
- if (idx == -1) return;
- while ((f = _cursor.NextFeature()) != null)
- {
- string jcbsm = f.Value[idx].ToTrim();
- if (!DicJcBSMs.ContainsKey(jcbsm))
- DicJcBSMs.Add(jcbsm, 0);
- }
- _cursor = TempNMKLayer.FeatureClass.Update(null, true);
- idx = TempNMKLayer.FeatureClass.FindField("BSM");
- if (idx == -1) return;
- while ((f = _cursor.NextFeature()) != null)
- {
- string bsm = f.Value[idx].ToTrim();
- if (DicJcBSMs.ContainsKey(bsm))
- {
- f.Value[idx] = "-1";
- _cursor.UpdateFeature(f);
- }
- }
- _cursor.Flush();
- (TempNMKLayer.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "BSM = '-1'" });
- IFeatureClassAPI fcAPI = new FeatureClassAPI(GxTbLayer.FeatureClass);
- fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false);
-
- fcAPI = new FeatureClassAPI(TempNMKLayer.FeatureClass);
- fcAPI.AddField("XZQDM", esriFieldType.esriFieldTypeString, "行政区代码");
- fcAPI.AddField("XZQTZLX", esriFieldType.esriFieldTypeInteger, "行政区调整类型");
- ////fcAPI.FcToFc(NMKLayer.FeatureClass, null, false);
- //fcAPI = new FeatureClassAPI(GxTbLayer.FeatureClass);
- //fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false);
-
- ITable nmkTable = TempNMKLayer.FeatureClass as ITable;
- //更新后年末库
- ICursor nmkCur = nmkTable.Update(null, true);
- IRow nmkRow = null;
- int bsmIdx = nmkTable.FindField("BSM");
- int zldwIdx = nmkTable.FindField("ZLDWDM");
- int xzqdmIdx = nmkTable.FindField("XZQDM");
- int XZQTZLXmIdx = nmkTable.FindField("XZQTZLX");
- int HDMCIdx = nmkTable.FindField("HDMC");
- while ((nmkRow = nmkCur.NextRow()) != null)
- {
- //string bsm = nmkRow.Value[bsmIdx].ToTrim();
- //if (hcbghbsm.Contains(bsm))
- //{
- // nmkRow.Value[XZQTZLXmIdx] = 2;
- //}
- //else if (msbghbsm.Contains(bsm))
- //{
- // nmkRow.Value[XZQTZLXmIdx] = 4;
- //}
- //else if (msbgqbsm.Contains(bsm) && !bghbsmDic.ContainsKey(bsm))
- //{
- // nmkRow.Value[XZQTZLXmIdx] = 4;
- //}
- //if (bhxxDic.ContainsKey(bsm))
- //{
- // for (int i = 0; i < nmkRow.Fields.FieldCount; i++)
- // {
- // IField field = nmkRow.Fields.Field[i];
- // string bghField = "BGH" + field.Name;
- // DataRow dr = bhxxDic[bsm];
- // if (!dr.Table.Columns.Contains(bghField))
- // bghField = "BGHTB" + field.Name;
- // if (dr.Table.Columns.Contains(bghField))
- // {
- // if (field.Type == esriFieldType.esriFieldTypeString)
- // {
- // nmkRow.Value[i] = msbghbsm.Contains(bsm) ? "" : dr[bghField];
- // }
- // else if (field.Type == esriFieldType.esriFieldTypeDouble)
- // {
- // nmkRow.Value[i] = msbghbsm.Contains(bsm) ? 0 : dr[bghField].ToDouble();
- // }
- // }
- // }
- //}
- if (zldwIdx != -1 && xzqdmIdx != -1)
- {
- string zldwdm = nmkRow.Value[zldwIdx].ToTrim();
- if (!string.IsNullOrWhiteSpace(zldwdm) && zldwdm.Length > 9)
- {
- nmkRow.Value[xzqdmIdx] = zldwdm.Substring(0, 9);
- }
- }
- if (HDMCIdx != -1)
- nmkRow.Value[HDMCIdx] = nmkRow.Value[HDMCIdx].ToString().ToTrim() == "" ? "" : nmkRow.Value[HDMCIdx].ToString().ToTrim();
- nmkCur.UpdateRow(nmkRow);
- }
- nmkCur.Flush();
- //nmkTable.DeleteSearchedRows(new QueryFilterClass() { WhereClause = "XZQTZLX=4 or XZQTZLX=2" });
- _nmTbLayer = TempNMKLayer;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
-
- ///
- /// 生成年末库数据(BUG:新增 年末库 图层)
- ///
- ///
- public virtual void CreateNMK(IDGParameter parm)
- {
- IFeatureCursor _cursor = null;
- try
- {
- //if (NmWsAPI.OpenFeatureClass("DLTB_NMK").FeatureClass is IFeatureClass ClassFC)
- // NmTbLayer = new FeatureLayer() { Name = ClassFC.AliasName, FeatureClass = ClassFC };
- if (NmTbLayer == null) return;
- (NmTbLayer.FeatureClass as ITable).DeleteSearchedRows(null);
- IFeatureClassAPI featureClassAPI = new FeatureClassAPI(JcTbLayer.FeatureClass);
- featureClassAPI.FcToFc(NmTbLayer.FeatureClass, new QueryFilterClass() { WhereClause = " (XZQTZLX <> '2' and XZQTZLX <> '4') or XZQTZLX Is NULL " }, false);
- _cursor = GxgcTBLayer.FeatureClass.Search(new QueryFilterClass() { SubFields = "BGQTBBSM" }, true);
- Dictionary DicJcBSMs = new Dictionary();
- IFeature f = null;
- int idx = GxgcTBLayer.FeatureClass.FindField("BGQTBBSM");
- if (idx == -1) return;
- while ((f = _cursor.NextFeature()) != null)
- {
- string jcbsm = f.Value[idx].ToTrim();
- if (!DicJcBSMs.ContainsKey(jcbsm))
- DicJcBSMs.Add(jcbsm, 0);
- }
- _cursor = NmTbLayer.FeatureClass.Update(null, true);
- idx = NmTbLayer.FeatureClass.FindField("BSM");
- if (idx == -1) return;
- while ((f = _cursor.NextFeature()) != null)
- {
- string bsm = f.Value[idx].ToTrim();
- if (DicJcBSMs.ContainsKey(bsm))
- {
- f.Value[idx] = "-1";
- _cursor.UpdateFeature(f);
- }
- }
- _cursor.Flush();
- (NmTbLayer.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "BSM = '-1'" });
- IFeatureClassAPI fcAPI = new FeatureClassAPI(GxTbLayer.FeatureClass);
- fcAPI.FcToFc(NmTbLayer.FeatureClass, null, false);
-
- ITable nmkTable = NmTbLayer.FeatureClass as ITable;
- //更新后年末库
- ICursor nmkCur = nmkTable.Update(null, true);
- IRow nmkRow = null;
- int bsmIdx = nmkTable.FindField("BSM");
- int zldwIdx = nmkTable.FindField("ZLDWDM");
- int xzqdmIdx = nmkTable.FindField("XZQDM");
- int XZQTZLXmIdx = nmkTable.FindField("XZQTZLX");
- int HDMCIdx = nmkTable.FindField("HDMC");
- while ((nmkRow = nmkCur.NextRow()) != null)
- {
- if (zldwIdx != -1 && xzqdmIdx != -1)
- {
- string zldwdm = nmkRow.Value[zldwIdx].ToTrim();
- if (!string.IsNullOrWhiteSpace(zldwdm) && zldwdm.Length > 9)
- {
- nmkRow.Value[xzqdmIdx] = zldwdm.Substring(0, 9);
- }
- }
- if (HDMCIdx != -1)
- nmkRow.Value[HDMCIdx] = nmkRow.Value[HDMCIdx].ToString().ToTrim() == "" ? "" : nmkRow.Value[HDMCIdx].ToString().ToTrim();
- nmkCur.UpdateRow(nmkRow);
- }
- nmkCur.Flush();
- }
- catch (Exception ex)
- {
- Console.WriteLine("Err:地类图斑数据提取-生成年末库数据异常!" + ex.Message);
- Console.WriteLine("Err:地类图斑数据提取-生成年末库数据异常!" + ex.StackTrace);
- throw ex;
- }
- finally
- {
- if (_cursor != null)
- Marshal.ReleaseComObject(_cursor);
- }
- }
-
- public virtual void CreateNMK(DBLayerSourceHelper pLayerSource)
- {
- IFeatureCursor _cursor = null;
- try
- {
- //GeoprocessorHelper gpHelper = new GeoprocessorHelper();
- //string path = Path.Combine(parm.PrjInfo.ProjDir, "NMDB" + ".gdb");
-
- //FileInfo fileInfo = new FileInfo(parm.PrjInfo.BGDatabase);
- //string path = Path.Combine(fileInfo.DirectoryName, "NMDB" + ".gdb");
- //if (JcTbLayer == null || GxTbLayer == null)
- // OpenDB(parm);
- IFeatureLayer TempNMKLayer = null;
- GPParamClass gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = pLayerSource.JcTbLayer;//基础地类图斑要素类
- //gPParamClass.SecondFeatureLayer = GxTbLayer;//地类图斑更新要素类
- gPParamClass.OutFeatureClassPath = pLayerSource.NmWsAPI.CurrentWorkspace.PathName;// + "\\" + "DLTB_NMK";//要添加的要素类图层
- gPParamClass.IsGetOutPutFeature = true;//是否获取GP工具生成后的图层
- gPParamClass.GPType = EnumGPType.FcToFc;
- gPParamClass.FcName = "DLTB_NMK";
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempNMKLayer);//擦除/相减分析
-
- _cursor = pLayerSource.GxgcTBLayer.FeatureClass.Search(new QueryFilterClass() { SubFields = "BGQTBBSM" }, true);
- Dictionary DicJcBSMs = new Dictionary();
- IFeature f = null;
- int idx = pLayerSource.GxgcTBLayer.FeatureClass.FindField("BGQTBBSM");
- if (idx == -1) return;
- while ((f = _cursor.NextFeature()) != null)
- {
- string jcbsm = f.Value[idx].ToTrim();
- if (!DicJcBSMs.ContainsKey(jcbsm))
- DicJcBSMs.Add(jcbsm, 0);
- }
- _cursor = TempNMKLayer.FeatureClass.Update(null, true);
- idx = TempNMKLayer.FeatureClass.FindField("BSM");
- if (idx == -1) return;
- while ((f = _cursor.NextFeature()) != null)
- {
- string bsm = f.Value[idx].ToTrim();
- if (DicJcBSMs.ContainsKey(bsm))
- {
- f.Value[idx] = "-1";
- _cursor.UpdateFeature(f);
- }
- }
- _cursor.Flush();
- (TempNMKLayer.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "BSM = '-1'" });
- IFeatureClassAPI fcAPI = new FeatureClassAPI(pLayerSource.GxTbLayer.FeatureClass);
- fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false);
-
- fcAPI = new FeatureClassAPI(TempNMKLayer.FeatureClass);
- fcAPI.AddField("XZQDM", esriFieldType.esriFieldTypeString, "行政区代码");
- fcAPI.AddField("XZQTZLX", esriFieldType.esriFieldTypeInteger, "行政区调整类型");
- ////fcAPI.FcToFc(NMKLayer.FeatureClass, null, false);
- //fcAPI = new FeatureClassAPI(pLayerSource.GxTbLayer.FeatureClass);
- //fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false);
-
- ITable nmkTable = TempNMKLayer.FeatureClass as ITable;
- //更新后年末库
- ICursor nmkCur = nmkTable.Update(null, true);
- IRow nmkRow = null;
- int bsmIdx = nmkTable.FindField("BSM");
- int zldwIdx = nmkTable.FindField("ZLDWDM");
- int xzqdmIdx = nmkTable.FindField("XZQDM");
- int XZQTZLXmIdx = nmkTable.FindField("XZQTZLX");
- int HDMCIdx = nmkTable.FindField("HDMC");
- while ((nmkRow = nmkCur.NextRow()) != null)
- {
- //string bsm = nmkRow.Value[bsmIdx].ToTrim();
- //if (hcbghbsm.Contains(bsm))
- //{
- // nmkRow.Value[XZQTZLXmIdx] = 2;
- //}
- //else if (msbghbsm.Contains(bsm))
- //{
- // nmkRow.Value[XZQTZLXmIdx] = 4;
- //}
- //else if (msbgqbsm.Contains(bsm) && !bghbsmDic.ContainsKey(bsm))
- //{
- // nmkRow.Value[XZQTZLXmIdx] = 4;
- //}
- //if (bhxxDic.ContainsKey(bsm))
- //{
- // for (int i = 0; i < nmkRow.Fields.FieldCount; i++)
- // {
- // IField field = nmkRow.Fields.Field[i];
- // string bghField = "BGH" + field.Name;
- // DataRow dr = bhxxDic[bsm];
- // if (!dr.Table.Columns.Contains(bghField))
- // bghField = "BGHTB" + field.Name;
- // if (dr.Table.Columns.Contains(bghField))
- // {
- // if (field.Type == esriFieldType.esriFieldTypeString)
- // {
- // nmkRow.Value[i] = msbghbsm.Contains(bsm) ? "" : dr[bghField];
- // }
- // else if (field.Type == esriFieldType.esriFieldTypeDouble)
- // {
- // nmkRow.Value[i] = msbghbsm.Contains(bsm) ? 0 : dr[bghField].ToDouble();
- // }
- // }
- // }
- //}
- if (zldwIdx != -1 && xzqdmIdx != -1)
- {
- string zldwdm = nmkRow.Value[zldwIdx].ToTrim();
- if (!string.IsNullOrWhiteSpace(zldwdm) && zldwdm.Length > 9)
- {
- nmkRow.Value[xzqdmIdx] = zldwdm.Substring(0, 9);
- }
- }
- if (HDMCIdx != -1)
- nmkRow.Value[HDMCIdx] = nmkRow.Value[HDMCIdx].ToString().ToTrim() == "" ? "" : nmkRow.Value[HDMCIdx].ToString().ToTrim();
- nmkCur.UpdateRow(nmkRow);
- }
- nmkCur.Flush();
- //nmkTable.DeleteSearchedRows(new QueryFilterClass() { WhereClause = "XZQTZLX=4 or XZQTZLX=2" });
- _nmTbLayer = TempNMKLayer;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
-
- internal IFeatureLayer OpenLayer(LayerCfg pLayerInfo)
- {
- try
- {
- if (pLayerInfo == null)
- return null;
- if (string.IsNullOrWhiteSpace(pLayerInfo.FcPath) || string.IsNullOrWhiteSpace(pLayerInfo.FcName))
- return null;
- if (!File.Exists(pLayerInfo.FcPath) && !Directory.Exists(pLayerInfo.FcPath))
- return null;
- FileInfo fInfo = new FileInfo(pLayerInfo.FcPath);
- WorkspaceTypeEnum wsType = WorkspaceTypeEnum.GDBFile;
- if (fInfo.FullName.EndsWith(".gdb"))
- wsType = WorkspaceTypeEnum.GDBFile;
- else if (fInfo.FullName.EndsWith(".mdb"))
- wsType = WorkspaceTypeEnum.MDBFile;
- else
- wsType = WorkspaceTypeEnum.ShapeFile;
- if (DicWsAPI == null)
- DicWsAPI = new Dictionary();
- if (!DicWsAPI.ContainsKey(fInfo.FullName))
- {
- IWorkspaceAPI wsAPI = null;
- if (wsType == WorkspaceTypeEnum.GDBFile)
- wsAPI = new WorkspaceAPI(fInfo.FullName, wsType, true);
- else
- wsAPI = new WorkspaceAPI(fInfo.FullName, wsType);
- DicWsAPI.Add(fInfo.FullName, wsAPI);
- }
- IFeatureClassAPI fcAPI = DicWsAPI[fInfo.FullName].OpenFeatureClass(pLayerInfo.FcName);
- return new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName };
- }
- catch (Exception ex)
- {
- LogAPI.Debug(ex.Message + ex.StackTrace);
- throw ex;
- }
-
- }
- internal IFeatureLayer OpenLayer(IWorkspaceAPI pWsAPI, string pLayerName)
- {
- try
- {
- if (string.IsNullOrWhiteSpace(pLayerName))
- return null;
- if (pWsAPI != null && pWsAPI.CurrentWorkspace != null)
- {
- IFeatureClassAPI fcAPI = pWsAPI.OpenFeatureClass(pLayerName);
- return new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName };
- }
- return null;
- }
- catch (Exception)
- {
- Console.WriteLine(string.Format("Err:{0}图层获取失败", pLayerName));
- return null;
- }
- }
-
- public string GetTime(DateTime timeA)
- {
- //timeA 表示需要计算
- DateTime timeB = DateTime.Now; //获取当前时间
- TimeSpan ts = timeB - timeA; //计算时间差
- //string time = ts.TotalSeconds.ToString(); //将时间差转换为秒
-
- string str = "";
- if (ts.Hours > 0)
- {
- str = String.Format("{0:00}", ts.Hours) + ":" + String.Format("{0:00}", ts.Minutes) + ":" + String.Format("{0:00}", ts.Seconds);
- }
- if (ts.Hours == 0 && ts.Minutes > 0)
- {
- str = "00:" + String.Format("{0:00}", ts.Minutes) + ":" + String.Format("{0:00}", ts.Seconds);
- }
- if (ts.Hours == 0 && ts.Minutes == 0)
- {
- str = "00:00:" + String.Format("{0:00}", ts.Seconds);
- }
- return str;
- }
-
- private bool disposed = false;
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (!disposed)
- {
- if (disposing)
- {
- // 释放其他托管资源(如数据库连接等)
- }
- // 释放非托管资源
- #region 释放数据库链接
- ZlWsAPI?.CloseWorkspace();
- JCWsAPI?.CloseWorkspace();
- NmWsAPI?.CloseWorkspace();
- #endregion
-
- if (_jcCzcLayer != null)
- Marshal.ReleaseComObject(_jcCzcLayer);
- _jcCzcLayer = null;
-
- disposed = true;
- }
- }
- }
-
- public class DBLayerSourceHelper
- {
- public Dictionary DicWsAPI { get; set; }
- public IWorkspaceAPI BgWsAPI { get; set; }
- public IWorkspaceAPI ZlWsAPI { get; set; }
- public IWorkspaceAPI NmWsAPI { get; set; }
- //public IFeatureLayer JCLayer { get => jCLayer; set => jCLayer = value; }
- //public IFeatureLayer GXLayer { get => gXLayer; set => gXLayer = value; }
- public IFeatureLayer NmTbLayer { get; set; }
- #region 地类图斑
- public IFeatureLayer JcTbLayer { get; set; }
- public IFeatureLayer JcPdtLayer { get; set; }
- public IFeatureLayer GxgcTBLayer { get; set; }
- public IFeatureLayer GxTbLayer { get; set; }
- public IFeatureLayer GxPdtLayer { get; set; }
- public IFeatureLayer BgTbLayer { get; set; }
- #endregion
-
- #region 村级调查区
- public IFeatureLayer JcCjdcqLayer { get; set; }
- public IFeatureLayer JcCjdcqJxLayer { get; set; }
- public IFeatureLayer GxCjdcqLayer { get; set; }
- public IFeatureLayer GxgcCjdcqLayer { get; set; }
- public IFeatureLayer GxCjdcqJxLayer { get; set; }
- #endregion
-
- #region 行政区
- public IFeatureLayer JcXzqLayer { get; set; }
- public IFeatureLayer JcXzqJxLayer { get; set; }
- public IFeatureLayer GxXzqLayer { get; set; }
- public IFeatureLayer GxgcXzqLayer { get; set; }
- public IFeatureLayer GxXzqJxLayer { get; set; }
- #endregion
-
- #region 城镇村
- public IFeatureLayer JcCzcLayer { get; set; }
- public IFeatureLayer GxCzcLayer { get; set; }
- public IFeatureLayer GxgcCzcLayer { get; set; }
- #endregion
-
- #region 耕地等别
- public IFeatureLayer JcGddbLayer { get; set; }
- public IFeatureLayer GxGddbLayer { get; set; }
- #endregion
-
- public IFeatureLayer OpenLayer(LayerCfg pLayerInfo)
- {
- if (pLayerInfo == null)
- return null;
- if (string.IsNullOrWhiteSpace(pLayerInfo.FcPath) || string.IsNullOrWhiteSpace(pLayerInfo.FcName))
- return null;
- if (!File.Exists(pLayerInfo.FcPath) && !Directory.Exists(pLayerInfo.FcPath))
- return null;
- FileInfo fInfo = new FileInfo(pLayerInfo.FcPath);
- WorkspaceTypeEnum wsType = WorkspaceTypeEnum.GDBFile;
- if (fInfo.FullName.EndsWith(".gdb"))
- wsType = WorkspaceTypeEnum.GDBFile;
- else if (fInfo.FullName.EndsWith(".mdb"))
- wsType = WorkspaceTypeEnum.MDBFile;
- else
- wsType = WorkspaceTypeEnum.ShapeFile;
- if (DicWsAPI == null)
- DicWsAPI = new Dictionary();
- if (!DicWsAPI.ContainsKey(fInfo.FullName))
- {
- IWorkspaceAPI wsAPI = new WorkspaceAPI(fInfo.FullName, wsType);
- DicWsAPI.Add(fInfo.FullName, wsAPI);
- }
- IFeatureClassAPI fcAPI = DicWsAPI[fInfo.FullName].OpenFeatureClass(pLayerInfo.FcName);
- return new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName };
- }
- public IFeatureLayer OpenLayer(IWorkspaceAPI pWsAPI, string pLayerName)
- {
- try
- {
- if (string.IsNullOrWhiteSpace(pLayerName))
- return null;
- if (pWsAPI != null && pWsAPI.CurrentWorkspace != null)
- {
- IFeatureClassAPI fcAPI = pWsAPI.OpenFeatureClass(pLayerName);
- return new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName };
- }
- return null;
- }
- catch (Exception ex)
- {
- Console.WriteLine(string.Format("Err:{0}图层获取失败", pLayerName));
- return null;
- }
- }
- }
-}
diff --git a/KGIS_DLTB/Helper/CZCDYDHelper.cs b/KGIS_DLTB/Helper/CZCDYDHelper.cs
deleted file mode 100644
index a699be1..0000000
--- a/KGIS_DLTB/Helper/CZCDYDHelper.cs
+++ /dev/null
@@ -1,1677 +0,0 @@
-using ESRI.ArcGIS.Carto;
-using ESRI.ArcGIS.DataSourcesGDB;
-using ESRI.ArcGIS.Geodatabase;
-using ESRI.ArcGIS.Geometry;
-using IDEParameter;
-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.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 KGIS.Framework.Utils.Utility;
-using Kingo.PluginServiceInterface;
-using Kingo.PluginServiceInterface.Model;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices;
-
-namespace IDGForNDBG
-{
- public class CZCDYDHelper : BaseIDG
- {
- //private IFeatureLayer _DLTBFc = null;
- public string IDataChangeName { get => "CZCDYDHelper"; }
- private string TempGDBPath = string.Empty;
- private string TempDBPath = string.Empty;
- #region ExecuteDataChange
- public void Execute(IDGParameter3 pParm)
- {
- try
- {
-
- ThreadManager.Instance.QueueUserWorkItem(new System.Threading.WaitCallback(ExtractExe), pParm);
-
- //IFeatureClass _CZCFc = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("城镇村等用地").FeatureClass;
- //Implement(_CZCFc, true, false);
- //ExtractExe(pParm, bgParm);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
-
- public void OpenDB(IDGParameter3 parm, ref CZC_Param pCzcParm)
- {
- IFeatureClassAPI BgTBFcAPI = null;
- IFeatureClassAPI JcTBFcAPI = null;
- IFeatureClassAPI JcCZCFcAPI = null;
- IFeatureClassAPI GxTBFcAPI = null;
- IFeatureClassAPI GxGcCZCFcAPI = null;
- IFeatureClassAPI GxCZCFcAPI = null;
- GPParamClass paramClass = null;// new GPParamClass();
- //GeoprocessorHelper gpHelper = new GeoprocessorHelper();
- try
- {
- BgWsAPI = new WorkspaceAPI(parm.BgDbPath, WorkspaceTypeEnum.GDBFile);
- if (BgWsAPI.CurrentWorkspace == null)
- {
- Console.WriteLine("打开变更数据库失败!");
- return;
- }
- JcWsAPI = new WorkspaceAPI(parm.JcDbPath, WorkspaceTypeEnum.GDBFile);
- if (JcWsAPI.CurrentWorkspace == null)
- {
- Console.WriteLine("打开基础数据库失败!");
- return;
- }
- ZlWsAPI = new WorkspaceAPI(parm.ZLDbPath, WorkspaceTypeEnum.GDBFile);
- if (ZlWsAPI.CurrentWorkspace == null)
- {
- Console.WriteLine("打开增量数据库失败!");
- return;
- }
- NmWsAPI = new WorkspaceAPI(parm.NmDbPath, WorkspaceTypeEnum.GDBFile);
-
- BgTBFcAPI = BgWsAPI.OpenFeatureClass("DLTBBG");
- JcTBFcAPI = JcWsAPI.OpenFeatureClass("DLTB");
- JcCZCFcAPI = JcWsAPI.OpenFeatureClass("CZCDYD");
- GxTBFcAPI = ZlWsAPI.OpenFeatureClass("DLTBGX");
- GxCZCFcAPI = ZlWsAPI.OpenFeatureClass("CZCDYDGX");
- GxGcCZCFcAPI = ZlWsAPI.OpenFeatureClass("CZCDYDGXGC");
-
- IFeatureLayer pJCTBLayer = null;
- if (JcTBFcAPI.FeatureClass != null)
- {
- //paramClass = new GPParamClass();
- //paramClass.FirstFeatureClass = JcTBFcAPI.FeatureClass;
- //paramClass.OutFeatureClassPath = "DLTB";
- //paramClass.IsGetOutPutFeature = true;
- //gpHelper.MakeFeatureLayer(paramClass, ref pJCTBLayer);
- IFeatureLayer pFeatureLayer = new FeatureLayerClass();
- pFeatureLayer.FeatureClass = JcTBFcAPI.FeatureClass;
- pFeatureLayer.Name = JcTBFcAPI.FeatureClass.AliasName;
- pCzcParm.JCTBLayer = pFeatureLayer;
- }
- IFeatureLayer pJCCZCLayer = null;
- if (JcCZCFcAPI.FeatureClass != null)
- {
- //paramClass = new GPParamClass();
- //paramClass.FirstFeatureClass = JcCZCFcAPI.FeatureClass;
- //paramClass.OutFeatureClassPath = "CZCDYD";
- //paramClass.IsGetOutPutFeature = true;
- //gpHelper.MakeFeatureLayer(paramClass, ref pJCCZCLayer);
-
- IFeatureLayer pFeatureLayer = new FeatureLayerClass();
- pFeatureLayer.FeatureClass = JcCZCFcAPI.FeatureClass;
- pFeatureLayer.Name = JcCZCFcAPI.FeatureClass.AliasName;
- pCzcParm.JCCZCLayer = pFeatureLayer;
- }
- IFeatureLayer pGXTBLayer = null;
- if (GxTBFcAPI.FeatureClass != null)
- {
- //paramClass = new GPParamClass();
- //paramClass.FirstFeatureClass = GxTBFcAPI.FeatureClass;
- //paramClass.OutFeatureClassPath = "DLTBGX";
- //paramClass.IsGetOutPutFeature = true;
- //gpHelper.MakeFeatureLayer(paramClass, ref pGXTBLayer);
-
- IFeatureLayer pFeatureLayer = new FeatureLayerClass();
- pFeatureLayer.FeatureClass = GxTBFcAPI.FeatureClass;
- pFeatureLayer.Name = GxTBFcAPI.FeatureClass.AliasName;
- pCzcParm.GXTBLayer = pFeatureLayer;
- }
- IFeatureLayer pGXCZCLayer = null;
- if (GxCZCFcAPI.FeatureClass != null)
- {
- //paramClass = new GPParamClass();
- //paramClass.FirstFeatureClass = GxCZCFcAPI.FeatureClass;
- //paramClass.OutFeatureClassPath = "CZCDYDGX";
- //paramClass.IsGetOutPutFeature = true;
- //gpHelper.MakeFeatureLayer(paramClass, ref pGXCZCLayer);
-
- IFeatureLayer pFeatureLayer = new FeatureLayerClass();
- pFeatureLayer.FeatureClass = GxCZCFcAPI.FeatureClass;
- pFeatureLayer.Name = GxCZCFcAPI.FeatureClass.AliasName;
- pCzcParm.GXCZCLayer = pFeatureLayer;
- }
- IFeatureLayer pGXGCCZCLayer = null;
- if (GxGcCZCFcAPI.FeatureClass != null)
- {
- //paramClass = new GPParamClass();
- //paramClass.FirstFeatureClass = GxGcCZCFcAPI.FeatureClass;
- //paramClass.OutFeatureClassPath = "CZCDYDGXGC";
- //paramClass.IsGetOutPutFeature = true;
- //gpHelper.MakeFeatureLayer(paramClass, ref pGXGCCZCLayer);
-
- IFeatureLayer pFeatureLayer = new FeatureLayerClass();
- pFeatureLayer.FeatureClass = GxGcCZCFcAPI.FeatureClass;
- pFeatureLayer.Name = GxGcCZCFcAPI.FeatureClass.AliasName;
- pCzcParm.GXGCCZCLayer = pFeatureLayer;
- }
- IFeatureLayer pBGTBLayer = null;
- if (BgTBFcAPI.FeatureClass != null)
- {
- //paramClass = new GPParamClass();
- //paramClass.FirstFeatureClass = BgTBFcAPI.FeatureClass;
- //paramClass.OutFeatureClassPath = "DLTBBG";
- //paramClass.IsGetOutPutFeature = true;
- //gpHelper.MakeFeatureLayer(paramClass, ref pBGTBLayer);
-
- IFeatureLayer pFeatureLayer = new FeatureLayerClass();
- pFeatureLayer.FeatureClass = BgTBFcAPI.FeatureClass;
- pFeatureLayer.Name = BgTBFcAPI.FeatureClass.AliasName;
- pCzcParm.BGTBLayer = pFeatureLayer;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
-
-
-
- private void ExtractExe(object parm)
- {
- IFeatureLayer jc_czcLayer = null;
- IFeatureLayer dltbgxLayer = null;
- IFeatureLayer dltbhrLayer = null;
- IFeatureLayer jcdltbLayer = null;
- IFeatureLayer dltbTempNMKLayer = null;
- IWorkspaceAPI Tempworkspace = null;
- IWorkspaceAPI Schemeworkspace = null;
- IFeatureClassAPI dltbFeatureClassAPI = null;
- IFeatureClassAPI czcdydFeatureClassAPI = null;
- IFeatureCursor pFeatureCursor = null;
- IFeatureCursor pInsertCursor = null;
- IFeatureClassAPI LSczcdydFeatureclassAPI = null;
- //IFeatureClassAPI pFeatureClass_4 = null;
- IFeatureClassAPI CZCDLTBFeatureClass = null;
- IWorkspaceFactory outputWorkspaceFactory = null;
- IWorkspaceFactory pOutWorkFactory = null;
- string TempfilePath = string.Empty;
- try
- {
- IDGParameter3 pParm = parm as IDGParameter3;
- CZC_Param bgParm = new CZC_Param();
- OpenDB(pParm, ref bgParm);
- string TempDir = CreateTempDB("CZC");
- TempGDBPath = System.IO.Path.Combine(TempDir, "TempGDB.gdb");
- TempDBPath = TempDir + @"\Temp" + ".sqlite";
-
- IRDBHelper rdbHelper = null;
- List qsDic = null;
- try
- {
-
- rdbHelper = RDBFactory.CreateDbHelper(System.IO.Path.Combine(pParm.ProjDir, "BGTJ.sqlite"), DatabaseType.SQLite);
- DataTable dicDt = rdbHelper.ExecuteDatatable("Dic", string.Format("SELECT * from Sys_Dicdetail where OWNERDIC=1"), true);
-
- //jccjdcqLayer = Parm.JC_CJDCQLay as IFeatureLayer;
- qsDic = KGIS.Framework.Utils.Utility.TBToList.ToList(dicDt);// Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM);
-
- }
- catch (Exception ex)
- {
- Console.WriteLine("获取权属字典失败!" + ex.Message);
- LogAPI.Debug(ex);
- }
- finally
- {
- if (rdbHelper != null)
- rdbHelper.DisConnect();
- }
- if (qsDic == null)
- {
- LogAPI.Debug($"权属单位代码表获取失败。");
- return;
- }
- //string filePath = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjDBPath();
- //string schemeDBPath = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetSchemeDBPath();
- //ProjGDBwkspace = new WorkspaceAPI(filePath, WorkspaceTypeEnum.GDBFile);
- //Schemeworkspace = new WorkspaceAPI(schemeDBPath, WorkspaceTypeEnum.GDBFile);
-
- #region 临时数据
- Console.WriteLine("正在提取城镇村等用地数据......");
- //TempfilePath = GetTempPath();//临时数据存放路径
- TempfilePath = TempGDBPath;
- if (string.IsNullOrEmpty(TempfilePath))
- {
- LogAPI.Debug($"获取到城镇村等用地数据模板失败。");
- return;
- }
-
- #region 地类图斑
- IFeatureClass bgtbFc = bgParm.BGTBLayer.FeatureClass;// MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG");
- dltbgxLayer = bgParm.GXTBLayer;// MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBGX");
- //dltbhrLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBHR");
- jcdltbLayer = bgParm.JCTBLayer;// MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑");
- jc_czcLayer = bgParm.JCCZCLayer;// MapsManager.Instance.MapService.GetFeatureLayerByLayerName("城镇村等用地");
- FeatureClass featureClass = jc_czcLayer.FeatureClass as FeatureClass;
- if (jc_czcLayer.FeatureClass.FeatureCount(null) == 0)
- {
- Console.WriteLine("基础城镇村等用地图层未找到数据,请确认基础城镇村数据是否导入!");
- return;
- }
-
- IFeatureLayer tempJCCZCLayer = null;
- //设置基础地类图斑选中
- GPParamClass gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = jc_czcLayer;
- gPParamClass.SecondFeatureLayer = dltbgxLayer;
- //gPParamClass.Tolerance = "-0.0001655555";
- //GeoprocessorHelper gpHelper = new GeoprocessorHelper();
- gPParamClass.GPType = EnumGPType.SelectLayerByLocation;
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.Overlap_type = "INTERSECT";
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref tempJCCZCLayer);
-
- IFeatureLayer _TempLayer = null;
- //选中的基础地类图斑导出至临时gdb
- gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer= tempJCCZCLayer;
- gPParamClass.OutFeatureClassPath = TempfilePath;
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.GPType = EnumGPType.FcToFc;
- gPParamClass.FcName = "JC_CZCDYD";
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref _TempLayer);
- try
- {
- ESRI.ArcGIS.Carto.IFeatureSelection selection = jc_czcLayer as IFeatureSelection;
- selection.Clear();
- }
- catch (Exception ex)
- {
- LogAPI.Debug(ex.Message);
- }
- tempJCCZCLayer = _TempLayer;
- IFeatureLayer TempJCDLTB = null;// GeoDBAPI.CreateFeatureLayerInmemeory("CZC203", "城镇村203范围", (jcdltbLayer.FeatureClass as IGeoDataset).SpatialReference, jcdltbLayer.FeatureClass.ShapeType, jcdltbLayer.FeatureClass.Fields);
-
- gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = jcdltbLayer;
- gPParamClass.SecondFeatureLayer = tempJCCZCLayer;
- gPParamClass.OutFeatureClassPath = TempfilePath + "\\" + "TempJCDLTB20X";
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.GPType = EnumGPType.Intersect;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref dltbTempNMKLayer);
- IWorkspace tempWs = (dltbTempNMKLayer.FeatureClass as FeatureClass).Workspace;
-
- tempWs.ExecuteSQL("Update TempJCDLTB20X set CZCSXM='201' where CZCLX='201'");
- tempWs.ExecuteSQL("Update TempJCDLTB20X set CZCSXM='201A' where CZCLX='201A'");
- tempWs.ExecuteSQL("Update TempJCDLTB20X set CZCSXM='202' where CZCLX='202'");
- tempWs.ExecuteSQL("Update TempJCDLTB20X set CZCSXM='202A' where CZCLX='202A'");
- tempWs.ExecuteSQL("Update TempJCDLTB20X set CZCSXM='203' where CZCLX='203'");
- tempWs.ExecuteSQL("Update TempJCDLTB20X set CZCSXM='203A' where CZCLX='203A'");
- tempWs.ExecuteSQL("Update TempJCDLTB20X set CZCSXM='204' where CZCLX='204'");
- tempWs.ExecuteSQL("Update TempJCDLTB20X set CZCSXM='205' where CZCLX='205'");
-
- gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = dltbTempNMKLayer;
- gPParamClass.OutFeatureClassPath = TempfilePath;
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.GPType = EnumGPType.FcToFc;
- gPParamClass.FcName = "CZC203";
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempJCDLTB);
-
- //IFeatureClassAPI dltb20xAPI = new FeatureClassAPI(dltbTempNMKLayer.FeatureClass);
- //dltb20xAPI.FcToFc(TempJCDLTB.FeatureClass, null, false);
-
- IFeatureLayer msTBLayer = GeoDBAPI.CreateFeatureLayerInmemeory("MSDLTB", "灭失图斑", (bgtbFc as IGeoDataset).SpatialReference, bgtbFc.ShapeType, bgtbFc.Fields);
- IQueryFilter filter2 = new QueryFilterClass();
- filter2.WhereClause = " XZQTZLX='2' or XZQTZLX='4'";
- (msTBLayer.FeatureClass as ITable).DeleteSearchedRows(null);
- InsertDataToMemeoryLayer(bgtbFc, msTBLayer.FeatureClass, filter2);
-
- IFeatureLayer pjbntFeatureLayer = null;
- gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = TempJCDLTB;
- gPParamClass.SecondFeatureLayer = msTBLayer;
- gPParamClass.OutFeatureClassPath = TempfilePath + "\\" + "TempDLTBNM";
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.GPType = EnumGPType.Erase;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref pjbntFeatureLayer);
-
- IFeatureLayer TempDLTB_MToS = null;
- gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = pjbntFeatureLayer;
- gPParamClass.OutFeatureClassPath = TempfilePath + "\\" + "TempDLTBNM_MToS";
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.GPType = EnumGPType.MultipartToSinglePath;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempDLTB_MToS);
-
- gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = TempDLTB_MToS;
- gPParamClass.SecondFeatureLayer = dltbgxLayer;
- gPParamClass.OutFeatureClassPath = TempfilePath + "\\" + "DLTBGXGC";
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.GPType = EnumGPType.Erase;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref dltbTempNMKLayer);
-
-
- IFeatureClassAPI fcAPI = new FeatureClassAPI(dltbgxLayer.FeatureClass);
- fcAPI.FcToFc(dltbTempNMKLayer.FeatureClass, null, false);
- //fcAPI = new FeatureClassAPI(dltbhrLayer.FeatureClass);
- //fcAPI.FcToFc(dltbTempNMKLayer.FeatureClass, null, false);
- fcAPI = new FeatureClassAPI(dltbTempNMKLayer.FeatureClass);
-
- //string dbPath = $"{pParm.ProjDir}\\BGTJ.sqlite";
- rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + TempDBPath, DatabaseType.SQLite);
-
-
- ITable nmkTable = dltbTempNMKLayer.FeatureClass as ITable;
- IQueryFilter filter = new QueryFilterClass();
- //foreach (string bsm in hcbghbsmList)
- //{
- // filter.WhereClause = string.Format("BSM ='{0}' ", bsm);
- // nmkTable.DeleteSearchedRows(filter);
- //}
-
- ICursor nmkCur = nmkTable.Update(null, true);
- IRow nmkRow = null;
- int bsmIdx = nmkTable.FindField("BSM");
- int zldwIdx = nmkTable.FindField("ZLDWDM");
- int zldwmcIdx = nmkTable.FindField("ZLDWMC");
- int sjnfIdx = nmkTable.FindField("SJNF");//数据年份
- int num1 = 0;
- while ((nmkRow = nmkCur.NextRow()) != null)
- {
- num1++;
- string bsm = nmkRow.Value[bsmIdx].ToTrim();
- //if (zlbgList.ContainsKey(bsm))
- //{
- // DataRow dr = zlbgList[bsm];
- // nmkRow.Value[zldwIdx] = dr["BGHZLDWDM"];
- // nmkRow.Value[zldwmcIdx] = dr["BGHZLDWMC"];
- //}
- //else
- //if (bhxxDic.ContainsKey(bsm))
- //{
- // for (int i = 0; i < nmkRow.Fields.FieldCount; i++)
- // {
- // IField field = nmkRow.Fields.Field[i];
- // string bghField = "BGH" + field.Name;
- // DataRow dr = bhxxDic[bsm];
- // if (!dr.Table.Columns.Contains(bghField))
- // bghField = "BGHTB" + field.Name;
- // if (dr.Table.Columns.Contains(bghField))
- // {
- // if (field.Type == esriFieldType.esriFieldTypeString)
- // nmkRow.Value[i] = dr[bghField];
- // else if (field.Type == esriFieldType.esriFieldTypeDouble)
- // nmkRow.Value[i] = dr[bghField].ToDouble();
- // }
- // }
- //}
-
- if (sjnfIdx != -1)
- {
- nmkRow.Value[sjnfIdx] = "2020";
- }
- nmkCur.UpdateRow(nmkRow);
-
- if (num1 % 1000 == 0)
- {
- nmkCur.Flush();
- }
- }
- nmkCur.Flush();
- #endregion
-
-
- IWorkspaceFactory TempWorkspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass();
- Tempworkspace = new WorkspaceAPI(TempWorkspaceFactory.OpenFromFile(TempfilePath, 0));
- dltbFeatureClassAPI = Tempworkspace.OpenFeatureClass("DLTBGXGC");
- #endregion
-
- czcdydFeatureClassAPI = new FeatureClassAPI(bgParm.GXCZCLayer.FeatureClass);// Schemeworkspace.OpenFeatureClass("CZCDYDGX");
- if (dltbFeatureClassAPI.FeatureClass.FeatureCount(null) <= 0)
- {
- return;
- }
- if (Tempworkspace.ExistFeatureClass("LSczcdyd"))
- {
- Tempworkspace.DeleteFeatureClass("LSczcdyd");
- }
- // 创建临时层
- LSczcdydFeatureclassAPI = Tempworkspace.CreateFeatureClass("LSczcdyd", (czcdydFeatureClassAPI.FeatureClass as IGeoDataset).SpatialReference, null);
- LSczcdydFeatureclassAPI.AddField("CZCLX", esriFieldType.esriFieldTypeString, "CZCLX");
- LSczcdydFeatureclassAPI.AddField("CZCDM", esriFieldType.esriFieldTypeString, "CZCDM");
- LSczcdydFeatureclassAPI.AddField("CZCMC", esriFieldType.esriFieldTypeString, "CZCMC");
- LSczcdydFeatureclassAPI.AddField("ZLDWDM", esriFieldType.esriFieldTypeString, "ZLDWDM");
- LSczcdydFeatureclassAPI.AddField("ZLDWMC", esriFieldType.esriFieldTypeString, "ZLDWMC");
- if (czcdydFeatureClassAPI == null || czcdydFeatureClassAPI.FeatureClass == null)
- {
- Console.WriteLine("当前工程数据库未找到城镇村等用地(CZCDYDGX)图层!");
- return;
- }
- int czcsxmIndex = dltbFeatureClassAPI.FeatureClass.Fields.FindField("CZCSXM");
- int czclxIndex = czcdydFeatureClassAPI.FeatureClass.Fields.FindField("CZCLX");
- int LSczclxIndex = LSczcdydFeatureclassAPI.FeatureClass.Fields.FindField("CZCLX");
- IQueryFilter queryFilter = new QueryFilter()
- {
- WhereClause = "CZCSXM IN('201','202','203','204','205','201A','202A','203A')"
- };
- int count = dltbFeatureClassAPI.FeatureClass.FeatureCount(queryFilter);
- if (czcdydFeatureClassAPI.FeatureClass.FeatureCount(null) > 0)
- {
- ITable pTable = czcdydFeatureClassAPI.FeatureClass as ITable;
- if (pTable != null)
- {
- pTable.DeleteSearchedRows(null);
- }
- else
- {
- Console.WriteLine("城镇村等用地数据清除失败!");
- return;
- }
- }
- pFeatureCursor = dltbFeatureClassAPI.FeatureClass.Search(queryFilter, false);
- pInsertCursor = LSczcdydFeatureclassAPI.FeatureClass.Insert(true);
-
- IFeatureBuffer featureAdd = LSczcdydFeatureclassAPI.FeatureClass.CreateFeatureBuffer();
- IFeature pFeature = null;
- int num = 0;
- int zldwdm = dltbFeatureClassAPI.FeatureClass.Fields.FindField("ZLDWDM");
- int zldwmc = dltbFeatureClassAPI.FeatureClass.Fields.FindField("ZLDWMC");
- int lszldwdm = LSczcdydFeatureclassAPI.FeatureClass.Fields.FindField("ZLDWDM");
- int lszldwmc = LSczcdydFeatureclassAPI.FeatureClass.Fields.FindField("ZLDWMC");
- while ((pFeature = pFeatureCursor.NextFeature()) != null)
- {
- featureAdd.Shape = pFeature.Shape;
- if (LSczclxIndex > -1)
- {
- featureAdd.set_Value(LSczclxIndex, pFeature.get_Value(czcsxmIndex));
- }
- if (lszldwdm != -1)
- {
- featureAdd.set_Value(lszldwdm, pFeature.get_Value(zldwdm));
- }
- if (lszldwmc != -1)
- {
- featureAdd.set_Value(lszldwmc, pFeature.get_Value(zldwmc));
- }
- pInsertCursor.InsertFeature(featureAdd);
- }
- pInsertCursor.Flush();
- Console.WriteLine("正在对城镇村等用地更新进行赋值......");
- pOutWorkFactory = new SqlWorkspaceFactoryClass();
- IWorkspace pOutWork = pOutWorkFactory.OpenFromFile(TempDBPath, 0);
- //IFeatureWorkspace SchemeWork = GetGdbWorkspace(schemeDBPath);
- IFeatureWorkspace TempWork2 = GetGdbWorkspace(TempfilePath);
- rdbHelper.ExecuteSQL(" drop table LSczcdyd ");
- TableToTable(TempWork2, pOutWork, "LSczcdyd");
-
- string updateSQL = string.Format("update {0} set CZCDM = substr(ZLDWDM,1,6) || '0000000000000' where CZCLX in ('201','201A')", "LSczcdyd");
- rdbHelper.ExecuteSQL(updateSQL);
- updateSQL = string.Format("update {0} set CZCDM = substr(ZLDWDM,1,9) || '0000000000' where CZCLX in ('202','202A')", "LSczcdyd");
- rdbHelper.ExecuteSQL(updateSQL);
- updateSQL = string.Format("update {0} set CZCDM = [ZLDWDM],CZCMC = [ZLDWMC] where CZCLX in ('203','203A','204','205')", "LSczcdyd");
- var x = rdbHelper.ExecuteSQL(updateSQL);
-
- DataTable dtLSczcdyd = rdbHelper.ExecuteDatatable("LSczcdyd", "select OBJECTID,CZCDM,CZCMC from LSczcdyd", true);
- pFeatureCursor = Tempworkspace.OpenFeatureClass("LSczcdyd").FeatureClass.Update(null, false);
- while ((pFeature = pFeatureCursor.NextFeature()) != null)
- {
- object czcdm = dtLSczcdyd.Select(string.Format(" OBJECTID={0} ", pFeature.get_Value(pFeature.Fields.FindField("OBJECTID"))))[0]["CZCDM"];
- pFeature.set_Value(pFeature.Fields.FindField("CZCDM"), czcdm);
- object czcmc = dtLSczcdyd.Select(string.Format(" OBJECTID={0} ", pFeature.get_Value(pFeature.Fields.FindField("OBJECTID"))))[0]["CZCMC"];
- pFeature.set_Value(pFeature.Fields.FindField("CZCMC"), czcmc);
- pFeatureCursor.UpdateFeature(pFeature);
- }
- pFeatureCursor.Flush();
- LSczcdydFeatureclassAPI = Tempworkspace.OpenFeatureClass("LSczcdyd");
- // 根据城镇村等用地类型及城镇村代码相同且相邻进行融合
- List columns = new List() { "CZCLX", "CZCDM", "CZCMC" };
- var beforeCount = LSczcdydFeatureclassAPI.FeatureClass.FeatureCount(null);
- var outFilePath = TempfilePath + "\\CZCDYD_Dissolve";
- gPParamClass = new GPParamClass()
- {
- FirstFeatureLayer =new FeatureLayerClass() { FeatureClass = LSczcdydFeatureclassAPI.FeatureClass },
- OutFeatureClassPath = outFilePath,
- IsGetOutPutFeature = true,
- ListDissolveFiledName = columns,
- //Statistics_Fields = "BSM COUNT",
- };
- if (Tempworkspace.ExistFeatureClass("CZCDYD_Dissolve"))
- {
- Tempworkspace.DeleteFeatureClass("CZCDYD_Dissolve");
- }
- if (Tempworkspace.ExistFeatureClass("CZCDYD_Dissolve_Result"))
- {
- Tempworkspace.DeleteFeatureClass("CZCDYD_Dissolve_Result");
- }
- string path = gPParamClass.OutFeatureClassPath;
- IFeatureLayer featureLayer = null;
- gPParamClass.GPType = EnumGPType.Dissolve;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref featureLayer);
-
- gPParamClass.FirstFeatureLayer = featureLayer;
- gPParamClass.OutFeatureClassPath = TempfilePath;
- gPParamClass.FcName = "CZCDYD_Dissolve_Result";
- gPParamClass.GPType = EnumGPType.FcToFc;
- IFeatureLayer tempLayer = null;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref tempLayer); ;
- //pFeatureClass_4 = tempLayer.FeatureClass;// Tempworkspace.OpenFeatureClass("CZCDYD_Dissolve_Result");
-
- int countt = tempLayer.FeatureClass.FeatureCount(null);
- if (countt <= 0)
- {
- //Console.WriteLineTips("融合之后出错!,数据异常");
- return;
- }
- pFeatureCursor = tempLayer.FeatureClass.Search(null, false);
- //网格大小引发的错误
- if (czcdydFeatureClassAPI.FeatureClass is IFeatureClassLoad pFclsLoad)
- pFclsLoad.LoadOnlyMode = true;
- pInsertCursor = czcdydFeatureClassAPI.FeatureClass.Insert(true);
- int cxmIndex = tempLayer.FeatureClass.FindField("CZCLX");
- int Index_1 = tempLayer.FeatureClass.FindField("CZCDM");
- int Index_2 = czcdydFeatureClassAPI.FeatureClass.FindField("CZCDM");
- int Index_3 = tempLayer.FeatureClass.FindField("CZCMC");
- int Index_4 = czcdydFeatureClassAPI.FeatureClass.FindField("CZCMC");
- featureAdd = czcdydFeatureClassAPI.FeatureClass.CreateFeatureBuffer();
- pFeature = null;
- string substr = "";
- num = 0;
- while ((pFeature = pFeatureCursor.NextFeature()) != null)
- {
- featureAdd.Shape = pFeature.Shape;
- if (czclxIndex > -1)
- {
- featureAdd.set_Value(czclxIndex, pFeature.get_Value(cxmIndex));
- featureAdd.set_Value(Index_2, pFeature.get_Value(Index_1));
- featureAdd.set_Value(Index_4, pFeature.get_Value(Index_3));
- if (string.IsNullOrEmpty(substr))
- {
- substr = pFeature.get_Value(Index_1).ToString();
- }
- }
- pInsertCursor.InsertFeature(featureAdd);
- }
- pInsertCursor.Flush();
- if (czcdydFeatureClassAPI.FeatureClass is IFeatureClassLoad pFclsLoads)
- pFclsLoads.LoadOnlyMode = false;
- path = TempfilePath;// GetTempPath();
- rdbHelper.ExecuteSQL(" drop table CZCDYDGX ");
- IFeatureWorkspace TempfeatureWorkspace = (bgParm.GXCZCLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace;
- TableToTable(TempfeatureWorkspace, pOutWork, "CZCDYDGX");
-
- #region 201 201A
- {
- var result = GetXZQDic().Find(p => p.CODE == substr.Substring(0, 6));
- if (result != null)
- {
- string SQLstr = $"UPDATE CZCDYDGX SET CZCMC = '{result.NAME}' WHERE CZCLX in ('201','201A')";
- rdbHelper.ExecuteSQL(SQLstr);
- }
- }
- #endregion
-
- rdbHelper.ExecuteSQL(" drop table CJDCQGX ");
- TableToTable(TempfeatureWorkspace, pOutWork, "CJDCQGX");
-
- DataTable dt = rdbHelper.ExecuteDatatable("CZCDYDGX", "select objectid,CZCMC from CZCDYDGX", true);
-
- string time = new DateTime(DateTime.Now.Year - 1, 12, 31).ToShortDateString();
- // 标识码赋值
- int maxValue = 1;
-
- string MaxBSM = GetMaxBSM(new List() { bgParm.JCCZCLayer.FeatureClass });
-
- string BSM = pParm.XZQDM + "2931";
- IFeatureCursor pFeatureCursor_LS = czcdydFeatureClassAPI.FeatureClass.Update(null, true);
- count = czcdydFeatureClassAPI.FeatureClass.FeatureCount(null);
- Console.WriteLine("正在对城镇村等用地更新进行赋值......");
- int bsmIndexof = czcdydFeatureClassAPI.FeatureClass.FindField("BSM");
- int czclxindex = czcdydFeatureClassAPI.FeatureClass.FindField("CZCLX");
- num = 0;
- IFeature pfeaFeature = pFeatureCursor_LS.NextFeature();
- int czcdmIdx = czcdydFeatureClassAPI.FeatureClass.Fields.FindField("CZCDM");
- while (pfeaFeature != null)
- {
- string bsmPrefix = pParm.XZQDM + MaxBSM.Substring(6, 4);
- int MaxNum = Convert.ToInt32(MaxBSM.Substring(10));
- MaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0');
- pfeaFeature.set_Value(bsmIndexof, MaxBSM);
- pfeaFeature.set_Value(czcdydFeatureClassAPI.FeatureClass.FindField("YSDM"), "2099030100");
- string czclx = pfeaFeature.Value[czclxindex].ToTrim();
- string czcmc = string.Empty;
- DataRow[] drSet = dt.Select(string.Format(" objectid='{0}' ", pfeaFeature.Value[0]));
- if (drSet != null && drSet.Length > 0)
- {
- czcmc = drSet[0]["CZCMC"].ToString();
- }
- if (string.IsNullOrWhiteSpace(czcmc) && czcdmIdx != -1 && qsDic != null)
- {
- string strCZCDM = pfeaFeature.Value[czcdmIdx].ToTrim();
- if (czclx == "203" || czclx == "203A" || czclx == "204" || czclx == "205")
- {
- if (strCZCDM.Length > 12)
- {
- DataDicTionary dic = qsDic.FirstOrDefault(qs => qs.CODE == strCZCDM || qs.CODE.StartsWith(strCZCDM.Substring(0, 12)));
- if (dic != null)
- czcmc = dic.NAME;
- }
- }
- else if (czclx == "202" || czclx == "202A")
- {
- if (strCZCDM.Length > 9)
- {
- DataDicTionary dic = qsDic.FirstOrDefault(qs => qs.CODE == strCZCDM || qs.CODE.StartsWith(strCZCDM.Substring(0, 9)));
- if (dic != null)
- czcmc = dic.NAME;
- }
- }
- else if (czclx == "201" || czclx == "201A")
- {
- if (strCZCDM.Length > 6)
- {
- DataDicTionary dic = qsDic.FirstOrDefault(qs => qs.CODE == strCZCDM || qs.CODE.StartsWith(strCZCDM.Substring(0, 6)));
- if (dic != null)
- czcmc = dic.NAME;
- }
- }
- }
- pfeaFeature.set_Value(czcdydFeatureClassAPI.FeatureClass.FindField("CZCMC"), czcmc);
- pfeaFeature.set_Value(czcdydFeatureClassAPI.FeatureClass.FindField("GXSJ"), time);
- pfeaFeature.set_Value(czcdydFeatureClassAPI.FeatureClass.FindField("CZCMJ"), pfeaFeature.ShapeCopy.GetEllipseArea());
- pFeatureCursor_LS.UpdateFeature(pfeaFeature);
- maxValue++;
- pfeaFeature = pFeatureCursor_LS.NextFeature();
- }
- pFeatureCursor_LS.Flush();
-
- //设置基础城镇村选中
- gPParamClass = new GPParamClass();
-
- IFeatureWorkspace inWs = GetGdbWorkspace(path);
-
- IFeatureLayer czcUnionLayer = null;
- gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = bgParm.JCCZCLayer;// MapsManager.Instance.MapService.GetFeatureLayerByLayerName("城镇村等用地");
- gPParamClass.SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = czcdydFeatureClassAPI.FeatureClass };
- gPParamClass.OutFeatureClassPath = path + "\\" + "TempCZCGXGC2";
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.GPType = EnumGPType.Union;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref czcUnionLayer);
-
- gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = czcUnionLayer;
- gPParamClass.OutFeatureClassPath = path + "\\" + "TempCZCGXGC";
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.GPType = EnumGPType.MultipartToSinglePath;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref czcUnionLayer);
-
- rdbHelper.ExecuteSQL(" drop table TempCZCGXGC ");
- TableToTable(inWs, pOutWork, "TempCZCGXGC");
- string FID_JC_CZCDYD = $"FID_{featureClass.Name}";
- string strSql = $"select objectid,fid_czcdydgx from (select count(1) num,objectid,{FID_JC_CZCDYD},czclx bgqczclx,czclx_1 bghczclx,czcdm bgqczcdm,czcdm_1 bghczcdm,czcmc bgqczcmc,czcmc_1 bghczcmc,FID_CZCDYDGX from TempCZCGXGC group by {FID_JC_CZCDYD}) where num=1 and bgqczclx=bghczclx and bgqczcdm=bghczcdm and bgqczcmc=bghczcmc";
- DataTable gxgcDT = rdbHelper.ExecuteDatatable("tempgxgc", strSql, true);
-
- strSql = $"select objectid,fid_czcdydgx from (select count(1) num,objectid,{FID_JC_CZCDYD},czclx bgqczclx,czclx_1 bghczclx,czcdm bgqczcdm,czcdm_1 bghczcdm,czcmc bgqczcmc,czcmc_1 bghczcmc,FID_CZCDYDGX from TempCZCGXGC group by FID_CZCDYDGX) where num=1 and bgqczclx=bghczclx and bgqczcdm=bghczcdm and bgqczcmc=bghczcmc";
- DataTable gxgcDT2 = rdbHelper.ExecuteDatatable("tempgxgc", strSql, true);
- List AllowDelOIDs = new List();
- if (gxgcDT2 != null)
- {
- foreach (DataRow row in gxgcDT2.Rows)
- {
- AllowDelOIDs.Add(Convert.ToInt32(row["FID_CZCDYDGX"]));
- }
- }
- if (gxgcDT != null)
- {
- List SqlList = new List();
- foreach (DataRow row in gxgcDT.Rows)
- {
- int oid = Convert.ToInt32(row["OBJECTID"]);
- int gxOID = Convert.ToInt32(row["FID_CZCDYDGX"]);
- if (!AllowDelOIDs.Contains(gxOID))
- continue;
- IFeature gx = czcdydFeatureClassAPI.FeatureClass.GetFeature(gxOID);
- gx.Delete();
- IFeature gcF = czcUnionLayer.FeatureClass.GetFeature(oid);
- gcF.Delete();
- SqlList.Add(string.Format("Delete from TempCZCGXGC where OBJECTID={0}", oid));
- }
- rdbHelper.BeginTransaction();
- try
- {
- foreach (var item in SqlList)
- {
- rdbHelper.ExecuteSQL(item);
- }
- rdbHelper.Commit();
- }
- catch (Exception ex)
- {
- rdbHelper.Rollback();
- }
- }
-
- IFeatureClassAPI czcGXGCAPI = new FeatureClassAPI(bgParm.GXGCCZCLayer.FeatureClass);// .OpenFeatureClass("CZCDYDGXGC");
- (czcGXGCAPI.FeatureClass as ITable).DeleteSearchedRows(null);
- IFeatureCursor cursor = czcUnionLayer.FeatureClass.Search(null, true);
- IFeature f = null;
- int idxBGQBSM = czcUnionLayer.FeatureClass.FindField("BSM");
- int idxBGHBSM = czcUnionLayer.FeatureClass.FindField("BSM_1");
- int idxBGQCZCLX = czcUnionLayer.FeatureClass.FindField("CZCLX");
- int idxBGHCZCLX = czcUnionLayer.FeatureClass.FindField("CZCLX_1");
- int idxBGQCZCDM = czcUnionLayer.FeatureClass.FindField("CZCDM");
- int idxBGHCZCDM = czcUnionLayer.FeatureClass.FindField("CZCDM_1");
- int idxBGQCZCMC = czcUnionLayer.FeatureClass.FindField("CZCMC");
- int idxBGHCZCMC = czcUnionLayer.FeatureClass.FindField("CZCMC_1");
- int idxCZCMJ = czcUnionLayer.FeatureClass.FindField("CZCMJ");
-
-
- int t_idxBGQBSM = czcGXGCAPI.FeatureClass.FindField("BGQBSM");
- int t_idxBGHBSM = czcGXGCAPI.FeatureClass.FindField("BGHBSM");
- int t_idxBGQCZCLX = czcGXGCAPI.FeatureClass.FindField("BGQCZCLX");
- int t_idxBGHCZCLX = czcGXGCAPI.FeatureClass.FindField("BGHCZCLX");
- int t_idxBGQCZCDM = czcGXGCAPI.FeatureClass.FindField("BGQCZCDM");
- int t_idxBGHCZCDM = czcGXGCAPI.FeatureClass.FindField("BGHCZCDM");
- int t_idxBGQCZCMC = czcGXGCAPI.FeatureClass.FindField("BGQCZCMC");
- int t_idxBGHCZCMC = czcGXGCAPI.FeatureClass.FindField("BGHCZCMC");
- int t_idxBGMJ = czcGXGCAPI.FeatureClass.FindField("BGMJ");
- int t_idxBGXW = czcGXGCAPI.FeatureClass.FindField("BGXW");
- int t_idxGXSJ = czcGXGCAPI.FeatureClass.FindField("GXSJ");
- //网格大小报错
- if (czcGXGCAPI.FeatureClass is IFeatureClassLoad pFclsLoad2)
- pFclsLoad2.LoadOnlyMode = true;
- IFeatureCursor insertCur = czcGXGCAPI.FeatureClass.Insert(true);
- IFeatureBuffer buf = null;
- List pcList = new List();
- IFeatureLayer czcgxLayer = bgParm.GXCZCLayer;// MapsManager.Instance.MapService.GetFeatureLayerByName("CZCDYDGX");
- IFeatureLayer jcczcLayer = bgParm.JCCZCLayer;// MapsManager.Instance.MapService.GetFeatureLayerByLayerName("城镇村等用地");
- int idxGXBSM = czcgxLayer.FeatureClass.FindField("BSM");
-
- strSql = $"select BSM from (select count(1) num,objectid,bsm from TempCZCGXGC group by {FID_JC_CZCDYD}) where num>1";
- DataTable txbgData = rdbHelper.ExecuteDatatable("tempgxgc", strSql, true);
- count = czcUnionLayer.FeatureClass.FeatureCount(null);
- num = 0;
- while ((f = cursor.NextFeature()) != null)
- {
- string s_bgqbsm = f.Value[idxBGQBSM].ToTrim();
- string s_bghbsm = f.Value[idxBGHBSM].ToTrim();
- string s_bgqczclx = f.Value[idxBGQCZCLX].ToTrim();
- string s_bghczclx = f.Value[idxBGHCZCLX].ToTrim();
- string s_bgqczcdm = f.Value[idxBGQCZCDM].ToTrim();
- string s_bghczcdm = f.Value[idxBGHCZCDM].ToTrim();
- string s_bgqczcmc = f.Value[idxBGQCZCMC].ToTrim();
- string s_bghczcmc = f.Value[idxBGHCZCMC].ToTrim();
- double czcmj = f.Value[idxCZCMJ].ToDouble(2);
- if ((s_bgqczclx == "203" || s_bgqczclx == "203A") && s_bgqczclx == s_bghczclx && s_bgqczcdm.Substring(0, 12) == s_bghczcdm.Substring(0, 12))
- {
- List jcList = FeatureAPI.Identify2(f.ShapeCopy, jcczcLayer);
- if (jcList.Count == 1 && FeatureAPI.GetEqual(jcList[0].ShapeCopy, f.ShapeCopy))
- {
- List gxList = FeatureAPI.Identify2(f.ShapeCopy, czcgxLayer);
- foreach (var tempGxItem in gxList)
- {
- tempGxItem.Shape = FeatureAPI.Difference(tempGxItem.ShapeCopy, f.ShapeCopy);
- tempGxItem.Store();
- if (tempGxItem.Shape.IsEmpty)
- {
- tempGxItem.Delete();
- }
- }
- continue;
- }
- else
- {
- }
- }
- string bgxw = string.Empty;
- if (string.IsNullOrWhiteSpace(s_bghczclx))
- {
- bgxw = "0";
- List gxList = FeatureAPI.Identify2(f.ShapeCopy, dltbgxLayer);
- if (gxList.Count == 0)
- {
- continue;
- }
- }
- else if (string.IsNullOrWhiteSpace(s_bgqczcdm))
- {
- bgxw = "3";
- List gxList = FeatureAPI.Identify2(f.ShapeCopy, dltbgxLayer);
- if (gxList.Count == 0)
- {
- List gxList2 = FeatureAPI.Identify2(f.ShapeCopy, czcgxLayer);
- foreach (var item in gxList2)
- {
- if (FeatureAPI.GetEqual(item.ShapeCopy, f.ShapeCopy))
- item.Delete();
- else
- {
- item.Shape = FeatureAPI.Difference(item.ShapeCopy, f.ShapeCopy);
- item.Store();
- }
- }
- continue;
- }
- }
- else
- {
- bgxw = "2";
- if (txbgData.Select(string.Format("BSM='{0}'", s_bgqbsm)).Length == 0)
- {
- List gxList = FeatureAPI.Identify2(f.ShapeCopy, czcgxLayer);
- if (gxList.Count == 1)
- {
- if (FeatureAPI.GetEqual(f.ShapeCopy, gxList[0].ShapeCopy))
- {
- bgxw = "1";
- s_bghbsm = s_bgqbsm;
- gxList[0].Value[idxGXBSM] = s_bghbsm;
- gxList[0].Store();
- }
- }
- }
- }
- buf = czcGXGCAPI.FeatureClass.CreateFeatureBuffer();
- buf.Shape = f.ShapeCopy;
- buf.Value[t_idxBGQCZCLX] = s_bgqczclx;
- buf.Value[t_idxBGQCZCDM] = s_bgqczcdm;
- buf.Value[t_idxBGQCZCMC] = s_bgqczcmc;
- buf.Value[t_idxBGQBSM] = s_bgqbsm;
- buf.Value[t_idxGXSJ] = time;
-
- buf.Value[t_idxBGXW] = bgxw;
- buf.Value[t_idxBGHCZCLX] = s_bghczclx;
- buf.Value[t_idxBGHCZCDM] = s_bghczcdm;
- buf.Value[t_idxBGHCZCMC] = s_bghczcmc;
- buf.Value[t_idxBGHBSM] = s_bghbsm;
-
- double bgmj = f.ShapeCopy.GetEllipseArea().ToDouble(2);
- if (bgxw == "3")
- {
- buf.Value[t_idxBGMJ] = bgmj;
- }
- object oid = insertCur.InsertFeature(buf);
-
- if (bgxw != "3")
- {
- PCModel pc = pcList.FirstOrDefault(e => e.BGQBSM == s_bgqbsm);
- if (pc == null)
- {
- pc = new PCModel();
- pc.BGQBSM = s_bgqbsm;
- pc.KZMJ = czcmj;
- pc.GCData.Add(new GCMJModel() { OID = Convert.ToInt32(oid), MJ = bgmj });
- pcList.Add(pc);
- }
- else
- {
- pc.GCData.Add(new GCMJModel() { OID = Convert.ToInt32(oid), MJ = bgmj });
- }
- }
- }
- insertCur.Flush();
- if (czcGXGCAPI.FeatureClass is IFeatureClassLoad pFclsLoad3)
- pFclsLoad3.LoadOnlyMode = false;
- foreach (var item in pcList)
- {
- item.PC2();
- foreach (var gcOID in item.GCData)
- {
- IFeature gc = czcGXGCAPI.FeatureClass.GetFeature(gcOID.OID);
- gc.Value[t_idxBGMJ] = gcOID.MJ;
- gc.Store();
- }
- }
- DataTable tempGcDt = new DataTable();
- IQueryFilter filt = new QueryFilterClass();
- filt.SubFields = "BGMJ,BGHBSM,BGQBSM,OBJECTID,BGXW";
- filt.WhereClause = "BGXW <> '0'";
- czcGXGCAPI.QueryFeaturesToDataTable(filt, -1, out tempGcDt);
-
- Dictionary bghMJs = new Dictionary();
- foreach (DataRow item in tempGcDt.Rows)
- {
- string bsm = item["BGHBSM"].ToTrim();
- if (string.IsNullOrWhiteSpace(bsm)) continue;
- if (bghMJs.ContainsKey(bsm))
- {
- bghMJs[bsm] += item["BGMJ"].ToDouble(2);
- }
- else
- {
- bghMJs.Add(bsm, item["BGMJ"].ToDouble(2));
- }
- }
- //List upMJSqlList = new List();
- //foreach (var item in bghMJs.Keys)
- //{
- // upMJSqlList.Add(string.Format("Update CZCDYDGX set CZCMJ={0} where BSM='{1}'", bghMJs[item].ToDouble(2), item));
- //}
- ICursor upCursor = (czcgxLayer.FeatureClass as ITable).Update(null, true);
- IRow upRow = null;
- int idxGXCZCMJ = czcgxLayer.FeatureClass.FindField("CZCMJ");
- while ((upRow = upCursor.NextRow()) != null)
- {
- string bsm = upRow.Value[idxGXBSM].ToTrim();
- if (bghMJs.ContainsKey(bsm))
- {
- upRow.Value[idxGXCZCMJ] = bghMJs[bsm].ToDouble(2);
- upCursor.UpdateRow(upRow);
- }
- }
-
- IFeatureLayer JC_CZC203Layer_Mem = GeoDBAPI.CreateFeatureLayerInmemeory("JCCZC203", "城镇村203范围", (bgParm.JCCZCLayer.FeatureClass as IGeoDataset).SpatialReference, bgParm.JCCZCLayer.FeatureClass.ShapeType, bgParm.JCCZCLayer.FeatureClass.Fields);
- filter.WhereClause = "CZCLX='203' or CZCLX='203A'";
- InsertDataToMemeoryLayer(tempJCCZCLayer.FeatureClass, JC_CZC203Layer_Mem.FeatureClass, filter);
- cursor = czcgxLayer.FeatureClass.Search(new QueryFilterClass() { WhereClause = " CZCLX='203' or CZCLX='203A'" }, true);
- f = null;
- List feaOIDs = new List();
- //int czclxIdx = czcgxLayer.FeatureClass.FindField("CZCLX");
- int jcczclxIdx = JC_CZC203Layer_Mem.FeatureClass.FindField("CZCLX");
- while ((f = cursor.NextFeature()) != null)
- {
- List jc203Features = FeatureAPI.Identify(f.ShapeCopy, JC_CZC203Layer_Mem);
- if (jc203Features != null)
- {
- foreach (var jcF in jc203Features)
- {
- if (FeatureAPI.GetEqual(jcF.ShapeCopy, f.ShapeCopy)) break;
- if (!FeatureAPI.IsInterSect(jcF.ShapeCopy, f.ShapeCopy)) continue;
-
- IGeometry InterGeo = FeatureAPI.InterSect(jcF.ShapeCopy, f.ShapeCopy);
- IGeometry DiffGeo = FeatureAPI.Difference(f.ShapeCopy, jcF.ShapeCopy);
- if (DiffGeo.IsEmpty)
- {
- break;
- }
- if (!feaOIDs.Contains(f.OID))
- feaOIDs.Add(f.OID);
- }
- }
- }
- idxGXBSM = czcgxLayer.FeatureClass.FindField("BSM");
- int idxGXCZCLX = czcgxLayer.FeatureClass.FindField("CZCLX");
- int idxGXCZCDM = czcgxLayer.FeatureClass.FindField("CZCDM");
- int idxGXCZCMC = czcgxLayer.FeatureClass.FindField("CZCMC");
- idxGXCZCMJ = czcgxLayer.FeatureClass.FindField("CZCMJ");
- int idxGXGXSJ = czcgxLayer.FeatureClass.FindField("GXSJ");
- IFeatureLayer czcgxgcLayer = bgParm.GXGCCZCLayer;// MapsManager.Instance.MapService.GetFeatureLayerByName("CZCDYDGXGC");
- int idxGXGCBGMJ = czcgxgcLayer.FeatureClass.FindField("BGMJ");
- int idxGXGCBGHBSM = czcgxgcLayer.FeatureClass.FindField("BGHBSM");
- insertCur = czcgxLayer.FeatureClass.Insert(true);
- foreach (int oid in feaOIDs)
- {
- f = czcgxLayer.FeatureClass.GetFeature(oid);
- string bsm = f.Value[idxGXBSM].ToTrim();
- string czclx = f.Value[idxGXCZCLX].ToTrim();
- List jc203Features = FeatureAPI.Identify(f.ShapeCopy, JC_CZC203Layer_Mem);
- if (jc203Features != null)
- {
- IGeometry jc203 = null;
- foreach (var jcF in jc203Features)
- {
- bool IsEquql = FeatureAPI.GetEqual(jcF.ShapeCopy, f.ShapeCopy);
- string jcczclx = jcF.Value[jcczclxIdx].ToTrim();
- if (IsEquql && jcczclx == czclx)
- {
- f.Delete();
- break;
- }
- if (!FeatureAPI.IsInterSect(jcF.ShapeCopy, f.ShapeCopy)) continue;
- if (FeatureAPI.IsContains(jcF.ShapeCopy, f.ShapeCopy))
- {
- break;
- }
- if (jc203 == null)
- jc203 = jcF.ShapeCopy;
- else
- jc203 = FeatureAPI.Union(jc203, jcF.ShapeCopy);
- }
- IGeometry InterGeo = FeatureAPI.InterSect(jc203, f.ShapeCopy);
- IGeometry DiffGeo = FeatureAPI.Difference(f.ShapeCopy, jc203);
-
- if (DiffGeo.IsEmpty)
- {
- continue;
- }
- List Rings = FeatureAPI.DissolveGeometryByRing(InterGeo);
- List Rings2 = FeatureAPI.DissolveGeometryByRing(DiffGeo);
- if (Rings == null) Rings = new List();
- if (Rings2 == null) Rings2 = new List();
- if (Rings2.Count == 0)
- {
- f.Delete();
- }
- else
- {
- IGeometry tempGeo = f.ShapeCopy;
- if (Rings2.Count > 0)
- tempGeo = Rings2[0];
- ITopologicalOperator topo = tempGeo as ITopologicalOperator;
- IGeometry tempGeo2 = topo.Buffer(-0.00015);
- List gcList = FeatureAPI.Identify(tempGeo2, czcgxgcLayer);
- Marshal.ReleaseComObject(tempGeo2);
- double czcmj = 0;
- foreach (IFeature gcF in gcList)
- {
- if (!FeatureAPI.IsInterSect(tempGeo, gcF.ShapeCopy)) continue;
- czcmj += gcF.Value[idxGXGCBGMJ].ToDouble(2);
- gcF.Store();
- }
- f.Value[idxGXCZCMJ] = czcmj.ToDouble(2);
-
- f.Shape = tempGeo;
- f.Store();
- if (Rings2.Count > 0)
- Rings2.RemoveAt(0);
- }
- if (Rings2.Count > 0)
- Rings.AddRange(Rings2);
- foreach (var GeoRing in Rings)
- {
-
- string bsmPrefix = pParm.XZQDM + MaxBSM.Substring(6, 4);
- int MaxNum = Convert.ToInt32(MaxBSM.Substring(10));
- MaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0');
-
- IFeatureBuffer buff = czcgxLayer.FeatureClass.CreateFeatureBuffer();
- buff.Value[idxGXBSM] = MaxBSM;
- buff.Value[idxGXCZCLX] = f.Value[idxGXCZCLX];
- buff.Value[idxGXCZCDM] = f.Value[idxGXCZCDM];
- buff.Value[idxGXCZCMC] = f.Value[idxGXCZCMC];
- buff.Value[idxGXGXSJ] = time;
- buff.Shape = GeoRing;
- List gcList = FeatureAPI.Identify2(GeoRing, czcgxgcLayer);
- double czcmj = 0;
- foreach (IFeature gcF in gcList)
- {
- if (!FeatureAPI.IsInterSect(GeoRing, gcF.ShapeCopy)) continue;
- czcmj += gcF.Value[idxGXGCBGMJ].ToDouble(2);
- gcF.Value[idxGXGCBGHBSM] = MaxBSM;
- gcF.Store();
- }
- buff.Value[idxGXCZCMJ] = czcmj.ToDouble(2);
- object addOid = insertCur.InsertFeature(buff);
- }
- }
- insertCur.Flush();
- Marshal.ReleaseComObject(f);
- }
- cursor = czcgxLayer.FeatureClass.Search(null, true);
- f = null;
- List oids = new List();
- while ((f = cursor.NextFeature()) != null)
- {
- List Rings = FeatureAPI.DissolveGeometryByRing(f.ShapeCopy);
- if (Rings == null) continue;
- if (Rings.Count == 1) continue;
- oids.Add(f.OID);
- }
- foreach (int oid in oids)
- {
- IFeature gxFeature = czcgxLayer.FeatureClass.GetFeature(oid);
-
- List Rings = FeatureAPI.DissolveGeometryByRing(gxFeature.ShapeCopy);
- if (Rings.Count > 1)
- {
- gxFeature.Shape = Rings[0];
- {
- List gcList = FeatureAPI.Identify2(Rings[0], czcgxgcLayer);
- double czcmj = 0;
- foreach (IFeature gcF in gcList)
- {
- czcmj += gcF.Value[idxGXGCBGMJ].ToDouble(2);
- gcF.Store();
- }
- gxFeature.Value[idxGXCZCMJ] = czcmj.ToDouble(2);
- }
- gxFeature.Store();
- for (int i = 1; i < Rings.Count; i++)
- {
- if (Rings[i].IsEmpty) continue;
- string bsmPrefix = pParm.XZQDM + MaxBSM.Substring(6, 4);
- int MaxNum = Convert.ToInt32(MaxBSM.Substring(10));
- MaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0');
-
- IFeatureBuffer buff = czcgxLayer.FeatureClass.CreateFeatureBuffer();
- buff.Value[idxGXBSM] = MaxBSM;
- buff.Value[idxGXCZCLX] = gxFeature.Value[idxGXCZCLX];
- buff.Value[idxGXCZCDM] = gxFeature.Value[idxGXCZCDM];
- buff.Value[idxGXCZCMC] = gxFeature.Value[idxGXCZCMC];
- buff.Value[idxGXGXSJ] = time;
- buff.Shape = Rings[i];
- List gcList = FeatureAPI.Identify2(Rings[i], czcgxgcLayer);
- double czcmj = 0;
- foreach (IFeature gcF in gcList)
- {
- czcmj += gcF.Value[idxGXGCBGMJ].ToDouble(2);
- gcF.Value[idxGXGCBGHBSM] = MaxBSM;
- gcF.Store();
- }
- buff.Value[idxGXCZCMJ] = czcmj.ToDouble(2);
- insertCur.InsertFeature(buff);
- }
- }
- }
- insertCur.Flush();
- if (false)
- {
- (czcgxLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete from CZCDYDGX where CZCMJ=0");
- (czcgxgcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete from CZCDYDGXGC where BGMJ=0");
- }
- rdbHelper.ExecuteSQL(" drop table CZCDYDGXGC ");
- TableToTable(TempfeatureWorkspace, pOutWork, "CZCDYDGXGC");
- rdbHelper.ExecuteSQL(" drop table CZCDYDGX ");
- TableToTable(TempfeatureWorkspace, pOutWork, "CZCDYDGX");
- string sql = "select a.bsm aoid,b.objectid boid from czcdydgx a left join czcdydgxgc b on a.bsm=b.bghbsm where boid is null";
- DataTable gxDT = rdbHelper.ExecuteDatatable("tempgx", sql, true);
- if (gxDT != null && gxDT.Rows.Count > 0)
- {
- foreach (DataRow dr in gxDT.Rows)
- {
- (czcgxLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Delete from CZCDYDGX where bsm='{0}'", dr["AOID"]));
- }
- }
- rdbHelper.ExecuteSQL(" drop table CZCDYDGXGC ");
- TableToTable(TempfeatureWorkspace, pOutWork, "CZCDYDGXGC");
- rdbHelper.ExecuteSQL(" drop table CZCDYDGX ");
- TableToTable(TempfeatureWorkspace, pOutWork, "CZCDYDGX");
- sql = "select bgqbsm from czcdydgxgc where bgqbsm in (select bgqbsm from czcdydgxgc where bghbsm in (select bghbsm from czcdydgxgc group by bghbsm HAVING count(1)=1) and bgqbsm!='')group by bgqbsm HAVING count(1)=1";
- gxgcDT = rdbHelper.ExecuteDatatable("tempgxgc", sql, true);
- string PrjCode = pParm.XZQDM;
- sql = "select * from CZCDYDGXGC";
- DataTable gxgcDTAll = rdbHelper.ExecuteDatatable("CZCDYDGXGC", sql, true);
- if (gxgcDT != null && gxgcDT.Rows.Count > 0)
- {
- foreach (DataRow dr in gxgcDT.Rows)
- {
- DataRow[] drs = gxgcDTAll.Select(string.Format("BGQBSM='{0}'", dr["BGQBSM"]));
- if (drs != null && drs.Length == 1)
- {
- if (drs[0]["BGQCZCLX"].ToTrim() == drs[0]["BGHCZCLX"].ToTrim() &&
- drs[0]["BGQCZCDM"].ToTrim() == drs[0]["BGHCZCDM"].ToTrim() &&
- drs[0]["BGQCZCMC"].ToTrim() == drs[0]["BGHCZCMC"].ToTrim())
- {
- (czcgxLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Delete from CZCDYDGX where bsm='{0}'", drs[0]["BGHBSM"]));
- (czcgxgcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Delete from CZCDYDGXGC where BGQBSM='{0}'", drs[0]["BGQBSM"]));
- }
- else
- {
- string bsm = dr["BGQBSM"].ToTrim();
- if (!dr["BGQBSM"].ToTrim().StartsWith(PrjCode))
- bsm = bsm.Replace(bsm.Substring(0, 6), PrjCode);
- (czcgxLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Update CZCDYDGX set BSM='{0}' where bsm='{1}'", bsm, drs[0]["BGHBSM"]));
-
- (czcgxgcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Update CZCDYDGXGC set BGXW='1',BGHBSM='{0}' where BGQBSM='{1}' and BGHBSM='{2}'", bsm, dr["BGQBSM"], drs[0]["BGHBSM"]));
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogAPI.Debug("提取城镇村等用地数据异常:" + ex.Message);
- throw ex;
- }
- finally
- {
- if (LSczcdydFeatureclassAPI != null)
- LSczcdydFeatureclassAPI.CloseFeatureClass();
- if (CZCDLTBFeatureClass != null)
- CZCDLTBFeatureClass.CloseFeatureClass();
- //if (pFeatureClass_4 != null)
- // pFeatureClass_4.CloseFeatureClass();
- if (pFeatureCursor != null)
- Marshal.ReleaseComObject(pFeatureCursor);
- if (pInsertCursor != null)
- Marshal.ReleaseComObject(pInsertCursor);
- if (czcdydFeatureClassAPI != null)
- czcdydFeatureClassAPI.CloseFeatureClass();
- if (dltbFeatureClassAPI != null)
- dltbFeatureClassAPI.CloseFeatureClass();
- if (Schemeworkspace != null)
- Schemeworkspace.CloseWorkspace();
- if (Tempworkspace != null)
- Tempworkspace.CloseWorkspace();
- if (pOutWorkFactory != null)
- Marshal.ReleaseComObject(pOutWorkFactory);
- if (outputWorkspaceFactory != null)
- Marshal.ReleaseComObject(outputWorkspaceFactory);
- }
- }
- 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($"获取城镇村范围数据失败:{ex.Message}");
- LogAPI.Debug(ex);
- }
- }
- private string GetMaxBSM(List fcList)
- {
- 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;
-
- }
- 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 ex)
- {
- LogAPI.Debug(ex + ":删除错误不处理");
- }
- }
-
- private string GetTempPath()
- {
- string path = string.Empty;
- try
- {
- string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\城镇村用地变更临时数据";
- if (!System.IO.Directory.Exists(gdbFolder))
- {
- System.IO.Directory.CreateDirectory(gdbFolder);
- }
- try
- {
- DelectDir(gdbFolder);//能删除就删除 删除报错不处理
- }
- catch
- { }
- string mdbFileName = Guid.NewGuid().ToString() + ".gdb";
- path = System.IO.Path.Combine(gdbFolder, mdbFileName);
- var TempGDBPath = SysAppPath.GetTemplatePath() + "TempGDB.gdb";//模板
- if (Directory.Exists(path))
- {
- Directory.Delete(path, true);
- }
- Directory.CreateDirectory(path);
- CopyDirectInfo(TempGDBPath, path);
- return path;
- }
- catch (Exception ex)
- {
- LogAPI.Debug("提取城镇村等用地错误:" + ex.Message.ToString());
- return path;
- }
- }
- private void CopyDirectInfo(string sourceDir, string toDir)
- {
- if (!Directory.Exists(sourceDir))
- {
- throw new ApplicationException("未找到文件:" + sourceDir);
- }
- if (!Directory.Exists(toDir))
- {
- Directory.CreateDirectory(toDir);
- }
- DirectoryInfo directInfo = new DirectoryInfo(sourceDir);
- FileInfo[] filesInfos = directInfo.GetFiles();
- foreach (FileInfo fileinfo in filesInfos)
- {
- string fileName = fileinfo.Name;
- File.Copy(fileinfo.FullName, toDir + @"/" + fileName, true);
- }
- }
-
- ///
- /// 获取全国区县代码字典
- ///
- ///
- public static List GetXZQDic()
- {
- List result = new List();
- IRDBHelper rdbHelper = null;
- try
- {
- string systemPath = SysAppPath.GetDataBasePath() + "System.mdb";
- if (System.IO.File.Exists(systemPath))
- {
- string connStr = SysConfigsOprator.GetDBConnectionByName("MDBOledbConnection");
- connStr = string.Format(connStr, systemPath);
- rdbHelper = RDBFactory.CreateDbHelper(connStr, DatabaseType.MSAccess);
- string strSQL = "select OBJECTID AS ID, XZQ AS CODE,XZQMC AS NAME from XZQ";
- DataTable dt = rdbHelper.ExecuteDatatable("Dic", strSQL, true);
- if (dt != null)
- {
- result = TBToList.ToList(dt);
- foreach (var item in result)
- {
- item.DisplayName = item.CODE + "-" + item.NAME;
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogAPI.Debug(ex);
- }
- finally
- {
- if (rdbHelper != null)
- {
- rdbHelper.DisConnect();
- }
- }
- return result;
- }
-
- public IFeatureWorkspace GetGdbWorkspace(string pPathName)
- {
- try
- {
- IWorkspaceFactory factoryGdb = new FileGDBWorkspaceFactoryClass();
- IWorkspace worckspace = factoryGdb.OpenFromFile(pPathName, 0);
- return worckspace as IFeatureWorkspace;
- }
- catch (Exception ex)
- {
- LogAPI.Debug(ex);
- return null;
- }
- }
-
- public bool TableToTable(IFeatureWorkspace pInWork, IWorkspace pOutWork, string tableName, IQueryFilter queryFilter = null)
- {
- try
- {
- if (pInWork == null || pOutWork == null || string.IsNullOrEmpty(tableName)) return false;
- IWorkspace2 workspace2 = pInWork as IWorkspace2;
- if (workspace2 != null)
- {
- if (!workspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, tableName))
- {
- return false;
- }
- }
- ITable pInTable = pInWork.OpenTable(tableName);
- if (pInTable == null) return false;
-
- IDataset pIndataset = (IDataset)pInTable;
- IDatasetName pInDatasetName = (IDatasetName)pIndataset.FullName;
-
- IEnumDataset enumDataset = pOutWork.get_Datasets(esriDatasetType.esriDTTable);
- IDataset dataset;
- enumDataset.Reset();
- while ((dataset = enumDataset.Next()) != null)
- {
- string[] names = dataset.Name.Split('.');
- if (string.Equals(names[names.Length - 1], tableName, StringComparison.CurrentCultureIgnoreCase))
- {
- dataset.Delete();
- break;
- }
- }
-
- IDataset pOutDataset = (IDataset)pOutWork;
- IDatasetName pOutDatasetName = new TableNameClass();
- pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName;
- pOutDatasetName.Name = tableName;
-
-
- //Validate the field names because you are converting between different workspace types.
- IFieldChecker fieldChecker = new FieldCheckerClass();
- IFields targetFeatureClassFields = pInTable.Fields;
- IFields sourceFeatureClassFields = pInTable.Fields;
- IEnumFieldError enumFieldError;
-
-
- // Most importantly set the input and validate workspaces!
- fieldChecker.InputWorkspace = pInWork as IWorkspace;
- fieldChecker.ValidateWorkspace = pOutWork;
- fieldChecker.Validate(sourceFeatureClassFields, out enumFieldError, out targetFeatureClassFields);
-
- IFeatureDataConverter one2another = new FeatureDataConverterClass();
- try
- {
- one2another.ConvertTable(pInDatasetName, queryFilter, pOutDatasetName, targetFeatureClassFields, "", 1000, 0);
- }
- finally
- {
- Marshal.ReleaseComObject(one2another);
- }
- return true;
- }
- catch (Exception ex)
- {
- LogAPI.Debug(ex);
- throw ex;
- }
- }
-
- public class PCModel
- {
- public string BGQBSM { get; set; }
- public string BGHBSM { get; set; }
- public double BGHMJ { get; set; }
- public double KZMJ { get; set; }
- //public Dictionary GCData { get; set; }
- public List GCData { get; set; }
- public PCModel()
- {
- GCData = new List();
- }
- public void PC()
- {
- //IOrderedEnumerable> GCData2 = GCData.OrderByDescending(e => e.Value);
- //GCData = new Dictionary();
- //foreach (var item in GCData2)
- //{
- // GCData.Add(item.Key, item.Value);
- //}
- GCData = GCData.OrderByDescending(o => o.MJ).ToList();
- double zmj = GCData.Sum(s => s.MJ);
- double mjc = Math.Round(zmj - KZMJ, 2);
- if (Math.Round(mjc, 2) == 0)
- {
- return;
- }
- 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 / GCData.Count;
- int f = tpsm % GCData.Count;
- if (f != 0)
- {
- double tpmj = (e + 1) * 0.01;
- for (int j = 0; j < f; j++)
- {
- if (mjc < 0)
- GCData[j].MJ = GCData[j].MJ + tpmj;
- else if (GCData[j].MJ > 0.01)
- GCData[j].MJ = GCData[j].MJ - tpmj;
- }
- }
- if (e != 0)
- {
- double tpmj = e * 0.01;
- for (int j = f; j < GCData.Count; j++)
- {
- if (mjc < 0)
- GCData[j].MJ = GCData[j].MJ + tpmj;
- else if (GCData[j].MJ > 0.01)
- GCData[j].MJ = GCData[j].MJ - tpmj;
- }
- }
- zmj = GCData.Sum(s => s.MJ);
- mjc = Math.Round(zmj - KZMJ, 2);
- //mjc = Math.Round(shpList.Sum(s => s.MJ), 2) - pKZMJ;
- }
- }
- public void PC2()
- {
- //IOrderedEnumerable> GCData2 = GCData.OrderByDescending(e => e.Value);
- //GCData = new Dictionary();
- //foreach (var item in GCData2)
- //{
- // GCData.Add(item.Key, item.Value);
- //}
- GCData = GCData.OrderByDescending(o => o.MJ).ToList();
- double zmj = GCData.Sum(s => s.MJ);
- double mjc = Math.Round(zmj - KZMJ, 2);
- if (Math.Round(mjc, 2) == 0 || (zmj == 0 && mjc < 0))
- {
- return;
- }
- int num = 0;
- while (Math.Round(mjc, 2) != 0 && num < 10)
- {
- foreach (var item in GCData)
- {
- if (Math.Round(mjc, 2) == 0) break;
- if (mjc < 0)
- {
- if (item.MJ <= 0.01) continue;
- item.MJ = Math.Round(item.MJ + 0.01, 2);
- zmj = GCData.Sum(s => s.MJ);
- mjc = Math.Round(zmj - KZMJ, 2);
- }
- else
- {
- if (item.MJ <= 0.01) continue;
- item.MJ = Math.Round(item.MJ - 0.01, 2);
- zmj = GCData.Sum(s => s.MJ);
- mjc = Math.Round(zmj - KZMJ, 2);
- }
- }
- }
- ////平差
- //while (Math.Round(mjc, 2) != 0 && num < 10)
- //{
- // num++;
- // int tpsm = (int)(Math.Abs(Math.Round(mjc, 2)) / (double)0.01);
- // int e = tpsm / GCData.Count;
- // int f = tpsm % GCData.Count;
- // if (f != 0)
- // {
- // double tpmj = (e + 1) * 0.01;
- // for (int j = 0; j < f; j++)
- // {
- // if (mjc < 0)
- // GCData[j].MJ = GCData[j].MJ + tpmj;
- // else if (GCData[j].MJ > 0.01)
- // GCData[j].MJ = GCData[j].MJ - tpmj;
- // }
- // }
- // if (e != 0)
- // {
- // double tpmj = e * 0.01;
- // for (int j = f; j < GCData.Count; j++)
- // {
- // if (mjc < 0)
- // GCData[j].MJ = GCData[j].MJ + tpmj;
- // else if (GCData[j].MJ > 0.01)
- // GCData[j].MJ = GCData[j].MJ - tpmj;
- // }
- // }
- // zmj = GCData.Sum(s => s.MJ);
- // mjc = Math.Round(zmj - KZMJ, 2);
- // //mjc = Math.Round(shpList.Sum(s => s.MJ), 2) - pKZMJ;
- //}
- }
- }
-
- public class GCMJModel
- {
- public int OID { get; set; }
- public double MJ { get; set; }
- }
- public class CZC_Param
- {
- public IFeatureLayer GXCZCLayer { get; set; }
- public IFeatureLayer GXGCCZCLayer { get; set; }
- public IFeatureLayer GXTBLayer { get; set; }
- public IFeatureLayer JCCZCLayer { get; set; }
- public IFeatureLayer JCTBLayer { get; set; }
- public IFeatureLayer BGTBLayer { get; set; }
-
- }
- }
-}
diff --git a/KGIS_DLTB/Helper/DLTB_IDGHelper.cs b/KGIS_DLTB/Helper/DLTB_IDGHelper.cs
deleted file mode 100644
index fc96f75..0000000
--- a/KGIS_DLTB/Helper/DLTB_IDGHelper.cs
+++ /dev/null
@@ -1,2729 +0,0 @@
-using ESRI.ArcGIS.Carto;
-using ESRI.ArcGIS.DataSourcesGDB;
-using ESRI.ArcGIS.esriSystem;
-using ESRI.ArcGIS.Geodatabase;
-using ESRI.ArcGIS.Geometry;
-using GPHelper;
-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.Utils;
-using KGIS.Framework.Utils.ExtensionMethod;
-using KGIS.Framework.Utils.Utility;
-using Kingo.PluginServiceInterface;
-using Kingo.PluginServiceInterface.Helper;
-using Kingo.PluginServiceInterface.Model;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Xml.Linq;
-using Path = System.IO.Path;
-
-namespace KGIS_DLTB
-{
- public class DLTB_IDGHelper : BaseIDG
- {
- private string TempDbPath = string.Empty;
- IWorkspace pOutWork = null;
- private IDGParameter Parm = null;
-
- public void Execute(IDGParameter parm)
- {
- Parm = parm;
- DateTime StartTime = DateTime.Now;
- IFeatureLayer Temp_DLTBGXGC = null;
- IFeatureLayer Temp_BGTBLayer = null;//变更图斑融合
- IFeatureLayer EraseAnalysisLayer = null;
- IFeatureLayer MultipartAnalysisLayer = null;
- IFeature feature = null;
- IFeatureCursor pCursor = null;
- IFeatureClassAPI fcAPI = null;
- GPParamClass paramClass = new GPParamClass();
- try
- {
- OpenDB(parm);
- string TempDir = CommonHelper.CreateTempDB("DLTB");
- TempDbPath = Path.Combine(TempDir, "TempGDB.gdb");
- (GxTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTBGX WHERE 1=1");
- (GxgcTBLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTBGXGC WHERE 1=1");
- #region 判断是否存在坐落变更 提取相关数据
- if (Parm.PrjInfo.ListZLXXInfo.Count > 0)
- {
- Console.WriteLine("Msg:正在处理坐落变更数据...");
- string TempZLBGDir = CommonHelper.CreateTempDB("DLTB_ZLBG");
- string TempZLBGDbPath = Path.Combine(TempZLBGDir, "TempGDB.gdb");
- IWorkspaceAPI wsAPI = new WorkspaceAPI(TempZLBGDbPath, WorkspaceTypeEnum.GDBFile, true);
- IFeatureClassAPI DLTBBG_ZLBGAPI = wsAPI.CreateFeatureClass("DLTBBG_ZLBG", (BgTbLayer.FeatureClass as IGeoDataset).SpatialReference, BgTbLayer.FeatureClass.Fields);
- fcAPI = new FeatureClassAPI(JcTbLayer.FeatureClass);
- IQueryFilter filter = new QueryFilterClass() { };
- bool isMDB = ((IDataset)fcAPI.FeatureClass).Workspace.PathName.ToUpper().Contains(".MDB");
- List repeat = new List();//记录筛选条件中的重复数据
- string sqlwhere = string.Empty;
- foreach (var item in Parm.PrjInfo.ListZLXXInfo)
- {
- if (string.IsNullOrWhiteSpace(item.BGQDM.ToTrim()) || string.IsNullOrWhiteSpace(item.BGHDM.ToTrim())) continue;
- if (isMDB)
- {
- if (item.IsQS == "是")
- filter.WhereClause = $"QSDWDM like '{item.BGQDM}*'";
- else
- filter.WhereClause = $"ZLDWDM like '{item.BGQDM}*' or QSDWDM like'{item.BGQDM}*' ";
- }
- else
- {
- if (item.IsQS == "是")
- {
- filter.WhereClause = $"QSDWDM like '{item.BGQDM}%'";
- }
- else
- {
- if (repeat.Count > 0)
- sqlwhere = $"and BSM not in({string.Join(",", repeat)})";
- filter.WhereClause = $"(ZLDWDM like '{item.BGQDM}%' or QSDWDM like'{item.BGQDM}%') {sqlwhere} ";
- }
- }
- fcAPI.FcToFc(DLTBBG_ZLBGAPI.FeatureClass, filter, false);
- ITable tempBGTb = DLTBBG_ZLBGAPI.FeatureClass as ITable;
- ICursor _cursor = tempBGTb.Update(filter, true);
- IRow _row = null;
- int _idxzldwdm = DLTBBG_ZLBGAPI.FeatureClass.FindField("ZLDWDM");
- int _idxZLMC = DLTBBG_ZLBGAPI.FeatureClass.FindField("ZLDWMC");
- int _idxQS = DLTBBG_ZLBGAPI.FeatureClass.FindField("QSDWDM");
- int _idxFRDBS = DLTBBG_ZLBGAPI.FeatureClass.FindField("FRDBS");
- int _idxDLBM = DLTBBG_ZLBGAPI.FeatureClass.FindField("DLBM");
- int _idxCZCSXM = DLTBBG_ZLBGAPI.FeatureClass.FindField("CZCSXM");
- int _idxBSM = DLTBBG_ZLBGAPI.FeatureClass.FindField("BSM");
- int _idxBZ = DLTBBG_ZLBGAPI.FeatureClass.FindField("BZ");
- int _idxQSXZ = DLTBBG_ZLBGAPI.FeatureClass.FindField("QSXZ");
- int _idxGCZZ = DLTBBG_ZLBGAPI.FeatureClass.FindField("GCZZ");
- while ((_row = _cursor.NextRow()) != null && _idxzldwdm != -1)
- {
- string bsm = _row.Value[_idxBSM].ToTrim();
- string DLBM = _row.Value[_idxDLBM].ToTrim();
- string CZCSXM = _row.Value[_idxCZCSXM].ToTrim();
- #region 变更后 地 类 为 1001 、 1002 、 1003 、 1007 、 1008 、 1009 、 1109 的 图 斑 , 城 镇 村 属 性 码 应 为 空 ; 其 中 , 原 数 据 库 中 己 标 注 20x 属 性 , 地 类 为 1001 、 1002 、 1003 、 1007 、 1008 、 1009 、 1109 的 图 斑 , 如 果 发 生 变 更 , 也 应 将 标 注 的 20x 属 性 置 空 ;
- if (DLBM == "1109" && !string.IsNullOrEmpty(CZCSXM))
- _row.Value[_idxCZCSXM] = "";
- #endregion
- if (repeat.Contains(bsm)) continue;
- repeat.Add($"'{bsm}'");
- string zldwdm = _row.Value[_idxzldwdm].ToTrim();
- string zldwmc = _row.Value[_idxZLMC].ToTrim();
- string qsdwdm = _row.Value[_idxQS].ToTrim();
- if (item.IsQS == "是")
- {
- _row.Value[_idxQS] = qsdwdm.Replace(item.BGQDM, item.BGHDM);
- }
- else
- {
- if (zldwdm == qsdwdm)//权属坐落相同的 FRDBS=0
- {
- _row.Value[_idxzldwdm] = zldwdm.Replace(item.BGQDM, item.BGHDM);
- _row.Value[_idxZLMC] = zldwmc.Replace(item.BGQMC.ToTrim(), item.BGHMC.ToTrim());
- _row.Value[_idxQS] = qsdwdm.Replace(item.BGQDM, item.BGHDM);
- if (_idxFRDBS != -1)
- _row.Value[_idxFRDBS] = "0";
- }
- else
- {
- if (zldwdm.Substring(0, item.BGQDM.Length) != item.BGQDM)//权属坐落不同 FRDBS=1
- {
- var listzLXXInfo = Parm.PrjInfo.ListZLXXInfo.Where(x => x.BGQDM == zldwdm.Substring(0, item.BGQDM.Length)).ToList();
- if (listzLXXInfo != null && listzLXXInfo.Count > 0)
- {
- var zLXXInfo = listzLXXInfo[0];
- _row.Value[_idxzldwdm] = zldwdm.Replace(zLXXInfo.BGQDM, zLXXInfo.BGHDM);
- _row.Value[_idxZLMC] = zldwmc.Replace(zLXXInfo.BGQMC.ToTrim(), zLXXInfo.BGHMC.ToTrim());
- }
- //权属赋值
- listzLXXInfo = Parm.PrjInfo.ListZLXXInfo.Where(x => x.BGQDM == qsdwdm.Substring(0, item.BGQDM.Length)).ToList();
- if (listzLXXInfo != null && listzLXXInfo.Count > 0)
- {
- var zLXXInfo = listzLXXInfo[0];
- _row.Value[_idxQS] = qsdwdm.Replace(zLXXInfo.BGQDM, zLXXInfo.BGHDM);
- }
- else
- {
- _row.Value[_idxQS] = qsdwdm.Replace(item.BGQDM, item.BGHDM);
- }
- }
- else if (zldwdm.Substring(0, item.BGQDM.Length) == item.BGQDM)
- {
- _row.Value[_idxzldwdm] = zldwdm.Replace(item.BGQDM, item.BGHDM.ToTrim());
- _row.Value[_idxZLMC] = zldwmc.Replace(item.BGQMC.ToTrim(), item.BGHMC.ToTrim());
- //权属赋值
- var listzLXXInfo = Parm.PrjInfo.ListZLXXInfo.Where(x => x.BGQDM == qsdwdm.Substring(0, item.BGQDM.Length)).ToList();
- if (listzLXXInfo != null && listzLXXInfo.Count > 0)
- {
- var zLXXInfo = listzLXXInfo[0];
- _row.Value[_idxQS] = qsdwdm.Replace(zLXXInfo.BGQDM, zLXXInfo.BGHDM);
- }
- else
- {
- _row.Value[_idxQS] = qsdwdm.Replace(item.BGQDM, item.BGHDM);
- }
- }
-
- }
- }
- //只有前12位不一致且权属性质是国家的 飞入地标0 其他情况都标1
- string qsxzValue = _row.Value[_idxQSXZ].ToTrim();
- zldwdm = _row.Value[_idxzldwdm].ToTrim();
- if (zldwdm.Length >= 12 && _row.Value[_idxQS].ToTrim().Length >= 12)
- {
- if (zldwdm.Substring(0, 12) != _row.Value[_idxQS].ToTrim().Substring(0, 12))
- {
- if (qsxzValue == "10" || qsxzValue == "20" || qsxzValue == "21")
- _row.Value[_idxFRDBS] = "0";
- else
- _row.Value[_idxFRDBS] = "1";
- }
- }
- _cursor.UpdateRow(_row);
- }
- _cursor.Flush();
- }
- #region 变更图斑擦除坐落变更的图斑
- paramClass.FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = DLTBBG_ZLBGAPI.FeatureClass, Name = "DLTBBG_ZLBG" };
- paramClass.SecondFeatureLayer = BgTbLayer;
- paramClass.OutFeatureClassPath = $"{TempZLBGDbPath}\\BGTB_Erase";
- paramClass.IsGetOutPutFeature = true;
- paramClass.GPType = EnumGPType.Erase;
- GPHelper.Instance.ExeGPForProces(paramClass, ref EraseAnalysisLayer);
- //拆分多部件
- paramClass = new GPParamClass();
- paramClass.FirstFeatureLayer = EraseAnalysisLayer;
- paramClass.OutFeatureClassPath = TempZLBGDbPath + "\\" + "TBBGErase";
- paramClass.IsGetOutPutFeature = true;
- paramClass.GPType = EnumGPType.MultipartToSinglePath;
- GPHelper.Instance.ExeGPForProces(paramClass, ref MultipartAnalysisLayer);
- #endregion
- (DLTBBG_ZLBGAPI.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Delete From DLTBBG_ZLBG WHERE 1=1");
- wsAPI = new WorkspaceAPI(TempZLBGDbPath, WorkspaceTypeEnum.GDBFile, true);
- fcAPI = wsAPI.OpenFeatureClass2("TBBGErase");
- fcAPI?.FcToFc(DLTBBG_ZLBGAPI.FeatureClass, null, false);
- fcAPI = new FeatureClassAPI(BgTbLayer.FeatureClass);
- fcAPI.FcToFc(DLTBBG_ZLBGAPI.FeatureClass, null, false);
- BgTbLayer.FeatureClass = DLTBBG_ZLBGAPI.FeatureClass;
- }
- #endregion
-
- string dbPath = TempDir + @"\Temp" + ".sqlite";
- Console.WriteLine("Msg:正在处理变更图斑数据...");
- Temp_BGTBLayer = ProcessBGTB();
-
- IWorkspaceAPI wsAPI1 = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- IFeatureClassAPI TempGXGCAPI = wsAPI1.OpenFeatureClass("DLTBGXGC");
- Temp_DLTBGXGC = new FeatureLayerClass() { FeatureClass = TempGXGCAPI.FeatureClass };
-
- pOutWork = CreateDBWorkspace(dbPath);
- //CustomGPHelper.TableToTable(Temp_DLTBGXGC, dbPath, "DLTBGXGC");
-
- IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
- rdbHelper.ExecuteSQL(" drop table DLTBGXGC ");
- TableToTable(wsAPI1.CurrentWorkspace as IFeatureWorkspace, pOutWork, "DLTBGXGC");
- rdbHelper.ExecuteSQL("CREATE INDEX IDX_FID_DLTBGX ON DLTBGXGC (FID_DLTBGX);");
- rdbHelper.ExecuteSQL("ALTER TABLE DLTBGXGC ADD ONLYZLBG INTEGER;");
- //Console.WriteLine("Msg:正在生成临时过程数据...");
- //Temp_DLTBGXGC = GenerateTempGXGC(Temp_BGTBLayer, dbPath);
- rdbHelper.ExecuteSQL(@"update dltbgxgc set BSM_1= null,TBBH_1=null");
- rdbHelper.ExecuteSQL(@"Update DLTBGXGC set KCDLBM ='' where KCDLBM ISNULL or KCDLBM=' ' or TRIM(KCDLBM)='';
- Update DLTBGXGC set KCXS=0 where KCXS ISNULL ;
- Update DLTBGXGC set GDLX =Null where GDLX ISNULL or GDLX=' ' or TRIM(GDLX)='';
- Update DLTBGXGC set GDPDJB ='' where GDPDJB ISNULL or GDPDJB=' ' or TRIM(GDPDJB)='';
- Update DLTBGXGC set XZDWKD=0 where XZDWKD ISNULL ;
- Update DLTBGXGC set TBXHDM ='' where TBXHDM ISNULL or TBXHDM=' ' or TRIM(TBXHDM)='';
- Update DLTBGXGC set TBXHMC ='' where TBXHMC ISNULL or TBXHMC=' ' or TRIM(TBXHMC)='';
- Update DLTBGXGC set ZZSXDM ='' where ZZSXDM ISNULL or ZZSXDM=' ' or TRIM(ZZSXDM)='';
- Update DLTBGXGC set ZZSXMC ='' where ZZSXMC ISNULL or ZZSXMC=' ' or TRIM(ZZSXMC)='';
- Update DLTBGXGC set GDDB =0 where GDDB ISNULL;
- Update DLTBGXGC set FRDBS ='' where FRDBS ISNULL or FRDBS=' ' or TRIM(FRDBS)='';
- Update DLTBGXGC set CZCSXM ='' where CZCSXM ISNULL or CZCSXM=' ' or TRIM(CZCSXM)='';
- Update DLTBGXGC set MSSM ='' where MSSM ISNULL or MSSM=' ' or TRIM(MSSM)='';
- Update DLTBGXGC set HDMC ='' where HDMC ISNULL or HDMC=' ' or TRIM(HDMC)='';
- Update DLTBGXGC set XZQTZLX =NULL where XZQTZLX ='' or XZQTZLX=' ' or TRIM(XZQTZLX)='';
- Update DLTBGXGC set BZ =NULL where BZ ='' or BZ=' ' or TRIM(BZ)='' or LENGTH(BZ)=0 ;");
- Console.WriteLine("Msg:正在进行变更行为赋值...");
- //Console.WriteLine("Log:正在进行变更行为赋值....");
- #region BGXW=2
- //变更图斑与基础库图斑一对多
- rdbHelper.ExecuteSQL(" UPDATE DLTBGXGC set BGXW='2' where FID_DLTBGX in (select FID_DLTBGX from DLTBGXGC where FID_DLTBGX <> -1 and shape_area>=0.001 GROUP BY FID_DLTBGX HAVING COUNT(FID_DLTBGX) > 1 ) ");
- rdbHelper.ExecuteSQL(@"UPDATE DLTBGXGC set BGXW='2' where BGXW IS NULL and BSM in (select BSM from DLTBGXGC where shape_area>=0.001 GROUP BY BSM HAVING COUNT(BSM) > 1 ) ");
- #endregion
- rdbHelper.ExecuteSQL(@"update dltbgxgc set bgxw='4' WHERE XZQTZLX is null and OBJECTID in (select objectid from DLTBGXGC WHERE BGXW is null
- and TRIM(IfNull(ZLDWDM,'')) = TRIM(IfNull(ZLDWDM_1,''))
- and TRIM(IfNull(ZLDWMC,'')) = TRIM(IfNull(ZLDWMC_1,''))
- and TRIM(IfNull(QSDWDM,'')) = TRIM(IfNull(QSDWDM_1,''))
- and TRIM(IfNull(DLBM,'')) = TRIM(IfNull(DLBM_1,''))
- and TRIM(IfNull(DLMC,'')) = TRIM(IfNull(DLMC_1,''))
- and TRIM(IfNull(QSXZ,'')) = TRIM(IfNull(QSXZ_1,''))
- and TRIM(IfNull(KCDLBM,'')) = TRIM(IfNull(KCDLBM_1,''))
- and (IfNull(KCXS,0) = IfNull(KCXS_1,0))
- and TRIM(IfNull(GDLX,'')) = TRIM(IfNull(GDLX_1,''))
- and TRIM(IfNull(GDPDJB,'')) = TRIM(IfNull(GDPDJB_1,''))
- and (IfNull(XZDWKD,0) = IfNull(XZDWKD_1,0))
- and TRIM(IfNull(TBXHDM,'')) = TRIM(IfNull(TBXHDM_1,''))
- and TRIM(IfNull(TBXHMC,'')) = TRIM(IfNull(TBXHMC_1,''))
- and TRIM(IfNull(ZZSXDM,'')) = TRIM(IfNull(ZZSXDM_1,''))
- and TRIM(IfNull(ZZSXMC,'')) = TRIM(IfNull(ZZSXMC_1,''))
- and (IfNull(GDDB,0) = IfNull(GDDB_1,0))
- and TRIM(IfNull(FRDBS,'')) = TRIM(IfNull(FRDBS_1,''))
- and TRIM(IfNull(CZCSXM,'')) = TRIM(IfNull(CZCSXM_1,''))
- and TRIM(IfNull(MSSM,'')) = TRIM(IfNull(MSSM_1,''))
- and TRIM(IfNull(HDMC,'')) = TRIM(IfNull(HDMC_1,''))
- and TRIM(IfNull(BZ,'')) = TRIM(IfNull(BZ_1,''))
- )");
-
- rdbHelper.ExecuteSQL(@"update dltbgxgc set bgxw='4' WHERE XZQTZLX is null and OBJECTID in (select OBJECTID from DLTBGXGC d WHERE BGXW is null and DLBM in ('0101','0102','0103') and DLBM_1 in ('0101','0102','0103')
- and TRIM(IfNull(ZLDWDM,'')) = TRIM(IfNull(ZLDWDM_1,''))
- and TRIM(IfNull(ZLDWMC,'')) = TRIM(IfNull(ZLDWMC_1,''))
- and TRIM(IfNull(QSDWDM,'')) = TRIM(IfNull(QSDWDM_1,''))
- and TRIM(IfNull(DLBM,'')) = TRIM(IfNull(DLBM_1,''))
- and TRIM(IfNull(DLMC,'')) = TRIM(IfNull(DLMC_1,''))
- and TRIM(IfNull(QSXZ,'')) = TRIM(IfNull(QSXZ_1,''))
- and TRIM(IfNull(GDPDJB,'')) = TRIM(IfNull(GDPDJB_1,''))
- and (IfNull(XZDWKD,0) = IfNull(XZDWKD_1,0))
- and TRIM(IfNull(TBXHDM,'')) = TRIM(IfNull(TBXHDM_1,''))
- and TRIM(IfNull(TBXHMC,'')) = TRIM(IfNull(TBXHMC_1,''))
- and TRIM(IfNull(ZZSXDM,'')) = TRIM(IfNull(ZZSXDM_1,''))
- and TRIM(IfNull(ZZSXMC,'')) = TRIM(IfNull(ZZSXMC_1,''))
- and TRIM(IfNull(GDLX,'')) = TRIM(IfNull(GDLX_1,''))
- and (IfNull(GDDB,0) = IfNull(GDDB_1,0))
- and TRIM(IfNull(FRDBS,'')) = TRIM(IfNull(FRDBS_1,''))
- and TRIM(IfNull(CZCSXM,'')) = TRIM(IfNull(CZCSXM_1,''))
- and TRIM(IfNull(MSSM,'')) = TRIM(IfNull(MSSM_1,''))
- and TRIM(IfNull(HDMC,'')) = TRIM(IfNull(HDMC_1,''))
- and TRIM(IfNull(BZ,'')) = TRIM(IfNull(BZ_1,''))
- )");//新增 and TRIM(IfNull(GDLX,'')) = TRIM(IfNull(GDLX_1, '')) 仅耕地类型变化需求BUG:15404
-
- #region BGXW=1
- rdbHelper.ExecuteSQL(@"update dltbgxgc set bgxw='1' where bgxw is null;");
- #endregion
- rdbHelper.ExecuteSQL(@"update dltbgxgc set bgxw='3' where xzqtzlx = '3';");
-
- //rdbHelper.ExecuteSQL($"delete from dltbgxgc where bgxw='4' and dlbm in({TBDLBMTypeList.DLBMs_JSYD_SQL}) ;");
- rdbHelper.ExecuteSQL($"delete from dltbgxgc where bgxw='4' and CZCSXM like '20%';");
- if (CJQTbLayer == null || CJQTbLayer.FeatureClass.FeatureCount(null) <= 0)
- rdbHelper.ExecuteSQL($" delete from dltbgxgc where bgxw='4' ;");
- rdbHelper.ExecuteSQL(@"delete from dltbgxgc where bgxw='1' and shape_area<0.001 ;");
-
- #region BGXW=-1
- rdbHelper.ExecuteSQL($"delete from DLTBGXGC where BGXW='2' AND (BSM = '' Or BSM Is Null Or DLBM = '');");//细缝
- rdbHelper.ExecuteSQL($"delete from DLTBGXGC where BGXW='2' AND shape_area < 0.01 AND BSM in (select BSM from DLTBGXGC " +
- $" GROUP BY BSM HAVING COUNT(BSM) = 1);");//单重叠
- rdbHelper.ExecuteSQL(@" UPDATE DLTBGXGC set BGXW='-1' where shape_area < 0.01 AND BSM in (select BSM from DLTBGXGC
- GROUP BY shape_area HAVING COUNT(shape_area) > 1) AND BSM in (select BSM from DLTBGXGC
- GROUP BY BSM HAVING COUNT(BSM) = 1) ");//双重叠
- rdbHelper.ExecuteSQL($"delete from DLTBGXGC where BGXW='-1';");//清除重叠
- #endregion
-
- Console.WriteLine("Msg:正在进行面积平差...");
- #region 面积平差
- DataTable data_BSM = rdbHelper.ExecuteDatatable("tab", "select BSM,TBMJ from DLTBGXGC GROUP BY BSM HAVING count(BSM)>1", true);
- List pcBSMList = new List();
- if (data_BSM != null && data_BSM.Rows.Count > 0)
- {
- foreach (DataRow row in data_BSM.Rows)
- {
- var jc_bsm = row["BSM"].ToTrim();
- if (!pcBSMList.Contains(jc_bsm))
- pcBSMList.Add(jc_bsm);
- }
- }
- pCursor = Temp_DLTBGXGC.FeatureClass.Search(new QueryFilterClass() { SubFields = "OBJECTID,BSM,TBMJ,SHAPE" }, true);
- var _itbmj = Temp_DLTBGXGC.FeatureClass.FindField("TBMJ");
- var bsmIdx = Temp_DLTBGXGC.FeatureClass.FindField("BSM");
- feature = null;
- Dictionary AreaList = new Dictionary();
- while ((feature = pCursor.NextFeature()) != null)
- {
- string bsm = feature.Value[bsmIdx].ToTrim();
- if (!pcBSMList.Contains(bsm))
- continue;
- double area = feature.ShapeCopy.GetEllipseArea();
- if (area == 0)
- area = 0.01;
- AreaList.Add(feature.OID, area.ToDouble());
- }
- if (pCursor != null)
- Marshal.ReleaseComObject(pCursor);
- DataTable data = rdbHelper.ExecuteDatatable("tab", "select OBJECTID,BSM,ZLDWDM_1,TBMJ from DLTBGXGC where FID_DLTBGX >= 0 ", true);
- var GXGClist = TBToList.ToList(data);
- Dictionary _GXGCvaluePairs = new Dictionary();//记录平差结果
- if (data_BSM != null && data_BSM.Rows.Count > 0)
- {
- foreach (DataRow row in data_BSM.Rows)
- {
- var jc_TBMJ = row["TBMJ"].ToDouble();
- List shpList = new List();
- List rows = GXGClist.Where(x => x.BSM == row["BSM"].ToTrim()).ToList();
- foreach (var item in rows)
- {
- Adjustment adj = new Adjustment();
- adj.ID = item.OBJECTID;
- if (AreaList.ContainsKey(adj.ID))
- adj.bgmj = AreaList[adj.ID];
- shpList.Add(adj);
- }
- if (shpList.Count > 0)
- {
- AreaAdjustment(shpList, jc_TBMJ);//面积平差
- foreach (var item in shpList)
- {
- if (!_GXGCvaluePairs.ContainsKey(item.ID))
- _GXGCvaluePairs.Add(item.ID, item.bgmj);
- }
- }
- }
- }
- var strBSM = GetNewBSM(new List() { JcTbLayer.FeatureClass });
- Dictionary dicTBBH = new Dictionary();
- GetMaxTBBH(JcTbLayer.FeatureClass, ref dicTBBH);
- rdbHelper.BeginTransaction();
- foreach (var oid in _GXGCvaluePairs.Keys)
- {
- rdbHelper.ExecuteSQL(string.Format(@"update dltbgxgc set tbbgmj={1} where objectid={0};", oid, _GXGCvaluePairs[oid]));
- }
- rdbHelper.Commit();
- DataTable txbgTB = rdbHelper.ExecuteDatatable("tab", "select OBJECTID,BSM,ZLDWDM_1,TBMJ from DLTBGXGC where (bgxw='2' or bgxw='3') and bsm_1 is null and tbbh_1 is null and tbbgmj is null", true);
- rdbHelper.BeginTransaction();
- foreach (DataRow item in txbgTB.Rows)
- {
- rdbHelper.ExecuteSQL(string.Format(@"update dltbgxgc set tbbgmj=TBMJ where objectid={0};", item["OBJECTID"]));
- }
- rdbHelper.Commit();
- #endregion
- rdbHelper.ExecuteSQL(string.Format(@"update dltbgxgc set tbbgmj=TBMJ,BSM_1=BSM,TBBH_1=TBBH where BGXW='1'"));
- rdbHelper.ExecuteSQL(string.Format(@"update dltbgxgc set shape_area_1=tbbgmj where BGXW='1'"));
- rdbHelper.ExecuteSQL(string.Format(@"update dltbgxgc set tbbgmj=TBMJ,BSM_1=BSM,TBBH_1=TBBH where BGXW='4'"));
- rdbHelper.ExecuteSQL(string.Format(@"update dltbgxgc set shape_area_1=tbbgmj where BGXW='4'"));
- #region 调出面积平差
-
- DataTable pcDT = rdbHelper.ExecuteDatatable("pc", "select sum(tbbgmj) from dltbgxgc where xzqtzlx='2'", true);
- DataTable pcDT1 = rdbHelper.ExecuteDatatable("pc", $"select sum(tbbgmj) from dltbgxgc where zldwdm not like '{parm.PrjInfo.CODE}%' and zldwdm_1 like '{parm.PrjInfo.CODE}%' ", true);
- double tcMJ = pcDT.Rows[0][0].ToDouble();
- double trMJ = pcDT1.Rows[0][0].ToDouble();
- if (parm.PrjInfo.KZMJ != null && tcMJ > 0)
- {
- double ldmjc = (parm.PrjInfo.KZMJ.TZQ_LDMJ + trMJ - parm.PrjInfo.KZMJ.TZH_LDMJ).ToDouble(2);
- if (!(parm.PrjInfo.KZMJ.TZQ_LDMJ == 0 && parm.PrjInfo.KZMJ.TZH_LDMJ == 0 && parm.PrjInfo.KZMJ.TZQ_HDMJ == 0 && parm.PrjInfo.KZMJ.TZH_HDMJ == 0))
- {
- double mjc = Math.Round((ldmjc - tcMJ).ToDouble(), 2);
- Console.WriteLine($"Log:正在进行调入调出面积平差【调入面积_{trMJ},调出面积_{tcMJ},面积差_{mjc}】...");
- while (mjc != 0)
- {
- int pcs = Math.Abs(mjc / 0.01).ToInt();
- string pcSql = string.Format($@"select objectid,tbbgmj,bsm,xzqtzlx,bgxw from dltbgxgc where xzqtzlx = '2' and bgxw = '2' and tbbgmj<>tbmj ORDER by tbbgmj desc LIMIT {pcs}");
- DataTable temp = rdbHelper.ExecuteDatatable("temp", pcSql, true);
- if (temp.Rows.Count == 0) break;
- pcSql = $@"select * from dltbgxgc where (xzqtzlx='0' or xzqtzlx is null) and bsm in (
- select bsm from dltbgxgc where xzqtzlx = '2' and bgxw = '2' and tbbgmj<>tbmj ORDER by tbbgmj desc LIMIT {pcs}
- )";
- DataTable temp1 = rdbHelper.ExecuteDatatable("temp2", pcSql, true);
-
- Dictionary hc_bsmCount = new Dictionary();
- Dictionary bsmCount = new Dictionary();
- rdbHelper.BeginTransaction();
- string upMJSql = $@"
-update dltbgxgc set tbbgmj=tbbgmj+0.01 where objectid in (select objectid from dltbgxgc where xzqtzlx = '2' and bgxw = '2' and tbbgmj<>tbmj ORDER by tbbgmj DESC LIMIT {pcs})";
- if (mjc < 0)
- {
- upMJSql = $@"
-update dltbgxgc set tbbgmj=tbbgmj-0.01 where objectid in (select objectid from dltbgxgc where xzqtzlx = '2' and bgxw = '2' and tbbgmj<>tbmj ORDER by tbbgmj DESC LIMIT {pcs})";
- }
- rdbHelper.ExecuteSQL(upMJSql);
- for (int i = 0; i < temp.Rows.Count; i++)
- {
- if (mjc > 0)
- {
- //+
- int oid = temp.Rows[i]["OBJECTID"].ToInt();
- string tempBSM = temp.Rows[i]["BSM"].ToTrim();
- string strTZLX = temp.Rows[i]["XZQTZLX"].ToTrim();
- if (_GXGCvaluePairs.ContainsKey(oid))
- {
- if (hc_bsmCount.ContainsKey(tempBSM))
- {
- hc_bsmCount[tempBSM] = hc_bsmCount[tempBSM] + 1;
- }
- else
- {
- hc_bsmCount.Add(tempBSM, 1);
- }
- _GXGCvaluePairs[oid] = (_GXGCvaluePairs[oid] + 0.01).ToDouble(2);
- }
- }
- else
- {
- //-
-
- int oid = temp.Rows[i]["OBJECTID"].ToInt();
- string tempBSM = temp.Rows[i]["BSM"].ToTrim();
- string strTZLX = temp.Rows[i]["XZQTZLX"].ToTrim();
- if (_GXGCvaluePairs.ContainsKey(oid))
- {
- if (hc_bsmCount.ContainsKey(tempBSM))
- {
- hc_bsmCount[tempBSM] = hc_bsmCount[tempBSM] + 1;
- }
- else
- {
- hc_bsmCount.Add(tempBSM, 1);
- }
- _GXGCvaluePairs[oid] = (_GXGCvaluePairs[oid] - 0.01).ToDouble(2);
- }
- }
- }
-
- for (int i = 0; i < temp1.Rows.Count; i++)
- {
- if (mjc > 0)
- {
- //+
- int oid = temp1.Rows[i]["OBJECTID"].ToInt();
- string tempBSM = temp1.Rows[i]["BSM"].ToTrim();
- string strTZLX = temp1.Rows[i]["XZQTZLX"].ToTrim();
- if (_GXGCvaluePairs.ContainsKey(oid))
- {
- if (bsmCount.ContainsKey(tempBSM))
- {
- continue;
- }
- else
- {
- bsmCount.Add(tempBSM, 1);
- }
- double value = 0.01 * hc_bsmCount[tempBSM];
- _GXGCvaluePairs[oid] = (_GXGCvaluePairs[oid] - value).ToDouble(2);
- rdbHelper.ExecuteSQL($@"update dltbgxgc set tbbgmj=tbbgmj-{value} where objectid={oid}");
- }
- }
- else
- {
- //-
- int oid = temp1.Rows[i]["OBJECTID"].ToInt();
- string tempBSM = temp1.Rows[i]["BSM"].ToTrim();
- string strTZLX = temp1.Rows[i]["XZQTZLX"].ToTrim();
- if (_GXGCvaluePairs.ContainsKey(oid))
- {
- if (bsmCount.ContainsKey(tempBSM))
- {
- continue;
- }
- else
- {
- bsmCount.Add(tempBSM, 1);
- }
- double value = 0.01 * hc_bsmCount[tempBSM];
- _GXGCvaluePairs[oid] = (_GXGCvaluePairs[oid] + value).ToDouble(2);
- rdbHelper.ExecuteSQL($@"update dltbgxgc set tbbgmj=tbbgmj+{value} where objectid={oid}");
- }
- }
- }
- rdbHelper.Commit();
- if (mjc > 0)
- {
- mjc = Math.Round(mjc - temp.Rows.Count * 0.01, 2);
- }
- else if (mjc < 0)
- {
- mjc = Math.Round(mjc + temp.Rows.Count * 0.01, 2);
- }
- }
- }
- }
- #endregion
-
- txbgTB = rdbHelper.ExecuteDatatable("tab", "select FID_DLTBGX,sum(tbbgmj) bghtbmj,ZLDWDM_1,BGXW,BSM,XZQTZLX from dltbgxgc where bgxw='2' or bgxw='3' or xzqtzlx='1' or (bgxw='1' and substr(ZLDWDM,0,13)<>substr(ZLDWDM_1,0,13)) group by FID_DLTBGX;", true);
- rdbHelper.BeginTransaction();
- foreach (DataRow item in txbgTB.Rows)
- {
- string TBBH = string.Empty;
- string BGQBSM = string.Empty;
- if (item["BGXW"].ToTrim() != "1" || item["XZQTZLX"].ToTrim() == "1")
- {
- var strbsm = strBSM.Substring(0, 10);
- var Maxbsm = strBSM.Substring(10).ToInt() + 1;
- strBSM = strbsm + Maxbsm.ToString().PadLeft(8, '0');//最新标识码
- }
- else
- {
- BGQBSM = item["BSM"].ToTrim();
- }
- string strZLDM = item["ZLDWDM_1"].ToTrim();
- if (strZLDM.Length > 12)
- strZLDM = strZLDM.Substring(0, 12);
- if (dicTBBH.ContainsKey(strZLDM))
- {
- dicTBBH[strZLDM] = dicTBBH[strZLDM] + 1;//最大图斑编号-去最新值
- TBBH = dicTBBH[strZLDM].ToTrim();
- }
- else
- {
- dicTBBH.Add(strZLDM, 1);
- TBBH = dicTBBH[strZLDM].ToTrim();
- }
-
- rdbHelper.ExecuteSQL(string.Format(@"update dltbgxgc set BSM_1='{1}',TBBH_1='{2}',shape_area_1={3} where FID_DLTBGX={0};", item["FID_DLTBGX"], string.IsNullOrWhiteSpace(BGQBSM) ? strBSM : BGQBSM, TBBH, item["BGHTBMJ"]));
- }
-
- rdbHelper.Commit();
- rdbHelper.ExecuteSQL(string.Format(@"update DLTBGXGC set ONLYZLBG='1' WHERE BGXW ='1'
- and
- (
- TRIM(IfNull(ZLDWDM,'')) != TRIM(IfNull(ZLDWDM_1,''))
- or TRIM(IfNull(ZLDWMC,'')) != TRIM(IfNull(ZLDWMC_1,''))
- or TRIM(IfNull(QSDWDM,'')) != TRIM(IfNull(QSDWDM_1,''))
- )
- and TRIM(IfNull(DLBM,'')) = TRIM(IfNull(DLBM_1,''))
- and TRIM(IfNull(DLMC,'')) = TRIM(IfNull(DLMC_1,''))
- and TRIM(IfNull(QSXZ,'')) = TRIM(IfNull(QSXZ_1,''))
- and TRIM(IfNull(KCDLBM,'')) = TRIM(IfNull(KCDLBM_1,''))
- and ((IfNull(KCXS,0)==0) = (IfNull(KCXS_1,0)=0))
- and TRIM(IfNull(GDLX,'')) = TRIM(IfNull(GDLX_1,''))
- and TRIM(IfNull(GDPDJB,'')) = TRIM(IfNull(GDPDJB_1,''))
- and ((IfNull(XZDWKD,0)==0) = (IfNull(XZDWKD_1,0)=0))
- and TRIM(IfNull(TBXHDM,'')) = TRIM(IfNull(TBXHDM_1,''))
- and TRIM(IfNull(TBXHMC,'')) = TRIM(IfNull(TBXHMC_1,''))
- and TRIM(IfNull(ZZSXDM,'')) = TRIM(IfNull(ZZSXDM_1,''))
- and TRIM(IfNull(ZZSXMC,'')) = TRIM(IfNull(ZZSXMC_1,''))
- and ((IfNull(GDDB,0)==0) = (IfNull(GDDB_1,0)=0))
- and TRIM(IfNull(FRDBS,'')) = TRIM(IfNull(FRDBS_1,''))
- and TRIM(IfNull(CZCSXM,'')) = TRIM(IfNull(CZCSXM_1,''))
- and TRIM(IfNull(BZ,'')) = TRIM(IfNull(BZ_1,''))"));
- rdbHelper.ExecuteSQL(string.Format(@"update DLTBGXGC set ONLYZLBG='1' WHERE BGXW ='1' and (XZQTZLX = '2' or XZQTZLX = '4')"));
-
- Console.WriteLine("Msg:正在写入过程数据...");
-
- #region 生成更新过程层
- DataTable data_BGXW = rdbHelper.ExecuteDatatable("tab", $"select FID_DLTBGX,FID_JC_DLTB,BGXW,TBBGMJ,BSM_1,TBBH_1,OBJECTID,TBMJ,ONLYZLBG,XZQTZLX from DLTBGXGC WHERE BGXW IS NOT NULL and SUBSTR(ZLDWDM_1,1,6)='{parm.PrjInfo.CODE}'", true);
- GXGCFcToFc(Temp_DLTBGXGC.FeatureClass, GxgcTBLayer.FeatureClass, null, false, data_BGXW, _GXGCvaluePairs);
- #endregion
-
- Console.WriteLine("Msg:正在写入更新数据...");
- #region 生成更新层
- IFeatureClassAPI TempGXAPI = wsAPI1.OpenFeatureClass("DLTBGX");
- DataTable dtDLTBGX = rdbHelper.ExecuteDatatable("tab", $"select FID_DLTBGX,shape_area_1 as TBMJ,BSM_1,TBBH_1,ONLYZLBG,XZQTZLX from DLTBGXGC WHERE BGXW IS NOT NULL and ((XZQTZLX <> '2' and XZQTZLX<> '4') or XZQTZLX is NULL) and SUBSTR(ZLDWDM_1,1,6)='{parm.PrjInfo.CODE}' ", true);
- GXFcToFc(TempGXAPI.FeatureClass, GxTbLayer.FeatureClass, null, dtDLTBGX);
- #endregion
-
- #region 关于无变化数据过滤
- if (GxgcTBLayer.FeatureClass.FeatureCount(new QueryFilterClass() { WhereClause = " BGXW = '4' " }) > 0)
- {
- IFeatureCursor featureCursor = GxgcTBLayer.FeatureClass.Search(new QueryFilterClass() { WhereClause = " BGXW = '4' " }, true);
- IFeature BGXW4_f = null;
- int BGHBSMindex = GxgcTBLayer.FeatureClass.FindField("BGHTBBSM");
- int BGQCZCSXMindex = GxgcTBLayer.FeatureClass.FindField("BGQCZCSXM");
- string GXBSMs = "";
- if (CJQTbLayer.FeatureClass.FeatureCount(null) > 0)
- {
- while ((BGXW4_f = featureCursor.NextFeature()) != null)
- {
- string BGQCZCSXMValue = BGXW4_f.Value[BGQCZCSXMindex].ToString();
- string BGHTBBSMValue = BGXW4_f.Value[BGHBSMindex].ToString();
- if (!string.IsNullOrWhiteSpace(BGQCZCSXMValue))
- {
- GXBSMs += $"'{BGHTBBSMValue}',";
- continue;
- }
- List GC_Fs = FeatureAPI.Identify2(BGXW4_f.ShapeCopy, JcCzcLayer);
- if (GC_Fs.Count <= 0)
- GXBSMs += $"'{BGHTBBSMValue}',";
- GC_Fs = FeatureAPI.Identify2(BGXW4_f.ShapeCopy, CJQTbLayer);
- if (GC_Fs.Count <= 0)
- GXBSMs += $"'{BGHTBBSMValue}',";
- }
- }
- else
- { //无拆旧区 BGXW为4的数据全部删除
- while ((BGXW4_f = featureCursor.NextFeature()) != null)
- {
- GXBSMs += $"'{BGXW4_f.Value[BGHBSMindex]}',";
- }
- }
- if (!string.IsNullOrWhiteSpace(GXBSMs.Trim(',')))
- {
- (GxTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Delete From DLTBGX WHERE BSM in({GXBSMs.Trim(',')})");
- (GxgcTBLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Delete From DLTBGXGC WHERE BGHTBBSM in({GXBSMs.Trim(',')})");
- }
- }
- if (GxgcTBLayer.FeatureClass.FeatureCount(new QueryFilterClass() { WhereClause = " TBBGMJ = 0.01 " }) > 0)
- {
- IFeatureCursor featureCursor = GxgcTBLayer.FeatureClass.Search(new QueryFilterClass() { WhereClause = " TBBGMJ = 0.01 " }, true);
- IFeature BGXW4_f = null;
- while ((BGXW4_f = featureCursor.NextFeature()) != null)
- {
- List GC_Fs = FeatureAPI.Identify(BGXW4_f.ShapeCopy, GxgcTBLayer);
- foreach (IFeature Gcitem in GC_Fs)
- {
- if (Gcitem.OID == BGXW4_f.OID || !FeatureAPI.IsAdjacent(Gcitem.ShapeCopy, BGXW4_f.ShapeCopy))
- continue;
- bool IsEqule = true;
- foreach (string Fileditem in ListDissolveFileds)
- {
- int Filedidnex = Gcitem.Class.FindField("BGQ" + Fileditem);
- if (Filedidnex == -1) continue;
- if (Gcitem.Value[Filedidnex].ToTrim() != BGXW4_f.Value[Filedidnex].ToTrim())
- {
- IsEqule = false; break;
- }
- Filedidnex = Gcitem.Class.FindField("BGH" + Fileditem);
- if (Filedidnex == -1) continue;
- if (Gcitem.Value[Filedidnex].ToTrim() != BGXW4_f.Value[Filedidnex].ToTrim())
- {
- IsEqule = false; break;
- }
- }
- if (IsEqule == false) continue;
- Gcitem.Shape = FeatureAPI.Union(Gcitem.ShapeCopy, BGXW4_f.ShapeCopy);
- Gcitem.Value[Gcitem.Class.FindField("TBBGMJ")] = Gcitem.Value[Gcitem.Class.FindField("TBBGMJ")].ToDouble() + 0.01;
- Gcitem.Value[Gcitem.Class.FindField("BGQKCMJ")] = Gcitem.Value[Gcitem.Class.FindField("BGQKCXS")].ToDouble() * Gcitem.Value[Gcitem.Class.FindField("TBBGMJ")].ToDouble();
- Gcitem.Value[Gcitem.Class.FindField("BGHKCMJ")] = Gcitem.Value[Gcitem.Class.FindField("BGHKCXS")].ToDouble() * Gcitem.Value[Gcitem.Class.FindField("TBBGMJ")].ToDouble();
- Gcitem.Value[Gcitem.Class.FindField("BGQTBDLMJ")] = Gcitem.Value[Gcitem.Class.FindField("TBBGMJ")].ToDouble() - Gcitem.Value[Gcitem.Class.FindField("BGQKCMJ")].ToDouble();
- Gcitem.Value[Gcitem.Class.FindField("BGHTBDLMJ")] = Gcitem.Value[Gcitem.Class.FindField("TBBGMJ")].ToDouble() - Gcitem.Value[Gcitem.Class.FindField("BGHKCMJ")].ToDouble();
- Gcitem.Store();
- BGXW4_f.Value[BGXW4_f.Class.FindField("BSM")] = "00";
- BGXW4_f.Store();
- break;
- }
- }
- (GxgcTBLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($" Delete From DLTBGXGC WHERE BSM = '00' ");
- }
- #endregion
-
- //CustomGPHelper.RepairGeo(GxgcTBLayer.FeatureClass);
- if (Parm != null && Parm.PrjInfo != null && (Parm.PrjInfo.ProjType == EnumProjType.RCBG_BCGD || Parm.PrjInfo.ProjType == EnumProjType.RCBG_ZJG))
- {
- //为日常变更赋值部分属性
- IFeatureCursor featureGC = GxgcTBLayer.FeatureClass.Update(null, true);
- IFeature GCFeature = null;
- int XMMCIndex = GxgcTBLayer.FeatureClass.FindField("XMMC");
- int XMBHIndex = GxgcTBLayer.FeatureClass.FindField("XMBH");
- int DKMCIndex = GxgcTBLayer.FeatureClass.FindField("DKMC");
- IFeatureLayer BgTbFLayer = OpenLayer(BgWsAPI, "DLTBBG");//只读取属性信息
- int BgXMMCIndex = BgTbFLayer.FeatureClass.FindField("XMMC");
- int BgXMBHIndex = BgTbFLayer.FeatureClass.FindField("XMBH");
- int BgDKMCIndex = BgTbFLayer.FeatureClass.FindField("DKMC");
- while ((GCFeature = featureGC.NextFeature()) != null)
- {
- List features = FeatureAPI.Identify2(GCFeature.ShapeCopy, BgTbFLayer);
- if (features == null || features.Count == 0) continue;
- if (features.Count == 1)
- {
- if (XMMCIndex != -1 && BgXMMCIndex != -1)
- GCFeature.Value[XMMCIndex] = features[0].Value[BgXMMCIndex];
- if (XMBHIndex != -1 && BgXMBHIndex != -1)
- GCFeature.Value[XMBHIndex] = features[0].Value[BgXMBHIndex];
- if (DKMCIndex != -1 && BgDKMCIndex != -1)
- GCFeature.Value[DKMCIndex] = features[0].Value[BgDKMCIndex];
- GCFeature.Store();
- }
- else
- {
- double sumMJ = 0;
- IFeature featureTemp = null;
- foreach (IFeature Fitem in features)
- {
- double sumMJTemp = FeatureAPI.GetInterArea(Fitem.ShapeCopy, GCFeature.ShapeCopy);
- if (sumMJTemp > sumMJ)
- {
- featureTemp = Fitem;
- sumMJ = sumMJTemp;
- }
- }
- if (featureTemp != null)
- {
- if (XMMCIndex != -1 && BgXMMCIndex != -1)
- GCFeature.Value[XMMCIndex] = featureTemp.Value[BgXMMCIndex];
- if (XMBHIndex != -1 && BgXMBHIndex != -1)
- GCFeature.Value[XMBHIndex] = featureTemp.Value[BgXMBHIndex];
- if (DKMCIndex != -1 && BgDKMCIndex != -1)
- GCFeature.Value[DKMCIndex] = featureTemp.Value[BgDKMCIndex];
- GCFeature.Store();
- }
- else
- {
- //Console.WriteLine($"Msg:为相交的数据:{GCFeature.OID}");
- }
- }
-
- }
- featureGC.Flush();
- }
- Console.WriteLine("Msg:正在生成年末数据...");
- base.CreateNMK(parm);
- Console.WriteLine($"Log:地类图斑数据提取完成。耗时:{GetTime(StartTime)}");
- base.Dispose();
- }
- catch (Exception ex)
- {
- LogAPI.Debug(ex);
- Console.WriteLine("Err:地类图斑数据提取失败!" + ex.Message);
- Console.WriteLine("Err:地类图斑数据提取失败!" + ex.StackTrace);
- }
- }
-
- public void OpenDB(IDGParameter parm)
- {
- try
- {
- LayerCfg layerInfo = null;
- if (parm.PrjInfo != null && !string.IsNullOrWhiteSpace(parm.PrjInfo.TempData))
- {
- byte[] contentArray = Convert.FromBase64String(parm.PrjInfo.TempData);
- string LayerCfg = System.Text.Encoding.Default.GetString(contentArray);
- layerInfo = SerializeAPI.DeserializeToObject(LayerCfg);
-
- LayerCfg JCLayerInfo = layerInfo.Layers.FirstOrDefault(f => f.LayerName == "年初数据") ?? throw new Exception("Err:获取年初数据库失败!");
- List NcList = JCLayerInfo.GetAllItem();
-
- LayerCfg _JcTBLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "地类图斑");
- _jcTbLayer = OpenLayer(_JcTBLayerInfo);
- if (_jcTbLayer == null)
- {
- throw new Exception("Err:获取年初地类图斑数据失败!");
- }
- else
- CheackJCGDB(_jcTbLayer);
- LayerCfg _JcPdtLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "坡度图");
- _jcPdtLayer = OpenLayer(_JcPdtLayerInfo);
- }
-
- string PathBgDB = parm.PrjInfo.BGDatabase;
- string PathZLDB = parm.PrjInfo.ZLDatabase;
- //string PathNMDB = parm.PrjInfo.NMDatabase;
- BgWsAPI = new WorkspaceAPI(PathBgDB, WorkspaceTypeEnum.GDBFile, true);
- if (BgWsAPI.CurrentWorkspace == null)
- {
- Console.WriteLine("Err:打开变更数据库失败!");
- return;
- }
- ZlWsAPI = new WorkspaceAPI(PathZLDB, WorkspaceTypeEnum.GDBFile, true);
- if (ZlWsAPI.CurrentWorkspace == null)
- {
- Console.WriteLine("Err:打开增量数据库失败!");
- return;
- }
- NmWsAPI = new WorkspaceAPI(parm.PrjInfo.NMDatabase, WorkspaceTypeEnum.GDBFile, true);
- if (NmWsAPI.CurrentWorkspace == null)
- {
- Console.WriteLine("Err:打开年末数据库失败!");
- return;
- }
- _bgTbLayer = OpenLayer(BgWsAPI, "DLTBBG");
- _cjqTbLayer = OpenLayer(BgWsAPI, "CJQ");
- _gxTbLayer = OpenLayer(ZlWsAPI, "DLTBGX");
- _gxgcTBLayer = OpenLayer(ZlWsAPI, "DLTBGXGC");
- _gxPdtLayer = OpenLayer(ZlWsAPI, "PDTGX");
- _nmTbLayer = OpenLayer(NmWsAPI, "DLTB_NMK");
- if (_jcTbLayer == null && !string.IsNullOrEmpty(parm.PrjInfo.JCKPath))
- {
- JCWsAPI = new WorkspaceAPI(parm.PrjInfo.JCKPath, WorkspaceTypeEnum.GDBFile, true);
- if (JCWsAPI.CurrentWorkspace == null)
- {
- Console.WriteLine("Err:打开基础数据库失败!");
- return;
- }
- _jcTbLayer = OpenLayer(JCWsAPI, "DLTB");
- _jcCzcLayer = OpenLayer(JCWsAPI, "CZCDYD");
- CheackJCGDB(_jcTbLayer);
- string pdtgdb = Path.Combine(Path.GetDirectoryName(parm.PrjInfo.JCKPath), parm.PrjInfo.CODE + "PDT.gdb");
- if (Directory.Exists(pdtgdb))
- {
- IWorkspaceAPI pdtwork = new WorkspaceAPI(pdtgdb, WorkspaceTypeEnum.GDBFile, true);
- _jcPdtLayer = OpenLayer(pdtwork, "PDT");
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("Err:打开数据库失败!" + ex.Message + ex.StackTrace);
- throw ex;
- }
- }
-
- public void CheackJCGDB(IFeatureLayer JClayer)
- {
- if (((IDataset)JClayer.FeatureClass).Name != "DLTB")
- {
- throw new Exception("Err:年初地类图斑要素类名称非“DLTB”,需使用国家下发的原始基础库!");
- }
- if (JClayer.FeatureClass.OIDFieldName != "OBJECTID")
- {
- throw new Exception("Err:年初地类图斑数据主键字段非“OBJECTID”,需使用国家下发的原始基础库!");
- }
- if (JClayer.FeatureClass.Fields.FieldCount == 0)
- {
- throw new Exception("Err:年初地类图斑数据字段结构与国家下发模板存在差异,需使用国家下发的原始基础库!");
- }
- string FieldsJH = "OBJECTID,BSM,TBYBH,YSDM,TBBH,DLBM,DLMC,QSXZ,QSDWDM,QSDWMC,ZLDWDM,ZLDWMC,TBMJ,KCDLBM,KCXS,KCMJ,TBDLMJ,GDLX,GDPDJB,XZDWKD,TBXHDM,TBXHMC,ZZSXDM,ZZSXMC,GDDB,FRDBS,CZCSXM,SJNF,MSSM,HDMC,BZ";
- foreach (var item in FieldsJH.Split(','))
- {
- int fieldIndex = JClayer.FeatureClass.Fields.FindField(item);
- if (fieldIndex == -1)
- throw new Exception($"Err:年初地类图斑数据缺失字段“{item}”,需使用国家下发的原始基础库!");
- }
- for (int i = 0; i < JClayer.FeatureClass.Fields.FieldCount; i++)
- {
- IField field = JClayer.FeatureClass.Fields.get_Field(i);
- if (!field.Editable || field.Name.ToUpper().Contains("SHAPE") || field.Name.ToUpper().Contains("XZQTZLX"))
- continue;
- if (!FieldsJH.Contains(field.Name))
- {
- Console.WriteLine($"Err:删除非年初地类图斑数据字段{field.Name}!");
- JClayer.FeatureClass.DeleteField(field);
- }
- }
- if (_jcTbLayer.FeatureClass.FindField("TBXHDM") != -1)
- {
- IField field2 = _jcTbLayer.FeatureClass.Fields.get_Field(_jcTbLayer.FeatureClass.FindField("TBXHDM"));
- if (field2.Length <= 10)
- { //临时修改基础地类图斑字段长度
- IFieldEdit fieldEdit = (IFieldEdit)field2;
- fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
- fieldEdit.Length_2 = 20;
- field2 = fieldEdit as IField;
- }
- }
-
- if (_jcTbLayer.FeatureClass.FindField("XZQTZLX") != -1)
- {
- IField fieldXZQTZLX = _jcTbLayer.FeatureClass.Fields.get_Field(_jcTbLayer.FeatureClass.FindField("XZQTZLX"));
- if (fieldXZQTZLX.Length != 1)
- {
- //临时修改基础地类图斑字段长度
- IFieldEdit fieldEdit = (IFieldEdit)fieldXZQTZLX;
- fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
- fieldEdit.Length_2 = 1;
- fieldXZQTZLX = fieldEdit as IField;
- }
- }
- else
- {
- //添加字段
- IFieldEdit _field = new FieldClass();
- _field.Name_2 = "XZQTZLX";
- _field.AliasName_2 = "行政区调整类型";
- _field.Type_2 = esriFieldType.esriFieldTypeString;
- _field.Length_2 = 1;
- _jcTbLayer.FeatureClass.AddField(_field as IField);
- }
- }
-
- private IWorkspace CreateDBWorkspace(string pDbPath)
- {
- try
- {
- if (!File.Exists(pDbPath))
- {
- Console.WriteLine(string.Format("指定的文件路径{0}不存在!", pDbPath));
- return null;
- }
- IWorkspaceFactory pOutWorkFactory = null;
- pOutWorkFactory = new SqlWorkspaceFactoryClass();
- IWorkspace pOutWork = pOutWorkFactory.OpenFromFile(pDbPath, 0);
- return pOutWork;
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Log:CreateDBWorkspace错误:{ex.Message}{ex.StackTrace}");
- throw;
- }
- }
- private IFeatureLayer ProcessBGTB()
- {
- IFeatureLayer result = null;
- IWorkspaceAPI wsAPI = null;
- IFeatureClassAPI fcAPI = null;
- try
- {
- #region 变更图斑 空属性值 赋值
- string BgtbName = (BgTbLayer.FeatureClass as FeatureClass).BrowseName;
- //Console.WriteLine($"Msg:变更图斑空属性赋值:" + BgtbName);
- //Console.WriteLine($"Log:KCDLBM");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set XZQTZLX =Null where XZQTZLX='3' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set XZQTZLX =Null where XZQTZLX='0' ");//变更层行政区调整类型影响变更过程图斑合并问题;
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set XZQTZLX =Null where XZQTZLX is Null OR XZQTZLX='' or XZQTZLX=' ' or XZQTZLX=' ' ");
- //2025.02.21需求:只要是扣除系数为0的,扣除地类编码都赋为空
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set KCDLBM =Null where KCDLBM is Null or KCDLBM=' ' or KCDLBM=' ' or KCXS=0 ");
- //Console.WriteLine($"Log:KCDLBM");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set GDLX =Null where GDLX is Null or GDLX=' ' or GDLX=' ' ");
- //Console.WriteLine($"Log:GDLX");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set GDPDJB =Null where GDPDJB is Null or GDPDJB=' ' or GDPDJB=' ' ");
- //Console.WriteLine($"Log:GDPDJB");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set XZDWKD=0 where XZDWKD is Null ");
- //Console.WriteLine($"Log:XZDWKD");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set TBXHDM =Null where TBXHDM is Null or TBXHDM=' ' or TBXHDM=' ' ");
- //Console.WriteLine($"Log:TBXHDM");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set TBXHMC =Null where TBXHMC is Null or TBXHMC=' ' or TBXHMC=' ' ");
- //Console.WriteLine($"Log:TBXHMC");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set ZZSXDM =Null where ZZSXDM is Null or ZZSXDM=' ' or ZZSXDM=' ' ");
- //Console.WriteLine($"Log:ZZSXDM");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set ZZSXMC =Null where ZZSXMC is Null or ZZSXMC=' ' or ZZSXMC=' ' ");
- //Console.WriteLine($"Log:ZZSXMC");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set GDDB =0 where GDDB is Null ");
- //Console.WriteLine($"Log:GDDB");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set FRDBS =Null where FRDBS is Null or FRDBS=' ' or FRDBS=' ' ");
- //Console.WriteLine($"Log:FRDBS");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set CZCSXM =Null where CZCSXM is Null or CZCSXM=' ' or CZCSXM=' ' ");
- //Console.WriteLine($"Log:CZCSXM");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set MSSM =Null where MSSM is Null or MSSM=' ' or MSSM=' ' ");
- //Console.WriteLine($"Log:MSSM");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set HDMC =Null where HDMC is Null or HDMC=' ' or HDMC=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set BZ = Null where BZ is Null or BZ = ' ' or BZ= ' ' ");
- #endregion
-
- #region 变更图斑 细化代码,种植代码,BZ 值排序
- IRDBHelper rdbHelper = null;
- List qsDic = null;
- try
- {
- rdbHelper = RDBFactory.CreateDbHelper(System.IO.Path.Combine(Parm.PrjInfo.ProjDir, "BGTJ.sqlite"), DatabaseType.SQLite);
- DataTable dicDt = rdbHelper.ExecuteDatatable("Dic", string.Format("SELECT * from Sys_Dicdetail where OWNERDIC IN(select id from Sys_DicManage where ALIASNAME IN('ZZSX','TBXHLX','BZ'))"), true);
- qsDic = TBToList.ToList(dicDt);
- }
- catch (Exception ex)
- {
- Console.WriteLine("Err:获取权属字典失败_ProcessBGTB!" + ex.Message);
- }
- finally
- {
- rdbHelper?.DisConnect();
- }
- Dictionary XHIndexMap = new Dictionary();//细化下标映射
- foreach (KGIS.Framework.Platform.DataDicTionary Dicitem in qsDic?.FindAll(x => x.OWNERDIC == "31"))
- {
- XHIndexMap[Dicitem.ToString()] = 0;
- }
- Dictionary ZZIndexMap = new Dictionary();//种植下标映射
- foreach (KGIS.Framework.Platform.DataDicTionary Dicitem in qsDic?.FindAll(x => x.OWNERDIC == "32"))
- {
- ZZIndexMap[Dicitem.ToString()] = 0;
- }
- IQueryFilter queFilter = new QueryFilterClass
- {
- WhereClause = @"TBXHDM Like '%\%' Or ZZSXDM Like '%\%' Or BZ Like '%\%'"
- };
- IFeatureCursor BgkCur = BgTbLayer.FeatureClass.Update(queFilter, true);
- IFeature nmkRow = null;
- int TBXHDMIdx = BgTbLayer.FeatureClass.FindField("TBXHDM");
- int TBXHMCIdx = BgTbLayer.FeatureClass.FindField("TBXHMC");
- int ZZSXDMIdx = BgTbLayer.FeatureClass.FindField("ZZSXDM");
- int ZZSXMCIdx = BgTbLayer.FeatureClass.FindField("ZZSXMC");
- int BZIdx = BgTbLayer.FeatureClass.FindField("BZ");
- Dictionary BZIndexMap = new Dictionary();//备注下标映射(暂无)
- while ((nmkRow = BgkCur.NextFeature()) != null)
- {
- #region 细化标注排序赋值
- //重置标注
- XHIndexMap = XHIndexMap.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => 0);
- string TBXHDMValue = nmkRow.Value[TBXHDMIdx].ToTrim().Replace(@"\", "_");
- foreach (var item in TBXHDMValue.Split('_'))
- {
- if (string.IsNullOrWhiteSpace(item)) continue;
- var SorValue = XHIndexMap.FirstOrDefault(x => x.Key.Split('-')[0].Equals(item));
- if (SorValue.Key != null) XHIndexMap[SorValue.Key] = 1;
- }
- if (!string.IsNullOrWhiteSpace(TBXHDMValue))
- {
- TBXHDMValue = string.Empty;
- string TBXHMCValue = string.Empty;
- foreach (var item in XHIndexMap)
- {
- if (item.Value == 1)
- {
- TBXHDMValue += string.Format(@"{0}_", item.Key.Split('-')[0]);
- TBXHMCValue += string.Format(@"{0}_", item.Key.Split('-')[1]);
- }
- }
- nmkRow.Value[TBXHDMIdx] = TBXHDMValue.Trim('_').Replace('_', '\\');
- nmkRow.Value[TBXHDMIdx] = TBXHDMValue.Trim('_').Replace('_', '\\');
- }
- #endregion
-
- #region 种植标注排序赋值
- //重置标注
- ZZIndexMap = ZZIndexMap.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => 0);
- string ZZSXDMValue = nmkRow.Value[ZZSXDMIdx].ToTrim().Replace(@"\", "_");
- foreach (var item in ZZSXDMValue.Split('_'))
- {
- if (string.IsNullOrWhiteSpace(item)) continue;
- var SorValue = ZZIndexMap.FirstOrDefault(x => x.Key.Split('-')[0].Equals(item));
- if (SorValue.Key != null) ZZIndexMap[SorValue.Key] = 1;
- }
- if (!string.IsNullOrWhiteSpace(ZZSXDMValue))
- {
- ZZSXDMValue = string.Empty;
- string ZZSXMCValue = string.Empty;
- foreach (var item in ZZIndexMap)
- {
- if (item.Value == 1)
- {
- ZZSXDMValue += string.Format(@"{0}_", item.Key.Split('-')[0]);
- ZZSXMCValue += string.Format(@"{0}_", item.Key.Split('-')[1]);
- }
- }
- nmkRow.Value[ZZSXDMIdx] = ZZSXDMValue.Trim('_').Replace('_', '\\');
- nmkRow.Value[ZZSXMCIdx] = ZZSXMCValue.Trim('_').Replace('_', '\\');
- }
- #endregion
-
- #region 备注标注排序赋值
- //备注集合不能进行重新排序,非字典元素
- string BZValue = nmkRow.Value[BZIdx].ToTrim().Replace(@"\", "*");
- foreach (var item in BZValue.Split('*'))
- {
- if (string.IsNullOrWhiteSpace(item)) continue;
- BZIndexMap[item] = 1;
- }
- if (!string.IsNullOrWhiteSpace(BZValue))
- {
- BZValue = string.Empty;
- foreach (var item in BZIndexMap)
- if (item.Value == 1)
- BZValue += string.Format(@"{0}*", item.Key);
- nmkRow.Value[BZIdx] = BZValue.Trim('*').Replace('*', '\\');
- BZIndexMap = BZIndexMap.ToDictionary(pair => pair.Key, pair => 0);
- }
- #endregion
- BgkCur.UpdateFeature(nmkRow);
- }
- BgkCur.Flush();
- XHIndexMap.Clear();
- ZZIndexMap.Clear();
- BZIndexMap.Clear();
- #endregion
-
- //拆旧区灭失城镇村
- if (CJQTbLayer.FeatureClass.FeatureCount(null) > 0)
- {
- Console.WriteLine("Msg:正在拆旧区灭失20属性...");
- SetCJQ_CZCMS();
- }
-
- //相邻同属性图斑是否合并(针对原始变更图斑层)
- if (Parm.AllowUnion)
- {
- Console.WriteLine("Msg:正在变更图斑合并...");
- IVariantArray mGPParm = new VarArrayClass();
- mGPParm.Add(BgTbLayer);
- mGPParm.Add(TempDbPath);
- mGPParm.Add("DLTBBG");
- CustomGPHelper.DLTBBGDissolve_Tool(mGPParm);
- wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- fcAPI = wsAPI.OpenFeatureClass("DLTBBG");
- BgTbLayer.FeatureClass = fcAPI.FeatureClass;
- }
-
- IVariantArray mTBBGGPParm = new VarArrayClass();
- mTBBGGPParm.Add(BgTbLayer);
- mTBBGGPParm.Add(JcTbLayer);
- mTBBGGPParm.Add(TempDbPath);
- CustomGPHelper.DLTBBG_Tool(mTBBGGPParm);
-
- //耕地单纯分割赋值逻辑
- if (Parm.AllowPDFZ && Parm.AllowDCFG)
- {
- //基础地类是耕地且变更后依旧是耕地且变更图斑与被动变更图斑都未发生与其他基础库中图斑合并的情况属于耕地单纯分割
- SetDCFGTBPro(TempDbPath);
- IWorkspaceAPI wsTeAPIs = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- IFeatureClassAPI fcTempAPIs = wsTeAPIs.OpenFeatureClass("TempDLTBGX");
- (fcTempAPIs.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Delete From TempDLTBGX WHERE 1=1");
- IFeatureClassAPI BGAPI = new FeatureClassAPI(BgTbLayer.FeatureClass);
- BGAPI.FcToFc(fcTempAPIs.FeatureClass, null, false);
- wsTeAPIs?.CloseWorkspace();
- }
- Console.WriteLine($"Msg:正在进行更新数据处理....");
- if (wsAPI == null)
- wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- fcAPI = wsAPI.OpenFeatureClass("TempDLTBGX");
- if (Parm.AllowPDFZ)
- {
- Console.WriteLine($"Msg:正在进行耕地坡度赋值....");//GDPDJB为0,为" ",为Null 才进行赋值;
- IFeatureLayer tempLayer = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = "地类图斑" };
- IVariantArray mGPParm = new VarArrayClass();
- mGPParm.Add(tempLayer);
- if (GxPdtLayer.FeatureClass.FeatureCount(null) > 0)
- {
- mGPParm.Add(GxPdtLayer);
- CustomGPHelper.SetGDPDJB_Tool(mGPParm);
- if (wsAPI == null)
- wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- fcAPI = wsAPI.OpenFeatureClass("TempDLTBGX");
- }
- else if (JcPdtLayer != null && JcPdtLayer.FeatureClass.FeatureCount(null) > 0)
- {
- mGPParm.Add(JcPdtLayer);
- CustomGPHelper.SetGDPDJB_Tool(mGPParm);
- if (wsAPI == null)
- wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- fcAPI = wsAPI.OpenFeatureClass("TempDLTBGX");
- }
- }
- if (Parm.AllowUnion)
- {
- BgtbName = "TempDLTBGX";
- //Console.WriteLine($"Msg:更新图斑空属性赋值:DLTBGX");
- if (Parm.AutoSetGDLX)
- {
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set GDLX='TT' where GDPDJB in ('2','3','4','5') and DLBM = '0101' and (GDLX <> 'TT' and GDLX <> 'PD' or GDLX is NULL) ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set GDLX='PD' where GDPDJB in ('2','3','4','5') and (DLBM='0102' or DLBM='0103') and (GDLX <> 'TT' and GDLX <> 'PD' or GDLX is NULL) ");
- }
-
- if (Parm.AutoCalcGDKCSX)
- {
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set GDLX =Null,KCDLBM=Null where GDPDJB='1' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set KCXS = 0 where GDPDJB='1' ");
- foreach (string key in Parm.KCXSDic.Keys)
- {
- string[] strGDPDArr = key.Split('-');
- string strGDLX = strGDPDArr[0];
- string strGDPDJB = strGDPDArr[1];
- decimal strKCXS = Parm.KCXSDic[key];
- string strKCDLBM = string.Empty;
- if ("2,3,4,5".Contains(strGDPDJB) && strKCXS != 0)
- strKCDLBM = "1203";
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set KCDLBM ='{strKCDLBM}' where GDPDJB='{strGDPDJB}' and GDLX='{strGDLX}' ");
- if (strGDPDJB == "1")
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set KCXS={strKCXS} where GDPDJB='{strGDPDJB}' and (KCXS is NULL or KCXS<>{strKCXS} )");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set KCXS={strKCXS} where GDPDJB='{strGDPDJB}' and GDLX='{strGDLX}' and (KCXS is NULL or KCXS<>{strKCXS} ) ");
- }
- }
- //2025.02.21需求:只要是扣除系数为0的,扣除地类编码都赋为空
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set KCDLBM =Null where KCDLBM is Null or KCDLBM=' ' or KCDLBM=' ' or KCXS=0 ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set KCXS=0 where KCXS is Null ");//无必要 不注释 数字类型空置赋值
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set GDLX =Null where GDLX is Null or GDLX=' ' or GDLX=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set GDPDJB =Null where GDPDJB is Null or GDPDJB=' ' or GDPDJB=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set XZDWKD=0 where XZDWKD is Null ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set TBXHDM =Null where TBXHDM is Null or TBXHDM=' ' or TBXHDM=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set TBXHMC =Null where TBXHMC is Null or TBXHMC=' ' or TBXHMC=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set ZZSXDM =Null where ZZSXDM is Null or ZZSXDM=' ' or ZZSXDM=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set ZZSXMC =Null where ZZSXMC is Null or ZZSXMC=' ' or ZZSXMC=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set GDDB =0 where GDDB is Null "); // 被动变更图斑GDDB可以为空 / NULL
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set FRDBS =Null where FRDBS is Null or FRDBS=' ' or FRDBS=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set CZCSXM =Null where CZCSXM is Null or CZCSXM=' ' or CZCSXM=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set MSSM =Null where MSSM is Null or MSSM=' ' or MSSM=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set HDMC =Null where HDMC is Null or HDMC=' ' or HDMC=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set BZ =Null where BZ is Null or BZ=' ' or BZ=' ' ");
- wsAPI.CurrentWorkspace.ExecuteSQL($"Update {BgtbName} set XZQTZLX = Null where XZQTZLX is Null OR XZQTZLX='' or XZQTZLX=' ' or XZQTZLX=' '");
- Console.WriteLine($"Msg:更新图斑进行融合....");
- IFeatureLayer tempLayer = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = "地类图斑" };
- IVariantArray mGPParm = new VarArrayClass();
- mGPParm.Add(tempLayer);
- mGPParm.Add(TempDbPath);
- mGPParm.Add("DLTBGX");
- CustomGPHelper.DLTBGXDissolve_Tool(mGPParm);
- wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- fcAPI = wsAPI.OpenFeatureClass("DLTBGX");
- }
- else
- {
- IFeatureLayer tempLayer = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = "地类图斑" };
- IFeatureLayer AllGxTBLayer = null;
- GPParamClass gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = tempLayer;
- gPParamClass.OutFeatureClassPath = TempDbPath;
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.ListDissolveFiledName = new List();
- gPParamClass.FcName = "DLTBGX";
- gPParamClass.GPType = EnumGPType.FcToFc;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref AllGxTBLayer);
- if (wsAPI == null)
- wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- fcAPI = wsAPI.OpenFeatureClass("DLTBGX");
- }
- IFeatureLayer tempDLTBGX = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = "地类图斑更新" };
- if (wsAPI == null)
- wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- IFeatureClassAPI jcFcAPI = wsAPI.OpenFeatureClass("JC_DLTB");
- IFeatureLayer tempJC_DLTB = new FeatureLayerClass() { FeatureClass = jcFcAPI.FeatureClass, Name = "基础地类图斑" };
-
- //IFeatureLayer ptempLayer = null;
- //GPParamClass gPParamClass2 = new GPParamClass();
- //gPParamClass2.FirstFeatureLayer = tempDLTBGX;
- //gPParamClass2.GPType = EnumGPType.Default;
- //GPHelper.Instance.ExeGPForProces(gPParamClass2, ref ptempLayer);
- Console.WriteLine("Msg:过程图斑进行融合....");
- IVariantArray mDLTBGXGCPParm = new VarArrayClass();
- mDLTBGXGCPParm.Add(tempDLTBGX);
- mDLTBGXGCPParm.Add(tempJC_DLTB);
- mDLTBGXGCPParm.Add(TempDbPath);
- CustomGPHelper.DLTBGXGC_Tool(mDLTBGXGCPParm);
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Log:变更前执行变更图斑数据处理失败:{ex.Message}");
- Console.WriteLine($"Log:变更前执行变更图斑数据处理失败:{ex.StackTrace}");
- throw ex;
- }
- return result;
- }
-
- private void SetCJQ_CZCMS()
- {
- IFeatureLayer DLTBBGCJQLayer = null;
- IFeatureLayer JCCZCJQLayer = null;
- IFeatureLayer JCDLTBJQLayer = null;
- try
- {
- string TempDir = CommonHelper.CreateTempDB("CZCMS");
- string TempGDBPath = Path.Combine(TempDir, "TempGDB.gdb");
- IVariantArray mTBBGGPParm = new VarArrayClass();
- mTBBGGPParm.Add(BgTbLayer);
- mTBBGGPParm.Add(JcTbLayer);
- mTBBGGPParm.Add(TempGDBPath);
- CustomGPHelper.DLTBBG_Tool(mTBBGGPParm);
- IWorkspaceAPI wsTeAPI = new WorkspaceAPI(TempGDBPath, WorkspaceTypeEnum.GDBFile, true);
- IFeatureClassAPI fcTempAPI = wsTeAPI.OpenFeatureClass("TempDLTBGX");
- if (wsTeAPI.ExistFeatureClass("DLTBBG")) wsTeAPI.DeleteFeatureClass("DLTBBG");
- IFeatureClassAPI TempBGTempAPI = wsTeAPI.CreateFeatureClass("DLTBBG", (BgTbLayer.FeatureClass as IGeoDataset).SpatialReference, BgTbLayer.FeatureClass.Fields);
- fcTempAPI.FcToFc(TempBGTempAPI.FeatureClass, null, false);
- BgTbLayer.FeatureClass = TempBGTempAPI.FeatureClass;
- fcTempAPI?.CloseFeatureClass();
-
- GPParamClass paramClass = new GPParamClass()
- {
- FirstFeatureLayer = BgTbLayer,
- SecondFeatureLayer = CJQTbLayer,
- OutFeatureClassPath = $"{Path.Combine(TempDir, "TempGDB.gdb")}\\DLTBBGCJQ",
- IsGetOutPutFeature = true,
- Tolerance = "0.0001",
- PreserveAttributes = "ALL"
- };
- GeoprocessorHelper.UnionAnalysis(paramClass, ref DLTBBGCJQLayer);
- IFeatureCursor cursor = DLTBBGCJQLayer.FeatureClass.Search(new QueryFilterClass() { WhereClause = " FID_CJQ > 0 AND FID_DLTBBG > 0 AND CZCSXM = '203'" }, true);
- int FID_DLTBBGindex = DLTBBGCJQLayer.FeatureClass.FindField("FID_DLTBBG");
- int JCZTindex = DLTBBGCJQLayer.FeatureClass.FindField("JCZT");
- IFeature MSBGTB_F = null;//主动变更拆旧区灭失
- while ((MSBGTB_F = cursor.NextFeature()) != null)
- {
- int FID_DLTBBGOID = MSBGTB_F.Value[FID_DLTBBGindex].ToInt();
- IFeature Bg_F = BgTbLayer.FeatureClass.GetFeature(FID_DLTBBGOID);//擦除后查看是否是完全灭失
- string DLBMValue = Bg_F.Value[Bg_F.Class.FindField("DLBM")].ToString();//建设用地直接过滤
- if (TBDLBMTypeList.DLBMs_JSYD_SList.Contains(DLBMValue.Trim())) continue;
- IGeometry DisGeo = AECommonHelper.EraseGeometry(Bg_F.ShapeCopy, MSBGTB_F.ShapeCopy);
- if (DisGeo == null || DisGeo.IsEmpty || DisGeo.GetEllipseArea() < 30)
- { //完全擦除或剩余30以内变更图斑直接全部灭失
- Bg_F.Value[Bg_F.Class.FindField("JCZT")] = "WQMS";
- Bg_F.Value[Bg_F.Class.FindField("CZCSXM")] = "";
- Bg_F.Store();
- } //灭失部分小于30平,同样进行灭失处理,出现碎图斑 当前由客户处理
- else
- {
- List geometrieDiss = FeatureAPI.DissolveGeometryByRing(DisGeo);
- for (int i = 0; i < geometrieDiss.Count; i++)
- {
- if (i == 0)
- {
- Bg_F.Shape = geometrieDiss[0];
- Bg_F.Store();
- }
- else
- {
- IFeature fMs_AddF = BgTbLayer.FeatureClass.CreateFeature();
- fMs_AddF.Shape = geometrieDiss[i];
- fMs_AddF.CopyFeatureAtt(Bg_F);
- fMs_AddF.Value[fMs_AddF.Class.FindField("TBMJ")] = geometrieDiss[i].GetEllipseArea();
- fMs_AddF.Value[fMs_AddF.Class.FindField("JCZT")] = "CFMS";//多部件非灭失部分
- fMs_AddF.Store();
- }
- }
- //IGeometry MsGeo = FeatureAPI.InterSect(Bg_F.ShapeCopy, MSBGTB_F.ShapeCopy);
- List geoInterSect = FeatureAPI.DissolveGeometryByRing(MSBGTB_F.ShapeCopy);
- if (geoInterSect != null && geoInterSect.Count >= 1)
- {
- foreach (IGeometry Interitem in geoInterSect)
- {
- IFeature Ms_AddF = BgTbLayer.FeatureClass.CreateFeature();
- Ms_AddF.Shape = Interitem;
- Ms_AddF.CopyFeatureAtt(Bg_F);
- Ms_AddF.Value[Ms_AddF.Class.FindField("CZCSXM")] = "";
- Ms_AddF.Value[Ms_AddF.Class.FindField("JCZT")] = "BFMS";
- Ms_AddF.Value[Ms_AddF.Class.FindField("TBMJ")] = Interitem.GetEllipseArea();
- Ms_AddF.Store();//与拆旧区相交区域 灭失20属性
- }
- }
- }
- }
- if (MSBGTB_F != null)
- Marshal.ReleaseComObject(MSBGTB_F);
-
- //删除不在拆旧区部分图斑 且 自主变更图斑
- (DLTBBGCJQLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(" Delete From DLTBBGCJQ WHERE FID_CJQ <= 0 or FID_DLTBBG > 0 ");
- paramClass = new GPParamClass()
- {
- FirstFeatureLayer = JcCzcLayer,
- SecondFeatureLayer = DLTBBGCJQLayer,
- OutFeatureClassPath = $"{Path.Combine(TempDir, "TempGDB.gdb")}\\JCCZCCJQ",
- IsGetOutPutFeature = true,
- Tolerance = "0.0001",
- PreserveAttributes = "ALL"
- };
- GeoprocessorHelper.UnionAnalysis(paramClass, ref JCCZCJQLayer);
- cursor = JCCZCJQLayer.FeatureClass.Search(new QueryFilterClass() { WhereClause = "FID_CZCDYD > 0 and FID_DLTBBGCJQ > 0 and CZCLX = '203' " }, true);
- IFeature XZBGTB_F = null;
- Dictionary keyValuePairs = new Dictionary();
- while ((XZBGTB_F = cursor.NextFeature()) != null)
- {
- List Jc_Fs = FeatureAPI.Identify2(XZBGTB_F.ShapeCopy, JcTbLayer);
- foreach (IFeature Jc_item in Jc_Fs)
- {
- string DLBMValue = Jc_item.Value[Jc_item.Class.FindField("DLBM")].ToString();//建设用地直接过滤
- string CZCSXMValue = Jc_item.Value[Jc_item.Class.FindField("CZCSXM")].ToString();//建设用地直接过滤
- string BSMValue = Jc_item.Value[Jc_item.Class.FindField("BSM")].ToString();//建设用地直接过滤
- if (TBDLBMTypeList.DLBMs_JSYD_SList.Contains(DLBMValue.Trim())) continue;
- IGeometry geometry = FeatureAPI.InterSect(XZBGTB_F.ShapeCopy, Jc_item.ShapeCopy);
- IGeometry Disgeo = FeatureAPI.Difference(Jc_item.ShapeCopy, geometry);
- //if (geometry.GetEllipseArea() < 30) continue;
- if (!keyValuePairs.ContainsKey(BSMValue))
- keyValuePairs.Add(BSMValue, "00");
- else continue;
- IFeature Ms_AddF = BgTbLayer.FeatureClass.CreateFeature();
- if (string.IsNullOrWhiteSpace(CZCSXMValue) || Disgeo.GetEllipseArea() < 30)
- {
- Ms_AddF.Shape = Jc_item.ShapeCopy;
- Ms_AddF.CopyFeatureAtt(Jc_item);
- Ms_AddF.Value[Ms_AddF.Class.FindField("CZCSXM")] = "";
- Ms_AddF.Value[Ms_AddF.Class.FindField("JCZT")] = "AddMS";
- Ms_AddF.Store();
- continue;
- }
- else
- {
- Ms_AddF.Shape = geometry;
- }
- Ms_AddF.CopyFeatureAtt(Jc_item);
- Ms_AddF.Value[Ms_AddF.Class.FindField("CZCSXM")] = "";
- Ms_AddF.Value[Ms_AddF.Class.FindField("JCZT")] = "AddMS";
- Ms_AddF.Store();
- List geometries = FeatureAPI.DissolveGeometryByRing(Disgeo);
- if (!Disgeo.IsEmpty && geometries.Count > 1)
- {
- for (int i = 0; i < geometries.Count; i++)
- {
- if (!geometries[i].IsEmpty && geometries[i].GetEllipseArea() < 30)
- {
- IFeature BfMs_AddF = BgTbLayer.FeatureClass.CreateFeature();
- BfMs_AddF.Shape = geometries[i];
- BfMs_AddF.CopyFeatureAtt(Jc_item);
- BfMs_AddF.Value[BfMs_AddF.Class.FindField("CZCSXM")] = "";
- BfMs_AddF.Value[BfMs_AddF.Class.FindField("JCZT")] = "Bf2AddMS";
- BfMs_AddF.Store();
- }
- }
- }
- }
- }
- (JCCZCJQLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(" Delete From JCCZCCJQ WHERE FID_CZCDYD > 0 ");
- paramClass = new GPParamClass()
- {
- FirstFeatureLayer = JcTbLayer,
- SecondFeatureLayer = JCCZCJQLayer,
- OutFeatureClassPath = $"{Path.Combine(TempDir, "TempGDB.gdb")}\\JCDLTBCJQ",
- IsGetOutPutFeature = true,
- Tolerance = "0.0001",
- PreserveAttributes = "ALL"
- };
- GeoprocessorHelper.IntersectAnalysis(paramClass, ref JCDLTBJQLayer);
- cursor = JCDLTBJQLayer.FeatureClass.Search(new QueryFilterClass() { WhereClause = "FID_DLTB > 0 and FID_DLTBBGCJQ > 0 and CZCSXM = '203' " }, true);
- int DLTBOID = JCDLTBJQLayer.FeatureClass.FindField("FID_DLTB");
- while ((XZBGTB_F = cursor.NextFeature()) != null)
- {
- IFeature Jc_F = JcTbLayer.FeatureClass.GetFeature(XZBGTB_F.Value[DLTBOID].ToInt());
- if (XZBGTB_F.ShapeCopy.GetEllipseArea() >= 30)//小于三十平是上述逻辑所包含的
- {
- IFeature BfMs_AddF = BgTbLayer.FeatureClass.CreateFeature();
- BfMs_AddF.Shape = XZBGTB_F.ShapeCopy;
- BfMs_AddF.CopyFeatureAtt(Jc_F);
- BfMs_AddF.Value[BfMs_AddF.Class.FindField("CZCSXM")] = "";
- BfMs_AddF.Value[BfMs_AddF.Class.FindField("JCZT")] = "Bf3AddMS";
- BfMs_AddF.Store();
- }
- }
- if (XZBGTB_F != null)
- Marshal.ReleaseComObject(XZBGTB_F);
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Err:拆旧区进行城镇村灭失异常:{ex.Message + ex.StackTrace}");
- throw ex;
- }
- }
-
- private readonly List ListDissolveFileds = new List() { "DLBM", "DLMC", "QSXZ", "QSDWDM", "ZLDWDM", "ZLDWMC", "KCDLBM", "KCXS", "GDLX", "GDPDJB", "XZDWKD", "TBXHDM", "TBXHMC", "ZZSXDM", "ZZSXMC", "GDDB", "FRDBS", "CZCSXM", "MSSM", "HDMC", "BZ", "XZQTZLX", "GCZZ" };
- private void SetDCFGTBPro(string TempDbPath)
- {
- IFeatureLayer outFeatureLayer = null;
- try
- {
- IWorkspaceAPI wsTeAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile, true);
- IFeatureClassAPI fcTempAPI = wsTeAPI.OpenFeatureClass("TempDLTBGX");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTBBG WHERE 1=1");
- fcTempAPI.FcToFc(BgTbLayer.FeatureClass, null, false);
- fcTempAPI?.CloseFeatureClass();
- IFeatureClassAPI DLTB_FDL = wsTeAPI.CreateFeatureClass("DLTB", (JcTbLayer.FeatureClass as IGeoDataset).SpatialReference, JcTbLayer.FeatureClass.Fields);
- IFeatureClassAPI JC_DLTBAPI = wsTeAPI.OpenFeatureClass("JC_DLTB");
- JC_DLTBAPI.FcToFc(DLTB_FDL.FeatureClass, null, false);
- IFeatureLayer SelectFeatureLayer = new FeatureLayer() { FeatureClass = DLTB_FDL.FeatureClass, Name = "DLTB" };
-
- if (true)//是否默认清除GDPDJB属性值(false-保留客户填写:ture-程序一键处理)
- (BgTbLayer as FeatureClass).Workspace.ExecuteSQL($"update DLTBBG set GDPDJB='0' where DLBM in('0101','0102','0103')");
- (BgTbLayer as FeatureClass).Workspace.ExecuteSQL($"update DLTBBG set GDPDJB=NULL where DLBM not in('0101','0102','0103')");
- List DLTBints = new List();
- List DLTBintsTemp = new List();
- string TempDir = CommonHelper.CreateTempDB("GDFZ");
- IWorkspaceAPI tempBGAPI = new WorkspaceAPI(Path.Combine(TempDir, "TempGDB.gdb"), WorkspaceTypeEnum.GDBFile, true);
- //Console.WriteLine($"Log:正在进行耕地单纯分割赋值分析:");
- GPParamClass paramClass = new GPParamClass()
- {
- FirstFeatureLayer = BgTbLayer,
- SecondFeatureLayer = SelectFeatureLayer,
- OutFeatureClassPath = $"{Path.Combine(TempDir, "TempGDB.gdb")}\\DLTBBG",
- IsGetOutPutFeature = true,
- Tolerance = "0.0001",
- PreserveAttributes = "ALL"
- };
- GeoprocessorHelper.UnionAnalysis(paramClass, ref outFeatureLayer);
- IWorkspace pOutWork;
- if (outFeatureLayer != null)
- {
- string dbPath = TempDir + @"\Temp" + ".sqlite";
- pOutWork = CreateDBWorkspace(dbPath);
- IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
- rdbHelper.ExecuteSQL(" drop table DLTBBG ");
- TableToTable((outFeatureLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace, pOutWork, "DLTBBG", new QueryFilterClass() { WhereClause = "Shape_Area>0.01" });
- string KJCKSql = "FID_DLTB not In(Select FID_DLTB From DLTBBG where FID_DLTBBG IN(Select FID_DLTBBG from DLTBBG GROUP by FID_DLTBBG HAVING COUNT(FID_DLTBBG)>1))";
- string FGDSql = "Select FID_DLTB from DLTBBG where DLBM not in('0101','0102','0103') or DLBM_1 not in('0101','0102','0103')";
- DataTable DCData_dt = rdbHelper.ExecuteDatatable("FGD_dt", $"Select * from DLTBBG where " +
- $"( {KJCKSql} and FID_DLTB not In({FGDSql}) ) AND FID_DLTB<>-1", true);
- //Console.WriteLine($"Msg:正在进行单纯分割图斑数据赋值...");
- foreach (DataRow item in DCData_dt.Rows)
- {
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"update DLTBBG set GDPDJB='{item["GDPDJB_1"]}' where OBJECTID={item["FID_DLTBBG"]} ");
- //if (!string.IsNullOrWhiteSpace(item["KCXS_1"].ToString()))
- // (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"update DLTBBG set KCXS={item["KCXS_1"]} where KCXS is NULL and OBJECTID={item["FID_DLTBBG"]} ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"update DLTBBG set GDLX='{item["GDLX_1"]}' where (GDLX='' OR GDLX is NULL) AND OBJECTID={item["FID_DLTBBG"]}");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"update DLTBBG set KCDLBM='{item["GDLX_1"]}' where OBJECTID={item["FID_DLTBBG"]}");
- }
- }
-
- #region 补充逻辑
- if (tempBGAPI.ExistFeatureClass("DLTBBG")) tempBGAPI.DeleteFeatureClass("DLTBBG");//用更新图斑替代变更字段模版,免除图斑融合逻辑
- #region 坡度占优比&&配置扣除系数
- //Console.WriteLine($"Log:正在进行坡度占优比计算...");
- IVariantArray mGPParm = new VarArrayClass();
- mGPParm.Add(BgTbLayer);
- mGPParm.Add(JcPdtLayer);
- CustomGPHelper.SetGDPDJB_Tool(mGPParm);
- Dictionary _kcxsDic = new Dictionary();//《字符串-数字》字典集合
- string strPath = Parm.PrjInfo.ProjDir + "\\BG_GDLXConfig.xml";//获取配置文件路径
- if (string.IsNullOrWhiteSpace(strPath) || !File.Exists(strPath))
- strPath = SysAppPath.GetBGGDLXConfigPath();
- XDocument xDoc = XDocument.Load(strPath);
- foreach (XElement xElement in xDoc.Descendants("Item"))
- {
- string gdlx = xElement.Attributes("GDLX").Single().Value;
- string gdpdjb = xElement.Attributes("GDPDJB").Single().Value;
- string strKcdlxs = xElement.Attributes("KCDLXS").Single().Value;
- decimal kcdlxs = Convert.ToDecimal(xElement.Attributes("KCDLXS").Single().Value == "" ? "0" : xElement.Attributes("KCDLXS").Single().Value);
- string key = string.Format("{0}-{1}", gdlx, gdpdjb);
- _kcxsDic.Add(key, kcdlxs);
- }
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update DLTBBG set GDLX ='TT' where DLBM='0101' AND (GDPDJB='2' OR GDPDJB='3' OR GDPDJB='4' OR GDPDJB='5') and (GDLX='' OR GDLX is NULL)");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update DLTBBG set GDLX ='PD' where (DLBM='0102' OR DLBM='0103') AND (GDPDJB='2' OR GDPDJB='3' OR GDPDJB='4' OR GDPDJB='5') and (GDLX='' OR GDLX is NULL)");
- foreach (string key in _kcxsDic.Keys)
- {
- string[] strGDPDArr = key.Split('-');
- string strGDLX = strGDPDArr[0];
- string strGDPDJB = strGDPDArr[1];
- decimal strKCXS = _kcxsDic[key];
- string strKCDLBM = string.Empty;
- if ("2,3,4,5".Contains(strGDPDJB) && strKCXS != 0)
- strKCDLBM = "1203";
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update DLTBBG set KCDLBM ='{strKCDLBM}' where GDPDJB='{strGDPDJB}' and GDLX='{strGDLX}' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update DLTBBG set KCXS={strKCXS} where GDPDJB='{strGDPDJB}' and GDLX='{strGDLX}' and (GCZZ='' OR GCZZ=' ' OR GCZZ is NULL) ");
- }
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update DLTBBG set KCDLBM =Null,GDLX=Null where GDPDJB='1' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update DLTBBG set KCXS=0 where GDPDJB='1' and KCXS is NULL ");
- #endregion
-
- #region 变更图斑赋值
- string BgtbName = (BgTbLayer.FeatureClass as FeatureClass).BrowseName;
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set XZQTZLX =Null where XZQTZLX='3' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set XZQTZLX =Null where XZQTZLX='0' ");//变更层行政区调整类型影响变更过程图斑合并问题;
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set XZQTZLX =Null where XZQTZLX is Null OR XZQTZLX='' or XZQTZLX=' ' or XZQTZLX=' ' ");
- //2025.02.21需求:只要是扣除系数为0的,扣除地类编码都赋为空
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set KCDLBM =Null where KCDLBM is Null or KCDLBM=' ' or KCDLBM=' ' or KCXS=0 ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set KCXS=0 where KCXS is Null ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set GDLX =Null where GDLX is Null or GDLX=' ' or GDLX=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set GDPDJB =Null where GDPDJB is Null or GDPDJB=' ' or GDPDJB=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set XZDWKD=0 where XZDWKD is Null ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set TBXHDM =Null where TBXHDM is Null or TBXHDM=' ' or TBXHDM=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set TBXHMC =Null where TBXHMC is Null or TBXHMC=' ' or TBXHMC=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set ZZSXDM =Null where ZZSXDM is Null or ZZSXDM=' ' or ZZSXDM=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set ZZSXMC =Null where ZZSXMC is Null or ZZSXMC=' ' or ZZSXMC=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set GDDB =0 where GDDB is Null "); //被动变更图斑GDDB可以为空/NULL
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set FRDBS =Null where FRDBS is Null or FRDBS=' ' or FRDBS=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set CZCSXM =Null where CZCSXM is Null or CZCSXM=' ' or CZCSXM=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set MSSM =Null where MSSM is Null or MSSM=' ' or MSSM=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set HDMC =Null where HDMC is Null or HDMC=' ' or HDMC=' ' ");
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set BZ =Null where BZ is Null or BZ=' ' or BZ=' ' ");
- #endregion
-
- IFeatureLayer Temp2Layer = null;
- IWorkspaceAPI wsAPI = new WorkspaceAPI(Path.Combine(TempDir, "TempGDB.gdb"), WorkspaceTypeEnum.GDBFile, true);
- IFeatureClassAPI DLTBBG_FDL = wsAPI.CreateFeatureClass("DLTBBG_FDL1", (BgTbLayer.FeatureClass as IGeoDataset).SpatialReference, BgTbLayer.FeatureClass.Fields);
- IFeatureClassAPI fcBGAPI = new FeatureClassAPI(BgTbLayer.FeatureClass);
- fcBGAPI.FcToFc(DLTBBG_FDL.FeatureClass, new QueryFilterClass() { WhereClause = " DLBM <> '1001' and DLBM <> '1002' and DLBM <> '1003' and DLBM <> '1004' and DLBM <> '1006' and DLBM <> '1009' and DLBM <> '1101' and DLBM <> '1107' and DLBM <> '1107A' " }, false);
- paramClass = new GPParamClass()
- {
- FirstFeatureLayer = new FeatureLayer() { FeatureClass = DLTBBG_FDL.FeatureClass, Name = "DLTBBG_FDL1" },
- OutFeatureClassPath = $"{Path.Combine(TempDir, "TempGDB.gdb")}\\DLTBBG1",
- IsGetOutPutFeature = true,
- Tolerance = "0.0001",
- ListDissolveFiledName = ListDissolveFileds
- };//非现状地物图斑融合
- GeoprocessorHelper.DissolveAnalysis(paramClass, ref Temp2Layer);
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTBBG WHERE DLBM <> '1001' and DLBM <> '1002' and DLBM <> '1003' and DLBM <> '1004' and DLBM <> '1006' and DLBM <> '1009' and DLBM <> '1101' and DLBM <> '1107' and DLBM <> '1107A' ");
- fcBGAPI = new FeatureClassAPI(Temp2Layer.FeatureClass);
- fcBGAPI.FcToFc(BgTbLayer.FeatureClass, null, false);
- if (tempBGAPI.ExistFeatureClass("DLTBBG"))
- tempBGAPI.DeleteFeatureClass("DLTBBG");
- //Console.WriteLine($"Log:正在进行单纯分割数据二次分析...");
- IFeatureLayer out2FeatureLayer = null;//二次更新单纯分割数据
- paramClass = new GPParamClass()
- {
- FirstFeatureLayer = BgTbLayer,
- SecondFeatureLayer = SelectFeatureLayer,
- OutFeatureClassPath = $"{Path.Combine(TempDir, "TempGDB.gdb")}\\DLTBBG",
- IsGetOutPutFeature = true,
- Tolerance = "0.0001",
- PreserveAttributes = "ALL"
- };
- GeoprocessorHelper.UnionAnalysis(paramClass, ref out2FeatureLayer);
- if (out2FeatureLayer != null)
- {
- string DelDLTBOIDs = ",";
- string dbPath = TempDir + @"\Temp" + ".sqlite";
- pOutWork = CreateDBWorkspace(dbPath);
- IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
- rdbHelper.ExecuteSQL(" drop table DLTBBG ");
- TableToTable((out2FeatureLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace, pOutWork, "DLTBBG", new QueryFilterClass() { WhereClause = "Shape_Area>0.01" });
- //跨基础库变更图斑
- string KJCKSql = "FID_DLTB In(Select FID_DLTB From DLTBBG where FID_DLTBBG IN(Select FID_DLTBBG from DLTBBG GROUP by FID_DLTBBG HAVING COUNT(FID_DLTBBG)>1))";
- DataTable KJCK_dt = rdbHelper.ExecuteDatatable("KJCK_dt", @"Select * from DLTBBG where " +
- $"( {KJCKSql} and DLBM in('0101','0102','0103') ) AND FID_DLTB<>-1", true);//DLBM_1已是耕地类型
- var DLTB_GDList = TBToList.ToList(KJCK_dt);
- foreach (var item in DLTB_GDList)
- {
- DelDLTBOIDs += $"{item.FID_DLTBBG},";
- }
- //因为融合由单纯分割变成非单纯分割图斑,重新赋值耕地坡度级别
- if (!string.IsNullOrWhiteSpace(DelDLTBOIDs.Trim(',')))
- (BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"update DLTBBG set GDPDJB='0' where OBJECTID in({DelDLTBOIDs.Trim(',')})");
- }
- #endregion
- DLTB_FDL?.CloseFeatureClass();
- JC_DLTBAPI?.CloseFeatureClass();
- wsTeAPI?.CloseWorkspace();
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Err:耕地单纯分割赋值异常:{ex.Message + ex.StackTrace}");
- throw ex;
- }
- }
-
- ///
- /// 新增质检规则“地类图斑更新过程层变更前图斑细化代码标注“LQGD”,“MQGD”,“SHGD”,“SMGD”,变更后地类为耕地的图斑,变更前后图斑细化代码应保持不变”,地类图斑更新过程层变更前图斑细化代码为林区耕地、牧区耕地、沙荒耕地或石漠化耕地,变更后地类仍为耕地的图斑,变更前后图斑细化代码应保持不变。
- ///
- ///
- ///
- private void GD_TBXHDM()
- {
- IWorkspace pOutWork = null;
- GPParamClass paramClass = new GPParamClass();
- IFeatureLayer IntersectLayer = null;
- IFeatureSelection jcfeatureSelection = null;
- IFeatureSelection bgfeatureSelection = null;
- try
- {
- string TempDir = CommonHelper.CreateTempDB("BGTB_JCDLTB");
- string temppath = System.IO.Path.Combine(TempDir, "TempGDB.gdb");
- bgfeatureSelection = BgTbLayer as IFeatureSelection;
- bgfeatureSelection.Clear();
- bgfeatureSelection.SelectFeatures(new QueryFilterClass() { WhereClause = "dlbm in ('0101','0102','0103') and (tbxhdm is null or tbxhdm='')" }, esriSelectionResultEnum.esriSelectionResultNew, false);
- if ((BgTbLayer as IFeatureSelection).SelectionSet.Count > 0)
- {
- jcfeatureSelection = JcTbLayer as IFeatureSelection;
- jcfeatureSelection.Clear();
- jcfeatureSelection.SelectFeatures(new QueryFilterClass() { WhereClause = "tbxhdm in('LQGD','MQGD','SHGD','SMGD')" }, esriSelectionResultEnum.esriSelectionResultNew, false);
- if ((JcTbLayer as IFeatureSelection).SelectionSet.Count > 0)
- {
- GPParamClass gPParamClass = new GPParamClass
- {
- FirstFeatureLayer = BgTbLayer,
- SecondFeatureLayer = JcTbLayer,
- OutFeatureClassPath = $"{temppath}\\BGTBJCDLTB",
- IsGetOutPutFeature = true,
- GPType = EnumGPType.Intersect
- };
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref IntersectLayer);
- }
- }
- bgfeatureSelection.Clear();
- jcfeatureSelection.Clear();
- if (IntersectLayer != null)
- {
- IFeature feature = null;
- IFeatureCursor Cursor = IntersectLayer.FeatureClass.Search(new QueryFilterClass() { WhereClause = " dlbm in ('0101','0102','0103') and (tbxhdm is null or tbxhdm='') and tbxhdm_1 in('LQGD','MQGD','SHGD','SMGD')" }, false);
- var ibgtboid = IntersectLayer.FeatureClass.FindField("FID_DLTBBG");
- var ixhdm = IntersectLayer.FeatureClass.FindField("TBXHDM_1");
- var ixhmc = IntersectLayer.FeatureClass.FindField("TBXHMC_1");
- while ((feature = Cursor.NextFeature()) != null)
- {
- string oid = feature.Value[ibgtboid].ToTrim();
- string TBXHDM = feature.Value[ixhdm].ToTrim();
- string TBXHMC = feature.Value[ixhmc].ToTrim();
- (BgTbLayer as FeatureClass).Workspace.ExecuteSQL($"update DLTBBG set TBXHDM='{TBXHDM}' where OBJECTID={oid} ");
- (BgTbLayer as FeatureClass).Workspace.ExecuteSQL($"update DLTBBG set TBXHMC='{TBXHMC}' where OBJECTID={oid} ");
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Err:变更前执行变更图斑数据处理失败:{ex.Message + ex.StackTrace}");
- }
- finally
- {
- if (pOutWork != null)
- Marshal.ReleaseComObject(pOutWork);
- }
- }
-
- private IFeatureLayer GenerateTempGXGC(IFeatureLayer pTempBgTbLayer, string pTempAttrDBPath)
- {
- IFeatureLayer result = null;
- GPParamClass paramClass = new GPParamClass();
- try
- {
-
- //GPParamClass paramClass = new GPParamClass();
-
-
- IFeatureLayer tempLayer = null;
-
- paramClass = new GPParamClass();
- paramClass.FirstFeatureLayer = JcTbLayer;
- paramClass.SecondFeatureLayer = pTempBgTbLayer;
- paramClass.TempGDBPath = $"{TempDbPath}";
- paramClass.Tolerance = "-0.001";
- paramClass.IsGetOutPutFeature = true;
- paramClass.GPType = EnumGPType.YBG;
- GPHelper.Instance.ExeGPForProces(paramClass, ref tempLayer);
- IWorkspaceAPI wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile);
- IFeatureClassAPI fcAPI = wsAPI.OpenFeatureClass("GXGC_Multipart");
- result = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName };
-
- return result;
-
- #region 设置基础地类图斑选中
- if (JcTbLayer.FeatureClass.FeatureCount(null) != pTempBgTbLayer.FeatureClass.FeatureCount(null))
- {
- paramClass.Tolerance = "0.0001";
- paramClass.FirstFeatureLayer = JcTbLayer;
- paramClass.SecondFeatureLayer = pTempBgTbLayer;
- paramClass.IsGetOutPutFeature = true;
- paramClass.GPType = EnumGPType.SelectLayerByLocation;
- paramClass.Overlap_type = "INTERSECT";
- GPHelper.Instance.ExeGPForProces(paramClass, ref result);
-
- }
- #endregion
-
- #region 变更层与基础地类图斑联合
- paramClass = new GPParamClass()
- {
- FirstFeatureLayer = pTempBgTbLayer,
- SecondFeatureLayer = result,
- OutFeatureClassPath = $"{TempDbPath}\\BGTB_DLTBUnion",
- IsGetOutPutFeature = true,
- PreserveAttributes = "ALL",
- GPType = EnumGPType.Union
- };
- GPHelper.Instance.ExeGPForProces(paramClass, ref result);
- #endregion
-
- #region 拆分多部件
- paramClass = new GPParamClass();
- paramClass.FirstFeatureLayer = result;
- paramClass.OutFeatureClassPath = $"{TempDbPath}\\GXGC_Multipart";
- paramClass.IsGetOutPutFeature = true;
- paramClass.GPType = EnumGPType.MultipartToSinglePath;
- GPHelper.Instance.ExeGPForProces(paramClass, ref result);
- #endregion
-
-
- #region TableToTable
- string dbPath = pTempAttrDBPath;
- IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
- rdbHelper.ExecuteSQL(" drop table GXGC_Multipart ");
- rdbHelper.DisConnect();
- IWorkspace ws = (result.FeatureClass as FeatureClass).Workspace;
- //添加字段
- IFieldEdit _field = new FieldClass();
- _field.Name_2 = "BGXW";
- _field.Type_2 = esriFieldType.esriFieldTypeString;
- _field.Length_2 = 2;
- if (result.FeatureClass.FindField("BGXW") == -1)
- result.FeatureClass.AddField(_field as IField);
- //矢量数据至db文件
- //(result.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "Shape_area < 0.01" });
- TableToTable(ws as IFeatureWorkspace, pOutWork, "GXGC_Multipart");
- #endregion
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Log:生成临时更新过程层数据失败:{ex.Message}");
- throw ex;
- }
- return result;
- }
-
- public void GDPDExcute()
- {
- //IFeatureClassAPI GXAPI = null;
- //IFeatureClassAPI pdtFcAPI = null;
- IFeatureLayer PDTLayer = null;
- IFeature feature = null;
- IFeatureCursor cursor = null;
- IWorkspaceFactory pFtWsFct = null;
- IWorkspaceName workspaceName = null;
- IFeatureLayer unionLayer = null;
- IFeatureClassAPI unionFcAPI = null;
- try
- {
- Console.WriteLine("Msg:正在进行耕地坡度级别赋值,请稍后...");
-
- #region 变更图斑层(GDB)
- //// 获取变更图斑
- //GXAPI = new FeatureClassAPI(BgTbLayer.FeatureClass);
- //if (GXAPI == null || GXAPI.FeatureClass == null)
- //{
- // Console.WriteLine("Err:未获取到更新层图斑");
- // return;
- //}
- #endregion
- #region 坡度图层(MDB)
- PDTLayer = GxPdtLayer;
- if (GxPdtLayer == null && JcPdtLayer == null)
- {
- Console.WriteLine("Warning:当前工程不存在坡度图图层!");
- return;
- }
- if (PDTLayer.FeatureClass.FeatureCount(null) <= 0)
- {
- PDTLayer = JcPdtLayer;
- }
- if (PDTLayer.FeatureClass.FeatureCount(null) <= 0)
- {
- Console.WriteLine("Warning:当前工程中未导入坡度数据!");
- return;
- }
- #endregion
-
-
- //IWorkspaceAPI psTempWorkspaceAPI = new WorkspaceAPI(pTempGDbPath, WorkspaceTypeEnum.GDBFile);
- //IFeatureClassAPI tempdltbgxFeatureclassAPI = psTempWorkspaceAPI.CreateFeatureClass("TempDLTBGX", (BgTbLayer.FeatureClass as IGeoDataset).SpatialReference, BgTbLayer.FeatureClass.Fields);
- //tempdltbgxFeatureclassAPI.AddField("OLDOBJECTID", esriFieldType.esriFieldTypeInteger, "老OBJECTID");
- //IFeatureClass tempdltbgxFC = tempdltbgxFeatureclassAPI.FeatureClass;
- //Dictionary fieldsDic = new Dictionary();
- //for (int i = 0; i < tempdltbgxFC.Fields.FieldCount; i++)
- //{
- // IField field = tempdltbgxFC.Fields.Field[i];
- // if (field.Name == tempdltbgxFC.ShapeFieldName || field.Name.Contains(tempdltbgxFC.ShapeFieldName) || field.Name == tempdltbgxFC.OIDFieldName || !field.Editable) continue;
-
- // if (!"DLBM,GDLX,GDDB,GDPDJB,KCXS".Contains(field.Name)) continue;
- // int index = -1;
- // index = BgTbLayer.FeatureClass.Fields.FindField(field.Name);
- // if (index == -1)
- // index = BgTbLayer.FeatureClass.Fields.FindFieldByAliasName(field.AliasName);
- // if (index == -1)
- // continue;
-
- // fieldsDic.Add(i, index);
- //}
-
- //if (fieldsDic.Count == 0)
- // return;
- //IFeatureBuffer buffer = tempdltbgxFC.CreateFeatureBuffer();
- //IFeatureCursor tempgxCursor = tempdltbgxFC.Insert(true);
- //int oldOIDIndex = tempdltbgxFC.FindField("OLDOBJECTID");
- //if (oldOIDIndex == -1)
- // return;
-
- //IQueryFilter queryfilter = new QueryFilterClass();
- //queryfilter.WhereClause = string.Format("DLBM like '01%' ");
-
- //int gdCount = BgTbLayer.FeatureClass.FeatureCount(queryfilter);
- //if (gdCount == 0)
- // return;
-
- //IFeature gxtbFeature = null;
- //IFeatureCursor dltbgxCursor = BgTbLayer.FeatureClass.Search(queryfilter, true);
- //int OIDIndex = BgTbLayer.FeatureClass.FindField("OBJECTID");
- //int num = 0;
- //while ((gxtbFeature = dltbgxCursor.NextFeature()) != null)
- //{
- // num++;
- // if (gxtbFeature.ShapeCopy.IsEmpty) continue;
- // buffer.Shape = gxtbFeature.ShapeCopy;
- // foreach (int item in fieldsDic.Keys)
- // {
- // if (string.IsNullOrWhiteSpace(gxtbFeature.Value[fieldsDic[item]].ToTrim()))
- // buffer.Value[item] = DBNull.Value;
- // buffer.Value[item] = gxtbFeature.Value[fieldsDic[item]];
- // }
-
- // buffer.Value[oldOIDIndex] = gxtbFeature.Value[OIDIndex];
- // tempgxCursor.InsertFeature(buffer);
- // if (num % 1000 == 0)
- // {
- // tempgxCursor.Flush();
- // }
- // Marshal.ReleaseComObject(gxtbFeature);
- //}
- //tempgxCursor.Flush();
-
- //DLTBGX与PDTGX 相交
- GPParamClass gPParamClass = new GPParamClass();
- gPParamClass.FirstFeatureLayer = BgTbLayer;
- gPParamClass.SecondFeatureLayer = PDTLayer;
- gPParamClass.OutFeatureClassPath = TempDbPath + "\\TB_PD";
- gPParamClass.IsGetOutPutFeature = true;
- gPParamClass.GPType = EnumGPType.Identify;
- GPHelper.Instance.ExeGPForProces(gPParamClass, ref unionLayer);
- unionFcAPI = new FeatureClassAPI(unionLayer.FeatureClass);
- cursor = unionFcAPI.FeatureClass.Search(null, true);
- feature = null;
- Dictionary DicPDJB = new Dictionary();
- Dictionary DicMJ = new Dictionary();
- Dictionary> DicPDJB_MJ = new Dictionary>();
- int idxOID = unionFcAPI.FeatureClass.FindField("OLDOBJECTID");
- if (idxOID == -1)
- {
- return;
- }
- int idxArea = unionFcAPI.FeatureClass.FindField("SHAPE_AREA");
- int idxPDJB = unionFcAPI.FeatureClass.FindField("PDJB");
- while ((feature = cursor.NextFeature()) != null)
- {
- int oid = Convert.ToInt32(feature.Value[idxOID].ToTrim());
- if (oid == 456)
- {
- }
- double area = feature.Value[idxArea].ToDouble(2);
- string pdjb = feature.Value[idxPDJB].ToTrim();
- if (!DicPDJB_MJ.ContainsKey(oid))
- {
- DicPDJB_MJ.Add(oid, new List() { new PDJBModel() { PDJB = pdjb, MJ = area } });
- }
- else
- {
- List list = DicPDJB_MJ[oid];
- PDJBModel pdjbMod = list.FirstOrDefault(f => f.PDJB == pdjb);
- if (pdjbMod == null)
- {
- list.Add(new PDJBModel() { PDJB = pdjb, MJ = area });
- }
- else
- {
- pdjbMod.MJ += area;
- }
- DicPDJB_MJ[oid] = list;
- }
- if (!DicMJ.ContainsKey(oid))
- {
- DicMJ.Add(oid, area);
- DicPDJB.Add(oid, pdjb);
- }
- else if (DicMJ[oid] < area)
- {
- DicMJ[oid] = area;
- DicPDJB[oid] = pdjb;
- }
- }
-
- cursor = BgTbLayer.FeatureClass.Update(new QueryFilter() { WhereClause = "DLBM like '01%' " }, false);
- int Objectid_GX = BgTbLayer.FeatureClass.FindField("objectid");
- int BSM_GX = BgTbLayer.FeatureClass.FindField("BSM");
- int GDPDJB_GX = BgTbLayer.FeatureClass.FindField("GDPDJB");
- int GDLX_GX = BgTbLayer.FeatureClass.FindField("GDLX");
- int idxKCXS = BgTbLayer.FeatureClass.FindField("KCXS");
- int DLBM_GX = BgTbLayer.FeatureClass.FindField("DLBM");
- int GDPDJBIndex = PDTLayer.FeatureClass.FindField("PDJB");
- var count = BgTbLayer.FeatureClass.FeatureCount(new QueryFilter() { WhereClause = "DLBM like '01%' " });
- var featurecount = 0;
- while ((feature = cursor.NextFeature()) != null)
- {
- featurecount++;
- if (featurecount % 500 == 0)
- {
- Console.WriteLine($"Msg:正在进行耕地坡度赋值...【{featurecount}/{count}】");
- }
- if (feature.OID == 529)
- {
- }
- string pdjb = string.Empty;
- if (!DicPDJB_MJ.ContainsKey(feature.OID))
- {
- continue;
- }
- double tempmj = feature.Value[feature.Fields.FindField("SHAPE_AREA")].ToDouble(0);
- if (tempmj == 850.0)
- {
- }
- List list = DicPDJB_MJ[feature.OID];
- list = list.OrderByDescending(o => o.MJ).ToList();
- pdjb = list[0].PDJB;//[feature.OID];
- feature.Value[GDPDJB_GX] = pdjb;
- string dlbm = feature.Value[DLBM_GX].ToString();
- string bghbsm = feature.Value[BSM_GX].ToString();
- string UpdateGCSql = string.Empty;
- string strGDLX = feature.Value[GDLX_GX].ToTrim();
- if (pdjb == "1")
- {
- strGDLX = "";
- }
- else
- if (!string.IsNullOrWhiteSpace(dlbm) && "2,3,4,5".Contains(pdjb) && string.IsNullOrWhiteSpace(strGDLX))
- {
- string kcxsKey1 = string.Format("{0}-{1}", "TT", pdjb);
- double xs1 = 0;
- if (Parm.KCXSDic.ContainsKey(kcxsKey1))
- {
- xs1 = Parm.KCXSDic[kcxsKey1].ToDouble();
- }
- string kcxsKey2 = string.Format("{0}-{1}", "PD", pdjb);
- double xs2 = 0;
- if (Parm.KCXSDic.ContainsKey(kcxsKey2))
- {
- xs2 = Parm.KCXSDic[kcxsKey2].ToDouble();
- }
- if (xs1 == 0 && xs2 != 0)
- {
- strGDLX = "PD";
- }
- else if (xs1 != 0 && xs2 == 0)
- {
- strGDLX = "TT";
- }
- else
- {
- if (dlbm == "0101")
- {
- strGDLX = "TT";
- }
- else if ("0102,0103".Contains(dlbm))
- {
- strGDLX = "PD";
- }
- }
- }
- string kcxsKey = string.Format("{0}-{1}", strGDLX, pdjb);
- if (Parm.KCXSDic.ContainsKey(kcxsKey))
- {
- feature.Value[idxKCXS] = Parm.KCXSDic[kcxsKey].ToDouble();
- }
- feature.Value[GDLX_GX] = strGDLX;
- cursor.UpdateFeature(feature);
-
- Marshal.ReleaseComObject(feature);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("Warning:耕地坡度级别赋值异常:" + ex.Message);
- Console.WriteLine("Warning:耕地坡度级别赋值异常:" + ex);
- }
- finally
- {
- //ProgressHelper.CloseProcessBar();
- if (feature != null)
- Marshal.ReleaseComObject(feature);
- if (cursor != null)
- Marshal.ReleaseComObject(cursor);
- if (pFtWsFct != null)
- Marshal.ReleaseComObject(pFtWsFct);
- if (workspaceName != null)
- Marshal.ReleaseComObject(workspaceName);
- if (unionLayer != null)
- Marshal.ReleaseComObject(unionLayer);
- }
- }
-
- #region 获取最新图斑编号
- private void GetMaxTBBH(IFeatureClass fc, ref Dictionary result)
- {
- ICursor cursor = (fc as ITable).Search(new QueryFilterClass() { SubFields = "ZLDWDM,TBBH" }, true);
- IRow row = null;
- int zlIndex = -1;
- int bhIndex = -1;
- while ((row = cursor.NextRow()) != null)
- {
- if (zlIndex == -1)
- zlIndex = row.Fields.FindField("ZLDWDM");
- if (bhIndex == -1)
- bhIndex = row.Fields.FindField("TBBH");
- if (zlIndex != -1 && bhIndex != -1)
- {
- string zl = row.Value[zlIndex].ToTrim();
- if (zl.Length > 12)
- zl = zl.Substring(0, 12);
- zl = zl.Replace(zl.Substring(0, 6), Parm.PrjInfo.CODE);
- int tbbh = 0;
- int.TryParse(row.Value[bhIndex].ToString(), out tbbh);
-
- if (result.ContainsKey(zl))
- {
- if (result[zl] < tbbh)
- result[zl] = tbbh;
- }
- else
- {
- result.Add(zl, tbbh);
- }
- }
- }
- }
- #endregion
-
- #region 获取最新标识码
- public string GetNewBSM(List fcList)
- {
- string result = string.Empty;
- int xh = 0;
- string leftStr = string.Empty;
- foreach (var item in fcList)
- {
- string MaxBSM = GetMaxBSM(item);
- if (MaxBSM.Length != 18)
- continue;
- int xh2 = Convert.ToInt32(MaxBSM.Substring(10));
- leftStr = MaxBSM.Substring(0, 10);
- if (xh < xh2)
- xh = xh2;
- }
- xh++;
- if (string.IsNullOrWhiteSpace(leftStr))
- leftStr = Parm.PrjInfo.CODE + "1210";
- result = leftStr + xh.ToString().PadLeft(8, '0');
- return result;
- }
- private static string GetMaxBSM(IFeatureClass fc)
- {
- 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;
- if (table.FindField("XZQTZLX") != -1)
- {
- tableSort.QueryFilter = new QueryFilterClass() { WhereClause = "XZQTZLX is NULL" };
- }
- 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;
- }
- return BSM;
- }
- #endregion
-
- #region 面积平差
- ///
- /// 面积平差
- ///
- /// 需要平差的对象集合
- /// 控制面积
- public void AreaAdjustment(List shpList, double pKZMJ)
- {
- try
- {
- if (shpList.Count == 1)
- {
- shpList[0].bgmj = pKZMJ;
- return;
- }
- shpList = shpList.OrderByDescending(o => o.bgmj).ToList();
- double mjc = Math.Round(shpList.Sum(s => s.bgmj) - pKZMJ, 2);
- //平差
- while (Math.Round(mjc, 2) != 0)
- {
- int tpsm = (int)(Math.Abs(Math.Round(mjc, 2)) / (double)0.01);
- int e = tpsm / shpList.Count;
- int f = tpsm % shpList.Count;
- if (tpsm < 0)//int值溢出了
- {
- long tems = (long)(Math.Abs(Math.Round(mjc, 2)) / (double)0.01);
- e = (int)(tems / shpList.Count);
- f = (int)(tems % shpList.Count);
- }
- if (f != 0)
- {
- double tpmj = (e + 1) * 0.01;
- for (int i = 0; i < f; i++)
- {
- if (mjc < 0)
- shpList[i].bgmj = shpList[i].bgmj + tpmj;
- else
- shpList[i].bgmj = shpList[i].bgmj - tpmj;
- }
- }
- if (e != 0)
- {
- double tpmj = e * 0.01;
- for (int i = f; i < shpList.Count; i++)
- {
- if (mjc < 0)
- shpList[i].bgmj = shpList[i].bgmj + tpmj;
- else
- shpList[i].bgmj = shpList[i].bgmj - tpmj;
- }
- }
- mjc = Math.Round(shpList.Sum(s => s.bgmj), 2) - pKZMJ;
- }
- }
- catch (Exception ex)
- {
- LogAPI.Debug("面积平差错误:" + ex.Message);
- LogAPI.Debug(ex);
- throw ex;
- }
- }
- #endregion
-
- #region GXGCFcToFc
- public bool GXGCFcToFc(IFeatureClass FeatureClass, IFeatureClass pFc, IQueryFilter pFilter, bool pIsCut, DataTable data_BSM, Dictionary GXGCvaluePairs)
- {
- IFeatureCursor S_Cursor = null;
- IFeatureCursor T_Cursor = null;
- try
- {
- if (FeatureClass == null || pFc == null) return false;
- //获取对应关系
- Dictionary dicField = new Dictionary();
- Dictionary dicField1 = new Dictionary();
- for (int i = 0; i < pFc.Fields.FieldCount; i++)
- {
- #region 注释项
- //IField field = pFc.Fields.Field[i];
- //if (field.Name == pFc.ShapeFieldName || field.Name.Contains(pFc.ShapeFieldName) || field.Name == pFc.OIDFieldName || !field.Editable) continue;
- //int index = -1;
- //if (field.Name.Contains("BGQ"))
- //{
- // index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQTB", "")}_1");
- // if (index == -1)
- // index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQ", "")}_1");
- // if (index == -1)
- // index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQ", "")}");
- //}
- //else
- //if (field.Name.Contains("BGH"))
- //{
- // index = FeatureClass.Fields.FindField(field.Name.Replace("BGHTB", ""));
- // if (index == -1)
- // index = FeatureClass.Fields.FindField(field.Name.Replace("BGH", ""));
- //}
- //else
- //if (field.Name == "BGHTBBSM" || field.Name == "BGQTBBSM")
- //{
- // index = FeatureClass.Fields.FindField($"BSM");
- //}
- //if (index == -1) continue;
- //dicField.Add(i, index);
- //index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQTB", "").Replace("BGHTB", "")}_1");
- //if (index == -1)
- // index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQ", "").Replace("BGH", "")}_1");
- //if (field.Name == "BGHTBBSM" || field.Name == "BGQTBBSM")
- //{
- // index = FeatureClass.Fields.FindField($"BSM");
- //}
- //if (index == -1) continue;
- //dicField1.Add(i, index);
- #endregion
-
- IField field = pFc.Fields.Field[i];
- if (field.Name == pFc.ShapeFieldName || field.Name.Contains(pFc.ShapeFieldName) || field.Name == pFc.OIDFieldName || !field.Editable) continue;
- int index = -1;
- if (field.Name.Contains("BGQ"))
- {
- string fieldName = field.Name.Replace("BGQTB", "").Replace("BGQ", "");
- if ("BGQTBBH,BGQTBMJ,BGQTBXHDM,BGQTBXHMC,BGQTBDLMJ".Contains(field.Name))
- fieldName = field.Name.Replace("BGQ", "");
- index = FeatureClass.Fields.FindField($"{fieldName}");
- if (index == -1)
- index = FeatureClass.Fields.FindField(fieldName);
- }
- else
- if (field.Name.Contains("BGH"))
- {
- string fieldName = field.Name.Replace("BGHTB", "").Replace("BGH", "");
- if ("BGHTBBH,BGHTBMJ,BGHTBXHDM,BGHTBXHMC,BGHTBDLMJ".Contains(field.Name))
- fieldName = field.Name.Replace("BGH", "");
- index = FeatureClass.Fields.FindField(fieldName + "_1");
- }
- if (index == -1) continue;
- dicField.Add(i, index);
- string fName = field.Name.Replace("BGQTB", "").Replace("BGHTB", "").Replace("BGQ", "").Replace("BGH", "");
- index = FeatureClass.Fields.FindField($"{fName}_1");
-
- if ("BGQTBBH,BGQTBMJ,BGQTBXHDM,BGQTBXHMC,BGQTBDLMJ,BGHTBBH,BGHTBMJ,BGHTBXHDM,BGHTBXHMC,BGHTBDLMJ".Contains(field.Name))
- fName = field.Name.Replace("BGH", "").Replace("BGQ", "");
- index = FeatureClass.Fields.FindField($"{fName}_1");
- if (index == -1)
- index = FeatureClass.Fields.FindField(fName);
- if (index == -1) continue;
- dicField1.Add(i, index);
- }
- (pFc as ITable).DeleteSearchedRows(null);
- //string s = (pFc as FeatureClass).Workspace.PathName;
- IFeatureClassLoad pFclsLoad = pFc as IFeatureClassLoad;
- if (pFclsLoad != null)
- pFclsLoad.LoadOnlyMode = true;
- //此处写编辑的代码
- S_Cursor = FeatureClass.Search(pFilter, true);
- IFeature f = null;
- T_Cursor = pFc.Insert(true);
- IFeatureBuffer buffer = pFc.CreateFeatureBuffer();
- var iFID_DLTBBG = FeatureClass.FindField("FID_DLTBGX");
- var iFID_DLTB = FeatureClass.FindField("FID_JC_DLTB");
- var ibgxw = pFc.FindField("BGXW");
- var itbbgmj = pFc.FindField("TBBGMJ");
- var ibgqkcxs = pFc.FindField("BGQKCXS");
- var ibgqkcmj = pFc.FindField("BGQKCMJ");
- var ibgqtbdlmj = pFc.FindField("BGQTBDLMJ");
- var ibghkcxs = pFc.FindField("BGHKCXS");
- var ibghkcmj = pFc.FindField("BGHKCMJ");
- var ibghtbdlmj = pFc.FindField("BGHTBDLMJ");
- var ibsm = pFc.FindField("BSM");
- var igxsj = pFc.FindField("GXSJ");
- var idxONLYZLBG = pFc.FindField("ONLYZLBG");
- var idxBGHTBBSM = pFc.FindField("BGHTBBSM");
- var idxBGHTBBH = pFc.FindField("BGHTBBH");
- var idxXZQTZLX = pFc.FindField("XZQTZLX");
- var idxJCTBBH = FeatureClass.FindField("TBBH_1");
- if (idxJCTBBH == -1)
- idxJCTBBH = FeatureClass.FindField("TBBH");
- var idxJCXZQTZLX = FeatureClass.FindField("XZQTZLX");
- var tbbgmj = 0.00;
- int bsm = 1;
- var GXGClist = TBToList.ToList(data_BSM);
- while ((f = S_Cursor.NextFeature()) != null)
- {
- string tempXZQTZLX = f.Value[idxJCXZQTZLX].ToTrim();
- if (GXGCvaluePairs.ContainsKey(f.OID))
- {
- tbbgmj = GXGCvaluePairs[f.OID];
- }
- var FID_DLTBBG = f.Value[iFID_DLTBBG].ToString();
- var FID_DLTB = f.Value[iFID_DLTB].ToString();
- List row = GXGClist.Where(x => x.FID_DLTBGX == FID_DLTBBG && x.FID_JC_DLTB == FID_DLTB).ToList();
- if (row == null || row.Count == 0) continue;
- buffer.Shape = f.ShapeCopy;
- if (pFilter is ISpatialFilter && pIsCut)
- {
- if (FeatureAPI.IsInterSect((pFilter as ISpatialFilter).Geometry, f.ShapeCopy))
- {
- buffer.Shape = FeatureAPI.InterSect(f.ShapeCopy, (pFilter as SpatialFilterClass).Geometry);
- }
- else
- {
- continue;
- }
- }
- if (FID_DLTBBG == "-1")
- {
- foreach (int item in dicField1.Keys)//被动变更的图斑 变更前后属性相同
- {
- try
- {
- if (f.Value[dicField1[item]].ToString().Contains(" ") || f.Value[dicField1[item]] is DBNull)
- {
- buffer.Value[item] = f.Value[dicField1[item]].ToTrim();
- }
- else
- {
- buffer.Value[item] = f.Value[dicField1[item]];
- }
- }
- catch
- {
- buffer.Value[item] = f.Value[dicField1[item]];
- }
- }
- }
- else
- {
- foreach (int item in dicField.Keys)
- {
- try
- {
- buffer.Value[item] = f.Value[dicField[item]];
- }
- catch
- {
- buffer.Value[item] = f.Value[dicField[item]];
- }
- }
- }
- if (idxJCTBBH != -1)
- buffer.Value[idxBGHTBBH] = f.Value[idxJCTBBH];
- buffer.Value[ibgxw] = row[0].BGXW;
- if (GXGCvaluePairs.ContainsKey(f.OID))
- tbbgmj = GXGCvaluePairs[f.OID];
- else
- tbbgmj = row[0].TBBGMJ.ToDouble();
- buffer.Value[itbbgmj] = Math.Round(tbbgmj, 2);//图斑变更面积
- var bgqkcmj = Math.Round((decimal)(buffer.Value[ibgqkcxs].ToDouble() * tbbgmj), 2, MidpointRounding.AwayFromZero).ToDouble();//变更前扣除面积
- buffer.Value[ibgqkcmj] = bgqkcmj;
- buffer.Value[ibgqtbdlmj] = tbbgmj - bgqkcmj;//变更前图斑地类面积
- var bghkcmj = Math.Round((decimal)(buffer.Value[ibghkcxs].ToDouble() * tbbgmj), 2, MidpointRounding.AwayFromZero).ToDouble();//变更后扣除面积
- if (tempXZQTZLX == "2" || tempXZQTZLX == "4")
- {
- buffer.Value[ibghkcmj] = 0;
- buffer.Value[ibghtbdlmj] = 0;//变更后图斑地类面积
- buffer.Value[idxBGHTBBSM] = "";
- buffer.Value[idxBGHTBBH] = "";
- for (int i = 0; i < pFc.Fields.FieldCount; i++)
- {
- IField bghField = pFc.Fields.Field[i];
- if (bghField.Name.StartsWith("BGH"))
- {
- try
- {
- buffer.Value[i] = DBNull.Value;
- }
- catch (Exception)
- {
- buffer.Value[i] = 0;
- }
- }
- }
- }
- else if (tempXZQTZLX == "3")
- {
- for (int i = 0; i < pFc.Fields.FieldCount; i++)
- {
- IField bghField = pFc.Fields.Field[i];
- if (bghField.Name.StartsWith("BGQ"))
- {
- try
- {
- buffer.Value[i] = DBNull.Value;
- }
- catch (Exception)
- {
- buffer.Value[i] = 0;
- }
- }
- }
- buffer.Value[ibghkcmj] = bghkcmj;
- buffer.Value[ibghtbdlmj] = tbbgmj - bghkcmj;//变更后图斑地类面积
- buffer.Value[idxBGHTBBSM] = row[0].BSM_1;
- buffer.Value[idxBGHTBBH] = row[0].TBBH_1;
- }
- else
- {
- buffer.Value[ibghkcmj] = bghkcmj;
- buffer.Value[ibghtbdlmj] = tbbgmj - bghkcmj;//变更后图斑地类面积
- buffer.Value[idxBGHTBBSM] = row[0].BSM_1;
- buffer.Value[idxBGHTBBH] = row[0].TBBH_1;
- }
- buffer.Value[idxONLYZLBG] = row[0].ONLYZLBG;
- if (idxJCXZQTZLX != -1)
- {
- if (string.IsNullOrWhiteSpace(f.Value[idxJCXZQTZLX].ToTrim()))
- {
- buffer.Value[idxXZQTZLX] = "0";
- }
- else
- {
- buffer.Value[idxXZQTZLX] = f.Value[idxJCXZQTZLX];
- }
- }
- else
- {
- buffer.Value[idxXZQTZLX] = "0";
- }
- buffer.Value[ibsm] = $"{Parm.PrjInfo.CODE}2111{(bsm++).ToString().PadLeft(8, '0')}";
- buffer.Value[igxsj] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
- T_Cursor.InsertFeature(buffer);
- }
- T_Cursor.Flush();
- if (pFclsLoad != null)
- pFclsLoad.LoadOnlyMode = false;
- return true;
- }
- catch (Exception ex)
- {
-
- throw ex;
- }
- finally
- {
- if (T_Cursor != null)
- {
- System.Runtime.InteropServices.Marshal.ReleaseComObject(T_Cursor);
- }
- if (S_Cursor != null)
- {
- System.Runtime.InteropServices.Marshal.ReleaseComObject(S_Cursor);
- }
- }
- }
- #endregion
-
- #region GXFcToFc
- public bool GXFcToFc(IFeatureClass FeatureClass, IFeatureClass pFc, IQueryFilter pFilter, DataTable dtDLTBGX)
- {
- IFeatureCursor S_Cursor = null;
- IFeatureCursor T_Cursor = null;
- try
- {
- if (FeatureClass == null || pFc == null) return false;
- Dictionary dicField = new Dictionary();
- int index = -1;
- for (int i = 0; i < pFc.Fields.FieldCount; i++)
- {
- IField field = pFc.Fields.Field[i];
- if (field.Name == pFc.ShapeFieldName || field.Name.Contains(pFc.ShapeFieldName) || field.Name == pFc.OIDFieldName || !field.Editable) continue;
- index = FeatureClass.Fields.FindField($"BGH{field.Name}");
- if (index == -1)
- index = FeatureClass.Fields.FindField($"BGHTB{field.Name}");
- if (index == -1)
- index = FeatureClass.Fields.FindField(field.Name);
- if (index == -1) continue;
- dicField.Add(i, index);
- }
- IFeatureClassLoad pFclsLoad = pFc as IFeatureClassLoad;
- if (pFclsLoad != null)
- pFclsLoad.LoadOnlyMode = true;
- //此处写编辑的代码
- S_Cursor = FeatureClass.Search(pFilter, true);
- IFeature f = null;
- T_Cursor = pFc.Insert(true);
- int idxBSM = pFc.FindField("BSM");
- int idxTBBH = pFc.FindField("TBBH");
- int idxTBMJ = pFc.FindField("TBMJ");
- int idxGXSJ = pFc.FindField("GXSJ");
- //int idxGXSJ = pFc.FindField("SJNF");
- var idxONLYZLBG = pFc.FindField("ONLYZLBG");
- int idxGXOID = FeatureClass.FindField("FID_DLTBGX");
- IFeatureBuffer buffer = pFc.CreateFeatureBuffer();
- var GXlist = TBToList.ToList(dtDLTBGX);
- while ((f = S_Cursor.NextFeature()) != null)
- {
- int gxOID = f.OID;// f.Value[idxGXOID].ToInt();
- List row = GXlist.Where(x => x.FID_DLTBGX == gxOID).ToList();// dtDLTBGX.Select($"FID_DLTBGX={gxOID}");
- if (row == null || row.Count == 0) continue;
- if (row[0].TBMJ.ToDouble() <= 0) continue;
- buffer.Shape = f.ShapeCopy;
- foreach (int item in dicField.Keys)
- {
- buffer.Value[item] = f.Value[dicField[item]];
- }
- buffer.Value[idxBSM] = row[0].BSM_1;
- buffer.Value[idxTBBH] = row[0].TBBH_1;
- buffer.Value[idxTBMJ] = row[0].TBMJ;
- buffer.Value[idxONLYZLBG] = row[0].ONLYZLBG;
- buffer.Value[idxGXSJ] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
- T_Cursor.InsertFeature(buffer);
- }
- T_Cursor.Flush();
- if (pFclsLoad != null)
- pFclsLoad.LoadOnlyMode = false;
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- finally
- {
- if (T_Cursor != null)
- {
- System.Runtime.InteropServices.Marshal.ReleaseComObject(T_Cursor);
- }
- if (S_Cursor != null)
- {
- System.Runtime.InteropServices.Marshal.ReleaseComObject(S_Cursor);
- }
- }
- }
- #endregion
-
- #region TableToTable
- public bool TableToTable(IFeatureWorkspace pInWork, IWorkspace pOutWork, string tableName, IQueryFilter queryFilter = null)
- {
- try
- {
- if (pInWork == null || pOutWork == null || string.IsNullOrEmpty(tableName)) return false;
- IWorkspace2 workspace2 = pInWork as IWorkspace2;
- if (workspace2 != null)
- {
- if (!workspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, tableName))
- {
- return false;
- }
- }
- ITable pInTable = pInWork.OpenTable(tableName);
- if (pInTable == null) return false;
- IDataset pIndataset = (IDataset)pInTable;
- IDatasetName pInDatasetName = (IDatasetName)pIndataset.FullName;
- IEnumDataset enumDataset = pOutWork.get_Datasets(esriDatasetType.esriDTTable);
- IDataset dataset;
- enumDataset.Reset();
- while ((dataset = enumDataset.Next()) != null)
- {
- string[] names = dataset.Name.Split('.');
- if (string.Equals(names[names.Length - 1], tableName, StringComparison.CurrentCultureIgnoreCase))
- {
- dataset.Delete();
- break;
- }
- }
- IDataset pOutDataset = (IDataset)pOutWork;
- IDatasetName pOutDatasetName = new TableNameClass();
- pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName;
- pOutDatasetName.Name = tableName;
- IFieldChecker fieldChecker = new FieldCheckerClass();
- IFields targetFeatureClassFields = pInTable.Fields;
- IFields sourceFeatureClassFields = pInTable.Fields;
- IEnumFieldError enumFieldError;
- fieldChecker.InputWorkspace = pInWork as IWorkspace;
- fieldChecker.ValidateWorkspace = pOutWork;
- fieldChecker.Validate(sourceFeatureClassFields, out enumFieldError, out targetFeatureClassFields);
- IFeatureDataConverter one2another = new FeatureDataConverterClass();
- try
- {
- one2another.ConvertTable(pInDatasetName, queryFilter, pOutDatasetName, targetFeatureClassFields, "", 1000, 0);
- }
- finally
- {
- Marshal.ReleaseComObject(one2another);
- }
- return true;
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Log:TableToTable处理失败:{ex.Message}");
- Console.WriteLine($"Log:TableToTable处理失败:{ex.StackTrace}");
- //LogAPI.Debug(ex);
- throw ex;
- }
- }
-
- #endregion
- }
- public class Adjustment
- {
- public int ID { get; set; }
- public double bgmj { get; set; }
- }
- public class PDJBModel
- {
- public string PDJB { get; set; }
- public double MJ { get; set; }
- }
-
- public class DLTBGXGC
- {
- public int OBJECTID { get; set; }
- public string BSM { get; set; }
- public string ZLDWDM_1 { get; set; }
- public double TBMJ { get; set; }
-
- }
- public class DLTBGX_Find
- {
- public int FID_DLTBGX { get; set; }
- public double TBMJ { get; set; }
- public string BSM_1 { get; set; }
- public string TBBH_1 { get; set; }
- public string BZ_1 { get; set; }
- public string ONLYZLBG { get; set; }
- public string XZQTZLX { get; set; }
- }
- public class DLTBGXGC_Find
- {
- public string FID_DLTBGX { get; set; }
- public string FID_JC_DLTB { get; set; }
- public string BGXW { get; set; }
- public double TBBGMJ { get; set; }
- public string BSM_1 { get; set; }
- public string TBBH_1 { get; set; }
- public int OBJECTID { get; set; }
- public double TBMJ { get; set; }
- public string BZ_1 { get; set; }
- public string ONLYZLBG { get; set; }
- public string XZQTZLX { get; set; }
-
- }
- public class DLTBBG_DLTB
- {
- public string OBJECTID { get; set; }
- public string GDPDJB_1 { get; set; }
- public string KCXS_1 { get; set; }
- public string GDLX_1 { get; set; }
- public string KCDLBM_1 { get; set; }
- public string BSM_1 { get; set; }
- }
- public class DLTB_GD
- {
- public string BSM_1 { get; set; }
- public string strdlbm { get; set; }
- public bool isBreak { get; set; }
- }
- public class DLTB_DLTBBG
- {
- public string FID_DLTB { get; set; }
- public string FID_DLTBBG { get; set; }
-
- }
-
-}
diff --git a/KGIS_DLTB/Helper/MsgHelper.cs b/KGIS_DLTB/Helper/MsgHelper.cs
deleted file mode 100644
index c891d0c..0000000
--- a/KGIS_DLTB/Helper/MsgHelper.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-using KGIS.Framework.Utils;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace IDGForNDBG
-{
- ///
- /// Start()
- /// Msg()
- /// Log()
- /// Err()
- /// End()
- ///
- public class MsgHelper
- {
- private int MsgNum { get; set; }
- public DateTime InitTime { get; set; }
- public DateTime ItemStartTime { get; set; }
- public void Start(string pMsg)
- {
- MsgNum++;
- InitTime = DateTime.Now;
- ItemStartTime = InitTime;
- string _msg = string.Empty;
- for (int i = 0; i < MsgNum; i++)
- {
- _msg += " ";
- }
- _msg += MsgNum + ":↓↓↓↓↓↓开始执行:" + pMsg + " - " + InitTime + " ↓↓↓↓↓↓ ";
- Console.WriteLine(_msg);
- Msg(pMsg, true);
-
- //Console.WriteLine(pMsg);
- }
- public void Msg(string pMsg, bool pIsLog = true)
- {
- string _msg = string.Empty;
- for (int i = 0; i < MsgNum; i++)
- {
- _msg += " ";
- }
- _msg += MsgNum + "正在执行:" + pMsg;
- Console.WriteLine("Msg:正在执行 " + pMsg);
- if (pIsLog)
- Log(pMsg);
- }
- public void Log(string pMsg)
- {
- string _msg = string.Empty;
- for (int i = 0; i < MsgNum; i++)
- {
- _msg += " ";
- }
- _msg += MsgNum + "正在执行:" + pMsg;
- string time = GetTime(ItemStartTime);
- LogAPI.Debug(_msg + " - 耗时:" + time);
- }
- public void Err(string pMsg)
- {
- string _msg = string.Empty;
- for (int i = 0; i < MsgNum; i++)
- {
- _msg += " ";
- }
- _msg += MsgNum + "Err:" + pMsg;
- string time = GetTime(ItemStartTime);
- LogAPI.Debug(_msg + " - 耗时:" + time);
- }
- public void Throw()
- {
- string time = GetTime(InitTime);
- string _msg = string.Empty;
- for (int i = 0; i < MsgNum; i++)
- {
- _msg += " ";
- }
- _msg += MsgNum + ":------- 程序异常 ------";
- Console.WriteLine(_msg);
- Err(_msg);
- MsgNum = 1;
- End();
- }
-
- public void End()
- {
- string time = GetTime(InitTime);
- string _msg = string.Empty;
- for (int i = 0; i < MsgNum; i++)
- {
- _msg += " ";
- }
- _msg += MsgNum + ":↑↑↑↑↑↑执行完成,总耗时:" + time + "↑↑↑↑↑↑";
- Console.WriteLine(_msg);
- MsgNum--;
- }
-
- private string GetTime(DateTime timeA)
- {
- //ItemStartTime = DateTime.Now;
- //timeA 表示需要计算
- DateTime timeB = DateTime.Now; //获取当前时间
- TimeSpan ts = timeB - timeA; //计算时间差
- string time = ts.TotalSeconds.ToString(); //将时间差转换为秒
- ItemStartTime = timeB;
- return time;
- }
- }
-}
diff --git a/KGIS_DLTB/KGIS_DLTB.csproj b/KGIS_DLTB/KGIS_DLTB.csproj
deleted file mode 100644
index dd3a5e0..0000000
--- a/KGIS_DLTB/KGIS_DLTB.csproj
+++ /dev/null
@@ -1,179 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {D900B82F-E8D3-45BD-985C-CE6A64DD4322}
- Exe
- KGIS_DLTB
- KGIS_DLTB
- v4.7.2
- 512
- true
- true
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- false
- true
-
-
- AnyCPU
- true
- full
- false
- ..\Apps\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- ..\Apps\
- TRACE
- prompt
- 4
- true
-
-
-
-
-
- true
-
-
- JKRJ.pfx
-
-
-
- False
- False
- ..\Lib\ESRI\ESRI.ArcGIS.Carto.dll
-
-
- False
- ..\Lib\ESRI\ESRI.ArcGIS.ConversionTools.dll
-
-
- False
- ..\Lib\ESRI\ESRI.ArcGIS.DataManagementTools.dll
- True
-
-
- False
- False
- ..\Lib\ESRI\ESRI.ArcGIS.DataSourcesGDB.dll
-
-
- False
- False
- ..\Lib\ESRI\ESRI.ArcGIS.Display.dll
-
-
- False
- False
- ..\Lib\ESRI\ESRI.ArcGIS.Geodatabase.dll
-
-
- False
- False
- ..\Lib\ESRI\ESRI.ArcGIS.Geometry.dll
-
-
- False
- False
- ..\Lib\ESRI\ESRI.ArcGIS.Geoprocessing.dll
-
-
- False
- ..\Lib\ESRI\ESRI.ArcGIS.Geoprocessor.dll
-
-
- False
- False
- ..\Lib\ESRI\ESRI.ArcGIS.System.dll
-
-
- False
- ..\packages\KGIS.Framework.AE.1.0.6\lib\KGIS.Framework.AE.dll
-
-
- ..\packages\KGIS.Framework.DBOperator.1.0.0\lib\KGIS.Framework.DBOperator.dll
-
-
- False
- ..\Kingo.Plugins\在线建库\周报统计表\lib\KGIS.Framework.Platform.dll
-
-
- ..\Apps\KGIS.Framework.Utils.dll
-
-
- False
- ..\Lib\授权dll\授权校验\Kingo.Core.FlowManager.dll
- True
-
-
- ..\packages\KGIS.Framework.AE.1.0.6\lib\stdole.dll
- True
-
-
-
-
-
- ..\packages\KGIS.Framework.DBOperator.1.0.0\lib\System.Data.SQLite.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {5e1f7e10-99ea-4893-8d52-a38b9491896d}
- Kingo.PluginServiceInterface
-
-
-
-
- False
- Microsoft .NET Framework 4.7.2 %28x86 和 x64%29
- true
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
-
-
\ No newline at end of file
diff --git a/KGIS_DLTB/Program.cs b/KGIS_DLTB/Program.cs
deleted file mode 100644
index bae8a7e..0000000
--- a/KGIS_DLTB/Program.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using KGIS.Framework.Utils;
-using Kingo.PluginServiceInterface;
-using Kingo.PluginServiceInterface.Model;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Security.Principal;
-using System.Text;
-using System.Xml.Linq;
-
-namespace KGIS_DLTB
-{
- class Program
- {
- [STAThread]
- static void Main(string[] args)
- {
- try
- {
- if (IsAdministrator())
- {
- Console.WriteLine("IsAdministrator_True");
- }
- else
- {
- Console.WriteLine("IsAdministrator_False");
- }
-
- #region 授权校验及GIS授权校验
- bool v = GPHelper.Instance.ValidityLic();
- if (!KGIS.Framework.AE.AELicense.AoInit())
- {
- Console.WriteLine("Err:获取GIS授权信息失效!");
- return;
- }
- else if (!v)
- {
- Console.WriteLine("Err:获取工程数据配置信息失败KGISDLTB!");
- return;
- }
- #endregion
-
- //args = new string[] { "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iZ2IyMzEyIj8+PElER1BhcmFtZXRlciB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4bWxuczp4c2Q9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hIj48QWxsb3dVbmlvbj50cnVlPC9BbGxvd1VuaW9uPjxBdXRvQ2FsY0dES0NTWD50cnVlPC9BdXRvQ2FsY0dES0NTWD48QXV0b1NldEdETFg+dHJ1ZTwvQXV0b1NldEdETFg+PEFsbG93UERGWj50cnVlPC9BbGxvd1BERlo+PFN0clByb2pJbmZvPkY6XOW7uuW6k+i9r+S7tuW3peeoi+ebruW9lVwwMuS7iuWlpeW3peeoi+WQiOmbhlzlvrfmg6DluIIoMjIwMTgzKVzlt6XnqIvnm67lvZVc5b635oOgNi4w54mI5pys5rWL6K+VXOW+t+aDoDYuMOeJiOacrOa1i+ivlS5LQkc8L1N0clByb2pJbmZvPjxFeGVETFRCPnRydWU8L0V4ZURMVEI+PEV4ZUdEREI+ZmFsc2U8L0V4ZUdEREI+PEV4ZUNKRENRPmZhbHNlPC9FeGVDSkRDUT48RXhlWFpRPmZhbHNlPC9FeGVYWlE+PEV4ZUNaQz5mYWxzZTwvRXhlQ1pDPjxFeGVaTEhaPmZhbHNlPC9FeGVaTEhaPjwvSURHUGFyYW1ldGVyPg==" };
- if (args.Length == 1)
- {
- Exe(args[0]);
- }
- //Console.WriteLine(DateTime.Now.ToString());
- //Console.WriteLine(GetTime(s_dt));
- //Console.ReadKey();
- }
- catch (Exception ex)
- {
- Console.WriteLine("Main_fila" + ex.Message + ex.StackTrace);
- Console.ReadKey();
- }
- }
- public static bool IsAdministrator()
- {
- WindowsIdentity current = WindowsIdentity.GetCurrent();
- WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current);
- return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
- }
- static void Exe(string pParm)
- {
- try
- {
- DateTime s_dt = DateTime.Now;
- byte[] base64ToByte = Convert.FromBase64String(pParm);
- string strParm = Encoding.UTF8.GetString(base64ToByte);
- IDGParameter gPParamClass = SerializeAPI.DeserializeToObject(strParm);
- if (gPParamClass == null)
- {
- return;
- }
- if (!string.IsNullOrWhiteSpace(gPParamClass.StrProjInfo) && File.Exists(gPParamClass.StrProjInfo))
- {
- gPParamClass.PrjInfo = ProjectInfo.OpenProject(gPParamClass.StrProjInfo);
- if (gPParamClass.PrjInfo == null)
- {
- Console.WriteLine("Err:获取工程信息失败!");
- }
- }
-
- Dictionary _kcxsDic = new Dictionary();//《字符串-数字》字典集合
- string strPath = gPParamClass.PrjInfo.ProjDir + "\\BG_GDLXConfig.xml";//获取配置文件路径
- if (string.IsNullOrWhiteSpace(strPath) || !File.Exists(strPath))
- strPath = SysAppPath.GetBGGDLXConfigPath();
- XDocument xDoc = XDocument.Load(strPath);
- foreach (XElement xElement in xDoc.Descendants("Item"))
- {
- string gdlx = xElement.Attributes("GDLX").Single().Value;
- string gdpdjb = xElement.Attributes("GDPDJB").Single().Value;
- string strKcdlxs = xElement.Attributes("KCDLXS").Single().Value;
- decimal kcdlxs = Convert.ToDecimal(xElement.Attributes("KCDLXS").Single().Value == "" ? "0" : xElement.Attributes("KCDLXS").Single().Value);
- string key = string.Format("{0}-{1}", gdlx, gdpdjb);
- _kcxsDic.Add(key, kcdlxs);
- }
- gPParamClass.KCXSDic = _kcxsDic;
- if (gPParamClass.PrjInfo.ListZLXXInfo == null)
- gPParamClass.PrjInfo.ListZLXXInfo = new System.Collections.ObjectModel.ObservableCollection();
- if (gPParamClass.ExeDLTB)
- {
- DLTB_IDGHelper helper = new DLTB_IDGHelper();
- Console.WriteLine($"Msg:正在执行地类图斑数据提取");
- Console.WriteLine($"Log:正在执行【{gPParamClass.PrjInfo.CodeName}_{gPParamClass.PrjInfo.ProjName}】变更成果数据提取");
- helper.Execute(gPParamClass);
- }
- Console.Clear();
- Console.WriteLine("执行完成,耗时:" + GetTime(s_dt) + "秒");
- Console.ReadKey();
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
- public static string GetTime(DateTime timeA)
- {
- //timeA 表示需要计算
- DateTime timeB = DateTime.Now; //获取当前时间
- TimeSpan ts = timeB - timeA; //计算时间差
- string time = ts.TotalSeconds.ToString(); //将时间差转换为秒
- return time;
- }
- }
-}
diff --git a/KGIS_DLTB/Properties/AssemblyInfo.cs b/KGIS_DLTB/Properties/AssemblyInfo.cs
deleted file mode 100644
index b840fac..0000000
--- a/KGIS_DLTB/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的一般信息由以下
-// 控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("KGIS_DLTB")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("KGIS_DLTB")]
-[assembly: AssemblyCopyright("Copyright © 2023")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 会使此程序集中的类型
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
-//请将此类型的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("d900b82f-e8d3-45bd-985c-ce6a64dd4322")]
-
-// 程序集的版本信息由下列四个值组成:
-//
-// 主版本
-// 次版本
-// 生成号
-// 修订号
-//
-//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
-//通过使用 "*",如下所示:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/KGIS_DLTB/packages.config b/KGIS_DLTB/packages.config
deleted file mode 100644
index e880d7c..0000000
--- a/KGIS_DLTB/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/KIngo.DataProcessing/App.config b/KIngo.DataProcessing/App.config
deleted file mode 100644
index 0169599..0000000
--- a/KIngo.DataProcessing/App.config
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/KIngo.DataProcessing/GdalConfiguration.cs b/KIngo.DataProcessing/GdalConfiguration.cs
deleted file mode 100644
index 2687e93..0000000
--- a/KIngo.DataProcessing/GdalConfiguration.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-/******************************************************************************
- *
- * Name: GdalConfiguration.cs.pp
- * Project: GDAL CSharp Interface
- * Purpose: A static configuration utility class to enable GDAL/OGR.
- * Author: Felix Obermaier
- *
- ******************************************************************************
- * Copyright (c) 2012-2018, Felix Obermaier
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *****************************************************************************/
-
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using Gdal = OSGeo.GDAL.Gdal;
-using Ogr = OSGeo.OGR.Ogr;
-
-namespace KIngo.DataProcessing
-{
- public static partial class GdalConfiguration
- {
- private static volatile bool _configuredOgr;
- private static volatile bool _configuredGdal;
- private static volatile bool _usable;
-
- [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
- static extern bool SetDefaultDllDirectories(uint directoryFlags);
- // LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
- private const uint DllSearchFlags = 0x00001000;
-
- [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- static extern bool AddDllDirectory(string lpPathName);
-
- ///
- /// Construction of Gdal/Ogr
- ///
- static GdalConfiguration()
- {
- string executingDirectory = null, gdalPath = null, nativePath = null;
- try
- {
- if (!IsWindows)
- {
- const string notSet = "_Not_set_";
- string tmp = Gdal.GetConfigOption("GDAL_DATA", notSet);
- _usable = tmp != notSet;
- return;
- }
-
- string executingAssemblyFile = new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;
- executingDirectory = Path.GetDirectoryName(executingAssemblyFile);
-
- if (string.IsNullOrEmpty(executingDirectory))
- throw new InvalidOperationException("cannot get executing directory");
-
-
- // modify search place and order
- //SetDefaultDllDirectories(DllSearchFlags);
-
- gdalPath = Path.Combine(executingDirectory, "gdal");
- nativePath = Path.Combine(gdalPath, GetPlatform());
- if (!Directory.Exists(nativePath))
- throw new DirectoryNotFoundException($"GDAL native directory not found at '{nativePath}'");
- if (!File.Exists(Path.Combine(nativePath, "gdal_wrap.dll")))
- throw new FileNotFoundException(
- $"GDAL native wrapper file not found at '{Path.Combine(nativePath, "gdal_wrap.dll")}'");
-
- // Add directories
- //AddDllDirectory(nativePath);
- //AddDllDirectory(Path.Combine(nativePath, "plugins"));
-
- // Set the additional GDAL environment variables.
- string gdalData = Path.Combine(gdalPath, "data");
- Environment.SetEnvironmentVariable("GDAL_DATA", gdalData);
- Gdal.SetConfigOption("GDAL_DATA", gdalData);
-
- string driverPath = Path.Combine(nativePath, "plugins");
- Environment.SetEnvironmentVariable("GDAL_DRIVER_PATH", driverPath);
- Gdal.SetConfigOption("GDAL_DRIVER_PATH", driverPath);
-
- Environment.SetEnvironmentVariable("GEOTIFF_CSV", gdalData);
- Gdal.SetConfigOption("GEOTIFF_CSV", gdalData);
-
- string projSharePath = Path.Combine(gdalPath, "share");
- Environment.SetEnvironmentVariable("PROJ_LIB", projSharePath);
- Gdal.SetConfigOption("PROJ_LIB", projSharePath);
- OSGeo.OSR.Osr.SetPROJSearchPaths(new[] { projSharePath });
- OSGeo.OSR.Osr.SetPROJSearchPath(@"./gdal/share");
-
- _usable = true;
- }
- catch (Exception e)
- {
- _usable = false;
- Trace.WriteLine(e, "error");
- Trace.WriteLine($"Executing directory: {executingDirectory}", "error");
- Trace.WriteLine($"gdal directory: {gdalPath}", "error");
- Trace.WriteLine($"native directory: {nativePath}", "error");
-
- //throw;
- }
- }
-
- ///
- /// Gets a value indicating if the GDAL package is set up properly.
- ///
- public static bool Usable
- {
- get { return _usable; }
- }
-
- ///
- /// Method to ensure the static constructor is being called.
- ///
- /// Be sure to call this function before using Gdal/Ogr/Osr
- public static void ConfigureOgr()
- {
- if (!_usable) return;
- if (_configuredOgr) return;
-
- // Register drivers
- Ogr.RegisterAll();
- _configuredOgr = true;
-
- PrintDriversOgr();
- }
-
- ///
- /// Method to ensure the static constructor is being called.
- ///
- /// Be sure to call this function before using Gdal/Ogr/Osr
- public static void ConfigureGdal()
- {
- if (!_usable) return;
- if (_configuredGdal) return;
-
- // Register drivers
- Gdal.AllRegister();
- _configuredGdal = true;
-
- PrintDriversGdal();
- }
-
-
- ///
- /// Function to determine which platform we're on
- ///
- private static string GetPlatform()
- {
- return Environment.Is64BitProcess ? "x64" : "x86";
- }
-
- ///
- /// Gets a value indicating if we are on a windows platform
- ///
- private static bool IsWindows
- {
- get
- {
- var res = !(Environment.OSVersion.Platform == PlatformID.Unix ||
- Environment.OSVersion.Platform == PlatformID.MacOSX);
-
- return res;
- }
- }
- private static void PrintDriversOgr()
- {
-#if DEBUG
- if (_usable)
- {
- var num = Ogr.GetDriverCount();
- for (var i = 0; i < num; i++)
- {
- var driver = Ogr.GetDriver(i);
- Trace.WriteLine($"OGR {i}: {driver.GetName()}", "Debug");
- }
- }
-#endif
- }
-
- private static void PrintDriversGdal()
- {
-#if DEBUG
- if (_usable)
- {
- var num = Gdal.GetDriverCount();
- for (var i = 0; i < num; i++)
- {
- var driver = Gdal.GetDriver(i);
- Trace.WriteLine($"GDAL {i}: {driver.ShortName}-{driver.LongName}");
- }
- }
-#endif
- }
- }
-}
\ No newline at end of file
diff --git a/KIngo.DataProcessing/KIngo.DataProcessing.csproj b/KIngo.DataProcessing/KIngo.DataProcessing.csproj
deleted file mode 100644
index d4a1e5e..0000000
--- a/KIngo.DataProcessing/KIngo.DataProcessing.csproj
+++ /dev/null
@@ -1,218 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {1572A6EB-AE63-42B0-B3A4-63D69C56C74A}
- WinExe
- KIngo.DataProcessing
- KIngo.DataProcessing
- v4.7.2
- 512
- true
- true
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- false
- true
- True
-
-
-
-
- AnyCPU
- true
- full
- false
- ..\Apps\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- true
-
-
- JKRJ.pfx
-
-
- NewIcon.ico
-
-
- LocalIntranet
-
-
- false
-
-
- Properties\app.manifest
-
-
-
- ..\packages\GDAL.3.5.0\lib\netstandard2.0\gdalconst_csharp.dll
-
-
- ..\packages\GDAL.3.5.0\lib\netstandard2.0\gdal_csharp.dll
-
-
- ..\packages\KGIS.Framework.AE.1.0.6\lib\KGIS.Framework.AE.dll
-
-
- ..\packages\Kingo.PluginLibrary.2.1.3\lib\KGIS.Framework.Commands.dll
-
-
- ..\packages\Kingo.PluginLibrary.2.1.3\lib\KGIS.Framework.Core.dll
-
-
- ..\packages\Kingo.PluginLibraryForMap.2.0.6\lib\KGIS.Framework.Maps.dll
-
-
- ..\packages\Kingo.PluginLibrary.2.1.3\lib\KGIS.Framework.Menus.dll
-
-
- ..\packages\KGIS.Framework.OpenData.1.0.0\lib\KGIS.Framework.OpenData.dll
-
-
- ..\packages\Kingo.PluginLibrary.2.1.3\lib\KGIS.Framework.Platform.dll
-
-
- ..\packages\Kingo.PluginLibrary.2.1.3\lib\KGIS.Framework.Utils.dll
-
-
- ..\packages\Kingo.PluginLibrary.2.1.3\lib\KGIS.Framework.Views.dll
-
-
- ..\packages\Kingo.Core.Authorize.1.1.15\lib\net452\Kingo.Core.Authorize.dll
-
-
- ..\packages\Kingo.Core.SntlAuthorize.1.0.5\lib\net452\Kingo.Core.SntlAuthorize.dll
-
-
- ..\packages\KUI.2.0.5\lib\KUI.dll
-
-
- ..\packages\log4net.2.0.12\lib\net45\log4net.dll
-
-
- ..\packages\KUI.2.0.5\lib\Microsoft.Windows.Shell.dll
-
-
- ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
-
-
- ..\packages\GDAL.3.5.0\lib\netstandard2.0\ogr_csharp.dll
-
-
- ..\packages\GDAL.3.5.0\lib\netstandard2.0\osr_csharp.dll
-
-
- ..\packages\KGIS.Framework.AE.1.0.6\lib\stdole.dll
- True
-
-
-
-
-
- ..\packages\KGIS.Framework.AE.1.0.6\lib\System.Data.SQLite.dll
-
-
-
-
- ..\packages\KUI.2.0.5\lib\System.Utility.dll
-
-
-
-
-
-
-
-
-
-
-
-
- ..\packages\Kingo.PluginLibrary.2.1.3\lib\UIShell.OSGi.dll
-
-
-
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- True
- Resources.resx
-
-
-
- Designer
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
- True
- Settings.settings
- True
-
-
-
-
-
-
-
- False
- Microsoft .NET Framework 4.7.2 %28x86 和 x64%29
- true
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
-
-
-
-
-
-
- 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/KIngo.DataProcessing/NewIcon.ico b/KIngo.DataProcessing/NewIcon.ico
deleted file mode 100644
index 167d94f..0000000
Binary files a/KIngo.DataProcessing/NewIcon.ico and /dev/null differ
diff --git a/KIngo.DataProcessing/Program.cs b/KIngo.DataProcessing/Program.cs
deleted file mode 100644
index 9082579..0000000
--- a/KIngo.DataProcessing/Program.cs
+++ /dev/null
@@ -1,302 +0,0 @@
-using KGIS.Framework.Core.Services;
-using KGIS.Framework.Platform;
-using KGIS.Framework.Platform.Interface;
-using KGIS.Framework.Utils;
-using KGIS.Framework.Utils.Helper;
-using Kingo;
-using Kingo.Core.Authorize;
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Diagnostics;
-using System.Linq;
-using System.Management;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.ServiceProcess;
-using System.Threading;
-using System.Windows.Forms;
-using UIShell.OSGi;
-
-namespace KIngo.DataProcessing
-{
- static class Program
- {
- internal delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
-
- [DllImport("user32.dll", EntryPoint = "FindWindow")]
- private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
-
- [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
- private static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- internal static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- internal static extern int GetWindowThreadProcessId(IntPtr hWnd, out IntPtr lpdwProcessId);
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- internal static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);
-
- [DllImport("USER32.DLL")]
- public static extern bool SetForegroundWindow(IntPtr hWnd);
- public static bool v = false;
- ///
- /// 应用程序的主入口点。
- ///
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- GdalConfiguration.ConfigureGdal();
- GdalConfiguration.ConfigureOgr();
- //Application.Run(platform.Instance);
- Platform.Instance.SystemType = SystemTypeEnum.TBBG;
- Mutex instance = new Mutex(true, $"{Platform.Instance.SystemType}_30", out bool createdNew);
- if (createdNew)
- {
- }
- else
- {
- //MessageHelper.ShowTips("已经打开该应用程序,请先关闭!");
- Process curr = Process.GetCurrentProcess();
-
- List process = Process.GetProcessesByName(curr.ProcessName).ToList();//.
- //Where(p => p.Id != curr.Id && p.GetCommandLine().Contains($"{Platform.Instance.SystemType}_30")).ToList();
-
- if (process != null && process.Count > 0)
- {
- foreach (Process item in process)
- {
- //IntPtr mainPtr = GetProcessHandle(item.Id);
- //ShowWindow(mainPtr, 3);
- ShowWindow(item.MainWindowHandle, 1);
- SetForegroundWindow(item.MainWindowHandle);
- break;
- }
- }
- Application.Exit();
- return;
- }
- try
- {
- ServiceController sc = new ServiceController("ArcGIS License Manager");
- if (!KGIS.Framework.AE.AELicense.AoInit(true) || sc.Status == ServiceControllerStatus.Stopped)
- {
- MessageHelper.Show("ArcGIS授权服务未启动或已到期,请检查ArcGIS授权!");
- return;
- }
- }
- catch (Exception EX)
- {
- MessageHelper.Show("ArcGIS授权服务未启动或已到期,请检查ArcGIS授权!");
- LogAPI.Debug(EX.Message);
- return;
- }
- using (var bundleRuntime = new BundleRuntime())
- {
- #region
- int loadedBundleCount = 0;
- Action action = null;
- IAsyncResult asyncResult = null;
- IPluginStart startPlugin = null;
- List bundles = new List();
- //插件状态发生改变事件,用来加载启动插件的进度
- EventHandler bundleStateChangeEventHandler = (sender, e) =>
- {
- if (e.CurrentState != BundleState.Starting || e.Bundle.Name == "SystemBundle")
- return;
- if (startPlugin == null)
- startPlugin = bundleRuntime.GetFirstOrDefaultService();
- string[] Name_ID = e.Bundle.Name.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
- if (startPlugin != null)
- {
- startPlugin.SetTitle(ConfigurationManager.AppSettings.Get("APPName"));
- startPlugin.SetSystemType(SystemTypeEnum.TBBG.ToString());
- if (Name_ID.Length == 2)
- {
- if (!Name_ID[1].Contains(SystemTypeEnum.TBBG.ToString()))
- {
- bundles.Add(e.Bundle);
- //e.Bundle.Stop(BundleStopOptions.Transient);
- }
- }
- //}
-
- if (!startPlugin.IsShow)
- {
- action = (ar) =>
- {
- if (ar)
- {
- startPlugin.ShowDialog();
- }
- else
- {
- }
- //isWelcomeShow = true;
- };
- asyncResult = action.BeginInvoke(true, null, null);
- //等待启动界面打开
- while (!startPlugin.IsShow)
- {
- Thread.Sleep(50);
- }
- loadedBundleCount++;
- startPlugin.SetPercent(loadedBundleCount, bundleRuntime.Framework.Bundles.Count - 1, Name_ID[0]);
- }
- else
- {
- loadedBundleCount++;
- startPlugin.SetPercent(loadedBundleCount, bundleRuntime.Framework.Bundles.Count - 1, Name_ID[0]);
- }
- }
- else
- {
- LogAPI.Debug("000000");
- }
- //e.Bundle.BundleID
- };
-#if DEBUG
- Validity(bundleRuntime);
-#else
- Validity(bundleRuntime);
-#endif
- if (!v)
- return;
-
- //注册插件状态事件
- bundleRuntime.Framework.EventManager.AddBundleEventListener(bundleStateChangeEventHandler, true);
- //开始启动插件
- bundleRuntime.Start();
- //取消插件状态的事件
- bundleRuntime.Framework.EventManager.RemoveBundleEventListener(bundleStateChangeEventHandler, true);
- #endregion
-
- foreach (IBundle item in bundles)
- {
- LogAPI.Debug("Del:" + item.Name);
- item.Stop(BundleStopOptions.Transient);
- }
-
- var platform = bundleRuntime.GetFirstOrDefaultService();
- if (platform != null)
- {
- //platform.InitService();
- Platform.Instance.Open();
- platform.InitUI(null);
- if (startPlugin != null)
- startPlugin.CloseForm();
- ExtensionShowWindow.MainWinForm = platform.Instance;
- Platform.Instance.OutputMsg("系统初始化完成。");
- Platform.Instance.UpdateStateBar("系统初始化完成");
-
- Application.Run(platform.Instance);
- RunIDService.Dispose();
- }
- else
- {
- LogAPI.Debug("IPlatformService接口获取失败!");
- }
- }
- }
-
- private static void Validity(object obj)
- {
- try
- {
- //判断授权方式
- var type = ConfigurationManager.AppSettings.Get("LicenseType");
- if (type == "F")//本地授权
- {
- Attribute guid_attr = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(GuidAttribute));
- string guid = ((GuidAttribute)guid_attr).Value;
- try
- {
- string[] licpath = System.IO.Directory.GetFiles(System.Environment.CurrentDirectory, "*.lic", System.IO.SearchOption.TopDirectoryOnly);
- if (licpath.Length == 0)
- {
- MessageHelper.ShowError("授权校验失败!");
- }
-
- if (licpath.Length == 0 || !RunIDService2.Instance.Verify(AuthorizeType.多合一授权, "BGDCPRO", "300", "3x", "", "10eaa61"))
- {
- KGIS.PlatformPlugin.Views.License.LicenseView lic = new KGIS.PlatformPlugin.Views.License.LicenseView(obj, "BGDCPRO", "300", "3x");
- lic.Code = "10eaa61";
- int num = -1;
- //lic.DocValidity = Validity;
- DialogResult dialog = lic.ShowDialog();
- if (dialog != DialogResult.Yes && dialog != DialogResult.OK)
- {
- v = false;
- return;
- }
- }
- else
- {
- v = true;
- return;
- }
- }
- catch (Exception ex)
- {
- MessageHelper.Show(ex.Message);
- LogAPI.Debug(ex);
- KGIS.PlatformPlugin.Views.License.LicenseView lic = new KGIS.PlatformPlugin.Views.License.LicenseView(obj, "BGDCPRO", "300", "3x");
- lic.Code = "10eaa61";
- int num = -1;
- //lic.DocValidity = Validity;
- DialogResult dialog = lic.ShowDialog();
- if (dialog != DialogResult.Yes || dialog != DialogResult.OK)
- {
- v = false;
- return;
- }
- }
- }
- else if (type == "D")
- {
- if (!RunIDService2.Instance.Verify("BGDCPRO", "300", "3x"))
- {
- KGIS.PlatformPlugin.Views.License.LicenseView lic = new KGIS.PlatformPlugin.Views.License.LicenseView(obj, "BGDCPRO", "300", "3x");
-
- DialogResult dialog = lic.ShowDialog();
- if (dialog != DialogResult.Yes && dialog != DialogResult.OK)
- {
- v = false;
- return;
- }
- }
- }
- else
- {
- KGIS.PlatformPlugin.Views.License.LicenseView lic = new KGIS.PlatformPlugin.Views.License.LicenseView(obj, "BGDCPRO", "300", "3x");
- int num = -1;
- lic.DocValidity = Validity;
- DialogResult dialog = lic.ShowDialog();
- if (dialog != DialogResult.Yes || dialog != DialogResult.OK)
- {
- v = false;
- return;
- }
- }
- v = true;
- }
- catch (Exception ex)
- {
- LogAPI.Debug(ex);
- }
- }
- private static string GetCommandLine(this Process process)
- {
- using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id))
- using (ManagementObjectCollection objects = searcher.Get())
- {
- return objects.Cast().SingleOrDefault()?["CommandLine"]?.ToString();
- }
-
- }
- }
-}
diff --git a/KIngo.DataProcessing/Properties/AssemblyInfo.cs b/KIngo.DataProcessing/Properties/AssemblyInfo.cs
deleted file mode 100644
index aafe13a..0000000
--- a/KIngo.DataProcessing/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的一般信息由以下
-// 控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("KIngo.DataProcessing")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("KIngo.DataProcessing")]
-[assembly: AssemblyCopyright("Copyright © 2022")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 会使此程序集中的类型
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
-//请将此类型的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("1572a6eb-ae63-42b0-b3a4-63d69c56c74a")]
-
-// 程序集的版本信息由下列四个值组成:
-//
-// 主版本
-// 次版本
-// 生成号
-// 修订号
-//
-//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
-//通过使用 "*",如下所示:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/KIngo.DataProcessing/Properties/Resources.Designer.cs b/KIngo.DataProcessing/Properties/Resources.Designer.cs
deleted file mode 100644
index ee020a3..0000000
--- a/KIngo.DataProcessing/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 此代码由工具生成。
-// 运行时版本: 4.0.30319.42000
-//
-// 对此文件的更改可能导致不正确的行为,如果
-// 重新生成代码,则所做更改将丢失。
-//
-//------------------------------------------------------------------------------
-
-
-namespace KIngo.DataProcessing.Properties
-{
- ///
- /// 强类型资源类,用于查找本地化字符串等。
- ///
- // 此类是由 StronglyTypedResourceBuilder
- // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
- // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
- // (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
- }
-
- ///
- /// 返回此类使用的缓存 ResourceManager 实例。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KIngo.DataProcessing.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// 重写当前线程的 CurrentUICulture 属性,对
- /// 使用此强类型资源类的所有资源查找执行重写。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/KIngo.DataProcessing/Properties/Resources.resx b/KIngo.DataProcessing/Properties/Resources.resx
deleted file mode 100644
index af7dbeb..0000000
--- a/KIngo.DataProcessing/Properties/Resources.resx
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/KIngo.DataProcessing/Properties/Settings.Designer.cs b/KIngo.DataProcessing/Properties/Settings.Designer.cs
deleted file mode 100644
index 437f28d..0000000
--- a/KIngo.DataProcessing/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-
-namespace KIngo.DataProcessing.Properties
-{
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default
- {
- get
- {
- return defaultInstance;
- }
- }
- }
-}
diff --git a/KIngo.DataProcessing/Properties/Settings.settings b/KIngo.DataProcessing/Properties/Settings.settings
deleted file mode 100644
index 3964565..0000000
--- a/KIngo.DataProcessing/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/KIngo.DataProcessing/Properties/app.manifest b/KIngo.DataProcessing/Properties/app.manifest
deleted file mode 100644
index da46558..0000000
--- a/KIngo.DataProcessing/Properties/app.manifest
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/KIngo.DataProcessing/TBBG.ico b/KIngo.DataProcessing/TBBG.ico
deleted file mode 100644
index 167d94f..0000000
Binary files a/KIngo.DataProcessing/TBBG.ico and /dev/null differ
diff --git a/KIngo.DataProcessing/packages.config b/KIngo.DataProcessing/packages.config
deleted file mode 100644
index 622ac64..0000000
--- a/KIngo.DataProcessing/packages.config
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Kingo.BuildDB.sln b/Kingo.BuildDB.sln
index 994ee05..bca8311 100644
--- a/Kingo.BuildDB.sln
+++ b/Kingo.BuildDB.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 18
-VisualStudioVersion = 18.0.11123.170
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36623.8 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kingo.BuildDB", "Kingo.PluginClient\Kingo.BuildDB.csproj", "{08716CF2-16E4-445A-8FD6-CB50010EAA61}"
EndProject
@@ -23,16 +23,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kingo.PluginServiceInterfac
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KGIS.Plugin.LayerProperty", "Kingo.Plugins\KGIS.Plugin.LayerProperty\KGIS.Plugin.LayerProperty.csproj", "{9CC2C7EC-6E24-4C13-9927-83C48E0E6C66}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KIngo.DataProcessing", "KIngo.DataProcessing\KIngo.DataProcessing.csproj", "{1572A6EB-AE63-42B0-B3A4-63D69C56C74A}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kingo.Framework.LayerStyleConvert", "Kingo.Plugins\Kingo.Framework.LayerStyleConvert\Kingo.Framework.LayerStyleConvert.csproj", "{2592A112-78AE-448D-A828-4DB3C5300E92}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "IDEParameter", "IDEParameter\IDEParameter.shproj", "{BFF9CCC3-7B6D-4984-BC9A-CF7E90807C0A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GPHelper", "GPHelper\GPHelper.csproj", "{D1BB1EC2-2112-4BE2-AB12-5F4394D8BEE8}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KGIS_DLTB", "KGIS_DLTB\KGIS_DLTB.csproj", "{D900B82F-E8D3-45BD-985C-CE6A64DD4322}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JKRJ_Startup", "JKRJ_Startup\JKRJ_Startup.csproj", "{1533760F-9DE6-4313-9DDF-B82A345D1397}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kingo.ThreadManager", "Kingo.ThreadManager\Kingo.ThreadManager.csproj", "{E94D3521-CDCF-4E00-80BB-0C81EF14C85C}"
@@ -125,14 +121,6 @@ Global
{9CC2C7EC-6E24-4C13-9927-83C48E0E6C66}.Release|Any CPU.Build.0 = Release|Any CPU
{9CC2C7EC-6E24-4C13-9927-83C48E0E6C66}.Release|x86.ActiveCfg = Release|x86
{9CC2C7EC-6E24-4C13-9927-83C48E0E6C66}.Release|x86.Build.0 = Release|x86
- {1572A6EB-AE63-42B0-B3A4-63D69C56C74A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1572A6EB-AE63-42B0-B3A4-63D69C56C74A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1572A6EB-AE63-42B0-B3A4-63D69C56C74A}.Debug|x86.ActiveCfg = Debug|Any CPU
- {1572A6EB-AE63-42B0-B3A4-63D69C56C74A}.Debug|x86.Build.0 = Debug|Any CPU
- {1572A6EB-AE63-42B0-B3A4-63D69C56C74A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1572A6EB-AE63-42B0-B3A4-63D69C56C74A}.Release|Any CPU.Build.0 = Release|Any CPU
- {1572A6EB-AE63-42B0-B3A4-63D69C56C74A}.Release|x86.ActiveCfg = Release|Any CPU
- {1572A6EB-AE63-42B0-B3A4-63D69C56C74A}.Release|x86.Build.0 = Release|Any CPU
{2592A112-78AE-448D-A828-4DB3C5300E92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2592A112-78AE-448D-A828-4DB3C5300E92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2592A112-78AE-448D-A828-4DB3C5300E92}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -149,14 +137,6 @@ Global
{D1BB1EC2-2112-4BE2-AB12-5F4394D8BEE8}.Release|Any CPU.Build.0 = Release|Any CPU
{D1BB1EC2-2112-4BE2-AB12-5F4394D8BEE8}.Release|x86.ActiveCfg = Release|Any CPU
{D1BB1EC2-2112-4BE2-AB12-5F4394D8BEE8}.Release|x86.Build.0 = Release|Any CPU
- {D900B82F-E8D3-45BD-985C-CE6A64DD4322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D900B82F-E8D3-45BD-985C-CE6A64DD4322}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D900B82F-E8D3-45BD-985C-CE6A64DD4322}.Debug|x86.ActiveCfg = Debug|Any CPU
- {D900B82F-E8D3-45BD-985C-CE6A64DD4322}.Debug|x86.Build.0 = Debug|Any CPU
- {D900B82F-E8D3-45BD-985C-CE6A64DD4322}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D900B82F-E8D3-45BD-985C-CE6A64DD4322}.Release|Any CPU.Build.0 = Release|Any CPU
- {D900B82F-E8D3-45BD-985C-CE6A64DD4322}.Release|x86.ActiveCfg = Release|Any CPU
- {D900B82F-E8D3-45BD-985C-CE6A64DD4322}.Release|x86.Build.0 = Release|Any CPU
{1533760F-9DE6-4313-9DDF-B82A345D1397}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1533760F-9DE6-4313-9DDF-B82A345D1397}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1533760F-9DE6-4313-9DDF-B82A345D1397}.Debug|x86.ActiveCfg = Debug|Any CPU
diff --git a/Kingo.PluginClient/Program.cs b/Kingo.PluginClient/Program.cs
index 2fd6bb3..de762b9 100644
--- a/Kingo.PluginClient/Program.cs
+++ b/Kingo.PluginClient/Program.cs
@@ -1,12 +1,4 @@
-using Fleck;
-using KGIS.Framework.Core.Services;
-using KGIS.Framework.Platform;
-using KGIS.Framework.Platform.Interface;
-using KGIS.Framework.Utils;
-using KGIS.Framework.Utils.Helper;
-using Kingo.PluginServiceInterface;
-using Microsoft.Win32;
-using System;
+using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
@@ -15,6 +7,14 @@ using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Threading;
using System.Windows.Forms;
+using Fleck;
+using KGIS.Framework.Core.Services;
+using KGIS.Framework.Platform;
+using KGIS.Framework.Platform.Interface;
+using KGIS.Framework.Utils;
+using KGIS.Framework.Utils.Helper;
+using Kingo.PluginServiceInterface;
+using Microsoft.Win32;
using UIShell.OSGi;
namespace Kingo.BuildDB
diff --git a/Kingo.PluginServiceInterface/Kingo.PluginServiceInterface.csproj b/Kingo.PluginServiceInterface/Kingo.PluginServiceInterface.csproj
index cdb93ca..b4bd884 100644
--- a/Kingo.PluginServiceInterface/Kingo.PluginServiceInterface.csproj
+++ b/Kingo.PluginServiceInterface/Kingo.PluginServiceInterface.csproj
@@ -115,9 +115,11 @@
..\Lib\GDAL.CSharp.dll
- False
..\packages\GeoAPI.Core.1.7.5\lib\net45\GeoAPI.dll
+
+ ..\packages\GeoAPI.CoordinateSystems.1.7.5\lib\net45\GeoAPI.CoordinateSystems.dll
+
False
..\packages\KGIS.Framework.AE.1.0.6\lib\KGIS.Framework.AE.dll
@@ -188,9 +190,11 @@
..\packages\KUI.2.0.5\lib\Microsoft.Windows.Shell.dll
- False
..\packages\NetTopologySuite.Core.1.15.3\lib\net45\NetTopologySuite.dll
+
+ ..\packages\NetTopologySuite.CoordinateSystems.1.15.3\lib\net45\NetTopologySuite.CoordinateSystems.dll
+
..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
diff --git a/Kingo.PluginServiceInterface/packages.config b/Kingo.PluginServiceInterface/packages.config
index bf74c9b..8d79c72 100644
--- a/Kingo.PluginServiceInterface/packages.config
+++ b/Kingo.PluginServiceInterface/packages.config
@@ -1,12 +1,17 @@
+
+
+
+
+
diff --git a/Kingo.Plugins/Kingo.Plugin.MapView/Commands/CmdCopyFileData.cs b/Kingo.Plugins/Kingo.Plugin.MapView/Commands/CmdCopyFileData.cs
deleted file mode 100644
index 8bfc5ea..0000000
--- a/Kingo.Plugins/Kingo.Plugin.MapView/Commands/CmdCopyFileData.cs
+++ /dev/null
@@ -1,520 +0,0 @@
-using ESRI.ArcGIS.Controls;
-using ESRI.ArcGIS.Geodatabase;
-using KGIS.Framework.AE;
-using KGIS.Framework.Commands;
-using KGIS.Framework.DBOperator;
-using KGIS.Framework.Maps;
-using KGIS.Framework.Platform;
-using KGIS.Framework.Utils;
-using KGIS.Framework.Utils.Helper;
-using KGIS.Framework.Views;
-using Kingo.PluginServiceInterface;
-using KUI.Windows;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.SQLite;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using UIShell.OSGi;
-
-namespace Kingo.Plugin.MapView.Commands
-{
- ///
- /// 同步模板数据
- ///
- public class CmdCopyFileData : BaseMenuCommand
- {
- private IEngineEditor m_Editor;
- public IHookHelper m_hookHelper { get; set; }
-
- private ProjectInfo projectInfo = null;
-
- public override void OnClick()
- {
- projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
- CopyFileData();
- }
-
- public override void OnCreate(object Hook)
- {
- try
- {
- if (m_hookHelper == null)
- {
- m_hookHelper = new HookHelper
- {
- Hook = Hook
- };
- }
- if (m_Editor == null)
- m_Editor = new EngineEditorClass();
- }
- catch (Exception ex)
- {
- LogAPI.Debug("初始化 同步模板数据 时异常,异常信息如下:");
- LogAPI.Debug(ex);
- LogAPI.Debug("初始化 同步模板数据 时异常信息结束");
- }
- }
-
- public override bool Enabled
- {
- get
- {
- //验证是否打开工程
- object ProInfo = KGIS.Framework.Maps.MapsManager.Instance.MapService.GetProjectInfo();
- if (ProInfo == null)
- return false;
- else
- return true;
- }
- }
-
- private void CopyFileData()
- {
- try
- {
- this.ShowLoading("正在进行同步模板数据.......", 0, 0);
- //GDB 1、BGDB.gdb 2、NMDB.gdb 3、Scheme0.gdb 4、Scheme-YCL.gdb 5、ZLDB.gdb
- CopyGDB("BGDB");
- CopyGDB("ZLDB");
- CopyGDB("NMDB");
- CopyGDB("Scheme0");
- CopyGDB("Scheme-YCL");
-
- //BGTJ.sqlite 里面的表格
- CopySqlite();
-
- //变更成果模板
- CopyBGCG();
-
- //dic.mdb ReportData.db 变更成果检查.xls 检查数据.xls 土地变更一览表.xls
- CopyFile();
-
- //DataCheckrResult.db
- CopyDataCheckrResultDB();
-
- //QualityCheckResult.db
- CopyQualityCheckResultDB();
-
- this.CloseLoading();
- MessageHelper.ShowTips("同步模板数据完成!");
- }
- catch (Exception ex)
- {
- this.CloseLoading();
- LogAPI.Debug("同步工程模板数据异常:" + ex.Message);
- LogAPI.Debug("同步工程模板数据异常:" + ex.StackTrace);
- MessageHelper.ShowTips("同步工程模板数据异常:" + ex.Message);
- }
- }
-
- private void CopyGDB(string GDBFileName)
- {
- IWorkspaceAPI templatewsAPI = null;
- IWorkspaceAPI projectwsAPI = null;
- try
- {
- string templateBGDBPath = SysAppPath.GetCurrentAppPath() + string.Format("工作空间\\模板\\新建变更工程\\{0}\\{1}.gdb", (int)Math.Floor(Math.Round(10 / projectInfo.XYResolution)), GDBFileName);
- if (GDBFileName.Contains("Scheme0") || GDBFileName.Contains("Scheme-YCL"))
- templateBGDBPath = SysAppPath.GetCurrentAppPath() + string.Format("工作空间DTBJK\\DatabaseTemplate\\{0}.gdb", GDBFileName);
-
- string projectBGDBPath = Path.Combine(projectInfo.ProjDir, $"{GDBFileName}.gdb");
- //先判定工程中GDB是否有数据
- //若没有数据 则直接copy
- //若有数据 则遍历模板GDB中字段 再遍历工程中GDB字段 判断是否一样
- if (!Directory.Exists(templateBGDBPath)) return;
- templatewsAPI = new WorkspaceAPI(templateBGDBPath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile, true);
- List templatefeatureClasses = templatewsAPI.GetAllFeatureClass(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTAny);
- if (templatefeatureClasses != null)
- {
- if (!Directory.Exists(projectBGDBPath))
- {
- PluginServiceInterface.CommonHelper.DirectoryCopy(templateBGDBPath, projectInfo.ProjDir);
- return;
- }
- projectwsAPI = new WorkspaceAPI(projectBGDBPath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile, true);
- List projectfeatureClasses = projectwsAPI.GetAllFeatureClass(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTAny);
-
- if (projectfeatureClasses != null)
- {
- bool isEmpty = true;
- foreach (IFeatureClass projectfeatureClass in projectfeatureClasses)
- {
- if (projectfeatureClass.FeatureCount(null) > 0)
- {
- isEmpty = false;
- break;
- }
- }
- if (isEmpty)
- {
- PluginServiceInterface.CommonHelper.DirectoryCopy(templateBGDBPath, projectInfo.ProjDir);
- }
- else
- {
- //判断增删IFeatureClass
- foreach (IFeatureClass projectfeatureClass in projectfeatureClasses)
- {
- if (templatefeatureClasses.FirstOrDefault(a => (a as FeatureClass).BrowseName == (projectfeatureClass as FeatureClass).BrowseName) == null)
- {
- //需删除
- projectwsAPI.DeleteFeatureClass((projectfeatureClass as FeatureClass).BrowseName);
- projectfeatureClasses.Remove(projectfeatureClass);
- }
- }
- foreach (IFeatureClass templatefeatureClass in templatefeatureClasses)
- {
- if (projectfeatureClasses.FirstOrDefault(a => (a as FeatureClass).BrowseName == (templatefeatureClass as FeatureClass).BrowseName) == null)
- {
- //需添加
- IFeatureClass newFeatureClass = projectwsAPI.CreateFeatureClass((templatefeatureClass as FeatureClass).BrowseName, projectfeatureClasses[0].FeatureDataset, (projectfeatureClasses[0] as IGeoDataset).SpatialReference, ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon, templatefeatureClass.Fields).FeatureClass;
- Marshal.ReleaseComObject(newFeatureClass);
- }
- }
-
- //判断每一个IFeatureClass中的字段
- foreach (IFeatureClass projectfeatureClass in projectfeatureClasses)
- {
- string featureName = (projectfeatureClass as FeatureClass).BrowseName;
- IFeatureClass currentTempFeatureClass = templatefeatureClasses.FirstOrDefault(a => (a as FeatureClass).BrowseName == featureName);
- if (currentTempFeatureClass == null) currentTempFeatureClass = templatefeatureClasses.FirstOrDefault(a => a.AliasName == projectfeatureClass.AliasName);
-
- for (int i = 0; i < currentTempFeatureClass.Fields.FieldCount; i++)
- {
- IField field = currentTempFeatureClass.Fields.get_Field(i);
- if (projectfeatureClass.FindField(field.Name) == -1)
- {
- projectfeatureClass.AddField(field);
- }
- }
-
- for (int i = projectfeatureClass.Fields.FieldCount - 1; i >= 0; i--)
- {
- IField field = projectfeatureClass.Fields.get_Field(i);
- if (currentTempFeatureClass.FindField(field.Name) == -1)
- {
- projectfeatureClass.DeleteField(field);
- }
- }
- }
-
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogAPI.Debug("同步工程GDB模板数据异常:" + ex.Message);
- LogAPI.Debug("同步工程GDB模板数据异常:" + ex.StackTrace);
- }
- finally
- {
- if (templatewsAPI != null)
- templatewsAPI.CloseWorkspace();
- if (projectwsAPI != null)
- projectwsAPI.CloseWorkspace();
- }
- }
-
- private void CopyTable(string sourceDatabase, string targetDatabase, string tableName)
- {
- SQLiteConnection sourceConnection = new SQLiteConnection($"Data Source={sourceDatabase}");
- SQLiteConnection targetConnection = new SQLiteConnection($"Data Source={targetDatabase}");
- try
- {
- // 打开源数据库连接
- sourceConnection.Open();
-
- // 打开目标数据库连接
- targetConnection.Open();
-
- // 创建SELECT语句查询源表的数据
- string selectQuery = $"SELECT * FROM {tableName}";
- SQLiteCommand selectCommand = new SQLiteCommand(selectQuery, sourceConnection);
-
- // 执行SELECT语句并读取数据
- SQLiteDataReader reader = selectCommand.ExecuteReader();
-
- // 获取源表的列名
- List columnNames = new List();
- for (int i = 0; i < reader.FieldCount; i++)
- {
- columnNames.Add(reader.GetName(i));
- }
-
- // 构建INSERT语句和参数
- StringBuilder insertQuery = new StringBuilder();
- insertQuery.Append($"INSERT INTO {tableName} (");
-
- StringBuilder columninsertQuery = new StringBuilder();
- foreach (string columnName in columnNames)
- {
- columninsertQuery.Append($"{columnName}, ");
- }
- columninsertQuery.Length -= 2; // 移除最后一个逗号和空格
-
- insertQuery.Append(columninsertQuery);
- insertQuery.Append(") VALUES (");
-
- foreach (string columnName in columnNames)
- {
- insertQuery.Append($"@{columnName}, ");
- }
- insertQuery.Length -= 2; // 移除最后一个逗号和空格
- insertQuery.Append(")");
-
- SQLiteCommand insertCommand = new SQLiteCommand(insertQuery.ToString(), targetConnection);
- //insertCommand.ExecuteNonQuery();
-
- // 根据源表的列名设置参数
- foreach (string columnName in columnNames)
- {
- insertCommand.Parameters.AddWithValue($"@{columnName}", null);
- }
-
- // 创建CREATE TABLE语句查询源表的结构
- string createTableQuery = "CREATE TABLE if not exists " + tableName + "(" + columninsertQuery + ");";
- SQLiteCommand createTableCommand = new SQLiteCommand(createTableQuery, targetConnection);
- // 执行CREATE TABLE语句
- createTableCommand.ExecuteNonQuery();
-
- // 遍历源表数据并插入到目标表
- while (reader.Read())
- {
- foreach (string columnName in columnNames)
- {
- insertCommand.Parameters[$"@{columnName}"].Value = reader[columnName];
- }
-
- int aaa = insertCommand.ExecuteNonQuery();
- }
-
- // 关闭数据读取器和连接对象
- reader.Close();
- sourceConnection.Close();
- targetConnection.Close();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
-
- private void CopySqlite()
- {
- IRDBHelper rdbHelper = null;
- List tableNames = new List() { "AttributeCheckRule", "CheckingRule", "Sys_DicDetail", "Sys_DicManage" };
- try
- {
- string templateFilePath = SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\BGTJ.sqlite";
- string projectFilePath = projectInfo.ProjDir + "\\BGTJ.sqlite";
- if (File.Exists(templateFilePath))
- {
- if (File.Exists(projectFilePath))
- {
- rdbHelper = RDBFactory.CreateDbHelper(projectFilePath, DatabaseType.SQLite);
- foreach (string tableName in tableNames)
- {
- if (rdbHelper.TableIsExist(tableName))
- rdbHelper.ExecuteSQL($" drop TABLE {tableName} ");
-
- CopyTable(templateFilePath, projectFilePath, tableName);
- }
- }
- else
- File.Copy(templateFilePath, projectFilePath, true);
- }
-
- }
- catch (Exception ex)
- {
- LogAPI.Debug("同步工程模板CopySqlite异常:" + ex.Message);
- LogAPI.Debug("同步工程模板CopySqlite异常:" + ex.StackTrace);
- }
- finally
- {
- if (rdbHelper != null && rdbHelper.Connect())
- rdbHelper.DisConnect();
- }
- }
-
- private void CopyBGCG()
- {
- try
- {
- string templateFilePath = SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\变更成果模板";
- string projectFilePath = projectInfo.ProjDir + "\\变更成果模板";
- if (Directory.Exists(templateFilePath))
- {
- PluginServiceInterface.CommonHelper.DirectoryCopy(templateFilePath, projectFilePath);
- }
- }
- catch (Exception ex)
- {
- LogAPI.Debug("同步工程模板CopyBGCG异常:" + ex.Message);
- LogAPI.Debug("同步工程模板CopyBGCG异常:" + ex.StackTrace);
- }
- }
-
- private void CopyFile()
- {
- string templateFilePath = string.Empty;
- string projectFilePath = string.Empty;
- try
- {
- List fileNames = new List() { "dic.mdb", "ReportData.db", "变更成果检查.xls", "检查数据.xls", "土地变更一览表.xls" };
- foreach (string fileName in fileNames)
- {
- templateFilePath = SysAppPath.GetCurrentAppPath() + $"工作空间\\模板\\新建变更工程\\{fileName}";
- projectFilePath = projectInfo.ProjDir + $"\\{fileName}";
- if (!File.Exists(templateFilePath)) continue;
- File.Copy(templateFilePath, projectFilePath, true);
- }
- }
- catch (Exception ex)
- {
- LogAPI.Debug("同步工程模板CopyFile异常:" + ex.Message);
- LogAPI.Debug("同步工程模板CopyFile异常:" + ex.StackTrace);
- }
- }
-
- private void CopyDataCheckrResultDB()
- {
- string templateFilePath = string.Empty;
- string projectFilePath = string.Empty;
- IRDBHelper rdbHelper = null;
- IRDBHelper rdbHelperTemplate = null;
- try
- {
- List tableNames = new List() { "DelectFJ", "ErrorInfo" };
- templateFilePath = SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\DataCheckrResult.db";
- projectFilePath = projectInfo.ProjDir + "\\DataCheckrResult.db";
- if (File.Exists(templateFilePath))
- {
- if (File.Exists(projectFilePath))
- {
- rdbHelperTemplate = RDBFactory.CreateDbHelper(templateFilePath, DatabaseType.SQLite);
- rdbHelper = RDBFactory.CreateDbHelper(projectFilePath, DatabaseType.SQLite);
- foreach (string tableName in tableNames)
- {
- if (!rdbHelper.TableIsExist(tableName))
- {
- CopyTable(templateFilePath, projectFilePath, tableName);
- continue;
- }
- DataTable templatedataTable = rdbHelperTemplate.ExecuteDatatable(tableName + "Temp", $"select * from {tableName}", true);
- DataTable dataTable = rdbHelper.ExecuteDatatable(tableName, $"select * from {tableName}", true);
- if (dataTable != null)
- {
- for (int i = 0; i < templatedataTable.Columns.Count; i++)
- {
- if (!dataTable.Columns.Contains(templatedataTable.Columns[i].ColumnName))
- {
- dataTable.Columns.Add(templatedataTable.Columns[i]);
- }
- }
-
- for (int i = dataTable.Columns.Count - 1; i >= 0; i--)
- {
- if (!templatedataTable.Columns.Contains(dataTable.Columns[i].ColumnName))
- {
- dataTable.Columns.Remove(dataTable.Columns[i]);
- }
- }
-
- }
- else
- CopyTable(templateFilePath, projectFilePath, tableName);
- }
- }
- else
- File.Copy(templateFilePath, projectFilePath, true);
- }
- }
- catch (Exception ex)
- {
- LogAPI.Debug("同步工程模板CopyDataCheckrResultDB异常:" + ex.Message);
- LogAPI.Debug("同步工程模板CopyDataCheckrResultDB异常:" + ex.StackTrace);
- }
- finally
- {
- if (rdbHelper != null && rdbHelper.Connect())
- rdbHelper.DisConnect();
- if (rdbHelperTemplate != null && rdbHelperTemplate.Connect())
- rdbHelperTemplate.DisConnect();
- }
- }
-
- private void CopyQualityCheckResultDB()
- {
- string templateFilePath = string.Empty;
- string projectFilePath = string.Empty;
- IRDBHelper rdbHelper = null;
- IRDBHelper rdbHelperTemplate = null;
- try
- {
- List tableNames = new List() { "ErrorBGYLB", "ErrorBGYLBSM", "ErrorBasic", "ErrorReport", "ErrorTC" };
- templateFilePath = SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\QualityCheckResult.db";
- projectFilePath = projectInfo.ProjDir + "\\QualityCheckResult.db";
- if (File.Exists(templateFilePath))
- {
- if (File.Exists(projectFilePath))
- {
- rdbHelperTemplate = RDBFactory.CreateDbHelper(templateFilePath, DatabaseType.SQLite);
- rdbHelper = RDBFactory.CreateDbHelper(projectFilePath, DatabaseType.SQLite);
- foreach (string tableName in tableNames)
- {
- if (!rdbHelper.TableIsExist(tableName))
- {
- CopyTable(templateFilePath, projectFilePath, tableName);
- continue;
- }
- DataTable templatedataTable = rdbHelperTemplate.ExecuteDatatable(tableName + "Temp", $"select * from {tableName}", true);
- DataTable dataTable = rdbHelper.ExecuteDatatable(tableName, $"select * from {tableName}", true);
- if (dataTable != null)
- {
- for (int i = 0; i < templatedataTable.Columns.Count; i++)
- {
- if (!dataTable.Columns.Contains(templatedataTable.Columns[i].ColumnName))
- {
- dataTable.Columns.Add(templatedataTable.Columns[i]);
- }
- }
-
- for (int i = dataTable.Columns.Count - 1; i >= 0; i--)
- {
- if (!templatedataTable.Columns.Contains(dataTable.Columns[i].ColumnName))
- {
- dataTable.Columns.Remove(dataTable.Columns[i]);
- }
- }
-
- }
- else
- CopyTable(templateFilePath, projectFilePath, tableName);
- }
- }
- else
- File.Copy(templateFilePath, projectFilePath, true);
- }
- }
- catch (Exception ex)
- {
- LogAPI.Debug("同步工程模板CopyQualityCheckResultDB异常:" + ex.Message);
- LogAPI.Debug("同步工程模板CopyQualityCheckResultDB异常:" + ex.StackTrace);
- }
- finally
- {
- if (rdbHelper != null && rdbHelper.Connect())
- rdbHelper.DisConnect();
- if (rdbHelperTemplate != null && rdbHelperTemplate.Connect())
- rdbHelperTemplate.DisConnect();
- }
- }
-
- }
-}
diff --git a/Kingo.Plugins/Kingo.Plugin.MapView/Kingo.Plugin.MapView.csproj b/Kingo.Plugins/Kingo.Plugin.MapView/Kingo.Plugin.MapView.csproj
index e856eb7..608687e 100644
--- a/Kingo.Plugins/Kingo.Plugin.MapView/Kingo.Plugin.MapView.csproj
+++ b/Kingo.Plugins/Kingo.Plugin.MapView/Kingo.Plugin.MapView.csproj
@@ -414,7 +414,6 @@
-
diff --git a/Kingo.Plugins/Kingo.Plugin.MapView/Manifest.xml b/Kingo.Plugins/Kingo.Plugin.MapView/Manifest.xml
index 3be7ea5..61daa65 100644
--- a/Kingo.Plugins/Kingo.Plugin.MapView/Manifest.xml
+++ b/Kingo.Plugins/Kingo.Plugin.MapView/Manifest.xml
@@ -343,17 +343,6 @@
ShortcutKeys=""
LocationUri="Menu.Start.Group.ProjManage"
CommandId="Kingo.Plugin.MapView.Commands.CmdCloseProject"/>
-