管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2022-11-09 6e9376fc933c8721cdf90e68ccf4457090af968d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Web;
 
namespace LFServer.cs
{
    public class ExportUtil
    {
        public static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory;
 
        private static string py;
 
        public string GetPy
        {
            get
            {
                if (py == null) py = Path.Combine(BaseDir, "Sources\\render.py");
 
                return py;
            }
        }
 
        private static string sourcesPath;
 
        public string GetSourcesPath
        {
            get
            {
                if (string.IsNullOrEmpty(sourcesPath))
                {
                    sourcesPath = Path.Combine(BaseDir, "Sources");
                }
 
                return sourcesPath;
            }
        }
 
        /// <summary>
        /// 执行Python
        /// </summary>
        /// <param name="py">Python文件</param>
        /// <param name="qgz">QGIS工程</param>
        /// <param name="qpt">QGIS模板</param>
        public static void ExecPython(string py, string qgz, string qpt)
        {
            try
            {
                string args = string.Format("{0} -qgz {1} -qpt {2}", py, qgz, qpt);
 
                Process p = new Process();
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.ErrorDialog = true;
                p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                p.StartInfo.RedirectStandardError = false;
                p.StartInfo.FileName = "python";
                p.StartInfo.Arguments = args;
                p.StartInfo.CreateNoWindow = true;
 
                p.Start();
            }
            catch
            {
            }
        }
    }
}