You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							176 lines
						
					
					
						
							8.6 KiB
						
					
					
				
			
		
		
	
	
							176 lines
						
					
					
						
							8.6 KiB
						
					
					
				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 | 
						|
{ | 
						|
    /// <summary> | 
						|
    /// 覆盖工程数据 的交互逻辑 | 
						|
    /// </summary> | 
						|
    public partial class FrmLoadProjectData : BaseWindow | 
						|
    { | 
						|
        public FrmLoadProjectData() | 
						|
        { | 
						|
            InitializeComponent(); | 
						|
            this.Title = "覆盖工程数据"; | 
						|
        } | 
						|
 | 
						|
        private string SelectPathName = string.Empty; | 
						|
        private readonly List<string> ZLlays = new List<string>() { "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); | 
						|
            } | 
						|
        } | 
						|
    } | 
						|
}
 | 
						|
 |