| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取Py初始化参数 |
| | | /// </summary> |
| | | public static string[] PyInitArgs |
| | | { |
| | | get |
| | | { |
| | | string args = GetSetting("pyInitArgs"); |
| | | |
| | | return args.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 字节格式化 |
| | | /// </summary> |
| | | public static string FormatBytes(long bytes) |
| | |
| | | List<string> list = new List<string>(); |
| | | if (isPy) |
| | | { |
| | | list.Add("cd \"C:\\Program Files\\QGIS 3.16\\apps\\Python37\""); |
| | | list.Add("\"C:\\Program Files\\QGIS 3.16\\bin\\qgis_process-qgis-ltr.bat\""); |
| | | //list.Add("cd \"C:\\Program Files\\QGIS 3.16\\apps\\Python37\""); |
| | | //list.Add("\"C:\\Program Files\\QGIS 3.16\\bin\\qgis_process-qgis-ltr.bat\""); |
| | | list.AddRange(PyInitArgs); |
| | | //list.Add("\"C:\\Program Files\\QGIS 3.16\\bin\\python-qgis-ltr.bat\""); |
| | | //list.Add("exit()"); |
| | | } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 执行命令 |
| | | /// </summary> |
| | | /// <param name="list">命令集合</param> |
| | | public static string ExecExe(string exe, string args, bool noWin = true) |
| | | { |
| | | string str = null; |
| | | Process p = null; |
| | | try |
| | | { |
| | | p = new Process(); |
| | | 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(); |
| | | p.WaitForExit(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); |
| | | str = ex.Message; |
| | | } |
| | | finally |
| | | { |
| | | if (p != null) |
| | | { |
| | | p.Close(); |
| | | } |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 创建数据发布类 |
| | | /// </summary> |
| | | public static SysPublish NewPublish(SysMeta meta, XYZArgs args, string url, string path) |