ExportMap/Controllers/TBController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ExportMap/ExportMap.csproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ExportMap/TerraBuilder/tb.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ExportMap/TerraBuilder/说明.txt | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ExportMap/cs/TBUtils.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ExportMap/cs/Tools.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ExportMap/Controllers/TBController.cs
@@ -7,6 +7,8 @@ using System.Net.Http; using System.Web.Http; using System.IO; using System.Diagnostics; using System.Threading; namespace ExportMap.Controllers { @@ -36,5 +38,46 @@ return ResponseMsg<string>.fail(ex.Message); } } [HttpGet] // http://localhost/ExportMap/TB/Test public ResponseMsg<string> Test() { try { Stopwatch sw = new Stopwatch(); sw.Start(); string err = null; bool rs = TBUtils.Test(ref err); sw.Stop(); return ResponseMsg<string>.success((rs ? "æå" : "失败") + "ï¼èæ¶ï¼" + sw.ElapsedMilliseconds / 1000.0 + " s", rs.ToString()); } catch (Exception ex) { LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); return ResponseMsg<string>.fail(ex.Message); } } [HttpGet] public ResponseMsg<string> Wait(long seconds) { try { Stopwatch sw = new Stopwatch(); sw.Start(); Thread.Sleep(new TimeSpan(seconds * 10 * 1000 * 1000)); sw.Stop(); return ResponseMsg<string>.success("æå", "èæ¶ï¼" + sw.ElapsedMilliseconds / 1000.0 + " s"); } catch (Exception ex) { LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); return ResponseMsg<string>.fail(ex.Message); } } } } ExportMap/ExportMap.csproj
@@ -130,6 +130,7 @@ <Content Include="Sources\说æ.txt" /> <Content Include="TerraBuilder\tb.js" /> <Content Include="TerraBuilder\template.js" /> <Content Include="TerraBuilder\说æ.txt" /> <Content Include="UE.html" /> <Content Include="up.html" /> <Content Include="Web.config"> ExportMap/TerraBuilder/tb.js
@@ -3,7 +3,7 @@ var project = TerraBuilder.OpenProject("E:\\terrait\\TianJin\\ExportMap\\ExportMap\\TerraBuilder\\tb01.tbp"); var shp = "D:\\LF\\data\\shp\\buffer_midline.shp"; var imgLayer = project.Layers.InsertLayer("D:\\LF\\data\\DOM\\CABQ_0641.tif", "imagery"); var imgLayer = project.Layers.InsertLayer("D:\\LF\\data\\DOM\\D0M_M.tif", "imagery"); if (null != imgLayer) { imgLayer.ImageryPyramidFormat = 0; @@ -16,7 +16,7 @@ poly2.type = 0; } var eleLayer = project.Layers.InsertLayer("D:\\LF\\data\\DEM\\DEM.tif", "Elevation"); var eleLayer = project.Layers.InsertLayer("D:\\LF\\data\\DEM\\DEM_M.tif", "Elevation"); if (null != eleLayer) { eleLayer.ElevationPyramidFormat = 0; @@ -34,8 +34,8 @@ poly3.type = 0; } project.CreateResolutionPyramids(); //project.Settings.MPTFileName = "D:\\LF\\data\\mpt\\0A.MPT"; project.CreateResolutionPyramids(); //project.Save(); project.CreateMPT(); ExportMap/TerraBuilder/˵Ã÷.txt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,15 @@ cmdï¼ cd "C:/Program Files/Skyline/TerraBuilder" TerraBuilder.exe -script E:/terrait/TianJin/ExportMap/ExportMap/TerraBuilder/tb.js D:\LF\data\DOM D:\LF\data\DEM D:\LF\data\mpt E:\terrait\TianJin\ExportMap\ExportMap\TerraBuilder http://localhost/ExportMap/TB/Test http://localhost/ExportMap/TB/Wait?seconds=30 ExportMap/cs/TBUtils.cs
@@ -49,7 +49,6 @@ public static string CreateMpt(string sourcePath, ref string err) { string time = TimeStr; try { if (isBusy) throw new Exception("å·²æä¸ä¸ªçæMptç任塿£å¨æ§è¡"); @@ -62,9 +61,10 @@ string tbp = GetNewTbp(time); string js = GetNewJs(time, tbp, targetPath); string cmd = string.Format("\"C:\\Program Files\\Skyline\\TerraBuilder\\TerraBuilder.exe\" -script \"{0}\"", js); // -DisablePrint ReloadTB(); err = Tools.ExecCmdForWin(new List<string> { cmd }); //string cmd = string.Format("\"C:\\Program Files\\Skyline\\TerraBuilder\\TerraBuilder.exe\" -script \"{0}\"", js); // -DisablePrint //err = Tools.ExecCmd(new List<string> { cmd }); err = Tools.ExecExe("\"C:/Program Files/Skyline/TerraBuilder/TerraBuilder.exe\"", string.Format("-script \"{0}\"", js)); isBusy = false; return File.Exists(MptPath) ? MoveMpt(MptPath, sourcePath) : null; @@ -83,6 +83,37 @@ } /// <summary> /// æµè¯ /// </summary> public static bool Test(ref string err) { string time = TimeStr; try { if (isBusy) throw new Exception("å·²æä¸ä¸ªçæMptç任塿£å¨æ§è¡"); isBusy = true; string js = "E:/terrait/TianJin/ExportMap/ExportMap/TerraBuilder/tb.js"; File.Copy("E:/terrait/TianJin/ExportMap/ExportMap/TerraBuilder/tb.tbp", "E:/terrait/TianJin/ExportMap/ExportMap/TerraBuilder/tb01.tbp", true); //string cmd = string.Format("\"C:/Program Files/Skyline/TerraBuilder/TerraBuilder.exe\" -script \"{0}\"", js); // -DisablePrint ReloadTB(); //err = Tools.ExecCmdForWin(new List<string> { cmd }); err = Tools.ExecExe("\"C:/Program Files/Skyline/TerraBuilder/TerraBuilder.exe\"", string.Format("-script \"{0}\"", js), false); isBusy = false; return File.Exists("D:/LF/data/mpt/tb.mpt"); } catch (Exception ex) { LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); err = ex.Message; isBusy = false; return false; } } /// <summary> /// è·åæ°Tbpæä»¶ /// </summary> private static string GetNewTbp(string time) ExportMap/cs/Tools.cs
@@ -377,35 +377,23 @@ /// æ§è¡å½ä»¤ /// </summary> /// <param name="list">å½ä»¤éå</param> public static string ExecCmdForWin(List<string> list, bool noWin = false) public static string ExecExe(string exe, string args, bool noWin = true) { string str = null; Process p = null; try { p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.FileName = exe; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = noWin; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; if (!string.IsNullOrEmpty(args)) p.StartInfo.Arguments = args; p.Start(); StreamWriter si = p.StandardInput; StreamReader se = p.StandardError; LogOut.Info("cmd = " + string.Join("ï¼", list)); si.AutoFlush = true; foreach (string cmd in list) { si.WriteLine(cmd); } si.WriteLine("exit"); str = se.ReadToEnd(); se.Close(); si.Close(); p.WaitForExit(); } catch (Exception ex) {