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;
}
}
///
/// 执行Python
///
/// Python文件
/// QGIS工程
/// QGIS模板
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
{
}
}
}
}