From 0a7a732a71aed91eadae992ec26d3f4726d04df2 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 03 八月 2023 14:40:58 +0800 Subject: [PATCH] 1 --- ExportMap/cs/ExportUtil.cs | 2 +- ExportMap/cs/Tools.cs | 12 +++++------- ExportMap/cs/XYZUtils.cs | 14 +------------- ExportMap/cs/OsgbUtils.cs | 2 +- ExportMap/cs/ConvertUtils.cs | 10 +++------- ExportMap/cs/TerraUtils.cs | 2 +- ExportMap/cs/LasUtils.cs | 2 +- 7 files changed, 13 insertions(+), 31 deletions(-) diff --git a/ExportMap/cs/ConvertUtils.cs b/ExportMap/cs/ConvertUtils.cs index 53c5c0f..5192923 100644 --- a/ExportMap/cs/ConvertUtils.cs +++ b/ExportMap/cs/ConvertUtils.cs @@ -84,8 +84,7 @@ Process p = null; try { - //string log = Path.Combine(ExportUtil.SourcesPath, "ns_log.txt"); - //string args = string.Format("-licensing AdLM -OpenFile \"{0}\" -ExecuteAddInPlugin \"EngineBatch_Sample.SmartEarth\" \"{1}\" -log \"{2}\" -NoGui -Exit", modelFile, configFile, log); + //string args = string.Format("-licensing AdLM -OpenFile \"{0}\" -ExecuteAddInPlugin \"EngineBatch_Sample.SmartEarth\" \"{1}\" -log \"{2}\" -NoGui -Exit", modelFile, configFile, Path.Combine(ExportUtil.SourcesPath, "ns_log.txt")); string args = string.Format("-licensing AdLM -OpenFile \"{0}\" -ExecuteAddInPlugin \"EngineBatch_Sample.SmartEarth\" \"{1}\" -NoGui -Exit", modelFile, configFile); LogOut.Info("Args:" + args); @@ -94,11 +93,8 @@ task.pid = p.Id; task.id = TaskDBHelper.Insert(task); - // 璁╃粍浠剁瓑鍊欑浉鍏崇殑杩涚▼杩涘叆闂茬疆鐘舵�� - p.WaitForInputIdle(); - - // 璁╃粍浠舵棤闄愭湡鍦扮瓑寰呭叧鑱旇繘绋嬮��鍑� - p.WaitForExit(); + p.WaitForInputIdle(); // 璁╃粍浠剁瓑鍊欑浉鍏崇殑杩涚▼杩涘叆闂茬疆鐘舵�� + p.WaitForExit(); // 璁╃粍浠舵棤闄愭湡鍦扮瓑寰呭叧鑱旇繘绋嬮��鍑� task = TaskDBHelper.SelectById(task.id); if (null != task && task.status < 2) diff --git a/ExportMap/cs/ExportUtil.cs b/ExportMap/cs/ExportUtil.cs index 00c7851..9b5860c 100644 --- a/ExportMap/cs/ExportUtil.cs +++ b/ExportMap/cs/ExportUtil.cs @@ -142,7 +142,7 @@ CreateTemplate(args); string cmd = string.Format("python \"{0}\" -qgz {1} -qpt {2}", PyFile, qgz, args.qpt); - err = Tools.ExecCmd(null, cmd, true, true); + err = Tools.ExecCmd(null, cmd, true); string qptFile = Path.Combine(SourcesPath, args.qpt); if (File.Exists(qptFile)) File.Delete(qptFile); diff --git a/ExportMap/cs/LasUtils.cs b/ExportMap/cs/LasUtils.cs index ca67a49..7f3a4f5 100644 --- a/ExportMap/cs/LasUtils.cs +++ b/ExportMap/cs/LasUtils.cs @@ -57,7 +57,7 @@ int idx = args.ids.IndexOf(meta.id); string cmd = string.Format("{0}\\gocesiumtiler.exe -i \"{1}\" -o \"{2}\" -e {3} -z {4} -g -s", tilerPath, lasPath, outPath, args.srids[idx], args.zs[idx]); - err = Tools.ExecCmd(null, cmd, false, false); + err = Tools.ExecCmd(null, cmd, false); string jsonFile = findTileset(meta, outPath); if ("laz" == meta.type && File.Exists(lasPath)) File.Delete(lasPath); diff --git a/ExportMap/cs/OsgbUtils.cs b/ExportMap/cs/OsgbUtils.cs index 8f9c457..07d3e91 100644 --- a/ExportMap/cs/OsgbUtils.cs +++ b/ExportMap/cs/OsgbUtils.cs @@ -61,7 +61,7 @@ int idx = args.ids.IndexOf(meta.id); string cmd = string.Format("{0}\\3dtile.exe -f osgb -i \"{1}\" -o \"{2}\" -c \"{{\\\"offset\\\": {3}}}\"", d3tilesPath, osgbPath, outPath, args.zs[idx]); - err = Tools.ExecCmd(null, cmd, false, false); + err = Tools.ExecCmd(null, cmd, false); err = null; if (null != srs) writeSRS(osgbPath, srs); diff --git a/ExportMap/cs/TerraUtils.cs b/ExportMap/cs/TerraUtils.cs index edf04e9..46fef82 100644 --- a/ExportMap/cs/TerraUtils.cs +++ b/ExportMap/cs/TerraUtils.cs @@ -174,7 +174,7 @@ } string cmd = string.Format("python \"{0}\" -qgz {1} -file \"{2}\" -out \"{3}\"", PyFile, Qgz, txtFile, tifFile); - err = Tools.ExecCmd(null, cmd, true, false); + err = Tools.ExecCmd(null, cmd, true); return tifFile; } diff --git a/ExportMap/cs/Tools.cs b/ExportMap/cs/Tools.cs index c251067..68bed79 100644 --- a/ExportMap/cs/Tools.cs +++ b/ExportMap/cs/Tools.cs @@ -171,7 +171,7 @@ /// <param name="isPy">鏄惁涓篞GIS Py鑴氭湰</param> /// <param name="isOut">鏄惁杈撳嚭閿欒</param> /// <returns>鎵ц缁撴灉鎴栧嚭閿欎俊鎭�</returns> - public static string ExecCmd(SysTask task, string cmd, bool isPy = false, bool isOut = false) + public static string ExecCmd(SysTask task, string cmd, bool isPy = false) { List<string> list = new List<string>(); if (isPy) @@ -183,7 +183,7 @@ } list.Add(cmd); - string str = ExecCmd(task, list, isOut); + string str = ExecCmd(task, list); return str; } @@ -195,7 +195,7 @@ /// <param name="list">鍛戒护闆嗗悎</param> /// <param name="isOut">鏄惁杈撳嚭閿欒</param> /// <returns>鎵ц缁撴灉鎴栧嚭閿欎俊鎭�</returns> - public static string ExecCmd(SysTask task, List<string> list, bool isOut = false) + public static string ExecCmd(SysTask task, List<string> list) { string str = null; try @@ -210,10 +210,8 @@ p.StartInfo.RedirectStandardError = true; p.Start(); - //p.Id; - StreamWriter si = p.StandardInput; // 鏍囧噯杈撳叆娴� - StreamReader so = isOut ? p.StandardOutput : null; // 鏍囧噯杈撳嚭娴� + //StreamReader so = isOut ? p.StandardOutput : null; // 鏍囧噯杈撳嚭娴� StreamReader se = p.StandardError; // 鏍囧噯閿欒娴� LogOut.Info("cmd = " + string.Join("锛�", list)); @@ -224,7 +222,7 @@ } si.WriteLine("exit"); - string info = null == so ? null : so.ReadToEnd(); + //string info = null == so ? null : so.ReadToEnd(); str = se.ReadToEnd(); //if (!string.IsNullOrEmpty(info)) LogOut.Debug(info); diff --git a/ExportMap/cs/XYZUtils.cs b/ExportMap/cs/XYZUtils.cs index f5cbc2d..e6af0c3 100644 --- a/ExportMap/cs/XYZUtils.cs +++ b/ExportMap/cs/XYZUtils.cs @@ -95,8 +95,7 @@ string cmd = string.Format("python \"{0}\" -qgz {1} -file \"{2}\" -out \"{3}\" -min {4} -max {5} -noData {6}", PyFile, Qgz, tifFile, xyzPath, args.min, args.max, args.noData); - //err = Tools.ExecCmd(GetCmds(batFile, cmd)); - err = Tools.ExecCmd(null, cmd, true, false); + err = Tools.ExecCmd(null, cmd, true); //if (File.Exists(batFile)) File.Delete(batFile); if (File.Exists(tifFile)) File.Delete(tifFile); @@ -112,17 +111,6 @@ } return ids; - } - - /// <summary> - /// 鑾峰彇鍛戒护琛� - /// </summary> - private static List<string> GetCmds(string batFile, string cmd) - { - string str = File.ReadAllText(BaseBat) + cmd; - File.WriteAllText(batFile, str); - - return new List<string>() { "\"" + batFile + "\"" }; } /// <summary> -- Gitblit v1.9.3