管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2023-06-27 a9d3642f93bdb25b5d72c8e28ee14d66ac7c4ea3
将TerraBuilder自动化创建mpt程序包装成Web服务
已修改2个文件
33 ■■■■ 文件已修改
ExportMap/Controllers/TBController.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/TBUtils.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Controllers/TBController.cs
@@ -17,18 +17,16 @@
        {
            try
            {
                if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(token))
                    return ResponseMsg<string>.fail("path和token参数不能为空");
                if (!ExportUtil.VerifyToken(token))
                    return ResponseMsg<string>.fail("令牌无效");
                if (!Directory.Exists(path))
                    return ResponseMsg<string>.fail("文件路径不存在");
                if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(token)) return ResponseMsg<string>.fail("path和token参数不能为空");
                if (!ExportUtil.VerifyToken(token)) return ResponseMsg<string>.fail("令牌无效");
                if (!Directory.Exists(path)) return ResponseMsg<string>.fail("文件路径不存在");
                string err = null;
                string rs = TBUtils.CreateMpt(path, ref err);
                if (string.IsNullOrEmpty(rs))
                    return ResponseMsg<string>.fail(null == err ? "失败" : err);
                if (string.IsNullOrEmpty(rs)) return ResponseMsg<string>.fail(null == err ? "失败" : err);
                return ResponseMsg<string>.success("成功", rs, 1);
            }
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("已有一个生成Mpt的任务正在执行");
                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)
            {