| | |
| | | Process p = null; |
| | | try |
| | | { |
| | | //string log = Path.Combine(ExportUtil.SourcesPath, "ns_log.txt"); |
| | | //string args = string.Format("-licensing AdLM -OpenFile \"{0}\" -ExecuteAddInPlugin \"EngineBatch_Sample.SmartEarth\" \"{1}\" -log \"{2}\" -NoGui -Exit", modelFile, configFile, log); |
| | | //string args = string.Format("-licensing AdLM -OpenFile \"{0}\" -ExecuteAddInPlugin \"EngineBatch_Sample.SmartEarth\" \"{1}\" -log \"{2}\" -NoGui -Exit", modelFile, configFile, Path.Combine(ExportUtil.SourcesPath, "ns_log.txt")); |
| | | string args = string.Format("-licensing AdLM -OpenFile \"{0}\" -ExecuteAddInPlugin \"EngineBatch_Sample.SmartEarth\" \"{1}\" -NoGui -Exit", modelFile, configFile); |
| | | LogOut.Info("Args:" + args); |
| | | |
| | |
| | | task.pid = p.Id; |
| | | task.id = TaskDBHelper.Insert(task); |
| | | |
| | | // 让组件等候相关的进程进入闲置状态 |
| | | p.WaitForInputIdle(); |
| | | |
| | | // 让组件无限期地等待关联进程退出 |
| | | p.WaitForExit(); |
| | | p.WaitForInputIdle(); // 让组件等候相关的进程进入闲置状态 |
| | | p.WaitForExit(); // 让组件无限期地等待关联进程退出 |
| | | |
| | | task = TaskDBHelper.SelectById(task.id); |
| | | if (null != task && task.status < 2) |
| | |
| | | CreateTemplate(args); |
| | | |
| | | string cmd = string.Format("python \"{0}\" -qgz {1} -qpt {2}", PyFile, qgz, args.qpt); |
| | | err = Tools.ExecCmd(null, cmd, true, true); |
| | | err = Tools.ExecCmd(null, cmd, true); |
| | | |
| | | string qptFile = Path.Combine(SourcesPath, args.qpt); |
| | | if (File.Exists(qptFile)) File.Delete(qptFile); |
| | |
| | | |
| | | int idx = args.ids.IndexOf(meta.id); |
| | | string cmd = string.Format("{0}\\gocesiumtiler.exe -i \"{1}\" -o \"{2}\" -e {3} -z {4} -g -s", tilerPath, lasPath, outPath, args.srids[idx], args.zs[idx]); |
| | | err = Tools.ExecCmd(null, cmd, false, false); |
| | | err = Tools.ExecCmd(null, cmd, false); |
| | | |
| | | string jsonFile = findTileset(meta, outPath); |
| | | if ("laz" == meta.type && File.Exists(lasPath)) File.Delete(lasPath); |
| | |
| | | |
| | | int idx = args.ids.IndexOf(meta.id); |
| | | string cmd = string.Format("{0}\\3dtile.exe -f osgb -i \"{1}\" -o \"{2}\" -c \"{{\\\"offset\\\": {3}}}\"", d3tilesPath, osgbPath, outPath, args.zs[idx]); |
| | | err = Tools.ExecCmd(null, cmd, false, false); |
| | | err = Tools.ExecCmd(null, cmd, false); |
| | | err = null; |
| | | |
| | | if (null != srs) writeSRS(osgbPath, srs); |
| | |
| | | } |
| | | |
| | | string cmd = string.Format("python \"{0}\" -qgz {1} -file \"{2}\" -out \"{3}\"", PyFile, Qgz, txtFile, tifFile); |
| | | err = Tools.ExecCmd(null, cmd, true, false); |
| | | err = Tools.ExecCmd(null, cmd, true); |
| | | |
| | | return tifFile; |
| | | } |
| | |
| | | /// <param name="isPy">是否为QGIS Py脚本</param> |
| | | /// <param name="isOut">是否输出错误</param> |
| | | /// <returns>执行结果或出错信息</returns> |
| | | public static string ExecCmd(SysTask task, string cmd, bool isPy = false, bool isOut = false) |
| | | public static string ExecCmd(SysTask task, string cmd, bool isPy = false) |
| | | { |
| | | List<string> list = new List<string>(); |
| | | if (isPy) |
| | |
| | | } |
| | | list.Add(cmd); |
| | | |
| | | string str = ExecCmd(task, list, isOut); |
| | | string str = ExecCmd(task, list); |
| | | |
| | | return str; |
| | | } |
| | |
| | | /// <param name="list">命令集合</param> |
| | | /// <param name="isOut">是否输出错误</param> |
| | | /// <returns>执行结果或出错信息</returns> |
| | | public static string ExecCmd(SysTask task, List<string> list, bool isOut = false) |
| | | public static string ExecCmd(SysTask task, List<string> list) |
| | | { |
| | | string str = null; |
| | | try |
| | |
| | | p.StartInfo.RedirectStandardError = true; |
| | | p.Start(); |
| | | |
| | | //p.Id; |
| | | |
| | | StreamWriter si = p.StandardInput; // 标准输入流 |
| | | StreamReader so = isOut ? p.StandardOutput : null; // 标准输出流 |
| | | //StreamReader so = isOut ? p.StandardOutput : null; // 标准输出流 |
| | | StreamReader se = p.StandardError; // 标准错误流 |
| | | |
| | | LogOut.Info("cmd = " + string.Join(",", list)); |
| | |
| | | } |
| | | si.WriteLine("exit"); |
| | | |
| | | string info = null == so ? null : so.ReadToEnd(); |
| | | //string info = null == so ? null : so.ReadToEnd(); |
| | | str = se.ReadToEnd(); |
| | | |
| | | //if (!string.IsNullOrEmpty(info)) LogOut.Debug(info); |
| | |
| | | |
| | | string cmd = string.Format("python \"{0}\" -qgz {1} -file \"{2}\" -out \"{3}\" -min {4} -max {5} -noData {6}", PyFile, Qgz, tifFile, xyzPath, args.min, args.max, args.noData); |
| | | |
| | | //err = Tools.ExecCmd(GetCmds(batFile, cmd)); |
| | | err = Tools.ExecCmd(null, cmd, true, false); |
| | | err = Tools.ExecCmd(null, cmd, true); |
| | | |
| | | //if (File.Exists(batFile)) File.Delete(batFile); |
| | | if (File.Exists(tifFile)) File.Delete(tifFile); |
| | |
| | | } |
| | | |
| | | return ids; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取命令行 |
| | | /// </summary> |
| | | private static List<string> GetCmds(string batFile, string cmd) |
| | | { |
| | | string str = File.ReadAllText(BaseBat) + cmd; |
| | | File.WriteAllText(batFile, str); |
| | | |
| | | return new List<string>() { "\"" + batFile + "\"" }; |
| | | } |
| | | |
| | | /// <summary> |