|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using IDEParameter;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using Kingo.PluginServiceInterface.Model;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.YJJK
|
|
|
|
|
{
|
|
|
|
|
public class ProcesHelper
|
|
|
|
|
{
|
|
|
|
|
public static ProcesHelper Instance { get; } = new ProcesHelper();
|
|
|
|
|
private ProcesHelper() { }
|
|
|
|
|
public Action<object> ProgressHandle { get; set; }
|
|
|
|
|
public string ExeGPForProces(string arg)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Byte[] toEncryptArray = Encoding.UTF8.GetBytes(arg);
|
|
|
|
|
string strParm = Convert.ToBase64String(toEncryptArray);
|
|
|
|
|
|
|
|
|
|
var psi = new ProcessStartInfo("IDGForNDBG.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)
|
|
|
|
|
{
|
|
|
|
|
var line = sout.ReadLine();
|
|
|
|
|
if (String.IsNullOrEmpty(line)) continue;
|
|
|
|
|
sbuffer.AppendLine(line);
|
|
|
|
|
//if (line.StartsWith("Msg:"))
|
|
|
|
|
//{
|
|
|
|
|
// //ProgressHandle?.Invoke(line.Replace("Msg:", ""));
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
ProgressHandle?.Invoke(line);
|
|
|
|
|
LogAPI.Debug(line);
|
|
|
|
|
//}
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
}
|
|
|
|
|
pes.WaitForExit();
|
|
|
|
|
pes.Close();
|
|
|
|
|
String res = sbuffer.ToString();
|
|
|
|
|
sbuffer.Clear();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
//{
|
|
|
|
|
ProgressHandle?.Invoke(line);
|
|
|
|
|
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<IDGParameter>(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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|