年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

112 lines
3.6 KiB

using ESRI.ArcGIS.Carto;
using KGIS.Framework.AE.GPHelper;
//using IDEParameter;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KDataCheck
{
public class GPHelper
{
public static GPHelper Instance { get; } = new GPHelper();
public GPHelper() { }
public string ExeProces(string pDataPath, string pOutDbPath, string pType)
{
string result = string.Empty;
//Byte[] toEncryptArray = Encoding.UTF8.GetBytes(arg);
//string strParm = Convert.ToBase64String(toEncryptArray);
//Console.WriteLine(strParm);
var psi = new ProcessStartInfo("GPHelper.exe", $"{pDataPath} {pOutDbPath} {pType}");
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
var pes = Process.Start(psi);
var sbuffer = new StringBuilder();
var sout = pes.StandardOutput;
while (!sout.EndOfStream)
{
result = sout.ReadLine();
if (String.IsNullOrEmpty(result)) continue;
sbuffer.AppendLine(result);
}
pes.WaitForExit();
pes.Close();
String res = sbuffer.ToString();
sbuffer.Clear();
//Console.WriteLine(res);
return result;
}
public void ExeGPForProces(string pDataPath, string pOutDbPath, string pProcesType = "")
{
string outPath = string.Empty;
try
{
outPath = ExeProces(pDataPath, pOutDbPath, pProcesType);
}
catch (Exception ex)
{
Console.WriteLine(outPath);
Console.WriteLine(ex.Message);
}
}
public string ExeProces(string pDataPath, string pType)
{
string result = string.Empty;
Byte[] toEncryptArray = Encoding.UTF8.GetBytes(pDataPath);
string strParm = Convert.ToBase64String(toEncryptArray);
//Console.WriteLine(strParm);
var psi = new ProcessStartInfo("GPHelper.exe", strParm);
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
var pes = Process.Start(psi);
var sbuffer = new StringBuilder();
var sout = pes.StandardOutput;
while (!sout.EndOfStream)
{
result = sout.ReadLine();
//if (result == "Close")
//{
// pes.Close();
// return result;
//}
if (String.IsNullOrEmpty(result)) continue;
sbuffer.AppendLine(result);
}
pes.WaitForExit();
pes.Close();
String res = sbuffer.ToString();
sbuffer.Clear();
//Console.WriteLine(res);
return result;
}
public void ExeGPForProces(string pDataPath, string pProcesType = "")
{
string outPath = string.Empty;
try
{
outPath = ExeProces(pDataPath, pProcesType);
}
catch (Exception ex)
{
Console.WriteLine(outPath);
Console.WriteLine(ex.Message);
}
}
}
}