管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2023-06-27 7d53d0fa3e5e74234bb14ae3ceea8be1f14182a5
移动Mpt文件
已修改1个文件
53 ■■■■■ 文件已修改
ExportMap/cs/TBUtils.cs 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/TBUtils.cs
@@ -42,20 +42,28 @@
        }
        /// <summary>
        /// 创建MPT
        /// 创建Mpt
        /// </summary>
        public static string CreateMpt(string sourcePath, ref string err)
        {
            string time = TimeStr;
            string targetPath = Path.Combine(Tools.TempDir, time);
            try
            {
                string targetPath = Path.Combine(Tools.TempDir, time);
                if (!Directory.Exists(targetPath)) Directory.CreateDirectory(targetPath);
                MoveFilesToTemp(sourcePath, targetPath);
                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.ExecCmd(cmd, false, false);
                if (File.Exists(MptPath))
                {
                    return MoveMpt(MptPath, sourcePath);
                }
                return null;
            }
@@ -67,7 +75,7 @@
            }
            finally
            {
                if (Directory.Exists(targetPath)) Directory.Delete(targetPath, true);
                ending(time);
            }
        }
@@ -158,5 +166,44 @@
            Tools.ExecCmd(list, false);
        }
        /// <summary>
        /// 移动Mpt文件
        /// </summary>
        private static string MoveMpt(string mpt, string targetPath)
        {
            string path = Path.Combine(targetPath, "Mpt");
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            FileInfo fi = new FileInfo(mpt);
            string newMpt = Path.Combine(path, fi.Name);
            File.Move(mpt, newMpt);
            string mIdx = mpt.Replace(".mpt", ".mIdx");
            if (File.Exists(mIdx)) File.Move(mIdx, newMpt.Replace(".mpt", ".mIdx"));
            string Strmi = mpt.Replace(".mpt", ".Strmi");
            if (File.Exists(Strmi)) File.Move(Strmi, newMpt.Replace(".mpt", ".Strmi"));
            return newMpt;
        }
        /// <summary>
        /// 收尾工作
        /// </summary>
        private static void ending(string time)
        {
            try
            {
                string targetPath = Path.Combine(Tools.TempDir, time);
                if (!Directory.Exists(targetPath)) return;
                //
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
    }
}