| | |
| | | /// <param name="isPy">是否为QGIS Py脚本</param> |
| | | /// <param name="isOut">是否输出错误</param> |
| | | /// <returns>执行结果或出错信息</returns> |
| | | public static string ExecCmd(SysTask task, string cmd, bool isPy = false) |
| | | public static string ExecCmd(SysTask task, string cmd, bool isPy = false, bool isOut = false) |
| | | { |
| | | List<string> list = new List<string>(); |
| | | if (isPy) |
| | |
| | | } |
| | | list.Add(cmd); |
| | | |
| | | string str = ExecCmd(task, list); |
| | | string str = ExecCmd(task, list, isOut); |
| | | |
| | | return str; |
| | | } |
| | |
| | | /// <param name="list">命令集合</param> |
| | | /// <param name="isOut">是否输出错误</param> |
| | | /// <returns>执行结果或出错信息</returns> |
| | | public static string ExecCmd(SysTask task, List<string> list) |
| | | public static string ExecCmd(SysTask task, List<string> list, bool isOut = false) |
| | | { |
| | | string str = null; |
| | | try |
| | |
| | | p.Start(); |
| | | |
| | | 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); |