From 2f38d9ee5f607a1078258a8575acf9600b9e8595 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期一, 13 三月 2023 16:54:13 +0800
Subject: [PATCH] 1

---
 ExportMap/cs/ExportUtil.cs |   63 +------------------------------
 1 files changed, 3 insertions(+), 60 deletions(-)

diff --git a/ExportMap/cs/ExportUtil.cs b/ExportMap/cs/ExportUtil.cs
index c11dc1a..117a64b 100644
--- a/ExportMap/cs/ExportUtil.cs
+++ b/ExportMap/cs/ExportUtil.cs
@@ -129,65 +129,6 @@
         }
 
         /// <summary>
-        /// 鎵цPython
-        /// </summary>
-        /// <param name="py">Python鏂囦欢</param>
-        /// <param name="qgz">QGIS宸ョ▼</param>
-        /// <param name="qpt">QGIS妯℃澘</param>
-        /// <returns>鎵ц缁撴灉</returns>
-        public static string ExecPython(string py, string qgz, string qpt)
-        {
-            string str = null;
-            try
-            {
-                string cmdText = string.Format("python {0} -qgz {1} -qpt {2}", py, qgz, qpt);
-                LogOut.Info("cmd = " + cmdText);
-
-                Process p = new Process();
-                p.StartInfo.FileName = "cmd.exe";
-                p.StartInfo.UseShellExecute = false;
-                p.StartInfo.CreateNoWindow = true;
-                p.StartInfo.RedirectStandardInput = true;
-                p.StartInfo.RedirectStandardOutput = true;
-                p.StartInfo.RedirectStandardError = true;
-                p.Start();
-
-                StreamWriter si = p.StandardInput; // 鏍囧噯杈撳叆娴� 
-                StreamReader so = p.StandardOutput; // 鏍囧噯杈撳嚭娴� 
-                StreamReader se = p.StandardError; // 鏍囧噯閿欒娴�
-
-                si.AutoFlush = true;
-                //si.WriteLine("cd \"C:\\Program Files\\QGIS 3.16\\apps\\Python37\"");
-                //si.WriteLine("set PYTHONHOME=\"C:\\Program Files\\QGIS 3.16\\apps\\Python37\"");
-                //si.WriteLine("set PYTHONPATH=\"C:\\Program Files\\QGIS 3.16\\apps\\qgis-ltr\\python;C:\\Program Files\\QGIS 3.16\\apps\\qgis-ltr\\bin;C:\\Program Files\\QGIS 3.16\\apps\\qgis-ltr\\python\\qgis;C:\\Program Files\\QGIS 3.16\\apps\\Python37\\Lib;C:\\Program Files\\QGIS 3.16\\apps\\Python37\\Lib\\site-packages;C:\\Program Files\\QGIS 3.16\\apps\\Python37\\DLLs;C:\\Program Files\\QGIS 3.16\\apps\\Python37\\Scripts;\"");
-                //si.WriteLine("set Path=\"C:\\Program Files\\QGIS 3.16\\apps\\Python37;C:\\Program Files\\QGIS 3.16\\bin;C:\\Program Files\\QGIS 3.16\\apps\\qgis-ltr\\\\bin\";%Path%");
-                //si.WriteLine("\"C:\\Program Files\\QGIS 3.16\\bin\\qgis_process-qgis-ltr.bat\"");
-                si.WriteLine("\"C:\\Program Files\\QGIS 3.16\\bin\\python-qgis-ltr.bat\"");
-                si.WriteLine(cmdText);
-                si.WriteLine("exit");
-
-                string info = so.ReadToEnd();
-                str = se.ReadToEnd();
-
-                if (!string.IsNullOrEmpty(info)) LogOut.Debug(info);
-                if (!string.IsNullOrEmpty(str)) LogOut.Error(str);
-                if (p.HasExited == false) p.Kill();
-
-                si.Close();
-                so.Close();
-                se.Close();
-                p.Close();
-            }
-            catch (Exception ex)
-            {
-                LogOut.Error(ex.StackTrace);
-                str = ex.Message;
-            }
-
-            return str;
-        }
-
-        /// <summary>
         /// 鐢熸垚
         /// </summary>
         /// <param name="args">鍑哄浘鍙傛暟</param>
@@ -204,7 +145,9 @@
 
             args.SetDefault();
             CreateTemplate(args);
-            err = ExecPython(PyFile, qgz, args.qpt);
+
+            string cmd = string.Format("python {0} -qgz {1} -qpt {2}", PyFile, qgz, args.qpt);
+            err = Tool.ExecPython(cmd);
 
             string qptFile = Path.Combine(SourcesPath, args.qpt);
             if (File.Exists(qptFile))

--
Gitblit v1.9.3