|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using Kingo.PluginServiceInterface.Model;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.BuildZLDatabase
|
|
|
|
|
{
|
|
|
|
|
public class ProcesHelper
|
|
|
|
|
{
|
|
|
|
|
public static ProcesHelper Instance { get; } = new ProcesHelper();
|
|
|
|
|
private ProcesHelper() { }
|
|
|
|
|
public Action<object> ProgressHandle { get; set; }
|
|
|
|
|
public string ExeGPForProces(string arg, string exeName = "IDGForNDBG.exe")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Byte[] toEncryptArray = Encoding.UTF8.GetBytes(arg);
|
|
|
|
|
string strParm = Convert.ToBase64String(toEncryptArray);
|
|
|
|
|
|
|
|
|
|
var psi = new ProcessStartInfo(exeName, 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)
|
|
|
|
|
{
|
|
|
|
|
var line = sout.ReadLine();
|
|
|
|
|
if (String.IsNullOrEmpty(line)) continue;
|
|
|
|
|
sbuffer.AppendLine(line);
|
|
|
|
|
if (line.StartsWith("Msg:"))
|
|
|
|
|
ProgressHandle?.Invoke(line.Replace("Msg:", ""));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pes.WaitForExit();
|
|
|
|
|
pes.Close();
|
|
|
|
|
String res = sbuffer.ToString();
|
|
|
|
|
sbuffer.Clear();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
string outPath = string.Empty;
|
|
|
|
|
public string ExeGPForProces(IDGParameter gPParam)
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string strParm = SerializeAPI.SerializeToXML(gPParam);
|
|
|
|
|
result = ExeGPForProces(strParm);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result = ex.Message;
|
|
|
|
|
Console.WriteLine(result);
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public string ExeGPForProces2(IDGParameter gPParam)
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string strParm = SerializeAPI.SerializeToXML(gPParam);
|
|
|
|
|
result = ExeGPForProces(strParm, "KGIS_DLTB.exe");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result = ex.Message;
|
|
|
|
|
Console.WriteLine(result);
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|