using ESRI.ArcGIS.Geodatabase; using KGIS.Framework.Maps; 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.PluginServiceInterface; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text.RegularExpressions; using System.Windows; namespace Kingo.Plugin.DLTB_IDG.View { /// /// CreateQualityCheckView.xaml 的交互逻辑 /// public partial class CreateQualityCheckView : BaseWindow { private ProjectInfo projectInfo = null; public CreateQualityCheckView() { InitializeComponent(); this.Loaded += (s, e) => { if (projectInfo == null) projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; txtXZQCode.Text = projectInfo.CODE; #region 获取【变更成果】文件夹下面的最后一次生成的数据 if (projectInfo.BGResultPath != null) { DirectoryInfo directoryInfo = new DirectoryInfo(projectInfo.BGResultPath); DirectoryInfo[] directoryInfos = directoryInfo.GetDirectories(); if (directoryInfos.Length > 0) { foreach (var idirectory in directoryInfos.OrderByDescending(x => x.CreationTime)) { if (idirectory.GetDirectories().Length == 0) { try { idirectory.Delete(); } catch { } } else { btnResult.Text = idirectory.GetDirectories().FirstOrDefault().FullName; break; } } //判断成果路径下是否存在基础数据包 string JCKPath = btnResult.Text.ToString() + @"\基础数据包";//@"\更新数据包\原格式数据"; if (!Directory.Exists(JCKPath)) Directory.CreateDirectory(JCKPath); btnJCK.Text = JCKPath; } } #endregion }; } /// /// 基础数据路径 /// /// /// private void BtnXZQPath_Click(object sender, RoutedEventArgs e) { btnJCK.Text = SelectPath(); } /// /// 坡度图路径 /// /// /// private void BtnPDQPath_Click(object sender, RoutedEventArgs e) { try { OpenDataDialog pDialog = new OpenDataDialog(); ISpatialDataObjectFilter pOFilter; pOFilter = new FilterDatasetsAndLayers(); pDialog.AddFilter(pOFilter, true); pDialog.Title = "选择导入的数据"; pDialog.AllowMultiSelect = false; pDialog.RestoreLocation = true; pDialog.StartLocation = pDialog.FinalLocation; System.Windows.Forms.DialogResult dialogResult = pDialog.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0) { foreach (ISpatialDataObject distObj in pDialog.Selection) { if (distObj.DatasetType == esriDatasetType.esriDTFeatureClass) { btnPDT.Text = distObj.FullName; break; } } } } catch (Exception ex) { LogAPI.Debug("btnExternalData_Click异常:" + ex.Message); LogAPI.Debug("btnExternalData_Click异常:" + ex.StackTrace); } } private void BtnOK_Click(object sender, RoutedEventArgs e) { //GT_QualityCallMiddleware.CallCreateQualityTask_GetControlArea s = null; //GT_QualityCallMiddleware.CallReQualityTaskFinishCheck s1 = null; //string strBGPath = @"E:\建库升级文档\国检软件调用测试\国检软件调用测试\王冠杰\福建省泉州市石狮市(350581)2022年度国土变更调查数据库更新成果"; //string strJCPath = @"E:\建库升级文档\国检软件调用测试\国检软件调用测试\王冠杰\福建省泉州市石狮市(350581)2022年度国土变更调查数据库更新成果\基础数据包"; string strBGPath = btnResult.Text; string strJCPath = btnJCK.Text; string strPDTPath = btnPDT.Text; if (string.IsNullOrWhiteSpace(strBGPath)) { MessageHelper.ShowTips("待检成果库路径不可为空!"); return; } else if (string.IsNullOrWhiteSpace(strJCPath)) { MessageHelper.ShowTips("基础数据路径不可为空!"); return; } //选择原格式数据,并复制 //CopyBasePackage(strJCPath); //string strBGFWPath = @"E:\建库升级文档\国检软件调用测试\国检软件调用测试\王冠杰\福建省泉州市石狮市(350581)2022年度国土变更调查数据库更新成果\350581石狮市变更范围成果"; //string strTaskOutputPath = @"E:\建库升级文档\国检软件调用测试\国检软件调用测试\王冠杰"; try { btnOK.IsEnabled = false; btnCancel.IsEnabled = false; string XZQCode = projectInfo.CODE.Trim(); string strExeFile = @"C:\Program Files (x86)\2023年度国土变更调查县级数据库质量检查软件\2023年度变更调查质检软件\GT_QualityCallMiddleware.exe"; FileInfo fileInfo = new FileInfo(strExeFile); if (!fileInfo.Exists) { //MessageHelper.ShowTips($"{strExeFile},默认安装路径未找到启动程序。"); MessageHelper.ShowTips("未能从默认安装路径找到国家质检软件启动程序,请手动选择国家质检软件“GT_QualityCallMiddleware.exe”路径。"); KGIS.Framework.Utils.Dialog.OpenFileDialog openFileDialog = new KGIS.Framework.Utils.Dialog.OpenFileDialog(); openFileDialog.Title = "选择国家质检软件"; openFileDialog.Filter = "Executable Files|*.exe"; openFileDialog.FileName = string.Empty; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog()) { strExeFile = openFileDialog.FileName; fileInfo = new FileInfo(strExeFile); } else return; } //string strParams = string.Format("{0} \"{1}\" \"{2}\" \"{3}\" \"{4}\" \"{5}\" \"{6}\"", 14, strBGPath, "350581", strJCPath, "", "", "变更调查质检"); string strParams = string.Format("{0} \"{1}\" \"{2}\" \"{3}\" \"{4}\" \"{5}\" \"{6}\" \"{7}\"", 14, strBGPath, "", strJCPath, "", strPDTPath, "", "变更调查质检"); string strInfo = RunMutilProcess(strExeFile, strParams, GetCreateTaskReturnFolderProcessInfo); GetReturnFolderPath(strInfo); } catch (Exception ex) { LogAPI.Debug("启动国家质检软件失败:" + ex.Message); LogAPI.Debug("启动国家质检软件失败:" + ex.StackTrace); MessageHelper.ShowError("启动国家质检软件失败" + ex.Message); } finally { btnOK.IsEnabled = true; btnCancel.IsEnabled = true; } } #region 选择原格式数据,并复制 //private void CopyBasePackage(string basePackagePath) //{ // try // { // if (string.IsNullOrEmpty(basePackagePath)) return; // if (Directory.Exists(Path.Combine(basePackagePath, "原格式数据"))) // { // Directory.Delete(Path.Combine(basePackagePath, "原格式数据"), true); // } // CopyFolder(txtOriginalData.Text, Path.Combine(basePackagePath, "原格式数据", Path.GetFileName(txtOriginalData.Text))); // } // catch (Exception ex) // { // LogAPI.Debug("复制原格式数据 异常:" + ex); // } //} //private void CopyFolder(string sourceFolderPath, string destinationFolderPath) //{ // if (!Directory.Exists(destinationFolderPath)) // { // Directory.CreateDirectory(destinationFolderPath); // } // string[] files = Directory.GetFiles(sourceFolderPath); // foreach (string file in files) // { // string destinationFilePath = Path.Combine(destinationFolderPath, Path.GetFileName(file)); // File.Copy(file, destinationFilePath, true); // } // string[] subFolders = Directory.GetDirectories(sourceFolderPath); // foreach (string subFolder in subFolders) // { // string destinationSubFolderPath = Path.Combine(destinationFolderPath, Path.GetFileName(subFolder)); // CopyFolder(subFolder, destinationSubFolderPath); // } //} #endregion private void BtnCancel_Click(object sender, RoutedEventArgs e) { this.Close(); } private string SelectPath() { KGIS.Framework.Utils.Dialog.FolderBrowserDialog pBrowser = new KGIS.Framework.Utils.Dialog.FolderBrowserDialog { ShowNewFolderButton = true }; if (pBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (string.IsNullOrWhiteSpace(pBrowser.SelectedPath)) return ""; return pBrowser.SelectedPath; } else return ""; } private static string GetReturnFolderPath(string strInfo) { if (string.IsNullOrWhiteSpace(strInfo)) return null; List Arr = Regex.Split(strInfo.ToString(), "%&%", RegexOptions.IgnoreCase).ToList(); if (Arr[0] == "成功") { return Arr[1]; } else { return null; } } private delegate bool GetProcessWriteInfoDelegate(string strLog); private static string RunMutilProcess(string strExePath, string strParams, GetProcessWriteInfoDelegate pGetProcessWriteInfoDelegate) { Process pProcess = new Process(); pProcess.StartInfo.FileName = strExePath; pProcess.StartInfo.Arguments = strParams; pProcess.StartInfo.UseShellExecute = false; pProcess.StartInfo.RedirectStandardOutput = true; pProcess.StartInfo.RedirectStandardInput = true; pProcess.Start(); while (true) { if (!pProcess.HasExited) { string strOutputTxt = pProcess.StandardOutput.ReadLine(); if (strOutputTxt != null) { if (pGetProcessWriteInfoDelegate.Invoke(strOutputTxt)) { return strOutputTxt; } } } else { break; } } return null; } private static bool GetCreateTaskReturnFolderProcessInfo(string strInfo) { if (!strInfo.Contains("%&%")) { return false; } else { return true; } } /// /// 待检成果路径 /// /// /// private void BtnResultPath_Click(object sender, RoutedEventArgs e) { btnResult.Text = SelectPath(); } //选择原格式数据 private void BtnTxtOriginalDataPath_Click(object sender, RoutedEventArgs e) { //txtOriginalData.Text = SelectPath(); } } }