管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2022-11-12 3e707d56a647c29055e1e64800a9300e9c1aa091
ExportMap/cs/ExportUtil.cs
@@ -1,4 +1,5 @@
using LFServer.Models;
using ExportMap.cs;
using LFServer.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -72,13 +73,13 @@
        }
        /// <summary>
        /// 获取出图目录
        /// 获取下载目录
        /// </summary>
        public static string ExportFolder
        public static string DownloadFolder
        {
            get
            {
                return ConfigurationManager.AppSettings["exportFolder"];
                return ConfigurationManager.AppSettings["downloadFolder"];
            }
        }
@@ -98,7 +99,7 @@
        /// </summary>
        public static string GetExportSubFolder()
        {
            string root = ExportFolder;
            string root = DownloadFolder;
            if (!Directory.Exists(root))
            {
                Directory.CreateDirectory(root);
@@ -140,6 +141,7 @@
            try
            {
                string cmdText = string.Format("python {0} -qgz {1} -qpt {2}", py, qgz, qpt);
                LogOut.Info(cmdText);
                Process p = new Process();
                p.StartInfo.FileName = "cmd.exe";
@@ -160,10 +162,9 @@
                string info = so.ReadToEnd();
                str = se.ReadToEnd();
                if (p.HasExited == false)
                {
                    p.Kill();
                }
                if (!string.IsNullOrEmpty(str)) LogOut.Error(str);
                if (p.HasExited == false) p.Kill();
                si.Close();
                so.Close();
@@ -172,6 +173,7 @@
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.StackTrace);
                str = ex.Message;
            }
@@ -182,8 +184,9 @@
        /// 生成
        /// </summary>
        /// <param name="args">出图参数</param>
        /// <param name="err">错误信息</param>
        /// <returns>图片路径</returns>
        public static string Generate(ExportArgs args)
        public static string Generate(ExportArgs args, ref string err)
        {
            string date = DateStr;
            string sub = GetExportSubFolder();
@@ -194,7 +197,7 @@
            args.SetDefault();
            CreateTemplate(args);
            string info = ExecPython(PyFile, qgz, args.qpt);
            err = ExecPython(PyFile, qgz, args.qpt);
            string qptFile = Path.Combine(SourcesPath, args.qpt);
            if (File.Exists(qptFile))
@@ -202,7 +205,7 @@
                File.Delete(qptFile);
            }
            string imgPath = Path.Combine(ExportFolder, args.imgPath);
            string imgPath = Path.Combine(DownloadFolder, args.imgPath);
            bool flag = File.Exists(imgPath);
            return flag ? args.imgPath : null;
@@ -214,7 +217,7 @@
        /// <param name="args">出图参数</param>
        public static void CreateTemplate(ExportArgs args)
        {
            string imgPath = Path.Combine(ExportFolder, args.imgPath);
            string imgPath = Path.Combine(DownloadFolder, args.imgPath);
            string templateFile = Path.Combine(SourcesPath, "Template.qpt");
            string qptFile = Path.Combine(SourcesPath, args.qpt);
            if (File.Exists(qptFile))
@@ -262,7 +265,7 @@
                return rm != null && rm.code == 200 && rm.result;
            }
            catch (Exception ex)
            catch
            {
                return false;
            }