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.

106 lines
4.4 KiB

using KGIS.Framework.Utils;
using Kingo.PluginServiceInterface;
using Kingo.PluginServiceInterface.Model;
using System;
using System.IO;
using System.Security.Principal;
using System.Text;
namespace KGIS_DLTB
{
class Program
{
[STAThread]
static void Main(string[] args)
{
try
{
if (IsAdministrator())
{
Console.WriteLine("True");
}
else
{
Console.WriteLine("False");
}
if (!KGIS.Framework.AE.AELicense.AoInit())
{
return;
}
//args = new string[] { "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iZ2IyMzEyIj8+PElER1BhcmFtZXRlciB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4bWxuczp4c2Q9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hIj48QWxsb3dVbmlvbj50cnVlPC9BbGxvd1VuaW9uPjxBdXRvQ2FsY0dES0NTWD50cnVlPC9BdXRvQ2FsY0dES0NTWD48QXV0b1NldEdETFg+dHJ1ZTwvQXV0b1NldEdETFg+PEFsbG93UERGWj50cnVlPC9BbGxvd1BERlo+PFN0clByb2pJbmZvPkk6XOW3peS9nFzlt6XkvZznm67lvZVc5rWB6YeP5YiG5p6Q5rWL6K+V5pWw5o2uXFNcVGVtcFwxMzExMjNcMTMxMTIzLktCRzwvU3RyUHJvakluZm8+PEV4ZURMVEI+dHJ1ZTwvRXhlRExUQj48RXhlR0REQj5mYWxzZTwvRXhlR0REQj48RXhlQ0pEQ1E+ZmFsc2U8L0V4ZUNKRENRPjxFeGVYWlE+ZmFsc2U8L0V4ZVhaUT48RXhlQ1pDPmZhbHNlPC9FeGVDWkM+PEV4ZVpMSFo+dHJ1ZTwvRXhlWkxIWj48L0lER1BhcmFtZXRlcj4=" };
if (args.Length == 1)
{
Exe(args[0]);
}
//Console.WriteLine(DateTime.Now.ToString());
//Console.WriteLine(GetTime(s_dt));
//Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadKey();
}
}
public static bool IsAdministrator()
{
WindowsIdentity current = WindowsIdentity.GetCurrent();
WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current);
return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
}
static void Exe(string pParm)
{
try
{
DateTime s_dt = DateTime.Now;
//string strParm = args[0];
byte[] base64ToByte = Convert.FromBase64String(pParm);
string strParm = Encoding.UTF8.GetString(base64ToByte);
IDGParameter gPParamClass = SerializeAPI.DeserializeToObject<IDGParameter>(strParm);
if (gPParamClass == null)
{
return;
}
if (!string.IsNullOrWhiteSpace(gPParamClass.StrProjInfo) && File.Exists(gPParamClass.StrProjInfo))
{
gPParamClass.PrjInfo = ProjectInfo.OpenProject(gPParamClass.StrProjInfo);
if (gPParamClass.PrjInfo == null)
{
Console.WriteLine("Err:获取工程信息失败!");
}
}
if (gPParamClass.PrjInfo.ListZLXXInfo == null)
gPParamClass.PrjInfo.ListZLXXInfo = new System.Collections.ObjectModel.ObservableCollection<Kingo.PluginServiceInterface.ZLXXInfo>();
if (gPParamClass.ExeDLTB)
{
DLTB_IDGHelper helper = new DLTB_IDGHelper();
Console.WriteLine("Msg:正在执行地类图斑数据提取");
helper.Execute(gPParamClass);
}
if (gPParamClass.ExeZLHZ)
{
Console.WriteLine("Msg:正在进行增量汇总");
ZLHZHelper zlhzhelper = new ZLHZHelper();
zlhzhelper.Execute(gPParamClass);
}
Console.Clear();
Console.WriteLine("执行完成,耗时:" + GetTime(s_dt) + "秒");
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public static string GetTime(DateTime timeA)
{
//timeA 表示需要计算
DateTime timeB = DateTime.Now; //获取当前时间
TimeSpan ts = timeB - timeA; //计算时间差
string time = ts.TotalSeconds.ToString(); //将时间差转换为秒
return time;
}
}
}