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.
		
		
		
		
		
			
		
			
				
					
					
						
							1350 lines
						
					
					
						
							57 KiB
						
					
					
				
			
		
		
	
	
							1350 lines
						
					
					
						
							57 KiB
						
					
					
				using ESRI.ArcGIS.ADF; | 
						|
using ESRI.ArcGIS.Carto; | 
						|
using ESRI.ArcGIS.Controls; | 
						|
using ESRI.ArcGIS.Geodatabase; | 
						|
using KGIS.Framework.AE; | 
						|
using KGIS.Framework.AE.Enum; | 
						|
using KGIS.Framework.DBOperator; | 
						|
using KGIS.Framework.Maps; | 
						|
using KGIS.Framework.OpenData.Control; | 
						|
using KGIS.Framework.OpenData.Filter; | 
						|
using KGIS.Framework.OpenData.InterFace; | 
						|
using KGIS.Framework.Platform; | 
						|
using KGIS.Framework.Utils; | 
						|
using KGIS.Framework.Utils.Helper; | 
						|
using KGIS.Framework.Utils.Utility; | 
						|
using Kingo.Framework.LayerStyleConvert.Common; | 
						|
using Kingo.Framework.LayerStyleConvert.XSDClass; | 
						|
using Kingo.OpenData.Filter; | 
						|
using Kingo.Plugin.DataLoad.Helper; | 
						|
using Kingo.Plugin.DataLoad.Model; | 
						|
using Kingo.PluginServiceInterface; | 
						|
using Kingo.PluginServiceInterface.Helper.VCT; | 
						|
using Kingo.PluginServiceInterface.Model; | 
						|
using KUI.Windows; | 
						|
using System; | 
						|
using System.Collections.Generic; | 
						|
using System.ComponentModel; | 
						|
using System.Data; | 
						|
using System.Globalization; | 
						|
using System.IO; | 
						|
using System.Linq; | 
						|
using System.Windows; | 
						|
using System.Windows.Controls; | 
						|
using System.Windows.Data; | 
						|
using System.Windows.Input; | 
						|
using UIShell.OSGi; | 
						|
using Path = System.IO.Path; | 
						|
using ESRI.ArcGIS.Geometry; | 
						|
using KGIS.Framework.Utils.ExtensionMethod; | 
						|
 | 
						|
namespace Kingo.Plugin.DataLoad.View | 
						|
{ | 
						|
    /// <summary> | 
						|
    /// FrmBatchDataImport.xaml 的交互逻辑 | 
						|
    /// </summary> | 
						|
    public partial class FrmLoadBaseData : BaseWindow | 
						|
    { | 
						|
        private IDataCatalogService _DataCatalog = null; | 
						|
        public bool shutDown = false; | 
						|
        private IHookHelper hookHelper = null; | 
						|
        /// <summary> | 
						|
        /// 导入数据类型(mdb文件为空,Shape文件为Shape) | 
						|
        /// </summary> | 
						|
        public string ImportDataType { get; set; } | 
						|
 | 
						|
        private string SourceMDBPath { get; set; } | 
						|
        private ISystemCfg SystemCfg = null; | 
						|
        private SystemConfig2 Cfg = null; | 
						|
        private SystemConfig2 SystemCfg2 = null; | 
						|
        /// <summary> | 
						|
        /// dgTableMapping.ItemsSource视图匹配项 | 
						|
        /// </summary> | 
						|
        List<LayerCfg> MapingData = new List<LayerCfg>(); | 
						|
        private ProjectInfo ProInfo = null; | 
						|
        private readonly IMap map = null; | 
						|
 | 
						|
        bool DataIsRight = true; | 
						|
 | 
						|
        public FrmLoadBaseData(IHookHelper m_hookHelper) | 
						|
        { | 
						|
            InitializeComponent(); | 
						|
            hookHelper = m_hookHelper; | 
						|
            try | 
						|
            { | 
						|
                ProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; | 
						|
                map = MapsManager.Instance.MapService.getAxMapControl().Map; | 
						|
                if (ProInfo == null) return; | 
						|
 | 
						|
                if (_DataCatalog == null) | 
						|
                    _DataCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>(); | 
						|
                SystemCfg = BundleRuntime.Instance.GetFirstOrDefaultService<ISystemCfg>(); | 
						|
                Cfg = SystemCfg.Load(); | 
						|
                if (Cfg.JcLayerLoadCfg == null) | 
						|
                { | 
						|
                    Cfg.JcLayerLoadCfg = new List<LayerCfg>(); | 
						|
                } | 
						|
                BindBaseDataPath(); | 
						|
                this.ResizeMode = ResizeMode = ResizeMode.CanResizeWithGrip; | 
						|
                object obj = _DataCatalog.CurrentLayers; | 
						|
                if (obj is LayerCfg) | 
						|
                { | 
						|
                    LayerCfg ncsj = (obj as LayerCfg).Layers.FirstOrDefault(f => f.LayerName == "年初数据" && f.LayerType == EnumLayerType.GroupLayer); | 
						|
                    if (ncsj != null && ncsj.Layers.Count > 0) | 
						|
                    { | 
						|
                        foreach (LayerCfg Layeritem in ncsj.Layers) | 
						|
                        { | 
						|
                            if (string.IsNullOrWhiteSpace(Layeritem.FcName) || string.IsNullOrWhiteSpace(Layeritem.FcPath)) continue; | 
						|
                            LayerCfg layerCfg = Cfg.JcLayerLoadCfg.FirstOrDefault(x => x.FcName == Layeritem.FcName); | 
						|
                            if (layerCfg != null) | 
						|
                            { | 
						|
                                layerCfg.FcPath = Layeritem.FcPath; | 
						|
                                layerCfg.IsLoad = true; | 
						|
                            } | 
						|
                        } | 
						|
                    } | 
						|
                } | 
						|
                dgTableMapping.ItemsSource = Cfg.JcLayerLoadCfg.FindAll(x => x.Required == true).OrderByDescending(x => x.Required).ToList(); | 
						|
            } | 
						|
            catch (Exception es) | 
						|
            { | 
						|
                LogAPI.Debug(es.Message); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        #region 最新数据加载 | 
						|
        private void BindBaseDataPath() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                IWorkCatalog workCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IWorkCatalog>(); | 
						|
                string code = (MapsManager.Instance.CurrProjectInfo as ProjectInfo).CODE; | 
						|
                string xzqmc = GetXZQMC(code); | 
						|
                string xzqDir = string.Format("{0}({1})", xzqmc, code); | 
						|
 | 
						|
                if (workCatalog != null && !string.IsNullOrWhiteSpace(code)) | 
						|
                { | 
						|
                    string projectPath = Path.Combine(workCatalog.SaveWorkSapcePath, xzqDir, "年初数据"); | 
						|
                    if (Directory.Exists(projectPath)) | 
						|
                    { | 
						|
                        List<string> dataPathList = new List<string>(); | 
						|
                        GetBaseDataPath(projectPath, dataPathList); | 
						|
                        if (dataPathList.Count != 0) | 
						|
                        { | 
						|
                            this.cobDataBase.ItemsSource = dataPathList.FindAll(x => !x.ToUpper().Contains(".MDB")); | 
						|
                        } | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("获取基础数据文件失败:" + ex); | 
						|
                MessageHelper.Show("获取基础数据文件失败:" + ex); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        //获取行政区名称 | 
						|
        private string GetXZQMC(string xzqdm) | 
						|
        { | 
						|
            string xzqmc = string.Empty; | 
						|
            KGIS.Framework.DBOperator.IRDBHelper rdbHelper = null; | 
						|
            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 '" + xzqdm + "%'"; | 
						|
                    string strSQL = string.Format("select OBJECTID AS ID, XZQ AS CODE,XZQMC AS NAME from XZQ  Where XZQ = '{0}'", xzqdm); | 
						|
                    DataTable dt = rdbHelper.ExecuteDatatable("Dic", strSQL, true); | 
						|
                    if (dt != null) | 
						|
                    { | 
						|
                        List<DataDicTionary> xzqCoderesult = TBToList.ToList<DataDicTionary>(dt); | 
						|
                        foreach (var item in xzqCoderesult) | 
						|
                        { | 
						|
                            if (dt.Rows.Count == 1) | 
						|
                                xzqmc = item.NAME; | 
						|
                        } | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug(ex); | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                if (rdbHelper != null) | 
						|
                    rdbHelper.DisConnect(); | 
						|
            } | 
						|
            return xzqmc; | 
						|
        } | 
						|
 | 
						|
        private void GetBaseDataPath(string dirPath, List<string> pathList) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                string[] dirArr = Directory.GetDirectories(dirPath); | 
						|
                string[] fileArr = Directory.GetFiles(dirPath); | 
						|
 | 
						|
                // 遍历所有文件 | 
						|
                if (fileArr.Length > 0) | 
						|
                { | 
						|
                    string fileName; | 
						|
                    foreach (string file in fileArr) | 
						|
                    { | 
						|
                        fileName = Path.GetFileName(file); | 
						|
                        if ((fileName.ToLower().Contains(".vct") || fileName.ToLower().Contains(".mdb")) && !pathList.Contains(file)) | 
						|
                        { | 
						|
                            pathList.Add(file); | 
						|
                        } | 
						|
                    } | 
						|
                } | 
						|
 | 
						|
                // 遍历所有文件夹 | 
						|
                if (dirArr.Length > 0) | 
						|
                { | 
						|
                    string folderName; | 
						|
                    foreach (string dir in dirArr) | 
						|
                    { | 
						|
                        folderName = Path.GetFileName(dir); | 
						|
                        if (folderName.ToLower().Contains(".gdb") && !pathList.Contains(dir)) | 
						|
                        { | 
						|
                            pathList.Add(dir); | 
						|
                        } | 
						|
                        GetBaseDataPath(dir, pathList); | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("获取基础数据文件失败:" + ex); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 数据路径切换 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void CobDataBase_SelectedIndexChanged(object sender, RoutedEventArgs e) | 
						|
        { | 
						|
            if (cobDataBase.ItemsSource != null) | 
						|
            { | 
						|
                try | 
						|
                { | 
						|
                    DataIsRight = true; | 
						|
                    string selectedPath = this.cobDataBase.SelectedItem.ToString(); | 
						|
                    using (ComReleaser com = new ComReleaser()) | 
						|
                    { | 
						|
                        ImportDataType = Path.GetExtension(selectedPath).ToUpper().Replace('.', ' ').TrimStart(); | 
						|
                        this.ShowLoading("正在打开数据文件...", 0, 0); | 
						|
                        System.Threading.Thread.Sleep(900); | 
						|
                        string fileName = string.Empty; | 
						|
                        if (!string.IsNullOrWhiteSpace(ImportDataType) && ImportDataType.Equals("VCT")) | 
						|
                        { | 
						|
                            string TempMDBFolderPath = Path.GetTempPath(); | 
						|
                            string TempMDBPath = Path.Combine(TempMDBFolderPath, string.Format("{0}.mdb", Path.GetFileNameWithoutExtension(selectedPath))); | 
						|
                            if (File.Exists(TempMDBPath)) | 
						|
                            { | 
						|
                                File.Delete(TempMDBPath); | 
						|
                            } | 
						|
                            this.ShowLoading("正在解析VCT文件... ...", 0, 0); | 
						|
                            VCTToMDBHelper3 vcttomdb = new VCTToMDBHelper3 | 
						|
                            { | 
						|
                                RootPath = TempMDBFolderPath | 
						|
                            }; | 
						|
                            vcttomdb.VCTToMDB(selectedPath); | 
						|
                            this.CloseLoading(); | 
						|
                            if (!File.Exists(TempMDBPath)) | 
						|
                            { | 
						|
                                MessageHelper.ShowError("VCT文件解析失败"); | 
						|
                                return; | 
						|
                            } | 
						|
                            SourceMDBPath = TempMDBPath; | 
						|
                        } | 
						|
                        SetTableMapping(); | 
						|
                        this.CloseLoading(); | 
						|
                    } | 
						|
                } | 
						|
                catch (Exception ex) | 
						|
                { | 
						|
                    LogAPI.Debug("选择基础数据库失败:" + ex); | 
						|
                    this.CloseLoading(); | 
						|
                    MessageHelper.Show("选择基础数据库失败:" + ex.Message); | 
						|
                } | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void SetTableMapping() | 
						|
        { | 
						|
            IWorkspaceAPI t_WsAPI = null; | 
						|
            IWorkspaceAPI s_WsAPI = null; | 
						|
            IFeatureClassAPI s_FCAPI = null; | 
						|
            try | 
						|
            { | 
						|
                string s_MdbPath = null; | 
						|
                if (ImportDataType == "VCT") | 
						|
                { | 
						|
                    s_MdbPath = SourceMDBPath; | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    if (this.cobDataBase.SelectedItem != null) | 
						|
                        s_MdbPath = this.cobDataBase.SelectedItem.ToString(); | 
						|
                } | 
						|
                if ((ImportDataType == "MDB" || ImportDataType == "VCT") && !File.Exists(s_MdbPath)) | 
						|
                { | 
						|
                    if (!Path.GetFileName(s_MdbPath).Equals(".mdb")) | 
						|
                    { | 
						|
                        MessageHelper.ShowTips("请确保文件存在,并且为mdb文件!"); | 
						|
                        return; | 
						|
                    } | 
						|
                } | 
						|
                else if (ImportDataType == "GDB" && !Directory.Exists(s_MdbPath)) | 
						|
                { | 
						|
                    MessageHelper.ShowTips("请确保GDB文件夹存在!"); | 
						|
                    return; | 
						|
                } | 
						|
                if (ImportDataType == "MDB" || ImportDataType == "VCT") | 
						|
                { | 
						|
                    s_WsAPI = new WorkspaceAPI(s_MdbPath, WorkspaceTypeEnum.MDBFile); | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    s_WsAPI = new WorkspaceAPI(s_MdbPath, WorkspaceTypeEnum.GDBFile, true); | 
						|
                } | 
						|
                //源数据获取图层 | 
						|
                if (s_WsAPI == null) return;//源数据不能为空 | 
						|
                //系统配置图层 | 
						|
                List<KeyAndValue> t_TbList = new List<KeyAndValue>(); | 
						|
                if (SystemCfg != null) | 
						|
                    Cfg = SystemCfg.Load();//根据配置文件是否为必选项 | 
						|
                foreach (LayerCfg Tempitem in Cfg.JcLayerLoadCfg) | 
						|
                { | 
						|
                    t_TbList.Add(new KeyAndValue() { S_Key = Tempitem.FcName, S_Value = Tempitem.LayerName, IsCheck = Tempitem.Required }); | 
						|
                } | 
						|
                List<KeyAndValue> s_TbList = s_WsAPI.GetFeatureClassName(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureDataset).Where(x => !x.Value.StartsWith("TDQSQ")).Select(x => new KeyAndValue() { S_Key = x.Key, S_Value = x.Value }).ToList();//周旺华 0424 排除TDQSQ导致的导入问题 | 
						|
                Dictionary<string, string> s_TbList2 = s_WsAPI.GetFeatureClassName(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass); | 
						|
                foreach (string item in s_TbList2.Keys) | 
						|
                { | 
						|
                    if (!s_TbList.Select(x => x.S_Value).Contains(item)) | 
						|
                        s_TbList.Add(new KeyAndValue() { S_Key = item, S_Value = s_TbList2[item] }); | 
						|
                } | 
						|
                bool IsMatching = false; | 
						|
                foreach (KeyAndValue item in s_TbList) | 
						|
                { | 
						|
                    LayerCfg cfg = Cfg.JcLayerLoadCfg.FirstOrDefault(x => x.FcName == item.S_Key || x.FcName == item.S_Value); | 
						|
                    if (cfg != null) | 
						|
                    { | 
						|
                        cfg.FcPath = s_MdbPath; | 
						|
                        IsMatching = true; | 
						|
                    } | 
						|
                } | 
						|
                if (!IsMatching) | 
						|
                { | 
						|
                    MessageHelper.ShowTips("无匹配项,请重新选择数据!"); | 
						|
                    return; | 
						|
                } | 
						|
                List<LayerCfg> Mappings = (dgTableMapping.ItemsSource as List<LayerCfg>).FindAll(x => x.FcName != "").ToList(); | 
						|
                string ExceptionMessage = string.Empty; | 
						|
                IFeatureClassAPI TempFL = null; | 
						|
                foreach (LayerCfg UpdateLayerPath in Mappings) | 
						|
                { | 
						|
                    LayerCfg layerCfg = Cfg.JcLayerLoadCfg.FirstOrDefault(x => x.FcName == UpdateLayerPath.FcName); | 
						|
                    if (layerCfg == null || string.IsNullOrWhiteSpace(layerCfg.FcPath)) continue; | 
						|
                    UpdateLayerPath.FcPath = layerCfg.FcPath; | 
						|
                    UpdateLayerPath.IsLoad = layerCfg.Required; | 
						|
                    TempFL = s_WsAPI.OpenFeatureClass2(layerCfg.FcName); | 
						|
                    if ("DLTB,CZCDYD,CJDCQ,XZQ,PDT".Contains(layerCfg.FcName) && TempFL != null) | 
						|
                    { | 
						|
                        CheackJCGDB(new FeatureLayer() { FeatureClass = TempFL.FeatureClass }, ref ExceptionMessage); | 
						|
                        TempFL.CloseFeatureClass(); | 
						|
                    } | 
						|
                    if (layerCfg.FcName.ToUpper().Contains("DLTB")) | 
						|
                    { | 
						|
                        IFeature TempF = TempFL.FeatureClass.Search(null, true).NextFeature(); | 
						|
                        IGeoDataset s_Ds = TempFL.FeatureClass as IGeoDataset; | 
						|
                        int BSMIndex = TempFL.FeatureClass.FindField("BSM"); | 
						|
                        if (TempF != null && !TempF.Value[BSMIndex].ToString().Substring(0, 6).Equals(ProInfo.CODE)) | 
						|
                        { | 
						|
                            DataIsRight = false; | 
						|
                            string errorMessage = "地类图斑图层数据BSM前六位与工程行政区代码不一致!"; | 
						|
                            MessageHelper.ShowTips($"提示:{errorMessage}"); | 
						|
                            LogAPI.Debug("基础数据加载数据异常提示:" + errorMessage); | 
						|
                        } | 
						|
                        else if (ProInfo.GetCurentProjectedCoordinate().FactoryCode != s_Ds.SpatialReference.FactoryCode) | 
						|
                        { | 
						|
                            DataIsRight = false; | 
						|
                            string errorMessage = "源图层坐标系与当前工程坐标系不一致!"; | 
						|
                            MessageHelper.ShowTips($"提示:{errorMessage}"); | 
						|
                            LogAPI.Debug("基础数据加载数据异常提示:" + errorMessage); | 
						|
                        } | 
						|
                    } | 
						|
                    TempFL = null; | 
						|
                } | 
						|
                if (!string.IsNullOrWhiteSpace(ExceptionMessage)) | 
						|
                { | 
						|
                    DataIsRight = false; | 
						|
                    LogAPI.Debug("基础数据加载数据异常提示:" + ExceptionMessage); | 
						|
                    MessageHelper.ShowTips(ExceptionMessage); | 
						|
                } | 
						|
                dgTableMapping.ItemsSource = null;//主要是刷新视图显示效果 | 
						|
                //Cfg.JcLayerLoadCfg.ForEach(x => x.IsLoad = x.Required); | 
						|
                dgTableMapping.ItemsSource = (Mappings as List<LayerCfg>).OrderByDescending(x => x.Required).ToList(); | 
						|
                dgTableMapping.RefreshData(); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug(ex); | 
						|
                throw new Exception($"{ex.Message}"); | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                if (s_WsAPI != null) | 
						|
                { | 
						|
                    s_WsAPI.CloseWorkspace(); | 
						|
                    s_WsAPI = null; | 
						|
                } | 
						|
                if (t_WsAPI != null) | 
						|
                { | 
						|
                    t_WsAPI.CloseWorkspace(); | 
						|
                    t_WsAPI = null; | 
						|
                } | 
						|
                if (s_FCAPI != null) | 
						|
                { | 
						|
                    s_FCAPI.CloseFeatureClass(); | 
						|
                    s_FCAPI = null; | 
						|
                } | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public void CheackJCGDB(IFeatureLayer JClayer, ref string ExceptionMessage) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                string LayerName_JC = ((IDataset)JClayer.FeatureClass).Name.ToUpper().ToTrim(); | 
						|
                if (!"DLTB,CZCDYD,CJDCQ,XZQ,PDT".Contains(LayerName_JC)) | 
						|
                    ExceptionMessage += $"Err:{JClayer.FeatureClass.AliasName}要素类名称非国家标准名称,需使用国家下发的原始基础库;\n"; | 
						|
 | 
						|
                if (JClayer.FeatureClass.OIDFieldName != "OBJECTID") | 
						|
                    ExceptionMessage += $"Err:{JClayer.FeatureClass.AliasName}数据主键字段非“OBJECTID”,需使用国家下发的原始基础库;\n"; | 
						|
 | 
						|
                if (JClayer.FeatureClass.Fields.FieldCount == 0) | 
						|
                    ExceptionMessage += $"Err:{JClayer.FeatureClass.AliasName}数据字段结构与国家下发模板存在差异,需使用国家下发的原始基础库;\n"; | 
						|
 | 
						|
                string FieldsJH = string.Empty; | 
						|
                if (LayerName_JC == "DLTB") | 
						|
                    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"; | 
						|
                else if (((IDataset)JClayer.FeatureClass).Name.ToUpper() == "CZCDYD") | 
						|
                    FieldsJH = "OBJECTID,CZCDM,CZCMC,CZCLX,YSDM,BSM,CZCMJ,BZ"; | 
						|
                else if (((IDataset)JClayer.FeatureClass).Name.ToUpper() == "CJDCQ") | 
						|
                    FieldsJH = "OBJECTID,BSM,YSDM,ZLDWDM,ZLDWMC,DCMJ,JSMJ,MSSM,HDMC,BZ"; | 
						|
                else if (((IDataset)JClayer.FeatureClass).Name.ToUpper() == "XZQ") | 
						|
                    FieldsJH = "OBJECTID,BSM,YSDM,XZQDM,XZQMC,DCMJ,JSMJ,MSSM,HDMC,BZ"; | 
						|
                else if (((IDataset)JClayer.FeatureClass).Name.ToUpper() == "PDT") | 
						|
                    FieldsJH = "OBJECTID,BSM,YSDM,PDJB,BZ"; | 
						|
                foreach (var item in FieldsJH.Split(',')) | 
						|
                { | 
						|
                    int fieldIndex = JClayer.FeatureClass.Fields.FindField(item); | 
						|
                    if (fieldIndex == -1) | 
						|
                        ExceptionMessage += $"Err:{JClayer.FeatureClass.AliasName}数据缺失字段“{item}”,需使用国家下发的原始基础库;\n"; | 
						|
                } | 
						|
                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") || field.Name.ToUpper().Contains("GXSJ")) | 
						|
                        continue;//字段 “SHAPE” “XZQTZLX” “GXSJ” 作为系统例外字段 | 
						|
                    if (!FieldsJH.Contains(field.Name)) | 
						|
                    { | 
						|
                        JClayer.FeatureClass.DeleteField(field); | 
						|
                        //ExceptionMessage += $"Err:{JClayer.FeatureClass.AliasName}数据出现非国家下发模板字段“{field.Name}”,需使用国家下发的原始基础库;\n"; | 
						|
                    } | 
						|
                    else if (field.Name.ToUpper() == "BZ" && field.Length != 255 && LayerName_JC == "DLTB") | 
						|
                        ExceptionMessage += $"Err:{JClayer.FeatureClass.AliasName}数据出现“{field.Name}”字段长度不符合标准长度(255),需更改该字段长度;\n"; | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                throw new Exception($"{ex.Message}"); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 全选和反选事件 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void ChkSelectedAll_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if ((dgTableMapping.ItemsSource as List<LayerCfg>) == null) return; | 
						|
                List<LayerCfg> listTableMapping = (dgTableMapping.ItemsSource as List<LayerCfg>); | 
						|
                bool check = (sender as DevExpress.Xpf.Editors.CheckEdit).IsChecked == null ? false : bool.Parse((sender as DevExpress.Xpf.Editors.CheckEdit).IsChecked.Value.ToString()); | 
						|
                if (check) | 
						|
                { | 
						|
                    listTableMapping.ForEach(x => x.IsLoad = true); | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    listTableMapping.ForEach(x => x.IsLoad = false); | 
						|
                } | 
						|
                dgTableMapping.ItemsSource = null; | 
						|
                dgTableMapping.ItemsSource = listTableMapping; | 
						|
                dgTableMapping.RefreshData(); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                MessageHelper.ShowTips("全选发生异常:" + ex.Message); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 加载 -  | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void BtnLoad_Click(object sender, RoutedEventArgs e) | 
						|
        { | 
						|
            this.btnLoad.IsEnabled = false; | 
						|
            IWorkspaceAPI pSourceWsAPI = null; | 
						|
            IWorkspaceAPI pTargetWsAPI = null; | 
						|
            string projectPath = string.Empty; | 
						|
            string s_MdbPath = null; | 
						|
            try | 
						|
            { | 
						|
                if (ImportDataType == "VCT") | 
						|
                { | 
						|
                    s_MdbPath = SourceMDBPath; | 
						|
                } | 
						|
                if (dgTableMapping.ItemsSource != null)//新匹配规则  | 
						|
                { | 
						|
                    if (!DataIsRight) | 
						|
                    { | 
						|
                        MessageHelper.ShowTips("所选基础库数据不符合要求,请修改后重新选择数据!"); | 
						|
                        return; | 
						|
                    } | 
						|
                    this.ShowLoading("正在进行数据加载......", 0, 0); | 
						|
                    ILayer layer = MapsManager.Instance.MapService.GetGroupLayer("JCSJ");//获取年初数据图层组 | 
						|
                    LayerCfg GroupLayerInfo = null; | 
						|
                    if (_DataCatalog != null) | 
						|
                    { | 
						|
                        _DataCatalog.GetNodeByLayer(layer); | 
						|
                        LayerCfg rootLayer = _DataCatalog.CurrentLayers as LayerCfg; | 
						|
                        List<LayerCfg> AllLayers = rootLayer.GetAllItem(); | 
						|
                        GroupLayerInfo = AllLayers.FirstOrDefault(f => f.LayerName == layer.Name); | 
						|
                        GroupLayerInfo.Layers.Clear(); | 
						|
                    } | 
						|
                    ISystemCfg cfg2 = BundleRuntime.Instance.GetFirstOrDefaultService<ISystemCfg>(); | 
						|
                    SystemCfg2 = cfg2.Load(); | 
						|
                    if (SystemCfg2.JcLayerLoadCfg == null) | 
						|
                    { | 
						|
                        SystemCfg2.JcLayerLoadCfg = new List<LayerCfg>(); | 
						|
                    } | 
						|
                    List<LayerCfg> TempMapingData = dgTableMapping.ItemsSource as List<LayerCfg>; | 
						|
                    if (layer != null) (layer as IGroupLayer).Clear(); | 
						|
 | 
						|
                    string message = string.Empty; | 
						|
                    string errorMessage = string.Empty; | 
						|
                    int SuccessImportLayerCount = 0; | 
						|
                    int DeletedImportLayerCount = 0; | 
						|
                    int FailImportLayerCount = 0; | 
						|
                    TempMapingData.Reverse(); | 
						|
                    foreach (LayerCfg itemLayer in TempMapingData) | 
						|
                    { | 
						|
                        if (GroupLayerInfo.Layers.FirstOrDefault(x => x.LayerName == itemLayer.LayerName) != null && itemLayer.IsLoad == true) | 
						|
                            GroupLayerInfo.Layers.RemoveAll(f => f.LayerName == itemLayer.LayerName);//仅替换将要加载的图层 | 
						|
                        if (itemLayer.IsLoad == false || string.IsNullOrWhiteSpace(itemLayer.FcPath)) continue;//不勾选的/空数据,不导入数据 | 
						|
                        IWorkspaceAPI workspaceAPI = GetImportDataWorkspace(itemLayer.FcPath); | 
						|
                        if (AddLayerToMap(GroupLayerInfo, itemLayer, workspaceAPI, ref message, ref errorMessage, ref FailImportLayerCount)) | 
						|
                        { | 
						|
                            itemLayer.LoadLayerState = PluginServiceInterface.TBState.EndImport; | 
						|
                            SuccessImportLayerCount++; | 
						|
                        } | 
						|
                        else | 
						|
                        { | 
						|
                            DeletedImportLayerCount++; | 
						|
                        } | 
						|
                        if (workspaceAPI != null) | 
						|
                        { | 
						|
                            workspaceAPI.CloseWorkspace(); | 
						|
                            workspaceAPI = null; | 
						|
                        } | 
						|
                    } | 
						|
                    TempMapingData.Reverse(); | 
						|
                    dgTableMapping.ItemsSource = null; | 
						|
                    dgTableMapping.ItemsSource = TempMapingData; | 
						|
                    _DataCatalog?.UpdateTree(); | 
						|
 | 
						|
                    #region 基础数据加载后默认设置字典/扣除系数 | 
						|
                    if (ZDSet.IsChecked == true) | 
						|
                    { | 
						|
                        this.UpdateMsg("正在进行默认字典设置......."); | 
						|
                        //设置字典 | 
						|
                        SetDicManageHelper.SetDicManage(); | 
						|
                    } | 
						|
                    if (KCXSSet.IsChecked == true) | 
						|
                    { | 
						|
                        this.UpdateMsg("正在进行默认扣除系数设置......."); | 
						|
                        //设置扣除系数 | 
						|
                        SetKCDLXSHelper.SetKCDLXS(); | 
						|
                    } | 
						|
                    #endregion | 
						|
 | 
						|
                    if (string.IsNullOrWhiteSpace(ProInfo.BGDatabase)) | 
						|
                    { | 
						|
                        this.UpdateMsg("正在进行创建变更数据库......."); | 
						|
                        PluginServiceInterface.CommonHelper.ExeCommandOperation("创建变更数据库"); | 
						|
                    } | 
						|
                    this.CloseLoading(); | 
						|
                    SaveProject(); | 
						|
 | 
						|
                    if (!string.IsNullOrWhiteSpace(errorMessage)) | 
						|
                    { | 
						|
                        int TotalImportLayerCount = SuccessImportLayerCount + DeletedImportLayerCount + FailImportLayerCount; | 
						|
                        errorMessage = string.Format("共导入{0}个图层,成功{1}个,删除{2}个,失败{3}个。", TotalImportLayerCount, SuccessImportLayerCount, | 
						|
                            DeletedImportLayerCount, FailImportLayerCount) + errorMessage; | 
						|
                        this.CloseLoading(); | 
						|
                        MessageHelper.Show(errorMessage, false); | 
						|
                    } | 
						|
                    else | 
						|
                    { | 
						|
                        int TotalImportLayerCount = SuccessImportLayerCount + DeletedImportLayerCount + FailImportLayerCount; | 
						|
                        message = string.Format("共导入{0}个图层,成功{1}个,删除{2}个,失败{3}个。", TotalImportLayerCount, SuccessImportLayerCount, | 
						|
                            DeletedImportLayerCount, FailImportLayerCount) + message; | 
						|
                        this.CloseLoading(); | 
						|
                        MessageHelper.Show(message, false); | 
						|
                    } | 
						|
                    if (DeletedImportLayerCount == 0 && FailImportLayerCount == 0) this.Close(); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                this.CloseLoading(); | 
						|
                LogAPI.Debug("导入 " + ImportDataType + " 数据时失败,异常原因: " + ex + " ; "); | 
						|
                MessageHelper.ShowTips("导入 " + ImportDataType + " 数据时失败,异常原因: " + ex.Message + " ; "); | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                this.btnLoad.IsEnabled = true; | 
						|
                pSourceWsAPI?.CloseWorkspace(); | 
						|
                pTargetWsAPI?.CloseWorkspace(); | 
						|
                this.CloseLoading(); | 
						|
                GC.Collect(); | 
						|
                GC.WaitForPendingFinalizers(); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private bool AddLayerToMap(LayerCfg ncsjGroupLayer, LayerCfg pTbMaping, IWorkspaceAPI pSourceWsAPI, ref string message, ref string errorMessage, ref int FailImportLayerCount) | 
						|
        { | 
						|
            if ((pSourceWsAPI == null || pSourceWsAPI.CurrentWorkspace == null || ncsjGroupLayer == null)) | 
						|
                return false; | 
						|
            IFeatureClassAPI s_FcAPI = null; | 
						|
            try | 
						|
            { | 
						|
                if (!string.IsNullOrWhiteSpace(pTbMaping.FcName) && pSourceWsAPI.ExistFeatureClass(pTbMaping.FcName)) | 
						|
                    s_FcAPI = pSourceWsAPI.OpenFeatureClass2(pTbMaping.FcName); | 
						|
                if (s_FcAPI != null && s_FcAPI.FeatureClass != null) | 
						|
                { | 
						|
                    bool isEqual = GeoDBAPI.SpatialReferenceCompare(map.SpatialReference, (s_FcAPI.FeatureClass as IGeoDataset).SpatialReference); | 
						|
                    if (!isEqual) | 
						|
                    { | 
						|
                        errorMessage += (pTbMaping.LayerName + "图层数据校验坐标系不一致!"); | 
						|
                        return false; | 
						|
                    } | 
						|
 | 
						|
                    IFeatureLayer pTargetLayer = new FeatureLayer | 
						|
                    { | 
						|
                        FeatureClass = s_FcAPI.FeatureClass, | 
						|
                        Name = pTbMaping.LayerName | 
						|
                    }; | 
						|
                    ILegendInfo pLegendInfo = pTargetLayer as ILegendInfo; | 
						|
                    int legendGroupCount = pLegendInfo.LegendGroupCount; | 
						|
                    ILegendGroup pLGroup; | 
						|
                    for (int i = 0; i < legendGroupCount; i++) | 
						|
                    { | 
						|
                        pLGroup = pLegendInfo.get_LegendGroup(i); | 
						|
                        pLGroup.Visible = false; | 
						|
                    } | 
						|
                    if (_DataCatalog != null) | 
						|
                    { | 
						|
                        SetILayerSymbol(pTargetLayer, pTargetLayer.FeatureClass.AliasName); | 
						|
                        _DataCatalog.AddLayer(pTargetLayer, ncsjGroupLayer); | 
						|
                        return true;//执行成功 | 
						|
                    } | 
						|
                } | 
						|
                LogAPI.Debug($"图层数据导入记录:匹配名称:{pTbMaping.FcName},打开不存在!"); | 
						|
                return false; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                FailImportLayerCount++; | 
						|
                errorMessage += (pTbMaping.LayerName + "图层数据导入异常!" + ex.Message); | 
						|
                LogAPI.Debug(pTbMaping.LayerName + "图层数据导入异常:" + ex); | 
						|
                return false; | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                s_FcAPI?.CloseFeatureClass(); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void SetILayerSymbol(IFeatureLayer tempLayer, string LayerAliseName) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                IFeatureRenderer result = null; | 
						|
                LayerCfg layerCfg = SystemCfg2.JcLayerLoadCfg.FirstOrDefault(x => x.FcName == LayerAliseName);//默认配置默认不为NULL  | 
						|
                if (layerCfg != null && !string.IsNullOrWhiteSpace(layerCfg.Symbol)) | 
						|
                { | 
						|
                    AdvancedDrawingInfo ad = AdvancedDrawingInfo.FromJson(layerCfg.Symbol); | 
						|
                    if (ad != null) | 
						|
                    { | 
						|
                        if (ad.DrawingInfo.Renderer is Framework.LayerStyleConvert.XSDClass.SimpleRenderer) | 
						|
                        { | 
						|
                            Symbol symbol1 = (ad.DrawingInfo.Renderer as Framework.LayerStyleConvert.XSDClass.SimpleRenderer).Symbol; | 
						|
                            ISimpleRenderer simpleRander2 = SymbolConvert.Instance().GetSimpleRenderer(symbol1, SymbolTypeEnum.Fill); | 
						|
                            result = simpleRander2 as IFeatureRenderer; | 
						|
                        } | 
						|
                        else if (ad.DrawingInfo.Renderer is Framework.LayerStyleConvert.XSDClass.UniqueValueRenderer) | 
						|
                        { | 
						|
                            Renderer rander = ad.DrawingInfo.Renderer; | 
						|
                            IUniqueValueRenderer uniqueValueRander = SymbolConvert.Instance().GetUniqueValueRenderer(rander, SymbolTypeEnum.Fill); | 
						|
                            result = uniqueValueRander as IFeatureRenderer; | 
						|
                        } | 
						|
                    } | 
						|
 | 
						|
                    #region 样式 | 
						|
                    if (result != null) | 
						|
                        (tempLayer as IGeoFeatureLayer).Renderer = result; | 
						|
                    #endregion | 
						|
 | 
						|
                    #region 显示比例设置 | 
						|
                    tempLayer.MinimumScale = layerCfg.MinScale; | 
						|
                    tempLayer.MaximumScale = layerCfg.MaxScale; | 
						|
                    #endregion | 
						|
 | 
						|
                    #region 图层透明度 | 
						|
                    if (tempLayer is ILayerEffects mLayerEffects)//透明度 | 
						|
                        mLayerEffects.Transparency = (short)layerCfg.Transparency; | 
						|
                    #endregion | 
						|
 | 
						|
                    #region 是否显示 | 
						|
                    tempLayer.Visible = layerCfg.Visible;//是否显示 | 
						|
                    #endregion | 
						|
 | 
						|
                    #region 是否可选择 | 
						|
                    tempLayer.Selectable = layerCfg.Selectable; | 
						|
                    #endregion | 
						|
 | 
						|
                    #region 过滤条件 | 
						|
                    IFeatureLayerDefinition pFLDefinition = tempLayer as IFeatureLayerDefinition; | 
						|
                    if (pFLDefinition != null) | 
						|
                    { | 
						|
                        pFLDefinition.DefinitionExpression = layerCfg.DefinitionExpression; | 
						|
                    } | 
						|
                    #endregion | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                throw ex; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 选择的文件保存在工程内部(年初数据) | 
						|
        /// </summary> | 
						|
        /// <param name="SavePath"></param> | 
						|
        /// <returns>工程内部文件路径</returns> | 
						|
        private string SaveFileToPrjDic(string SavePath) | 
						|
        { | 
						|
            if (SavePath == null || string.IsNullOrWhiteSpace(SavePath)) return ""; | 
						|
            string fileName = string.Empty; | 
						|
            IWorkCatalog workCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IWorkCatalog>(); | 
						|
            string code = (MapsManager.Instance.CurrProjectInfo as ProjectInfo).CODE; | 
						|
            string xzqmc = GetXZQMC(code); | 
						|
            string xzqDir = string.Format("{0}({1})", xzqmc, code); | 
						|
            string projectPath = string.Empty; | 
						|
            if (workCatalog != null && !string.IsNullOrWhiteSpace(code)) | 
						|
            { | 
						|
                projectPath = Path.Combine(workCatalog.SaveWorkSapcePath, xzqDir, "年初数据"); | 
						|
                if (!Directory.Exists(projectPath)) | 
						|
                { | 
						|
                    Directory.CreateDirectory(projectPath); | 
						|
                } | 
						|
                fileName = Path.GetFileName(SavePath); | 
						|
                if (!string.IsNullOrWhiteSpace(fileName)) | 
						|
                { | 
						|
                    if (Path.GetExtension(SavePath).ToUpper().Replace('.', ' ').TrimStart() == "GDB") | 
						|
                    { | 
						|
                        DirectoryCopy(SavePath, projectPath); | 
						|
                    } | 
						|
                    else | 
						|
                    { | 
						|
                        DelFileMDB(Path.Combine(projectPath, fileName));//是否保持替换 | 
						|
                        if (!(File.Exists(SavePath) && SavePath.Contains(projectPath))) | 
						|
                            File.Copy(SavePath, projectPath + "\\" + fileName, true); | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            return Path.Combine(projectPath, fileName); | 
						|
        } | 
						|
 | 
						|
        Dictionary<string, IWorkspaceAPI> keyValueWorkAPI = new Dictionary<string, IWorkspaceAPI>(); | 
						|
        private IWorkspaceAPI GetImportDataWorkspace(string strS_DataPath) | 
						|
        { | 
						|
            strS_DataPath = SaveFileToPrjDic(strS_DataPath); | 
						|
            if (strS_DataPath != null && keyValueWorkAPI.ContainsKey(strS_DataPath)) | 
						|
                return keyValueWorkAPI[strS_DataPath];//在当前工程下打开WorkSpaceAPI | 
						|
            if (!File.Exists(strS_DataPath) && !Directory.Exists(strS_DataPath)) | 
						|
                return null; | 
						|
            string DataType = Path.GetExtension(strS_DataPath).ToUpper().Replace('.', ' ').TrimStart(); | 
						|
            IWorkspaceAPI workspaceAPI; | 
						|
            if (DataType == "MDB" || DataType == "VCT") | 
						|
            { | 
						|
                workspaceAPI = new WorkspaceAPI(strS_DataPath, WorkspaceTypeEnum.MDBFile, true); | 
						|
            } | 
						|
            else | 
						|
            { | 
						|
                workspaceAPI = new WorkspaceAPI(strS_DataPath, WorkspaceTypeEnum.GDBFile, true); | 
						|
            } | 
						|
            PluginServiceInterface.Helper.AECommonHelper.SetGeoDatasetSpatialReference(workspaceAPI.CurrentWorkspace, GeoDBAPI.CreteSpatialReference(ProInfo.PrjFileStr), ProInfo.XYResolution); | 
						|
            if (workspaceAPI != null && !keyValueWorkAPI.ContainsKey(strS_DataPath)) | 
						|
                keyValueWorkAPI.Add(strS_DataPath, workspaceAPI); | 
						|
            return workspaceAPI; | 
						|
        } | 
						|
 | 
						|
        private void DelFileMDB(string MDBPath) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (File.Exists(MDBPath)) | 
						|
                { | 
						|
                    File.Delete(MDBPath); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
                LogAPI.Debug("当前MDB文件删除失败不处理!"); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void SaveProject() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" }); | 
						|
                Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "InitProject" }); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("添加图层到地图时发生异常,异常信息如下:"); | 
						|
                LogAPI.Debug(ex); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 选择- | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void BtnSelectedBaseData_Click(object sender, RoutedEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                using (ComReleaser com = new ComReleaser()) | 
						|
                { | 
						|
                    List<string> baseDataPathList = new List<string>(); | 
						|
                    OpenDataDialog pDialog = new OpenDataDialog(); | 
						|
                    ISpatialDataObjectFilter pOFilter = new FilterGeoDatabasePersonal(); | 
						|
                    pDialog.AddFilter(pOFilter, true); | 
						|
                    //pOFilter = new FilterVCTFile();///VCT文件模式 | 
						|
                    //pDialog.AddFilter(pOFilter, true); | 
						|
                    pOFilter = new FilterGeoDatabaseFile(); | 
						|
                    pDialog.AddFilter(pOFilter, true); | 
						|
                    pDialog.AllowMultiSelect = false; | 
						|
                    pDialog.Title = "选择基础数据"; | 
						|
                    pDialog.RestoreLocation = true; | 
						|
                    pDialog.StartLocation = pDialog.FinalLocation; | 
						|
                    System.Windows.Forms.DialogResult dialogResult = pDialog.ShowDialog(); | 
						|
                    if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0) | 
						|
                    { | 
						|
                        ImportDataType = Path.GetExtension(pDialog.FinalLocation).ToUpper().Replace('.', ' ').TrimStart(); | 
						|
                        if (string.IsNullOrWhiteSpace(ImportDataType) || (ImportDataType != "VCT" && ImportDataType != "GDB" && ImportDataType != "MDB" && ImportDataType != "SHP")) | 
						|
                        { | 
						|
                            MessageHelper.Show("选择的数据路径有误,请根据过滤条件,重新选择数据库!!"); | 
						|
                            return; | 
						|
                        } | 
						|
                        if (ImportDataType == "SHP") | 
						|
                        { | 
						|
                            ImportDataType = "Shape"; | 
						|
                        } | 
						|
                        this.cobDataBase.ItemsSource = null; | 
						|
                        baseDataPathList.Add(pDialog.FinalLocation); | 
						|
                        this.cobDataBase.ItemsSource = baseDataPathList; | 
						|
                        string fileName = string.Empty; | 
						|
 | 
						|
                        if (!string.IsNullOrWhiteSpace(ImportDataType) && ImportDataType.Equals("VCT")) | 
						|
                        { | 
						|
                            string TempMDBFolderPath = Path.GetTempPath(); | 
						|
                            string TempMDBPath = Path.Combine(TempMDBFolderPath, string.Format("{0}.mdb", Path.GetFileNameWithoutExtension(pDialog.FinalLocation))); | 
						|
                            if (File.Exists(TempMDBPath)) | 
						|
                            { | 
						|
                                File.Delete(TempMDBPath); | 
						|
                            } | 
						|
                            this.ShowLoading("正在解析VCT文件……", 0, 0); | 
						|
                            VCTToMDBHelper3 vcttomdb = new VCTToMDBHelper3 | 
						|
                            { | 
						|
                                RootPath = TempMDBFolderPath | 
						|
                            }; | 
						|
                            vcttomdb.VCTToMDB(pDialog.FinalLocation); | 
						|
                            this.CloseLoading(); | 
						|
                            if (!File.Exists(TempMDBPath)) | 
						|
                            { | 
						|
                                MessageHelper.ShowError("VCT文件解析失败"); | 
						|
                                return; | 
						|
                            } | 
						|
                            SourceMDBPath = TempMDBPath; | 
						|
                        } | 
						|
                        this.cobDataBase.SelectedIndex = 0; | 
						|
                        //SetTableMapping(); | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("选择基础数据库失败:" + ex); | 
						|
                MessageHelper.Show("选择基础数据库失败:" + ex.Message); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public string DirectoryCopy(string sourceDir, string targetDirPath) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (!Directory.Exists(sourceDir)) return ""; | 
						|
                string targetDir = Path.Combine(targetDirPath, Path.GetFileName(sourceDir)); | 
						|
                //string targetDir = Path.Combine(targetDirPath, guid.ToString() + "." + Path.GetFileName(sourceDir).Split('.')[1]); | 
						|
                if (!Directory.Exists(targetDir)) | 
						|
                { | 
						|
                    Directory.CreateDirectory(targetDir); | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    return ""; | 
						|
                } | 
						|
                // 文件及文件夹名称数组 | 
						|
                string[] dirColl = Directory.GetDirectories(sourceDir); | 
						|
                string[] fileColl = Directory.GetFiles(sourceDir); | 
						|
                // 遍历复制所有文件 | 
						|
                if (fileColl.Length > 0) | 
						|
                { | 
						|
                    string fileName; | 
						|
                    foreach (string fileDir in fileColl) | 
						|
                    { | 
						|
                        fileName = Path.GetFileName(fileDir); | 
						|
                        File.Copy(sourceDir + "\\" + fileName, targetDir + "\\" + fileName, true); | 
						|
                    } | 
						|
                } | 
						|
                // 遍历复制所有文件夹 | 
						|
                if (dirColl.Length > 0) | 
						|
                { | 
						|
                    string folderName; | 
						|
                    foreach (string dir in dirColl) | 
						|
                    { | 
						|
                        folderName = Path.GetFileName(dir); | 
						|
                        // 递归调用 | 
						|
                        Directory.CreateDirectory(targetDir + "\\" + folderName); | 
						|
                        DirectoryCopy(dir, targetDir + "\\" + folderName); | 
						|
                    } | 
						|
                } | 
						|
                return ""; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("创建工程目录页面中,文件夹复制时失败,异常原因: " + ex.Message + " ; "); | 
						|
                return ""; | 
						|
                throw; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 图层加载状态栏-事件 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void CheckBox_Click(object sender, RoutedEventArgs e) | 
						|
        { | 
						|
            if (dgTableMapping.SelectedItem is LayerCfg tbm) | 
						|
            { | 
						|
                switch (tbm.LoadLayerState) | 
						|
                { | 
						|
                    case PluginServiceInterface.TBState.Waiting: | 
						|
                        tbm.LoadLayerState = PluginServiceInterface.TBState.Waiting; | 
						|
                        break; | 
						|
                    case PluginServiceInterface.TBState.Delete: | 
						|
                        tbm.LoadLayerState = PluginServiceInterface.TBState.Delete; | 
						|
                        break; | 
						|
                    case PluginServiceInterface.TBState.BeingImport: | 
						|
                        tbm.LoadLayerState = PluginServiceInterface.TBState.BeingImport; | 
						|
                        break; | 
						|
                    case PluginServiceInterface.TBState.EndImport: | 
						|
                        tbm.LoadLayerState = PluginServiceInterface.TBState.EndImport; | 
						|
                        break; | 
						|
                    default: | 
						|
                        break; | 
						|
                } | 
						|
                dgTableMapping.RefreshData(); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 取消 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void btnClose_Click(object sender, RoutedEventArgs e) | 
						|
        { | 
						|
            this.Close(); | 
						|
        } | 
						|
 | 
						|
        private void BaseWindow_Closing(object sender, CancelEventArgs e) | 
						|
        { | 
						|
            this.shutDown = true; | 
						|
        } | 
						|
        #endregion | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 列-操作-选择 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void Txt_Delete_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                OpenDataDialog pDialog = new OpenDataDialog(); | 
						|
                ISpatialDataObjectFilter pOFilter = new FilterGeoDatabasePersonal(); | 
						|
                pDialog.AddFilter(pOFilter, true); | 
						|
                pOFilter = new FilterVCTFile(); | 
						|
                pDialog.AddFilter(pOFilter, true); | 
						|
                pOFilter = new FilterGeoDatabaseFile(); | 
						|
                pDialog.AddFilter(pOFilter, true); | 
						|
                pDialog.AllowMultiSelect = false; | 
						|
                pDialog.Title = "选择基础数据"; | 
						|
                pDialog.RestoreLocation = true; | 
						|
                pDialog.StartLocation = pDialog.FinalLocation; | 
						|
                System.Windows.Forms.DialogResult dialogResult = pDialog.ShowDialog(); | 
						|
                if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count == 1) | 
						|
                { | 
						|
                    string txtBoxTag = (sender as TextBlock).Tag.ToString(); | 
						|
                    string ImportDataType = Path.GetExtension(pDialog.FinalLocation).ToUpper().Replace('.', ' ').TrimStart(); | 
						|
                    if (string.IsNullOrWhiteSpace(ImportDataType) || (ImportDataType != "GDB" && ImportDataType != "MDB")) | 
						|
                    { | 
						|
                        MessageHelper.Show("选择的数据路径有误,请根据过滤条件,重新选择数据库!!"); | 
						|
                        return; | 
						|
                    } | 
						|
                    string code = (MapsManager.Instance.CurrProjectInfo as ProjectInfo).CODE; | 
						|
                    IWorkspaceAPI workspaceAPI; | 
						|
                    if (ImportDataType == "MDB" || ImportDataType == "VCT") | 
						|
                    { | 
						|
                        workspaceAPI = new WorkspaceAPI(pDialog.FinalLocation, WorkspaceTypeEnum.MDBFile, true); | 
						|
                    } | 
						|
                    else | 
						|
                    { | 
						|
                        workspaceAPI = new WorkspaceAPI(pDialog.FinalLocation, WorkspaceTypeEnum.GDBFile, true); | 
						|
                    } | 
						|
                    if (workspaceAPI == null) | 
						|
                    { | 
						|
                        MessageHelper.Show($"请选择GDB、MDB或者VCT数据库!!"); | 
						|
                        return; | 
						|
                    } | 
						|
                    if (!workspaceAPI.ExistFeatureClass(txtBoxTag)) | 
						|
                    { | 
						|
                        MessageHelper.Show($"选择的数据中不存在{txtBoxTag},请重新选择数据库!!"); | 
						|
                        return; | 
						|
                    } | 
						|
                    IFeatureClassAPI BGTBFCAPI = workspaceAPI.OpenFeatureClass2(txtBoxTag); | 
						|
                    if (BGTBFCAPI == null || BGTBFCAPI.FeatureClass == null) | 
						|
                    { | 
						|
                        MessageHelper.Show($"选择的数据{txtBoxTag}为空,请重新选择数据库!!"); | 
						|
                        return; | 
						|
                    } | 
						|
                    ISpatialReference sp = (BGTBFCAPI.FeatureClass as IGeoDataset).SpatialReference; | 
						|
                    string spatialrefstr = string.Empty; | 
						|
                    IESRISpatialReferenceGEN2 prjsr = sp as IESRISpatialReferenceGEN2; | 
						|
                    prjsr.ExportToESRISpatialReference2(out spatialrefstr, out int t); | 
						|
                    if (ProInfo.PrjFileStr != spatialrefstr) | 
						|
                    { | 
						|
                        MessageHelper.Show($"选择的数据与工程坐标系不一致,请重新选择数据库!!"); | 
						|
                        return; | 
						|
                    } | 
						|
 | 
						|
                    MapingData.Clear(); | 
						|
                    MapingData = dgTableMapping.ItemsSource as List<LayerCfg>; | 
						|
                    if (MapingData != null && MapingData.Count != 0) | 
						|
                    { | 
						|
                        LayerCfg layerCfg = MapingData.FirstOrDefault(x => x.FcName == txtBoxTag); | 
						|
                        if (layerCfg == null) return; | 
						|
                        layerCfg.FcPath = pDialog.Selection[0].FullName; | 
						|
                        layerCfg.IsLoad = true; | 
						|
                        dgTableMapping.ItemsSource = null; | 
						|
                        dgTableMapping.ItemsSource = MapingData.OrderByDescending(x => x.Required).ToList(); | 
						|
                        dgTableMapping.RefreshData(); | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug(ex.Message); | 
						|
                MessageHelper.ShowError(ex.Message); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
    } | 
						|
    public class DateConverter : IValueConverter | 
						|
    { | 
						|
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (value is TableMapping) | 
						|
                { | 
						|
                    return (value as TableMapping).FieldMapping; | 
						|
                } | 
						|
                return null; | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
                return null; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | 
						|
        { | 
						|
            return null; | 
						|
        } | 
						|
    } | 
						|
    public class StateConverter : IValueConverter | 
						|
    { | 
						|
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (value is TBState) | 
						|
                { | 
						|
                    return (TBState)value == TBState.Waiting; | 
						|
                } | 
						|
                return value; | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
                return null; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | 
						|
        { | 
						|
            return null; | 
						|
        } | 
						|
    } | 
						|
    /// <summary> | 
						|
    /// 表映射关系 | 
						|
    /// </summary> | 
						|
    public class TableMapping : INotifyPropertyChanged | 
						|
    { | 
						|
        /// <summary> | 
						|
        /// 源数据表名 | 
						|
        /// </summary> | 
						|
        public string S_TableName { get; set; } | 
						|
        /// <summary> | 
						|
        /// 源数据表名 | 
						|
        /// </summary> | 
						|
        public string S_TableAliasName { get; set; } | 
						|
        /// <summary> | 
						|
        /// 数据源表类型 | 
						|
        /// </summary> | 
						|
        public string S_TableType { get; set; } | 
						|
        /// <summary> | 
						|
        /// 坐标系 | 
						|
        /// </summary> | 
						|
        public string S_Spatial { get; set; } | 
						|
        ///// <summary> | 
						|
        ///// 数据源要素类型 | 
						|
        ///// </summary> | 
						|
        //public string S_ShapeType { get; set; } | 
						|
        ///// <summary> | 
						|
        ///// 目标要素类型 | 
						|
        ///// </summary> | 
						|
        //public string T_ShapeType { get; set; } | 
						|
        private string _T_TableName; | 
						|
        /// <summary> | 
						|
        /// 目标数据表名 | 
						|
        /// </summary> | 
						|
        public string T_TableName | 
						|
        { | 
						|
            get { return _T_TableName; } | 
						|
            set | 
						|
            { | 
						|
                _T_TableName = value; | 
						|
                if (PropertyChanged2 != null) | 
						|
                { | 
						|
                    PropertyChanged2(this, new PropertyChangedEventArgs("T_TableName")); | 
						|
                } | 
						|
            } | 
						|
        } | 
						|
        /// <summary> | 
						|
        /// 目标数据表名 | 
						|
        /// </summary> | 
						|
        public string T_TableAliasName { get; set; } | 
						|
        /// <summary> | 
						|
        /// 目标表类型 | 
						|
        /// </summary> | 
						|
        public string T_TableType { get; set; } | 
						|
        /// <summary> | 
						|
        /// 目标排序 | 
						|
        /// </summary> | 
						|
        public int OrderIndex { get; set; } | 
						|
 | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 条件sql语句 | 
						|
        /// </summary> | 
						|
        private string _S_YSDM_SQL; | 
						|
        public string S_YSDM_SQL | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                return _S_YSDM_SQL; | 
						|
            } | 
						|
            set | 
						|
            { | 
						|
                _S_YSDM_SQL = value; | 
						|
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("S_YSDM_SQL")); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private List<FieldMapping> _FieldMapping; | 
						|
        /// <summary> | 
						|
        /// 字段映射信息 | 
						|
        /// </summary> | 
						|
        public List<FieldMapping> FieldMapping | 
						|
        { | 
						|
            get { return _FieldMapping; } | 
						|
            set | 
						|
            { | 
						|
                _FieldMapping = value; | 
						|
                int count = _FieldMapping.FindAll(f => f.S_FieldIndex == -1).Count; | 
						|
                if (count == 0) | 
						|
                { | 
						|
                    FieldMappingMsg = "所有字段已匹配"; | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    FieldMappingMsg = string.Format("{0} 个字段未匹配", count); | 
						|
                } | 
						|
            } | 
						|
        } | 
						|
        /// <summary> | 
						|
        /// 目标数据表值域 | 
						|
        /// </summary> | 
						|
        public List<DataDicTionary> T_TableList { get; set; } | 
						|
 | 
						|
        private string _FieldMappingMsg; | 
						|
        public string FieldMappingMsg | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                return _FieldMappingMsg; | 
						|
            } | 
						|
            set | 
						|
            { | 
						|
                _FieldMappingMsg = value; | 
						|
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("FieldMappingMsg")); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        #region | 
						|
        private TBState _State; | 
						|
        public TBState State | 
						|
        { | 
						|
            get { return _State; } | 
						|
            set | 
						|
            { | 
						|
                _State = value; | 
						|
                if (PropertyChanged != null) | 
						|
                { | 
						|
                    PropertyChanged(this, new PropertyChangedEventArgs("State")); | 
						|
                } | 
						|
            } | 
						|
        } | 
						|
        private int _Count; | 
						|
        /// <summary> | 
						|
        /// 总进度 | 
						|
        /// </summary> | 
						|
        public int Count | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                return _Count; | 
						|
            } | 
						|
            set | 
						|
            { | 
						|
                _Count = value; | 
						|
                if (PropertyChanged != null) | 
						|
                { | 
						|
                    PropertyChanged(this, new PropertyChangedEventArgs("Count")); | 
						|
                } | 
						|
            } | 
						|
        } | 
						|
        private int _Progress; | 
						|
        /// <summary> | 
						|
        /// 当前进度 | 
						|
        /// </summary> | 
						|
        public int Progress | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                return _Progress; | 
						|
            } | 
						|
            set | 
						|
            { | 
						|
                _Progress = value; | 
						|
                if (PropertyChanged != null) | 
						|
                { | 
						|
                    PropertyChanged(this, new PropertyChangedEventArgs("Progress")); | 
						|
                } | 
						|
            } | 
						|
        } | 
						|
        #endregion | 
						|
 | 
						|
        public event PropertyChangedEventHandler PropertyChanged; | 
						|
 | 
						|
        public event PropertyChangedEventHandler PropertyChanged2; | 
						|
    } | 
						|
 | 
						|
    public enum TBState | 
						|
    { | 
						|
        /// <summary> | 
						|
        /// 等待中 | 
						|
        /// </summary> | 
						|
        Waiting = 0, | 
						|
        /// <summary> | 
						|
        /// 删除 | 
						|
        /// </summary> | 
						|
        Delete = 1, | 
						|
        /// <summary> | 
						|
        /// 开始导入 | 
						|
        /// </summary> | 
						|
        BeingImport = 2, | 
						|
        /// <summary> | 
						|
        /// 结束导入 | 
						|
        /// </summary> | 
						|
        EndImport = 3 | 
						|
 | 
						|
    } | 
						|
}
 | 
						|
 |