using KGIS.Framework.Maps; using KGIS.Framework.Platform.Helper; using KGIS.Framework.Utils; using KGIS.Framework.Utils.Helper; using KGIS.Framework.Utils.Model; using kingo.Plugin.BGResultManager.Interface; using Kingo.PluginServiceInterface; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; namespace kingo.Plugin.BGResultManager.Utility { class MDBToVCTWindow : IVCTExport { public string OutPath { get; set; } public ScaleCodeTable Scale { get; set; } public void ExportVCT(bool haspdt,string sTheMDBPath="") { GC.Collect(); string vctpath = null; string mdbpath = null;//GDB路径 if (string.IsNullOrEmpty(null)) { vctpath = "VCTTemplate3.VCT"; if (haspdt == false) { vctpath = "VCTTemplate3NoPDT.VCT"; } } if (string.IsNullOrWhiteSpace(sTheMDBPath) == false) { mdbpath = sTheMDBPath; } if (string.IsNullOrEmpty(vctpath)) { //MessageHelper.Show("请选择需要转换的VCT结构文件!"); LogAPI.Debug("请选择需要转换的VCT结构文件"); return; } if (string.IsNullOrEmpty(mdbpath)) { //MessageHelper.Show("请选择MDB文件路径!"); LogAPI.Debug("请选择MDB文件路径"); return; } if (string.IsNullOrEmpty(OutPath)) { //MessageHelper.Show("请选择保存文件路径!"); LogAPI.Debug("请选择保存文件路径"); return; } try { //if (!qq()) //{ // return; //} //RegionAuthorize regionAuthorize = new RegionAuthorize(); //int validateType = 0; //if (!regionAuthorize.ValidateAuthorizeByXZQDM(ref validateType)) //{ // if (validateType.Equals(1)) // { // //KGIS.Common.MessageHelper.ShowError("地类图斑数据区域授权未通过"); // LogAPI.Debug("一键成果输出,地类图斑数据区域授权未通过"); // } // else if (validateType.Equals(2)) // { // //KGIS.Common.MessageHelper.ShowError("行政区数据区域授权未通过"); // LogAPI.Debug("一键成果输出,行政区数据区域授权未通过"); // } // else // { // //KGIS.Common.MessageHelper.ShowError("区域授权验证失败"); // LogAPI.Debug("一键成果输出,区域授权验证失败"); // } // return; //} //this.btnBegin.IsEnabled = false; //启动外部程序 #region 启动外部程序的方式 //var vT = "\"" + System.Windows.Forms.Application.StartupPath + "\\" + vctpath + "\" \"" + mdbpath + "\" \"" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE + "\" \"" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).FDD + "\" \"" + Scale.ScaleCode + "\" \"" + OutPath.TrimEnd('\\') + "\""; //Process proc = Process.Start("VCTConvertWPFApp3.exe", "\"" + vctpath + "\" \"" + mdbpath + "\" \"" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE + "\" \"" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).FDD + "\" \"" + Scale.ScaleCode + "\" \"" + OutPath.TrimEnd('\\') + "\""); //LogAPI.Debug(vT); Process proc = Process.Start("VCTConvertApp.exe", "\"" + System.Windows.Forms.Application.StartupPath + "\\" + vctpath + "\" " + "\"" + mdbpath + "\" " + "\"" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE + "\" " + "\"" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).FDD + "\" " + "\"" + Scale.ScaleCode + "\" " + "\"" + OutPath.TrimEnd('\\') + "\"" ); if (proc != null) { proc.WaitForExit(); ProgressHelper.CloseProcessBar(); //this.btnBegin.IsEnabled = true; if (proc.ExitCode == 200) { // MessageHelper.Show("导出完成!"); } else { LogAPI.Debug("一键成果输出,VCT导出失败!"); } try { //获取vct文件名 List filenames = new List(); List dirnames = new List(); string[] files = Directory.GetFiles(OutPath.TrimEnd());//得到文件 foreach (string file in files)//循环文件 { if (System.IO.Path.GetExtension(file) == ".VCT") { filenames.Add(System.IO.Path.GetFileNameWithoutExtension(file)); } } string[] dirs = Directory.GetDirectories(OutPath.TrimEnd());//得到目录 foreach (string file in dirs)//循环文件 { if (file.EndsWith("_idx")) { dirnames.Add(file); } } foreach (var name in filenames) { var tmpname = ""; if (name.EndsWith("000000")) { tmpname = name.Substring(0, name.Length - 6); System.IO.File.Move(OutPath + @"\" + name + ".VCT", OutPath + @"\" + tmpname + ".VCT"); } } foreach (var name in dirs) { var tmpname = ""; if (name.EndsWith("000000_idx")) { tmpname = name.Substring(0, name.Length - 10); System.IO.Directory.Move(name, tmpname + "_idx"); } } } catch (Exception ex) { LogAPI.Debug(ex); } } #endregion } catch (Exception ex) { ProgressHelper.CloseProcessBar(); MessageHelper.ShowError(ex.ToString()); } } } }