管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2024-09-03 3cfb6aa02516135fb174ab1b30620f2007924663
ExportMap/cs/Tools.cs
@@ -28,6 +28,17 @@
        /// </summary>
        public static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory;
        /// <summary>
        /// 获取令牌
        /// </summary>
        public static string Token
        {
            get
            {
                return "c36e4f94-dfde-401e-9967-2c4a449f1300";
            }
        }
        private static string tempDir;
        /// <summary>
@@ -65,6 +76,19 @@
                }
                return _dbHelper;
            }
        }
        /// <summary>
        /// 获取Py初始化参数
        /// </summary>
        public static string[] PyInitArgs
        {
            get
            {
                string args = GetSetting("pyInitArgs");
                return args.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            }
        }
@@ -177,8 +201,9 @@
            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()");
            }
@@ -363,6 +388,43 @@
        }
        /// <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)