From 38ff6f2303068518460d6ce4486bda33daa3d3eb Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 27 六月 2023 12:31:44 +0800
Subject: [PATCH] 添加TB模板文件处理过程

---
 ExportMap/cs/TBUtils.cs |   88 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/ExportMap/cs/TBUtils.cs b/ExportMap/cs/TBUtils.cs
index ec2ac03..d32b9f9 100644
--- a/ExportMap/cs/TBUtils.cs
+++ b/ExportMap/cs/TBUtils.cs
@@ -1,5 +1,6 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Web;
 
@@ -8,13 +9,96 @@
     public class TBUtils
     {
         /// <summary>
+        /// 鑾峰彇婧愮洰褰�
+        /// </summary>
+        public static string SourcesPath
+        {
+            get
+            {
+                return Path.Combine(Tools.BaseDir, "TerraBuilder");
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇鏃堕棿瀹覆
+        /// </summary>
+        public static string GetTime
+        {
+            get
+            {
+                return DateTime.Now.ToString("yyyyMMddhhmmss");
+            }
+        }
+
+        /// <summary>
         /// 鍒涘缓MPT
         /// </summary>
         public static string CreateMpt(string path, ref string err)
         {
-            //
+            string tbp = null;
+            try
+            {
+                tbp = GetNewTbp();
 
-            return null;
+
+                return null;
+            }
+            catch (Exception ex)
+            {
+                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
+                err = ex.Message;
+                return null;
+            }
+            finally
+            {
+                if (tbp != null && File.Exists(tbp)) File.Delete(tbp);
+
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇鏂癟bp鏂囦欢
+        /// </summary>
+        private static string GetNewTbp()
+        {
+            string tbp = Path.Combine(SourcesPath, "tb.tbp");
+            string newTbp = Path.Combine(SourcesPath, GetTime + ".tbp");
+
+            File.Copy(tbp, newTbp);
+
+            return newTbp;
+        }
+
+        /// <summary>
+        /// 鑾峰彇鏂癑S
+        /// </summary>
+        private static string GetNewJs(string tbp, string shp, string img, string dem)
+        {
+            string js = Path.Combine(SourcesPath, "template.js");
+            string str = File.ReadAllText(js);
+            str = str.Replace("{tbp}", tbp)
+                .Replace("{shp}", shp)
+                .Replace("{img}", img)
+                .Replace("{dem}", dem)
+                .Replace("\\", "\\\\");
+
+            string newJs = Path.Combine(SourcesPath, GetTime + ".js");
+            File.WriteAllText(newJs, str);
+
+            return newJs;
+        }
+
+        /// <summary>
+        /// 閲嶅惎TB绋嬪簭
+        /// </summary>
+        private static void ReloadTB()
+        {
+            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");
+
+            Tools.ExecCmd(list, false);
         }
     }
 }

--
Gitblit v1.9.3