| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Web; |
| | | |
| | |
| | | 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> |
| | | /// è·åæ°Tbpæä»¶ |
| | | /// </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> |
| | | /// è·åæ°JS |
| | | /// </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); |
| | | } |
| | | } |
| | | } |