From cd2f07da67b9fe66ca9c77193daac2b2fca51014 Mon Sep 17 00:00:00 2001 From: huhaijun Date: Thu, 30 Oct 2025 17:17:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 - .../Commands/CmdDataConversion.cs | 55 -- .../Commands/CmdLayerDataExport.cs | 20 +- .../Commands/CmdLoadBaseData.cs | 31 +- .../Commands/CmdLoadDB.cs | 5 +- .../Commands/CmdLoadProjectData.cs | 77 -- .../Kingo.Plugin.DataLoad/Commands/CmdSJTQ.cs | 59 -- .../Kingo.Plugin.DataLoad.csproj | 24 - .../Kingo.Plugin.DataLoad/Manifest.xml | 33 - .../View/FrmDataConversion.xaml | 64 -- .../View/FrmDataConversion.xaml.cs | 749 ------------------ .../View/FrmLoadProjectData.xaml | 51 -- .../View/FrmLoadProjectData.xaml.cs | 176 ---- .../Kingo.Plugin.DataLoad/View/FrmSJTQ.xaml | 52 -- .../View/FrmSJTQ.xaml.cs | 600 -------------- .../Kingo.Plugin.MapView/UcMapControl.cs | 119 +-- 16 files changed, 35 insertions(+), 2086 deletions(-) delete mode 100644 Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdDataConversion.cs delete mode 100644 Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadProjectData.cs delete mode 100644 Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdSJTQ.cs delete mode 100644 Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmDataConversion.xaml delete mode 100644 Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmDataConversion.xaml.cs delete mode 100644 Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmLoadProjectData.xaml delete mode 100644 Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmLoadProjectData.xaml.cs delete mode 100644 Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmSJTQ.xaml delete mode 100644 Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmSJTQ.xaml.cs diff --git a/.gitignore b/.gitignore index a0e13ac..4503250 100644 --- a/.gitignore +++ b/.gitignore @@ -413,12 +413,6 @@ FodyWeavers.xsd /发布 /Confused/Apps /Apps/Template/JK_Task.jkrw -/在线建库/Kingo.DataRepairServiceAPI/日志 -/在线建库/Kingo.DataRepairServiceAPI/Temp -/在线建库/Kingo.OnlineBuildDB.API1 -/在线建库/Kingo.OnlineBuildDB.API.rar -/在线建库/Kingo.DataRepairServiceAPI/NO -/在线建库/WinServiceAPI/日志/log20240829.txt /Kingo.Plugins/Apps/Plugins/Kingo.Plugin.DataCheck /在线建库/linux.rar /在线建库/WinServiceAPI/日志/log20240910.txt diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdDataConversion.cs b/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdDataConversion.cs deleted file mode 100644 index 851c28c..0000000 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdDataConversion.cs +++ /dev/null @@ -1,55 +0,0 @@ -using ESRI.ArcGIS.Controls; -using KGIS.Framework.Commands; -using KGIS.Framework.Utils.Helper; -using Kingo.Plugin.DataLoad.View; -using System; - -namespace Kingo.Plugin.DataLoad.Commands -{ - public class CmdDataConversion : BaseMenuCommand - { - private EngineEditorClass pEditor = null; - public IHookHelper m_hookHelper; - public override void OnClick() - { - try - { - if (pEditor == null) - pEditor = new EngineEditorClass(); - if (pEditor.EditState != esriEngineEditState.esriEngineStateNotEditing) - { - MessageHelper.ShowTips("请先关闭编辑!"); - return; - } - - FrmDataConversion main = new FrmDataConversion - { - WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen - }; - main.ShowInMainWindow(true); - } - catch (Exception ex) - { - MessageHelper.ShowError("初始化数据转换页面异常:" + ex.Message); - PluginServiceInterface.CommonHelper.RecordsErrLog("初始化数据转换页面异常:", ex); - } - } - - public override void OnCreate(object Hook) - { - if (Hook == null) return; - try - { - if (m_hookHelper == null) - m_hookHelper = new HookHelperClass { Hook = Hook }; - if (pEditor == null) - pEditor = new EngineEditorClass(); - } - catch - { - m_hookHelper = null; - return; - } - } - } -} diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLayerDataExport.cs b/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLayerDataExport.cs index 2977ad1..e56e29a 100644 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLayerDataExport.cs +++ b/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLayerDataExport.cs @@ -3,14 +3,9 @@ using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.Geodatabase; using KGIS.Framework.AE.ExtensionMethod; using KGIS.Framework.Maps; -using KGIS.Framework.Utils; using KGIS.Framework.Utils.Helper; using Kingo.Plugin.DataLoad.View; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Kingo.Plugin.DataLoad.Commands { @@ -19,8 +14,9 @@ namespace Kingo.Plugin.DataLoad.Commands /// public class CmdLayerDataExport : BaseMapMenuCommand { - private IEngineEditor editor = null; - private new IHookHelper m_hookHelper = null; + private IEngineEditor editor { get; set; } + private IHookHelper HookHelper { get; set; } + public override void OnClick() { try @@ -29,7 +25,7 @@ namespace Kingo.Plugin.DataLoad.Commands { editor = new EngineEditorClass(); } - object pTargetObj = m_hookHelper.GetCustomProperty(); + object pTargetObj = HookHelper.GetCustomProperty(); if (pTargetObj != null) { IFeatureLayer pFeatureLayer = pTargetObj as IFeatureLayer; @@ -68,10 +64,12 @@ namespace Kingo.Plugin.DataLoad.Commands { try { - if (m_hookHelper == null) + if (HookHelper == null) { - m_hookHelper = new HookHelper(); - m_hookHelper.Hook = Hook; + HookHelper = new HookHelper + { + Hook = Hook + }; } editor = new EngineEditorClass(); } diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadBaseData.cs b/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadBaseData.cs index 89c3a54..d97a52c 100644 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadBaseData.cs +++ b/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadBaseData.cs @@ -32,8 +32,10 @@ namespace Kingo.Plugin.DataLoad.Commands } try { - FrmLoadBaseData frmLoadBaseData = new FrmLoadBaseData(m_hookHelper); - frmLoadBaseData.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; + FrmLoadBaseData frmLoadBaseData = new FrmLoadBaseData(m_hookHelper) + { + WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen + }; frmLoadBaseData.ShowInMainWindow(true); } catch (Exception ex) @@ -45,7 +47,7 @@ namespace Kingo.Plugin.DataLoad.Commands } } - void main_Closed(object sender, EventArgs e) + private void Main_Closed(object sender, EventArgs e) { NotifyMsgPackage msg = new NotifyMsgPackage { @@ -60,8 +62,7 @@ namespace Kingo.Plugin.DataLoad.Commands { try { - if (NotifyMsgEven != null) - NotifyMsgEven(msg); + NotifyMsgEven?.Invoke(msg); } catch (Exception ex) { @@ -69,16 +70,19 @@ namespace Kingo.Plugin.DataLoad.Commands } } + public override bool Enabled + { + get + { + return JudgeIsHaveTargetPath(); + } + } private bool JudgeIsHaveTargetPath() { try { - ProjectInfo prj = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; - if (prj == null) - { - return false; - } + if (!(MapsManager.Instance.MapService.GetProjectInfo() is ProjectInfo prj)) return false; return true; } catch (Exception ex) @@ -87,12 +91,5 @@ namespace Kingo.Plugin.DataLoad.Commands return false; } } - public override bool Enabled - { - get - { - return JudgeIsHaveTargetPath(); - } - } } } diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadDB.cs b/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadDB.cs index a69a6f5..b41e488 100644 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadDB.cs +++ b/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadDB.cs @@ -14,7 +14,6 @@ namespace Kingo.Plugin.DataLoad.Commands IEngineEditor m_pEditor; public override void OnCreate(object hook) { - //throw new NotImplementedException(); m_pEditor = new EngineEditorClass(); } @@ -34,12 +33,12 @@ namespace Kingo.Plugin.DataLoad.Commands MessageHelper.ShowError("举证成果加载出现错误,可能的原因是:" + ex.Message); } } + public override bool Enabled { get { - ProjectInfo prj = MapsManager.Instance.CurrProjectInfo as ProjectInfo; - if (prj == null) return false; + if (!(MapsManager.Instance.CurrProjectInfo is ProjectInfo prj)) return false; return !string.IsNullOrWhiteSpace(prj.BGDatabase) && m_pEditor.EditState == esriEngineEditState.esriEngineStateNotEditing; } } diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadProjectData.cs b/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadProjectData.cs deleted file mode 100644 index 74508b8..0000000 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdLoadProjectData.cs +++ /dev/null @@ -1,77 +0,0 @@ -using ESRI.ArcGIS.Controls; -using KGIS.Framework.Commands; -using KGIS.Framework.Maps; -using KGIS.Framework.Utils; -using KGIS.Framework.Utils.Helper; -using Kingo.Plugin.DataLoad.View; -using Kingo.PluginServiceInterface; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Kingo.Plugin.DataLoad.Commands -{ - public class CmdLoadProjectData : BaseMenuCommand - { - private IEngineEditor pEditor = null; - private IHookHelper m_hookHelper = null; - public override void OnClick() - { - if (pEditor.EditState == esriEngineEditState.esriEngineStateEditing) - { - MessageHelper.ShowTips("请先关闭编辑!"); - return; - } - try - { - FrmLoadProjectData frmLoadOtherData = new FrmLoadProjectData - { - WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen - }; - frmLoadOtherData.ShowInMainWindow(true); - } - catch (Exception ex) - { - LogAPI.Debug("辅助功能:" + ex); - } - } - - public override void OnCreate(object Hook) - { - if (m_hookHelper == null) - { - m_hookHelper = new HookHelperClass(); - } - m_hookHelper.Hook = Hook; - pEditor = new EngineEditorClass(); - } - - public override bool Enabled - { - get - { - return JudgeIsHaveTargetPath(); - } - } - - private bool JudgeIsHaveTargetPath() - { - try - { - if (!(MapsManager.Instance.MapService.GetProjectInfo() is ProjectInfo prj)) - { - return false; - } - return true; - } - catch (Exception ex) - { - LogAPI.Debug("判定 检测数据加载 按钮是否有效时失败,异常原因: " + ex + " ; "); - return false; - } - } - - } -} diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdSJTQ.cs b/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdSJTQ.cs deleted file mode 100644 index a380c26..0000000 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/Commands/CmdSJTQ.cs +++ /dev/null @@ -1,59 +0,0 @@ -using ESRI.ArcGIS.Controls; -using KGIS.Framework.Commands; -using KGIS.Framework.Maps; -using KGIS.Framework.Platform; -using KGIS.Framework.Utils; -using KGIS.Framework.Utils.Helper; -using Kingo.Plugin.DataLoad.View; -using Kingo.PluginServiceInterface; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Kingo.Plugin.DataLoad.Commands -{ - public class CmdSJTQ : BaseMenuCommand - { - IEngineEditor m_pEditor; - public override void OnCreate(object hook) - { - m_pEditor = new EngineEditorClass(); - } - - public override void OnClick() - { - try - { - List Dics = Platform.Instance.DicHelper.GetDic(DicTypeEnum.QSDM, true); - if (Dics == null) - { - MessageHelper.ShowTips("请先设置权属字典!"); - return; - } - FrmSJTQ main = new FrmSJTQ - { - Width = 430, - Height = 300, - WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen - }; - main.ShowInMainWindow(true); - } - catch (Exception ex) - { - LogAPI.Debug(ex); - MessageHelper.ShowError("举证成果加载出现错误,可能的原因是:" + ex.Message); - } - } - public override bool Enabled - { - get - { - ProjectInfo prj = MapsManager.Instance.CurrProjectInfo as ProjectInfo; - if (prj == null) return false; - return !string.IsNullOrWhiteSpace(prj.BGDatabase) && m_pEditor.EditState == esriEngineEditState.esriEngineStateNotEditing; - } - } - } -} diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/Kingo.Plugin.DataLoad.csproj b/Kingo.Plugins/Kingo.Plugin.DataLoad/Kingo.Plugin.DataLoad.csproj index 9e40d5d..3d2a81d 100644 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/Kingo.Plugin.DataLoad.csproj +++ b/Kingo.Plugins/Kingo.Plugin.DataLoad/Kingo.Plugin.DataLoad.csproj @@ -308,7 +308,6 @@ - @@ -316,9 +315,7 @@ - - @@ -328,9 +325,6 @@ - - FrmDataConversion.xaml - FrmDataExport.xaml @@ -352,12 +346,6 @@ FrmLoadOtherData.xaml - - FrmLoadProjectData.xaml - - - FrmSJTQ.xaml - UCSQLFilterCondition.xaml @@ -383,10 +371,6 @@ - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -415,14 +399,6 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - MSBuild:Compile Designer diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/Manifest.xml b/Kingo.Plugins/Kingo.Plugin.DataLoad/Manifest.xml index ebb6b51..7722207 100644 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/Manifest.xml +++ b/Kingo.Plugins/Kingo.Plugin.DataLoad/Manifest.xml @@ -32,38 +32,5 @@ TextImageRelation="" LocationUri="Menu.Start.Group.DataLoad" CommandId="Kingo.Plugin.DataLoad.Commands.CmdLoadOtherData"/> - - - \ No newline at end of file diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmDataConversion.xaml b/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmDataConversion.xaml deleted file mode 100644 index 1bb9a6a..0000000 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmDataConversion.xaml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmDataConversion.xaml.cs b/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmDataConversion.xaml.cs deleted file mode 100644 index e695b8b..0000000 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmDataConversion.xaml.cs +++ /dev/null @@ -1,749 +0,0 @@ -using ESRI.ArcGIS.ADF; -using ESRI.ArcGIS.Geodatabase; -using ESRI.ArcGIS.Geometry; -using KGIS.Framework.AE; -using KGIS.Framework.AE.Enum; -using KGIS.Framework.OpenData.Control; -using KGIS.Framework.OpenData.Filter; -using KGIS.Framework.OpenData.InterFace; -using KGIS.Framework.Utils; -using KGIS.Framework.Utils.Helper; -using Kingo.OpenData.Filter; -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Forms; -using KUI.Windows; -using Kingo.Plugin.DataLoad.Helper; - -namespace Kingo.Plugin.DataLoad.View -{ - /// - /// 数据转化 的交互逻辑 - /// - public partial class FrmDataConversion : BaseWindow - { - /// - /// 源数据类型 - /// - private string ImportDataType; - public FrmDataConversion() - { - InitializeComponent(); - } - - private void BtnSelectedYJGD_Click(object sender, RoutedEventArgs e) - { - try - { - using (ComReleaser com = new ComReleaser()) - { - OpenDataDialog pDialog = new OpenDataDialog(); - ISpatialDataObjectFilter pOFilter = new FilterGeoDatabasePersonal(); - pDialog.AddFilter(pOFilter, true); - pOFilter = new FilterGeoDatabaseFile(); - pDialog.AddFilter(pOFilter, true); - pDialog.AllowMultiSelect = false; - pDialog.Title = "选择MDB/GDB数据"; - pDialog.RestoreLocation = true; - pDialog.StartLocation = pDialog.FinalLocation; - DialogResult dialogResult = pDialog.ShowDialog(); - if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0) - { - ImportDataType = System.IO.Path.GetExtension(pDialog.FinalLocation).ToUpper().Replace('.', ' ').TrimStart(); - if (string.IsNullOrWhiteSpace(ImportDataType) || (ImportDataType != "MDB" && ImportDataType != "GDB")) - { - MessageHelper.Show("选择的数据路径有误,请根据过滤条件,重新选择数据库!!"); - return; - } - else if ("MDB,GDB".Contains(ImportDataType)) - { - rdG.IsChecked = ImportDataType != "GDB"; - rdG.IsEnabled = ImportDataType != "GDB"; - rdM.IsChecked = ImportDataType != "MDB"; - rdM.IsEnabled = ImportDataType != "MDB"; - } - cobYJGDTextEdit.Text = pDialog.FinalLocation; - } - } - } - catch (Exception ex) - { - LogAPI.Debug("选择基础数据库失败:" + ex); - MessageHelper.Show("选择基础数据库失败:" + ex.Message); - } - } - - private void BtnGDBBaseData_Click(object sender, RoutedEventArgs e) - { - FolderBrowserDialog dialog = new FolderBrowserDialog(); - DialogResult result = dialog.ShowDialog(); - if (result == System.Windows.Forms.DialogResult.OK) - cobTextEdit.Text = dialog.SelectedPath; - } - - private void BtnLoad_Click(object sender, RoutedEventArgs e) - { - try - { - #region 数据转化前置条件 - if (!File.Exists(cobYJGDTextEdit.Text) && ImportDataType == "MDB") - { - MessageHelper.Show("请先选择源数据库!"); - return; - } - if (!Directory.Exists(cobYJGDTextEdit.Text) && ImportDataType == "GDB") - { - MessageHelper.Show("请先选择源数据库!"); - return; - } - if (string.IsNullOrWhiteSpace(cobTextEdit.Text)) - { - MessageHelper.Show("请选择输出数据库路径!"); - return; - } - if (rdG.IsChecked == false && rdM.IsChecked == false && rdS.IsChecked == false) - { - MessageHelper.Show("请选择输出的数据类型!"); - return; - } - #endregion - this.ShowLoading("正在转化数据......", 0, 0); - System.Threading.Thread.Sleep(1000); - if (ImportDataType == "MDB" && rdG.IsChecked == true) - { - this.UpdateMsg("正在进行MDB转化为GDB数据中.........."); - MDBConversionGDB(cobYJGDTextEdit.Text, cobTextEdit.Text); - } - else if (ImportDataType == "MDB" && rdS.IsChecked == true) - { - this.UpdateMsg("正在进行MDB转化为Shape数据中........."); - MGDBConversionShape(cobYJGDTextEdit.Text, cobTextEdit.Text, ImportDataType); - } - else if (ImportDataType == "GDB" && rdM.IsChecked == true) - { - this.UpdateMsg("正在进行GDB转化为MDB数据中.........."); - GDBConversionMDB(cobYJGDTextEdit.Text, cobTextEdit.Text); - } - else if (ImportDataType == "GDB" && rdS.IsChecked == true) - { - this.UpdateMsg("正在进行GDB转化为Shape数据中........."); - MGDBConversionShape(cobYJGDTextEdit.Text, cobTextEdit.Text, ImportDataType); - } - this.CloseLoading(); - MessageHelper.ShowTips("转化完成!"); - } - catch (Exception ex) - { - this.CloseLoading(); - MessageHelper.ShowTips("数据转化异常" + ex.Message); - LogAPI.Debug("数据转化异常" + ex.Message); - } - finally - { - this.CloseLoading(); - } - } - - /// - /// MDB 转 GDB - /// - /// 源路径 - /// 输出路径 - private void MDBConversionGDB(string S_MDBPath, string E_GDBPath) - { - WorkspaceAPI s_WsAPI = null; - WorkspaceAPI t_WsAPI = null; - IEnumDataset pEnumDataset = null; - try - { - s_WsAPI = new WorkspaceAPI(S_MDBPath, WorkspaceTypeEnum.MDBFile, true); - string MDBName = System.IO.Path.GetFileNameWithoutExtension(S_MDBPath); - string GDBTempPath = PluginServiceInterface.CommonHelper.CreateTempGDB(MDBName, E_GDBPath); - t_WsAPI = new WorkspaceAPI(GDBTempPath, WorkspaceTypeEnum.GDBFile, true); - pEnumDataset = s_WsAPI.CurrentWorkspace.Datasets[esriDatasetType.esriDTFeatureDataset]; - if (pEnumDataset != null) - { - pEnumDataset.Reset(); - IDataset pDataset = null; - //如果数据集是IFeatureDataset,则遍历它下面的子类 - while ((pDataset = pEnumDataset.Next()) != null) - { - IDataset newDataset = null; - newDataset = DLAECommonHelper.CreateFeatureDataset(t_WsAPI); - if (newDataset == null) continue; - List listFeatureClass = new List(); - List listFeatureClassNameList = new List(); - IEnumDataset ed = pDataset.Subsets; - if (ed != null) - { - IDataset dataset = ed.Next(); - while (dataset != null) - { - if ((dataset as IFeatureClass) != null) - { - string featureClassName = dataset.BrowseName; - if (!string.IsNullOrWhiteSpace(featureClassName) && !listFeatureClass.Contains(featureClassName)) - { - listFeatureClass.Add(System.IO.Path.Combine(pDataset.Workspace.PathName.ToString(), pDataset.BrowseName, featureClassName)); - listFeatureClassNameList.Add(featureClassName); - } - } - Marshal.FinalReleaseComObject(dataset); - dataset = ed.Next(); - } - } - if (listFeatureClass.Count > 0) - InsertGDBFeatureClass(cobYJGDTextEdit.Text, listFeatureClassNameList, GDBTempPath, newDataset.BrowseName); - if (newDataset != null) - Marshal.FinalReleaseComObject(newDataset); - } - //若不存在数据集仅仅为要素类 - List featureClasses = s_WsAPI.GetAllFeatureClass(esriDatasetType.esriDTFeatureClass); - List FeatureClassNameList = new List(); - foreach (IFeatureClass item in featureClasses) - { - if (!t_WsAPI.ExistFeatureClass((item as IDataset).Name) && !FeatureClassNameList.Contains((item as IDataset).Name)) - { - FeatureClassNameList.Add((item as IDataset).Name); - IFeatureClassAPI featureTemp = s_WsAPI.OpenFeatureClass2((item as IDataset).Name); - if (featureTemp == null) continue; - IFeatureClassAPI TempFL = t_WsAPI.CreateFeatureClass((item as IDataset).Name, (featureTemp.FeatureClass as IGeoDataset).SpatialReference, featureTemp.FeatureClass.Fields); - featureTemp.FcToFc(TempFL.FeatureClass, null, true); - featureTemp?.CloseFeatureClass(); - TempFL?.CloseFeatureClass(); - } - } - } - } - catch (Exception ex) - { - throw ex; - } - finally - { - t_WsAPI?.CloseWorkspace(); - s_WsAPI?.CloseWorkspace(); - if (pEnumDataset != null) - Marshal.ReleaseComObject(pEnumDataset); - } - } - - private void GDBConversionMDB(string S_GDBFullPath, string E_MDBFullPath) - { - WorkspaceAPI t_WsAPI = null; - WorkspaceAPI s_WsAPI = null; - IEnumDataset pEnumDataset = null; - try - { - s_WsAPI = new WorkspaceAPI(S_GDBFullPath, WorkspaceTypeEnum.GDBFile, true); - string GDBName = System.IO.Path.GetFileNameWithoutExtension(S_GDBFullPath); - //创建mdb - string temp = SysAppPath.GetTemplatePath() + "Temp.mdb"; - E_MDBFullPath = System.IO.Path.Combine(E_MDBFullPath, GDBName + ".mdb"); - if (File.Exists(temp)) - File.Copy(temp, E_MDBFullPath, true); - t_WsAPI = new WorkspaceAPI(E_MDBFullPath, WorkspaceTypeEnum.MDBFile, true); - pEnumDataset = s_WsAPI.CurrentWorkspace.Datasets[esriDatasetType.esriDTFeatureDataset]; - if (pEnumDataset != null) - { - pEnumDataset.Reset(); - IDataset pDataset = null; - //如果数据集是IFeatureDataset,则遍历它下面的子类 - while ((pDataset = pEnumDataset.Next()) != null) - { - IDataset newDataset = null; - newDataset = DLAECommonHelper.CreateFeatureDataset(t_WsAPI); - if (newDataset == null) continue; - List listFeatureClass = new List(); - List listFeatureClassNameList = new List(); - IEnumDataset ed = pDataset.Subsets; - if (ed != null) - { - IDataset dataset = ed.Next(); - while (dataset != null) - { - if ((dataset as IFeatureClass) != null) - { - string featureClassName = dataset.BrowseName; - if (!string.IsNullOrWhiteSpace(featureClassName) && !listFeatureClass.Contains(featureClassName)) - { - listFeatureClass.Add(System.IO.Path.Combine(pDataset.Workspace.PathName.ToString(), pDataset.BrowseName, featureClassName)); - listFeatureClassNameList.Add(featureClassName); - } - } - Marshal.FinalReleaseComObject(dataset); - dataset = ed.Next(); - } - } - if (listFeatureClass.Count > 0) - InsertMDBFeatureClass(S_GDBFullPath, listFeatureClassNameList, E_MDBFullPath, newDataset.BrowseName, null); - if (newDataset != null) - Marshal.FinalReleaseComObject(newDataset); - } - } - if (t_WsAPI.ExistFeatureClass("MJHZJCTJB_YJJBNTTB")) - t_WsAPI.DeleteFeatureClass("MJHZJCTJB_YJJBNTTB");//删除多余的表结构数据 - } - catch (Exception ex) - { - LogAPI.Debug(ex.Message); - } - finally - { - t_WsAPI?.CloseWorkspace(); - s_WsAPI?.CloseWorkspace(); - if (pEnumDataset != null) - Marshal.ReleaseComObject(pEnumDataset); - } - } - - private void MGDBConversionShape(string S_M_GDBPath, string E_ShapePath, string DataType) - { - WorkspaceAPI s_WsAPI = null; - IEnumDataset pEnumDataset = null; - IWorkspaceFactory workFactory = null; - IWorkspace pWorkspace = null; - IWorkspaceAPI workspaceAPI = null; - try - { - if (DataType == "MDB") - { - s_WsAPI = new WorkspaceAPI(S_M_GDBPath, WorkspaceTypeEnum.MDBFile, true); - } - else if (DataType == "GDB") - { - s_WsAPI = new WorkspaceAPI(S_M_GDBPath, WorkspaceTypeEnum.GDBFile, true); - } - string GDBName = System.IO.Path.GetFileNameWithoutExtension(S_M_GDBPath); - E_ShapePath = System.IO.Path.Combine(E_ShapePath, GDBName); - if (!Directory.Exists(E_ShapePath)) - Directory.CreateDirectory(E_ShapePath); - //PluginServiceInterface.CommonHelper.DelectDir(E_ShapePath); - pEnumDataset = s_WsAPI.CurrentWorkspace.Datasets[esriDatasetType.esriDTFeatureDataset]; - if (pEnumDataset != null) - { - pEnumDataset.Reset(); - IDataset pDataset = null; - //如果数据集是IFeatureDataset,则遍历它下面的子类 - while ((pDataset = pEnumDataset.Next()) != null) - { - IEnumDataset ed = pDataset.Subsets; - if (ed != null) - { - IDataset dataset = ed.Next(); - while (dataset != null) - { - if ((dataset as IFeatureClass) != null) - { - string featureClassName = dataset.BrowseName; - DLAECommonHelper.DeleteShp((dataset as IFeatureClass).AliasName, E_ShapePath); - DLAECommonHelper.ExportFeaturesToShp(dataset as IFeatureClass, null, E_ShapePath, featureClassName); - } - Marshal.FinalReleaseComObject(dataset); - dataset = ed.Next(); - } - } - } - //若不存在数据集仅仅为要素类 - List featureClasses = s_WsAPI.GetAllFeatureClass(esriDatasetType.esriDTFeatureClass); - workFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass(); - pWorkspace = workFactory.OpenFromFile(E_ShapePath, 0); - workspaceAPI = new WorkspaceAPI(pWorkspace); - foreach (IFeatureClass item in featureClasses) - { - if (!workspaceAPI.ExistFeatureClass((item as IDataset).Name)) - { - IFeatureClassAPI featureTemp = s_WsAPI.OpenFeatureClass2((item as IDataset).Name); - if (featureTemp == null) continue; - DLAECommonHelper.DeleteShp(item.AliasName, E_ShapePath); - IFeatureClassAPI TempFL = workspaceAPI.CreateFeatureClass((item as IDataset).Name, (featureTemp.FeatureClass as IGeoDataset).SpatialReference, featureTemp.FeatureClass.Fields); - featureTemp.FcToFc(TempFL.FeatureClass, null, true); - featureTemp?.CloseFeatureClass(); - TempFL?.CloseFeatureClass(); - } - } - } - } - catch (Exception ex) - { - throw ex; - } - finally - { - if (pEnumDataset != null) - Marshal.ReleaseComObject(pEnumDataset); - if (pWorkspace != null) - Marshal.ReleaseComObject(pWorkspace); - s_WsAPI?.CloseWorkspace(); - workspaceAPI?.CloseWorkspace(); - } - } - - /// - /// 从MDB中拷贝要素类插入到GDB - /// - /// GDB地址 - /// GDB中要拷贝的要素类名称列表 - /// 要插入到的MDB的地址路径 - /// 输出的数据集的名字 - public void InsertGDBFeatureClass(string sFromGDBPath, List iFeatureClassNameList, string iOutPutMDBPath, string sOutPutDataSetName) - { - IFeatureWorkspace fws_gdb = null; - WorkspaceAPI wsapi_gdb = null; - IFeatureClassAPI fcapi_gdb = null; - IFeatureClass fc_gdb = null; - IFeatureClass newFeatureClass = null; - IFeatureWorkspace fws_mdb = null; - - int iAddSuccessCount = 0; - int iAddFailCount = 0; - int iFCToFCType = 0;//fc2fc类型(0不涉及到数据集的方式 1涉及到数据集的方式) - try - { - iFCToFCType = string.IsNullOrWhiteSpace(sOutPutDataSetName) == true ? 0 : 1; - - if (string.IsNullOrWhiteSpace(sFromGDBPath) == true) - { - LogAPI.Debug("从MDB中拷贝要素类插入到GDB中 时失败,原因: MDB地址 为空 ; "); - throw new Exception("GDB地址 不能为空"); - } - - if (iFeatureClassNameList == null || iFeatureClassNameList.Count <= 0) - { - LogAPI.Debug("从MDB中拷贝要素类插入到GDB中 时失败,原因: MDB中要拷贝的要素类名称列表 为空 ; "); - throw new Exception("要转换的要素类 不能为空"); - } - wsapi_gdb = new WorkspaceAPI(sFromGDBPath, WorkspaceTypeEnum.MDBFile, true); - fws_gdb = wsapi_gdb.CurrentWorkspace as IFeatureWorkspace; - IWorkspace ws_gdb = fws_gdb as IWorkspace; - WorkspaceAPI wsapi_mdb = new WorkspaceAPI(iOutPutMDBPath, WorkspaceTypeEnum.GDBFile, true); - fws_mdb = wsapi_mdb.CurrentWorkspace as IFeatureWorkspace; - - for (int i = 0; i < iFeatureClassNameList.Count; i++) - { - fcapi_gdb = wsapi_gdb.OpenFeatureClass(iFeatureClassNameList[i]); - if (fcapi_gdb != null) - { - fc_gdb = fcapi_gdb.FeatureClass; - IGeoDataset geoDataset = fc_gdb as IGeoDataset; - bool bFC2FCResult_Temp; - if (iFCToFCType == 1)//fc2fc类型:1涉及到数据集的方式; - { - bFC2FCResult_Temp = MDBFc2FcGDB(fc_gdb, fws_mdb as IWorkspace, iFeatureClassNameList[i], sOutPutDataSetName, null); - #region 处理坐标参考系 - IFeatureDataset dataSet = fws_mdb.OpenFeatureDataset(sOutPutDataSetName); - ISpatialReference sp = geoDataset.SpatialReference; - IGeoDataset pGeoDataset = dataSet as IGeoDataset; - IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = pGeoDataset as IGeoDatasetSchemaEdit; - if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true) - pGeoDatasetSchemaEdit.AlterSpatialReference(sp); - Marshal.ReleaseComObject(dataSet); - Marshal.ReleaseComObject(pGeoDataset); - #endregion - } - else - { - bFC2FCResult_Temp = MDBFc2FcGDB(fc_gdb, fws_mdb as IWorkspace, iFeatureClassNameList[i]); - #region 处理坐标参考系 - newFeatureClass = fws_mdb.OpenFeatureClass(iFeatureClassNameList[i]); - IGeoDataset gdataset = newFeatureClass as IGeoDataset; - if (gdataset != null) - { - IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = gdataset as IGeoDatasetSchemaEdit; - if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true) - pGeoDatasetSchemaEdit.AlterSpatialReference(geoDataset.SpatialReference); - } - #endregion - Marshal.ReleaseComObject(gdataset); - } - Marshal.ReleaseComObject(geoDataset); - if (bFC2FCResult_Temp == true) - iAddSuccessCount += 1; - else - iAddFailCount += 1; - } - } - return; - } - catch (Exception ex) - { - LogAPI.Debug("将要素类拷贝至GDB中失败,异常原因: " + ex + " ; "); - LogAPI.DebugRunLog(ex, "将要素类拷贝至GDB中失败,异常原因: ", "InsertGDBFeatureClass"); - throw new Exception("GDB转化成MDB地址失败"); - } - finally - { - if (fws_gdb != null) - Marshal.ReleaseComObject(fws_gdb); - wsapi_gdb?.CloseWorkspace(); - fcapi_gdb?.CloseFeatureClass(); - if (fc_gdb != null) - Marshal.ReleaseComObject(fc_gdb); - if (fws_mdb != null) - { - Marshal.ReleaseComObject(fws_mdb); - fws_mdb = null; - } - if (newFeatureClass != null) - Marshal.ReleaseComObject(newFeatureClass); - } - } - - /// - /// 从GDB中拷贝要素类插入到MDB中 2020-6-1 沈超 - /// - /// GDB地址 - /// GDB中要拷贝的要素类名称列表 - /// 要插入到的MDB的地址路径 - /// 输出的数据集的名字 - /// 输出坐标参考:如果不是要素集下的图层,则要赋坐标参考 - public void InsertMDBFeatureClass(string sFromGDBPath, List iFeatureClassNameList, string iOutPutMDBPath, string sOutPutDataSetName, string sSpatialReference = null) - { - IFeatureWorkspace fws_gdb = null; - IWorkspace ws_gdb = null; - WorkspaceAPI wsapi_gdb = null; - IFeatureClassAPI fcapi_gdb = null; - IFeatureClass fc_gdb = null; - IFeatureClass newFeatureClass = null; - IFeatureWorkspace fws_mdb = null; - int iAddSuccessCount = 0; - int iAddFailCount = 0; - bool bFC2FCResult_Temp = false; - int iFCToFCType = 0;//fc2fc类型(0不涉及到数据集的方式 1涉及到数据集的方式) - try - { - iFCToFCType = string.IsNullOrWhiteSpace(sOutPutDataSetName) == true ? 0 : 1; - if (string.IsNullOrWhiteSpace(sFromGDBPath) == true) - { - LogAPI.Debug("从GDB中拷贝要素类插入到MDB中 时失败,原因: GDB地址 为空 ; "); - throw new Exception("GDB地址 不能为空"); - } - if (iFeatureClassNameList == null || iFeatureClassNameList.Count <= 0) - { - LogAPI.Debug("从GDB中拷贝要素类插入到MDB中 时失败,原因: GDB中要拷贝的要素类名称列表 为空 ; "); - throw new Exception("要转换的要素类 不能为空"); - } - WorkspaceAPI wsapi_MDB = new WorkspaceAPI(iOutPutMDBPath, WorkspaceTypeEnum.MDBFile, true); - fws_mdb = wsapi_MDB.CurrentWorkspace as IFeatureWorkspace; - if (fws_mdb == null) - throw new Exception("MDB地址 不能为空"); - wsapi_gdb = new WorkspaceAPI(sFromGDBPath, WorkspaceTypeEnum.GDBFile, true); - fws_gdb = wsapi_gdb.CurrentWorkspace as IFeatureWorkspace; - ws_gdb = fws_gdb as IWorkspace; - - for (int i = 0; i < iFeatureClassNameList.Count; i++) - { - fcapi_gdb = wsapi_gdb.OpenFeatureClass(iFeatureClassNameList[i]); - if (fcapi_gdb != null) - { - fc_gdb = fcapi_gdb.FeatureClass; - IGeoDataset geoDataset = fc_gdb as IGeoDataset; - if (iFCToFCType == 1)//fc2fc类型:1涉及到数据集的方式; - { - bFC2FCResult_Temp = GDBFc2FcMDB(fc_gdb, fws_mdb as IWorkspace, iFeatureClassNameList[i], sOutPutDataSetName, null); - #region 处理坐标参考系 - IFeatureDataset dataSet = fws_mdb.OpenFeatureDataset(sOutPutDataSetName); - ISpatialReference sp = geoDataset.SpatialReference; - IGeoDataset pGeoDataset = dataSet as IGeoDataset; - IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = pGeoDataset as IGeoDatasetSchemaEdit; - if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true) - pGeoDatasetSchemaEdit.AlterSpatialReference(sp); - Marshal.ReleaseComObject(dataSet); - Marshal.ReleaseComObject(pGeoDataset); - #endregion - } - else//fc2fc类型:0不涉及到数据集的方式; - { - bFC2FCResult_Temp = GDBFc2FcMDB(fc_gdb, fws_mdb as IWorkspace, iFeatureClassNameList[i], null); - #region 处理坐标参考系 - newFeatureClass = fws_mdb.OpenFeatureClass(iFeatureClassNameList[i]); - IGeoDataset gdataset = newFeatureClass as IGeoDataset; - if (gdataset != null) - { - IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = gdataset as IGeoDatasetSchemaEdit; - if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true) - pGeoDatasetSchemaEdit.AlterSpatialReference(geoDataset.SpatialReference); - } - #endregion - Marshal.ReleaseComObject(gdataset); - } - Marshal.ReleaseComObject(geoDataset); - - if (bFC2FCResult_Temp == true) - { - iAddSuccessCount += 1; - } - else - { - iAddFailCount += 1; - } - } - } - return; - } - catch (Exception ex) - { - LogAPI.Debug("将要素类拷贝至MDB中失败,异常原因: " + ex + " ; "); - throw new Exception("GDB转化成MDB地址失败"); - } - finally - { - if (fws_gdb != null) - { - Marshal.ReleaseComObject(fws_gdb); - fws_gdb = null; - } - wsapi_gdb?.CloseWorkspace(); - fcapi_gdb?.CloseFeatureClass(); - - if (fc_gdb != null) - { - Marshal.ReleaseComObject(fc_gdb); - fc_gdb = null; - } - - if (fws_mdb != null) - { - Marshal.ReleaseComObject(fws_mdb); - fws_mdb = null; - } - - if (newFeatureClass != null) - { - Marshal.ReleaseComObject(newFeatureClass); - newFeatureClass = null; - } - } - } - - public bool MDBFc2FcGDB(IFeatureClass pInFeatureClass, IWorkspace pOutWorkspace, string poutFatureName, string pOutDataSetName = null, IQueryFilter queryFilter = null) - { - try - { - if (pInFeatureClass == null || pOutWorkspace == null || string.IsNullOrEmpty(poutFatureName)) return false; - IFeatureClassName pInFeatureclassName; - IDataset pIndataset; - pIndataset = (IDataset)pInFeatureClass; - pInFeatureclassName = (IFeatureClassName)pIndataset.FullName; - IFeatureClassName pOutFeatureClassName; - IDatasetName pOutDatasetName; - IDataset pOutDataset; - pOutDataset = (IDataset)pOutWorkspace; - IEnumDatasetName dataset = pOutWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset); - while ((pOutDatasetName = dataset.Next()) != null) - { - if (pOutDatasetName.Name == pOutDataSetName) - { - break; - } - } - pOutFeatureClassName = new FeatureClassNameClass() { Name = poutFatureName }; - if (pOutDatasetName == null) - { - pOutDatasetName = (IDatasetName)pOutFeatureClassName; - pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName; - pOutDatasetName.Name = poutFatureName; - } - pOutFeatureClassName.FeatureDatasetName = pOutDatasetName; - IFields pInFields; - IFieldChecker pFieldChecker = new FieldCheckerClass(); - pInFields = pInFeatureClass.Fields; - - //pOutFields - pFieldChecker.Validate(pInFields, out IEnumFieldError pError, out IFields pOutFields); - Console.WriteLine(pError); - IFeatureDataConverter one2another = new FeatureDataConverterClass(); - try - { - if (pOutWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) - { - one2another.ConvertFeatureClass(pInFeatureclassName, null, null, pOutFeatureClassName, null, pOutFields, "", 1000, 0); - } - else - { - one2another.ConvertFeatureClass(pInFeatureclassName, queryFilter, pOutDatasetName as IFeatureDatasetName, pOutFeatureClassName, null, pOutFields, "", 1000, 0); - } - } - finally - { - Marshal.ReleaseComObject(one2another); - } - return true; - } - catch (Exception ex) - { - throw ex; - } - } - - public bool GDBFc2FcMDB(IFeatureClass pInFeatureClass, IWorkspace pOutWorkspace, string poutFatureName, string pOutDataSetName = null, IQueryFilter queryFilter = null) - { - try - { - if (pInFeatureClass == null || pOutWorkspace == null || string.IsNullOrEmpty(poutFatureName)) return false; - IFeatureClassName pInFeatureclassName; - IDataset pIndataset; - pIndataset = (IDataset)pInFeatureClass; - pInFeatureclassName = (IFeatureClassName)pIndataset.FullName; - IFeatureClassName pOutFeatureClassName; - IDatasetName pOutDatasetName; - IDataset pOutDataset; - pOutDataset = (IDataset)pOutWorkspace; - IEnumDatasetName dataset = pOutWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset); - while ((pOutDatasetName = dataset.Next()) != null) - { - if (pOutDatasetName.Name == pOutDataSetName) - { - break; - } - } - pOutFeatureClassName = new FeatureClassNameClass() { Name = poutFatureName }; - if (pOutDatasetName == null) - { - pOutDatasetName = (IDatasetName)pOutFeatureClassName; - pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName; - pOutDatasetName.Name = poutFatureName; - } - pOutFeatureClassName.FeatureDatasetName = pOutDatasetName; - IFields pInFields, pOutFields; - IFieldChecker pFieldChecker = new FieldCheckerClass(); - IEnumFieldError pError; - pInFields = pInFeatureClass.Fields; - - //pOutFields - pFieldChecker.Validate(pInFields, out pError, out pOutFields); - Console.WriteLine(pError); - IFeatureDataConverter one2another = new FeatureDataConverterClass(); - try - { - if (pOutWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) - { - one2another.ConvertFeatureClass(pInFeatureclassName, null, null, pOutFeatureClassName, null, - pOutFields, "", 1000, 0); - } - else - { - one2another.ConvertFeatureClass(pInFeatureclassName, queryFilter, pOutDatasetName as IFeatureDatasetName, pOutFeatureClassName, null, pOutFields, "", 1000, 0); - } - } - finally - { - Marshal.ReleaseComObject(one2another); - } - return true; - } - catch (Exception ex) - { - throw ex; - } - } - - private void BtnClose_Click(object sender, RoutedEventArgs e) - { - this.Close(); - } - } -} diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmLoadProjectData.xaml b/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmLoadProjectData.xaml deleted file mode 100644 index 263b6b4..0000000 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmLoadProjectData.xaml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmLoadProjectData.xaml.cs b/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmLoadProjectData.xaml.cs deleted file mode 100644 index 226d1a3..0000000 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmLoadProjectData.xaml.cs +++ /dev/null @@ -1,176 +0,0 @@ -using ESRI.ArcGIS.Carto; -using ESRI.ArcGIS.Geodatabase; -using KGIS.Framework.AE; -using KGIS.Framework.AE.Enum; -using KGIS.Framework.Utils; -using KGIS.Framework.Utils.Dialog; -using KGIS.Framework.Utils.Helper; -using KUI.Windows; -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Windows; - -namespace Kingo.Plugin.DataLoad.View -{ - /// - /// 覆盖工程数据 的交互逻辑 - /// - public partial class FrmLoadProjectData : BaseWindow - { - public FrmLoadProjectData() - { - InitializeComponent(); - this.Title = "覆盖工程数据"; - } - - private string SelectPathName = string.Empty; - private readonly List ZLlays = new List() { "DLTBGX", "DLTBGXGC", "CZCDYDGX", "CZCDYDGXGC", "CZCDYDGX", "CJDCQGX", "CJDCQJXGX", "CJDCQGXGC", "XZQGX", "XZQJXGX", "XZQGXGC", "TTQGX", "LMFWGX", "GCHZZGX", "GFBQGX", "GDDBGX", "CCWJQGX", "PDTGX" }; - private void BtnSelectedOtherData_Click(object sender, RoutedEventArgs e) - { - try - { - FolderBrowserDialog m_Dialog = new FolderBrowserDialog(); - System.Windows.Forms.DialogResult result = m_Dialog.ShowDialog(); - if (result == System.Windows.Forms.DialogResult.Cancel) return; - string m_Dir = m_Dialog.SelectedPath.Trim(); - SelectPathName = m_Dir; - this.btnPrjDir.Text = m_Dir;//工程路径 - } - catch (Exception ex) - { - LogAPI.Debug("新建工程页面中-选择工程目录时失败,异常原因: " + ex + " ; "); - MessageHelper.ShowTips("操作异常:" + ex.Message); - } - } - - private void BtnLoad_Click(object sender, RoutedEventArgs e) - { - IWorkspaceAPI s_WsAPI = null; - IFeatureClassAPI TempFCApi = null; - try - { - this.ShowLoading("正在进行数据覆盖中.......", 0, 0); - IFeatureLayer ImproDataLayer; - if (cbOverlayBGData.IsChecked == true) - { - this.UpdateMsg($"正在进行DLTBBG数据覆盖中......."); - s_WsAPI = new WorkspaceAPI(System.IO.Path.Combine(SelectPathName, "BGDB.gdb"), WorkspaceTypeEnum.GDBFile, true); - ImproDataLayer = KGIS.Framework.Maps.MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG"); - if (ImproDataLayer != null && ImproDataLayer.FeatureClass != null) - (ImproDataLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTBBG WHERE 1=1"); - TempFCApi = s_WsAPI.OpenFeatureClass2("DLTBBG"); - if (TempFCApi != null && s_WsAPI != null) - TempFCApi.FcToFc(ImproDataLayer.FeatureClass, null, false); - } - ImproDataLayer = null; - TempFCApi = null; - s_WsAPI = null; - if (cbOverlayZLData.IsChecked == true) - { - s_WsAPI = new WorkspaceAPI(System.IO.Path.Combine(SelectPathName, "ZLDB.gdb"), WorkspaceTypeEnum.GDBFile, true); - if (s_WsAPI == null) ZLlays.Clear(); - foreach (var item in ZLlays) - { - this.UpdateMsg($"正在进行{item}数据覆盖中......."); - ImproDataLayer = KGIS.Framework.Maps.MapsManager.Instance.MapService.GetFeatureLayerByName(item); - if (ImproDataLayer == null) continue; - if (ImproDataLayer != null && ImproDataLayer.FeatureClass != null) - (ImproDataLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Delete From {item} WHERE 1=1"); - TempFCApi = s_WsAPI.OpenFeatureClass2(item); - if (TempFCApi != null && ImproDataLayer.FeatureClass != null && TempFCApi.FeatureClass.FeatureCount(null) != 0) - TempFCApi.FcToFc(ImproDataLayer.FeatureClass, null, false); - TempFCApi = null; - } - } - ImproDataLayer = null; - s_WsAPI = null; - if (cbOverlayNMData.IsChecked == true) - { - this.UpdateMsg($"正在进行DLTB_NMK数据覆盖中......."); - s_WsAPI = new WorkspaceAPI(System.IO.Path.Combine(SelectPathName, "NMDB.gdb"), WorkspaceTypeEnum.GDBFile, true); - ImproDataLayer = KGIS.Framework.Maps.MapsManager.Instance.MapService.GetFeatureLayerByName("DLTB_NMK"); - if (ImproDataLayer != null) - { - if (ImproDataLayer != null && ImproDataLayer.FeatureClass != null) - (ImproDataLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTB_NMK WHERE 1=1"); - TempFCApi = s_WsAPI.OpenFeatureClass2("DLTB_NMK"); - if (TempFCApi != null && s_WsAPI != null) - TempFCApi.FcToFc(ImproDataLayer.FeatureClass, null, false); - } - } - this.CloseLoading(); - MessageHelper.ShowTips("覆盖数据成功!"); - } - catch (Exception ex) - { - this.CloseLoading(); - LogAPI.Debug("覆盖数据异常:" + ex); - MessageHelper.ShowTips("覆盖数据异常:" + ex.Message); - } - finally - { - this.CloseLoading(); - s_WsAPI?.CloseWorkspace(); - TempFCApi?.CloseFeatureClass(); - } - } - - private void BtnClose_Click(object sender, RoutedEventArgs e) - { - this.Close(); - } - - private void BtnDele_Click(object sender, RoutedEventArgs e) - { - IFeatureLayer DeleDataLayer = null; - try - { - if (cbOverlayBGData.IsChecked == false && cbOverlayZLData.IsChecked == false && cbOverlayNMData.IsChecked == false) - { - MessageHelper.ShowTips("清除数据至少勾选一项进行清除!"); - return; - } - this.ShowLoading("正在进行数据清除中.......", 0, 0); - if (cbOverlayBGData.IsChecked == true) - { - this.UpdateMsg($"正在进行DLTBBG数据清除中......."); - DeleDataLayer = KGIS.Framework.Maps.MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG"); - if (DeleDataLayer != null && DeleDataLayer.FeatureClass != null) - (DeleDataLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTBBG WHERE 1=1"); - } - if (cbOverlayZLData.IsChecked == true) - { - foreach (var item in ZLlays) - { - this.UpdateMsg($"正在进行{item}数据清除中......."); - DeleDataLayer = KGIS.Framework.Maps.MapsManager.Instance.MapService.GetFeatureLayerByName(item); - if (DeleDataLayer != null && DeleDataLayer.FeatureClass != null) - (DeleDataLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Delete From {item} WHERE 1=1"); - } - } - if (cbOverlayNMData.IsChecked == true) - { - this.UpdateMsg($"正在进行DLTB_NMK数据清除中......."); - DeleDataLayer = KGIS.Framework.Maps.MapsManager.Instance.MapService.GetFeatureLayerByName("DLTB_NMK"); - if (DeleDataLayer != null && DeleDataLayer.FeatureClass != null) - (DeleDataLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTB_NMK WHERE 1=1"); - } - this.CloseLoading(); - KGIS.Framework.Maps.MapsManager.Instance.MapService.getAxMapControl().ActiveView.Refresh(); - MessageHelper.ShowTips("清除数据结束!"); - } - catch (Exception ex) - { - this.CloseLoading(); - PluginServiceInterface.CommonHelper.RecordsErrLog("数据覆盖-清除数据异常", ex); - MessageHelper.ShowTips("清除数据异常:" + ex.Message); - } - finally - { - if (DeleDataLayer != null && DeleDataLayer.FeatureClass != null) - Marshal.ReleaseComObject(DeleDataLayer); - } - } - } -} diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmSJTQ.xaml b/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmSJTQ.xaml deleted file mode 100644 index 3adfa4b..0000000 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmSJTQ.xaml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - 地类图斑 - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmSJTQ.xaml.cs b/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmSJTQ.xaml.cs deleted file mode 100644 index b46b3da..0000000 --- a/Kingo.Plugins/Kingo.Plugin.DataLoad/View/FrmSJTQ.xaml.cs +++ /dev/null @@ -1,600 +0,0 @@ -using ESRI.ArcGIS.Carto; -using ESRI.ArcGIS.Geodatabase; -using KGIS.Framework.AE; -using KGIS.Framework.AE.GPHelper; -using KGIS.Framework.Maps; -using KGIS.Framework.Platform; -using KGIS.Framework.Utils; -using KGIS.Framework.Utils.ExtensionMethod; -using KGIS.Framework.Utils.Helper; -using Kingo.PluginServiceInterface; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using KUI.Windows; - -namespace Kingo.Plugin.DataLoad.View -{ - /// - /// 初始化图斑变更 的交互逻辑 - /// - public partial class FrmSJTQ : BaseWindow - { - /// - /// 是否乡镇提取 - /// - private bool _isXz = false; - - /// - /// 坐落单位字典 - /// - private List ZLDMdataDic = null; - private List DLBMDics = null; - - public FrmSJTQ() - { - InitializeComponent(); - rbXZ.IsChecked = true; - InitData(); - } - - private void InitData() - { - ProjectInfo info = (MapsManager.Instance.CurrProjectInfo as ProjectInfo); - - //行政区下拉框绑定值 - ComboxSelXZQ.ItemsSource = GetZLDWDMList().Values; - //默认-地类图斑 - SeleComboxLayer.SelectedIndex = 0; - - DLBMDics = Platform.Instance.DicHelper.GetDic(DicTypeEnum.DLBM); - } - - /// - /// 是否禁用乡镇下拉框 - /// - /// - /// - private void RadioButton_Checked(object sender, RoutedEventArgs e) - { - RadioButton radioButton = sender as RadioButton; - - if (radioButton.Content.ToString() == "提取全部基础地类图斑数据") - { - _isXz = false; - ComboxSelXZQ.IsEnabled = false; - } - else - { - _isXz = true; - ComboxSelXZQ.IsEnabled = true; - } - } - - /// - /// 图层改变事件 - /// - /// - /// - private void SeleComboxLayer_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (SeleComboxLayer.SelectedIndex.ToString() == "0") - { - rbXZ.IsEnabled = false; - rbALL.IsEnabled = false; - ComboxSelXZQ.IsEnabled = false; - } - else - { - rbXZ.IsEnabled = true; - rbALL.IsEnabled = true; - ComboxSelXZQ.IsEnabled = true; - if (rbALL.IsChecked == true) - ComboxSelXZQ.IsEnabled = false; - } - } - - /// - /// 提取图斑 - /// - /// - /// - private void BtnTBTQ_Clic(object sender, RoutedEventArgs e) - { - btnOK.IsEnabled = false; - btnCanel.IsEnabled = false; - try - { - //IFeatureClass jctbFC = MapsManager.Instance.MapService.GetFeatureClassByName("JCTB"); - string SelIndex = SeleComboxLayer.SelectedIndex.ToString(); - if (ComboxSelXZQ.SelectedItems.Count <= 0 && _isXz) - { - MessageHelper.ShowTips("请选择乡镇数据!"); - return; - } - IFeatureClass TargetFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG"); - IFeatureLayer tempBG_Layer = GeoDBAPI.CreateFeatureLayerInmemeory("TempBG", "TempBG", (TargetFC as IGeoDataset).SpatialReference, TargetFC.ShapeType, TargetFC.Fields); - - ITable pTable = TargetFC as ITable; - if (pTable.RowCount(null) != 0) - { - System.Windows.Forms.DialogResult result = MessageHelper.ShowYesNoCancelAndTips("变更图斑层数据不为空,是否清空现有数据?"); - if (result == System.Windows.Forms.DialogResult.Yes) - { - pTable.DeleteSearchedRows(null); - } - else if (result == System.Windows.Forms.DialogResult.Cancel) - { - return; - } - } - this.ShowLoading("正在进行数据提取~", 0, 0); - int SJLYIndex = TargetFC.FindField("SJLY"); - int BGTBYBHIndex = TargetFC.FindField("TBYBH"); - int BGDLBMIndex = TargetFC.FindField("DLBM"); - int BGDLMCIndex = TargetFC.FindField("DLMC"); - - if (SelIndex == "0") - { - #region 地类图斑提取数据 - IFeatureClassAPI fCAPI_JCDLTB = new FeatureClassAPI(MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑").FeatureClass); - string currentAppPath = SysAppPath.GetCurrentAppPath(); - string templeteGDBPath = Path.Combine(currentAppPath, "Template", "TempGDB.gdb"); - string resultPath = Path.Combine(currentAppPath, "Temp\\Temp_TQBGTB"); - string savePath = Path.Combine(resultPath, Guid.NewGuid().ToString() + ".gdb"); - - DelectDir(resultPath); - CopyDirectory(templeteGDBPath, savePath, true); - WorkspaceAPI workspaceAPI_Temp = new WorkspaceAPI(savePath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile, true); - IQueryFilter queryFilter = new QueryFilterClass(); - if (_isXz) - { - string where = string.Empty; - if (GetZLDWDMList().Count != ComboxSelXZQ.SelectedItems.Count) - { - foreach (var item in ComboxSelXZQ.SelectedItems) - { - where += string.Format(" ZLDWDM like '{0}%' or", item.ToString().Split('_')[0].Substring(0, 9)); - } - where = where.Substring(0, where.Length - 2); - queryFilter.WhereClause = where; - } - fCAPI_JCDLTB.FcToFc(tempBG_Layer.FeatureClass, queryFilter, false); - } - else - { - fCAPI_JCDLTB.FcToFc(tempBG_Layer.FeatureClass, null, false); - } - IFeatureLayer JCTBFL = MapsManager.Instance.MapService.GetFeatureLayerByName("JCTB"); - if (JCTBFL.FeatureClass.FeatureCount(null) == 0)//无监测图斑直接提取 - { - fCAPI_JCDLTB.FcToFc(TargetFC, queryFilter, false); - this.CloseLoading(); - MessageHelper.ShowTips("提取完成!"); - return; - } - - IFeatureLayer SelectFeatureLayer = null; - GPParamClass gPParamClass = new GPParamClass - { - Tolerance = "0.0001", - FirstFeatureLayer = JCTBFL, - SecondFeatureLayer = tempBG_Layer, - IsGetOutPutFeature = true, - Overlap_type = "INTERSECT" - }; - GeoprocessorHelper.SelectLayerByLocationAnalysis(gPParamClass, ref SelectFeatureLayer); - //基础图斑与监测图斑相交, - IFeatureLayer featureLayer = null; - gPParamClass = new GPParamClass - { - FirstFeatureLayer = tempBG_Layer, - SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = JCTBFL.FeatureClass }, - OutFeatureClassPath = savePath + "\\DLTBGX_UNION", - IsGetOutPutFeature = true - }; - GeoprocessorHelper.UnionAnalysis(gPParamClass, ref featureLayer); - - int indexBsm = featureLayer.FeatureClass.FindField("BSM"); - int indexBSM = tempBG_Layer.FeatureClass.FindField("BSM"); - - StringBuilder stringBuilder = new StringBuilder(); - StringBuilder JCOIDSBuilder = new StringBuilder(); - StringBuilder JCSJLYBuilder = new StringBuilder(); - Dictionary keyValuePairs = new Dictionary(); - Dictionary JCValuePairs = new Dictionary(); - ICursor pCur = null; - IRow pRow = null; - IQueryDef pQDef = ((featureLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace).CreateQueryDef(); - pQDef.Tables = "DLTBGX_UNION"; - pQDef.WhereClause = " 1=1 AND FID_JCTB<>-1 AND BSM<>'' AND SHAPE_Area>=10.0 "; - pQDef.SubFields = "FID_JCTB,BSM,TBBH,FID_TempBG"; - pCur = pQDef.Evaluate(); - while ((pRow = pCur.NextRow()) != null) - { - //存储监测图斑OIDS - JCOIDSBuilder.Append(string.Format("{0},", pRow.get_Value(0).ToString())); - //存储基础库图斑OIDS - stringBuilder.Append(string.Format("{0},", pRow.get_Value(3).ToString())); - if (!string.IsNullOrWhiteSpace(pRow.get_Value(2).ToString())) - { - if (!keyValuePairs.ContainsKey(pRow.get_Value(1).ToString())) - { - //存储BSM和监测编号 - keyValuePairs[pRow.get_Value(1).ToString()] = pRow.get_Value(2).ToString(); - //存储BSM和监测OIDS - JCValuePairs[pRow.get_Value(1).ToString()] = pRow.get_Value(0).ToString(); - } - else - { - //单个BSM对应多个JCBH - if (!keyValuePairs[pRow.get_Value(1).ToString()].Contains(pRow.get_Value(2).ToString())) - keyValuePairs[pRow.get_Value(1).ToString()] += "," + pRow.get_Value(2).ToString(); - } - } - Marshal.ReleaseComObject(pRow); - } - Marshal.ReleaseComObject(pCur); - //擦除变更层中监测图斑 - IFeatureClassAPI JC_FcAPI = new FeatureClassAPI(JCTBFL.FeatureClass); - IFeatureLayer jctb_Layer = GeoDBAPI.CreateFeatureLayerInmemeory("JCTBTemp", "JCTBTempData", (JCTBFL.FeatureClass as IGeoDataset).SpatialReference, JCTBFL.FeatureClass.ShapeType, JCTBFL.FeatureClass.Fields); - //与基础库图斑相交上的监测图斑 - if (JCOIDSBuilder.Length > 0) - JC_FcAPI.FcToFc(jctb_Layer.FeatureClass, new QueryFilterClass() { WhereClause = string.Format("OBJECTID in({0}) ", JCOIDSBuilder.ToString().Trim(',')) }, false); - else - JC_FcAPI.FcToFc(jctb_Layer.FeatureClass, null, false); - //上一步生成的变更图斑擦除监测图斑 - IFeatureLayer pdltbbgFeatureLayer = null; - gPParamClass = new GPParamClass - { - FirstFeatureLayer = tempBG_Layer, - SecondFeatureLayer = jctb_Layer, - OutFeatureClassPath = savePath + "\\" + "TempDLTBBG", - IsGetOutPutFeature = true - }; - GeoprocessorHelper.EraseAnalysis(gPParamClass, ref pdltbbgFeatureLayer); - - IFeatureLayer TempTBBG_Erase = null; - gPParamClass = new GPParamClass - { - FirstFeatureLayer = pdltbbgFeatureLayer, - OutFeatureClassPath = savePath + "\\" + "TempTBBG_Erase", - IsGetOutPutFeature = true - }; - GeoprocessorHelper.MultipartToSinglePath(gPParamClass, ref TempTBBG_Erase); - - IFeatureClassAPI Tebgfc_API = new FeatureClassAPI(TempTBBG_Erase.FeatureClass); - queryFilter.WhereClause = " SHAPE_Area >= 0.1"; - Tebgfc_API.FcToFc(TargetFC, queryFilter, false); - - IFeatureLayer featureLayer_Intercet = null; - gPParamClass = new GPParamClass - { - FirstFeatureLayer = tempBG_Layer, - SecondFeatureLayer = jctb_Layer, - Tolerance = "0.0001", - IsGetOutPutFeature = true, - OutFeatureClassPath = savePath + "\\" + "TempTBBG_Intersect", - }; - GeoprocessorHelper.IntersectAnalysis(gPParamClass, ref featureLayer_Intercet); - - int Index_JCTBYBH = featureLayer_Intercet.FeatureClass.FindField("TBYBH"); - int Index_JCBH = featureLayer_Intercet.FeatureClass.FindField("TBBH"); - int Index_JCSJLY = featureLayer_Intercet.FeatureClass.FindField("SJLY"); - ITable table_JC = featureLayer_Intercet.FeatureClass as ITable; - ICursor cursor_JC = table_JC.Update(null, true); - IRow row_JC = null; - while ((row_JC = cursor_JC.NextRow()) != null) - { - row_JC.Value[Index_JCTBYBH] = row_JC.Value[Index_JCBH]; - row_JC.Value[Index_JCSJLY] = "1"; - cursor_JC.UpdateRow(row_JC); - } - cursor_JC.Flush(); - IFeatureClassAPI Tejcfc_API = new FeatureClassAPI(featureLayer_Intercet.FeatureClass); - Tejcfc_API.FcToFc(TargetFC, null, false); - - //根据变更BSM修改数据来源 - //if (JCSJLYBuilder.Length != 0) - // (TargetFC as FeatureClass).Workspace.ExecuteSQL(string.Format("Update DLTBBG set SJLY = '1' WHERE BSM IN({0})", JCSJLYBuilder.ToString().TrimEnd(','))); - if (null != featureLayer) - Marshal.FinalReleaseComObject(featureLayer); - if (TargetFC != null) - Marshal.FinalReleaseComObject(TargetFC); - if (tempBG_Layer != null) - Marshal.FinalReleaseComObject(tempBG_Layer); - if (jctb_Layer != null) - Marshal.FinalReleaseComObject(jctb_Layer); - if (featureLayer_Intercet != null) - Marshal.FinalReleaseComObject(featureLayer_Intercet); - #endregion - } - this.CloseLoading(); - MessageHelper.ShowTips("提取完成!"); - } - catch (Exception ex) - { - MessageHelper.ShowTips(ex.Message); - LogAPI.Debug(ex.Message); - this.CloseLoading(); - } - finally - { - btnOK.IsEnabled = true; - btnCanel.IsEnabled = true; - } - } - - private void BtnTBTQ_Click(object sender, RoutedEventArgs e) - { - btnOK.IsEnabled = false; - btnCanel.IsEnabled = false; - IFeatureLayer featureLayer = null; - IFeatureLayer tempBG_Layer = null; - ICursor pCur = null; - try - { - string SelIndex = SeleComboxLayer.SelectedIndex.ToString(); - if (ComboxSelXZQ.SelectedItems.Count <= 0 && _isXz) - { - MessageHelper.ShowTips("请选择乡镇数据!"); - return; - } - IFeatureClass TargetFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG"); - tempBG_Layer = GeoDBAPI.CreateFeatureLayerInmemeory("TempBG", "TempBG", (TargetFC as IGeoDataset).SpatialReference, TargetFC.ShapeType, TargetFC.Fields); - ITable pTable = TargetFC as ITable; - if (pTable.RowCount(null) != 0) - { - System.Windows.Forms.DialogResult result = MessageHelper.ShowYesNoCancelAndTips("变更图斑层数据不为空,是否清空现有数据?"); - if (result == System.Windows.Forms.DialogResult.Yes) - { - pTable.DeleteSearchedRows(null); - } - else if (result == System.Windows.Forms.DialogResult.Cancel) - { - return; - } - } - this.ShowLoading("正在进行数据提取~", 0, 0); - int SJLYIndex = TargetFC.FindField("SJLY"); - int BGTBYBHIndex = TargetFC.FindField("TBYBH"); - int BGDLBMIndex = TargetFC.FindField("DLBM"); - int BGDLMCIndex = TargetFC.FindField("DLMC"); - - if (SelIndex == "0") - { - #region 地类图斑提取数据 - IFeatureClassAPI fCAPI_JCDLTB = new FeatureClassAPI(MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑").FeatureClass); - string currentAppPath = SysAppPath.GetCurrentAppPath(); - string templeteGDBPath = Path.Combine(currentAppPath, "Template", "TempGDB.gdb"); - string resultPath = Path.Combine(currentAppPath, "Temp\\Temp_TQBGTB"); - string savePath = Path.Combine(resultPath, Guid.NewGuid().ToString() + ".gdb"); - - DelectDir(resultPath); - CopyDirectory(templeteGDBPath, savePath, true); - WorkspaceAPI workspaceAPI_Temp = new WorkspaceAPI(savePath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile, true); - IQueryFilter queryFilter = new QueryFilterClass(); - if (_isXz) - { - string where = string.Empty; - if (GetZLDWDMList().Count != ComboxSelXZQ.SelectedItems.Count) - { - foreach (var item in ComboxSelXZQ.SelectedItems) - { - where += string.Format(" ZLDWDM like '{0}%' or", item.ToString().Split('_')[0].Substring(0, 9)); - } - where = where.Substring(0, where.Length - 2); - queryFilter.WhereClause = where; - } - fCAPI_JCDLTB.FcToFc(tempBG_Layer.FeatureClass, queryFilter, false); - } - else - { - fCAPI_JCDLTB.FcToFc(tempBG_Layer.FeatureClass, null, false); - } - IFeatureLayer JCTBFL = MapsManager.Instance.MapService.GetFeatureLayerByName("JCTB"); - if (JCTBFL.FeatureClass.FeatureCount(null) == 0)//无监测图斑直接提取 - { - this.CloseLoading(); - MessageHelper.ShowTips("监测图斑没有数据!"); - return; - } - - IFeatureLayer SelectFeatureLayer = null; - GPParamClass gPParamClass = new GPParamClass - { - Tolerance = "0.0001", - FirstFeatureLayer = JCTBFL, - SecondFeatureLayer = tempBG_Layer, - IsGetOutPutFeature = true, - Overlap_type = "INTERSECT" - }; - GeoprocessorHelper.SelectLayerByLocationAnalysis(gPParamClass, ref SelectFeatureLayer); - //基础图斑与监测图斑相交, - - gPParamClass = new GPParamClass - { - FirstFeatureLayer = tempBG_Layer, - //SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = JCTBFL.FeatureClass }, - SecondFeatureLayer = JCTBFL, - OutFeatureClassPath = savePath + "\\DLTBGX_UNION", - IsGetOutPutFeature = true - }; - GeoprocessorHelper.UnionAnalysis(gPParamClass, ref featureLayer); - - int indexBsm = featureLayer.FeatureClass.FindField("BSM"); - int indexBSM = tempBG_Layer.FeatureClass.FindField("BSM"); - int DLBMIndex = TargetFC.FindField("DLBM"); - StringBuilder JCSJLYBuilder = new StringBuilder(); - IRow pRow = null; - IQueryDef pQDef = ((featureLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace).CreateQueryDef(); - pQDef.Tables = "DLTBGX_UNION"; - pQDef.WhereClause = " 1=1 AND FID_JCTB<>-1 AND BSM<>'' AND SHAPE_Area>=10.0 "; - pQDef.SubFields = "FID_JCTB,BSM,TBBH,FID_TempBG,NYRDDL";//NYRDDL替换当前基础图斑地类 - pCur = pQDef.Evaluate(); - while ((pRow = pCur.NextRow()) != null) - { - if (!string.IsNullOrWhiteSpace(pRow.get_Value(1).ToString()) && !string.IsNullOrWhiteSpace(pRow.get_Value(4).ToTrim())) - { - if (TargetFC.Fields.Field[DLBMIndex].Length >= pRow.get_Value(4).ToTrim().Length) - { - pRow.Value[DLBMIndex] = pRow.get_Value(4).ToTrim(); - pCur.UpdateRow(pRow); - } - } - Marshal.ReleaseComObject(pRow); - } - pCur.Flush(); - //if (!string.IsNullOrWhiteSpace(JCSJLYBuilder.ToString().Trim(','))) - queryFilter.WhereClause = " 1=1 AND FID_JCTB<>-1 AND BSM<>'' AND SHAPE_Area>=10.0 "; - ////queryFilter.WhereClause = string.Format(" BSM IN({0})", JCSJLYBuilder.ToString().Trim(',')); - //else - //{ - // MessageHelper.ShowTips("当前未提取到数据!"); - // if (null != featureLayer) - // Marshal.FinalReleaseComObject(featureLayer); - // if (tempBG_Layer != null) - // Marshal.FinalReleaseComObject(tempBG_Layer); - // if (pCur != null) - // Marshal.ReleaseComObject(pCur); - // return; - //} - IFeatureClassAPI classAPI = new FeatureClassAPI(featureLayer.FeatureClass); - classAPI.FcToFc(TargetFC, queryFilter, false); - #endregion - } - this.CloseLoading(); - MessageHelper.ShowTips("提取完成!"); - } - catch (Exception ex) - { - MessageHelper.ShowTips(ex.Message); - LogAPI.Debug(ex.Message); - this.CloseLoading(); - } - finally - { - this.CloseLoading(); - btnOK.IsEnabled = true; - btnCanel.IsEnabled = true; - if (null != featureLayer) - Marshal.FinalReleaseComObject(featureLayer); - if (tempBG_Layer != null) - Marshal.FinalReleaseComObject(tempBG_Layer); - if (pCur != null) - Marshal.ReleaseComObject(pCur); - } - } - - /// - /// 删除该路径下的所有文件和目录 - /// - /// - public static void DelectDir(string srcPath) - { - try - { - DirectoryInfo dir = new DirectoryInfo(srcPath); - FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录 - foreach (FileSystemInfo i in fileinfo) - { - try - { - if (i is DirectoryInfo) //判断是否文件夹 - { - DirectoryInfo subdir = new DirectoryInfo(i.FullName); - subdir.Delete(true); //删除子目录和文件 - } - else - { - File.Delete(i.FullName); //删除指定文件 - } - } - catch (Exception) - { - continue; - } - } - } - catch (Exception ex) - { - LogAPI.Debug(ex + ":此项错误不处理!");//文件占用报错 - } - } - - /// - /// 拷贝模板gdb文件夹 - /// - /// - /// - /// - public static void CopyDirectory(string SourcePath, string DestinationPath, bool overwriteexisting) - { - try - { - SourcePath = SourcePath.EndsWith(@"\") ? SourcePath : SourcePath + @"\"; - DestinationPath = DestinationPath.EndsWith(@"\") ? DestinationPath : DestinationPath + @"\"; - - if (Directory.Exists(SourcePath)) - { - if (Directory.Exists(DestinationPath) == false) - Directory.CreateDirectory(DestinationPath); - - foreach (string fls in Directory.GetFiles(SourcePath)) - { - FileInfo flinfo = new FileInfo(fls); - flinfo.CopyTo(DestinationPath + flinfo.Name, overwriteexisting); - } - foreach (string drs in Directory.GetDirectories(SourcePath)) - { - DirectoryInfo drinfo = new DirectoryInfo(drs); - CopyDirectory(drs, DestinationPath + drinfo.Name, overwriteexisting); - } - } - } - catch (Exception ex) - { - throw ex; - } - } - - /// - /// 获取行政区代码及名称 - /// - /// - /// - private Dictionary GetZLDWDMList() - { - try - { - ZLDMdataDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM); - Dictionary keyValuePairs = new Dictionary(); - if (ZLDMdataDic != null) - { - foreach (var item in ZLDMdataDic.FindAll(x => x.CODE.Length == 9)) - { - keyValuePairs[item.CODE] = item.CODE + "_" + item.NAME; - } - } - //验证代码BUG - LogAPI.Debug("获取坐落代码数量:" + keyValuePairs.Count); - return keyValuePairs; - } - catch (Exception ex) - { - LogAPI.Debug("获取坐落代码失败:" + ex.Message); - return null; - } - } - - private void BtnCanel_Click(object sender, RoutedEventArgs e) - { - this.Close(); - } - } -} diff --git a/Kingo.Plugins/Kingo.Plugin.MapView/UcMapControl.cs b/Kingo.Plugins/Kingo.Plugin.MapView/UcMapControl.cs index c24021c..bba6abd 100644 --- a/Kingo.Plugins/Kingo.Plugin.MapView/UcMapControl.cs +++ b/Kingo.Plugins/Kingo.Plugin.MapView/UcMapControl.cs @@ -20,7 +20,6 @@ using KGIS.Framework.Platform; using KGIS.Framework.Utils; using KGIS.Framework.Utils.ExtensionMethod; using KGIS.Framework.Utils.Helper; -//using KGIS.Framework.Utils.Model; using KGIS.Framework.Views; using Kingo.Framework.LayerStyleConvert.Common; using Kingo.Framework.LayerStyleConvert.XSDClass; @@ -70,11 +69,10 @@ namespace Kingo.Plugin.MapView /// /// 工作目录服务接口 /// - IDataCatalogService _DataCatalog = null; - IWorkCatalog _workCatalog = null; - //IEngineEditor m_EngineEditor = new EngineEditorClass(); - private IElementInfo ucJCTBTree { get; set; } - LayerCfg allLayerInfo = null; + IDataCatalogService _DataCatalog { get; set; } + IWorkCatalog _workCatalog { get; set; } + + LayerCfg allLayerInfo { get; set; } private UCProjectInfoSetting frmUserInfoSetting { get; set; } public UcMapControl() @@ -94,43 +92,6 @@ namespace Kingo.Plugin.MapView axMapControl.OnExtentUpdated += AxMapControl_OnExtentUpdated; if (editor == null) editor = new EngineEditorClass(); - List Listobjid_update = new List(); - List Listobjid_insert = new List(); - editor.OnStopOperation += () => - { - #region 变化图斑提取 - //添加新的监测图斑时,自动维护相应的属性值 - if (projectInfo != null && projectInfo.ProjType == EnumProjType.BHTBTQ) - { - IWorkspaceEdit2 workspaceEdit2 = (IWorkspaceEdit2)editor.EditWorkspace; - IDataChangesEx dataChangesEx = workspaceEdit2.get_EditDataChanges(esriEditDataChangesType.esriEditDataChangesWithinSession); - int featureOID = -1; - IFIDSet fids = dataChangesEx.ChangedIDs["JCTB", esriDifferenceType.esriDifferenceTypeInsert]; - fids.Next(out featureOID); - while (featureOID != -1) - { - IFeatureLayer pFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("JCTB"); - IFeature feature = pFeatureLayer.FeatureClass.GetFeature(featureOID); - feature.Value[feature.Fields.FindField("XZQDM")] = projectInfo.CODE; - feature.Value[feature.Fields.FindField("XMC")] = GetXZQDic(projectInfo.CODE); - IArea area = feature.ShapeCopy as IArea; - IPoint point = new PointClass(); - area.QueryCentroid(point); - if (area.Area > 0) - { - feature.Value[feature.Fields.FindField("XZB")] = point.X; - feature.Value[feature.Fields.FindField("YZB")] = point.Y; - feature.Value[feature.Fields.FindField("JCMJ")] = area.Area > 0 ? (area.Area / 666.7).ToDouble(2) : 0; - feature.Store(); - } - Marshal.FinalReleaseComObject(feature); - feature = null; - fids.Next(out featureOID); - } - Marshal.FinalReleaseComObject(fids); - } - #endregion - }; panel1.MouseWheel += MapCtrlContainer_MouseWheel; dockManager = dockManager1; Platform.Instance.NotifyMsgEven2 += o => @@ -158,52 +119,14 @@ namespace Kingo.Plugin.MapView try { StrTig = o.Content.ToTrim(); - axMapControl.ActiveView.Extent = o.Extend as IEnvelope;// MapsManager.Instance.MapService.getAxMapControl().Extent; + axMapControl.ActiveView.Extent = o.Extend as IEnvelope; axMapControl.ActiveView.Refresh(); } catch { } } }; } - /// - /// 根据区划代码获取县级名称 - /// - /// - /// - public string GetXZQDic(string Codes) - { - IRDBHelper rdbHelper = null; - string CodeName = string.Empty; - try - { - string systemPath = SysAppPath.GetDataBasePath() + "System.mdb"; - if (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 Where XZQ LIKE '" + Codes + "%'"; - DataTable dt = rdbHelper.ExecuteDatatable("Dic", strSQL, true); - if (dt != null) - { - CodeName = dt.Rows[0]["NAME"].ToString(); - } - } - } - catch (Exception ex) - { - LogAPI.Debug(ex.Message); - LogAPI.Debug(ex.StackTrace); - } - finally - { - if (rdbHelper != null) - { - rdbHelper.DisConnect(); - } - } - return CodeName; - } + private void AddMask() { try @@ -238,10 +161,11 @@ namespace Kingo.Plugin.MapView } catch (Exception ex) { - + PluginServiceInterface.CommonHelper.RecordsErrLog("执行AddMask发生异常:", ex); return; } } + private void AxMapControl_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) { if (StrTig != "Map2") @@ -478,7 +402,6 @@ namespace Kingo.Plugin.MapView return allLayers; } - /// 创建菜单项 /// /// @@ -1325,28 +1248,6 @@ namespace Kingo.Plugin.MapView } } - private void CreateXml(string path) - { - try - { - System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); - xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null)); - System.Xml.XmlElement root = xmlDoc.CreateElement("Root"); - xmlDoc.AppendChild(root); - - System.Xml.XmlElement roots = xmlDoc.CreateElement("File"); - roots.SetAttribute("path", path); - root.AppendChild(roots); - xmlDoc.Save(m_XmlPath); - } - catch (Exception ex) - { - LogAPI.Debug("在初始化 目录切换 命令时异常,异常信息如下:"); - LogAPI.Debug(ex); - LogAPI.Debug("在初始化 目录切换 命令时异常信息结束"); - } - } - #region 接口函数 public void InitMapTools(IEnumerable pageDatas) { @@ -1628,7 +1529,7 @@ namespace Kingo.Plugin.MapView if (Platform.Instance.SystemType != SystemTypeEnum.DTBJK) { layerInfo2s.Remove(layerInfo2s[i]); - i--; + i--; } continue; } @@ -1638,7 +1539,7 @@ namespace Kingo.Plugin.MapView { if (!Directory.Exists(layerInfo2s[i].FcPath)) { - if(Platform.Instance.SystemType != SystemTypeEnum.DTBJK) + if (Platform.Instance.SystemType != SystemTypeEnum.DTBJK) { layerInfo2s.Remove(layerInfo2s[i]); i--;