From a9d3642f93bdb25b5d72c8e28ee14d66ac7c4ea3 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 27 六月 2023 17:21:25 +0800
Subject: [PATCH] 将TerraBuilder自动化创建mpt程序包装成Web服务

---
 ExportMap/cs/TBUtils.cs |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/ExportMap/cs/TBUtils.cs b/ExportMap/cs/TBUtils.cs
index eb85942..26a139d 100644
--- a/ExportMap/cs/TBUtils.cs
+++ b/ExportMap/cs/TBUtils.cs
@@ -41,6 +41,8 @@
             }
         }
 
+        private static bool isBusy = false;
+
         /// <summary>
         /// 鍒涘缓Mpt
         /// </summary>
@@ -50,6 +52,9 @@
 
             try
             {
+                if (isBusy) throw new Exception("宸叉湁涓�涓敓鎴怣pt鐨勪换鍔℃鍦ㄦ墽琛�");
+
+                isBusy = true;
                 string targetPath = Path.Combine(Tools.TempDir, time);
                 if (!Directory.Exists(targetPath)) Directory.CreateDirectory(targetPath);
 
@@ -60,17 +65,15 @@
                 string cmd = string.Format("\"C:\\Program Files\\Skyline\\TerraBuilder\\TerraBuilder.exe\" -script \"{0}\"", js); // -DisablePrint
                 ReloadTB();
                 err = Tools.ExecCmd(cmd, false, false);
-                if (File.Exists(MptPath))
-                {
-                    return MoveMpt(MptPath, sourcePath);
-                }
+                isBusy = false;
 
-                return null;
+                return File.Exists(MptPath) ? MoveMpt(MptPath, sourcePath) : null;
             }
             catch (Exception ex)
             {
                 LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
                 err = ex.Message;
+                isBusy = false;
                 return null;
             }
             finally
@@ -161,8 +164,8 @@
         {
             List<string> list = new List<string>();
             list.Add("taskkill /f /t /im TerraBuilder.exe");
-            list.Add("taskkill /f /t /im TBFuser.exe");
-            list.Add("start /d \"C:\\Program Files\\Skyline\\TerraBuilder Fuser\" TBFuser.exe");
+            //list.Add("taskkill /f /t /im TBFuser.exe");
+            //list.Add("start /d \"C:\\Program Files\\Skyline\\TerraBuilder Fuser\" TBFuser.exe /b");
 
             Tools.ExecCmd(list, false);
         }
@@ -205,6 +208,8 @@
                 if (null != dem) MoveFile(dem, Path.Combine(sourcePath, "鏁板瓧楂樼▼妯″瀷"));
 
                 MoveFolder(Path.Combine(path, "shp"), Path.Combine(sourcePath, "涓嚎瑁佸壀鑼冨洿"));
+
+                Directory.Delete(path, true);
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3