管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2022-12-23 80580b65be75b0ad876f8d0ca56fc7a64ba11b36
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);
@@ -160,10 +161,10 @@
                string info = so.ReadToEnd();
                str = se.ReadToEnd();
                if (p.HasExited == false)
                {
                    p.Kill();
                }
                if (!string.IsNullOrEmpty(info)) LogOut.Debug(info);
                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))
@@ -226,6 +229,7 @@
            xml = xml
                .Replace("{dpi}", args.dpi.ToString())
                .Replace("{title}", args.title)
                .Replace("{sourcesPath}", SourcesPath)
                .Replace("{rotation}", args.rotation.ToString())
                .Replace("{xmin}", args.xmin.ToString())
                .Replace("{ymin}", args.ymin.ToString())
@@ -234,9 +238,9 @@
                .Replace("{province}", args.province)
                .Replace("{scale}", args.scale)
                .Replace("{resolution}", args.resolution)
                .Replace("{date}", args.date)
                //.Replace("{date}", args.date)
                .Replace("{date}", DateTime.Now.ToString("yyyy.MM.dd"))
                .Replace("{layers}", args.layers)
                .Replace("{sourcesPath}", SourcesPath)
                .Replace("{imgPath}", imgPath);
            File.WriteAllText(qptFile, xml);
@@ -262,7 +266,7 @@
                return rm != null && rm.code == 200 && rm.result;
            }
            catch (Exception ex)
            catch
            {
                return false;
            }