using KGIS.Framework.Utils; using Kingo.PluginServiceInterface; using Kingo.PluginServiceInterface.Model; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Principal; using System.Text; using System.Xml.Linq; namespace KGIS_DLTB { class Program { [STAThread] static void Main(string[] args) { try { if (IsAdministrator()) { Console.WriteLine("IsAdministrator_True"); } else { Console.WriteLine("IsAdministrator_False"); } #region 授权校验及GIS授权校验 bool v = GPHelper.Instance.ValidityLic(); if (!KGIS.Framework.AE.AELicense.AoInit()) { Console.WriteLine("Err:获取GIS授权信息失效!"); return; } else if (!v) { Console.WriteLine("Err:获取工程数据配置信息失败KGISDLTB!"); return; } #endregion //args = new string[] { "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iZ2IyMzEyIj8+PElER1BhcmFtZXRlciB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4bWxuczp4c2Q9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hIj48QWxsb3dVbmlvbj50cnVlPC9BbGxvd1VuaW9uPjxBdXRvQ2FsY0dES0NTWD50cnVlPC9BdXRvQ2FsY0dES0NTWD48QXV0b1NldEdETFg+dHJ1ZTwvQXV0b1NldEdETFg+PEFsbG93UERGWj50cnVlPC9BbGxvd1BERlo+PFN0clByb2pJbmZvPkY6XOW7uuW6k+i9r+S7tuW3peeoi+ebruW9lVwwMuS7iuWlpeW3peeoi+WQiOmbhlzlvrfmg6DluIIoMjIwMTgzKVzlt6XnqIvnm67lvZVc5b635oOgNi4w54mI5pys5rWL6K+VXOW+t+aDoDYuMOeJiOacrOa1i+ivlS5LQkc8L1N0clByb2pJbmZvPjxFeGVETFRCPnRydWU8L0V4ZURMVEI+PEV4ZUdEREI+ZmFsc2U8L0V4ZUdEREI+PEV4ZUNKRENRPmZhbHNlPC9FeGVDSkRDUT48RXhlWFpRPmZhbHNlPC9FeGVYWlE+PEV4ZUNaQz5mYWxzZTwvRXhlQ1pDPjxFeGVaTEhaPmZhbHNlPC9FeGVaTEhaPjwvSURHUGFyYW1ldGVyPg==" }; if (args.Length == 1) { Exe(args[0]); } //Console.WriteLine(DateTime.Now.ToString()); //Console.WriteLine(GetTime(s_dt)); //Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("Main_fila" + ex.Message + ex.StackTrace); 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; byte[] base64ToByte = Convert.FromBase64String(pParm); string strParm = Encoding.UTF8.GetString(base64ToByte); IDGParameter gPParamClass = SerializeAPI.DeserializeToObject(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:获取工程信息失败!"); } } Dictionary _kcxsDic = new Dictionary();//《字符串-数字》字典集合 string strPath = gPParamClass.PrjInfo.ProjDir + "\\BG_GDLXConfig.xml";//获取配置文件路径 if (string.IsNullOrWhiteSpace(strPath) || !File.Exists(strPath)) strPath = SysAppPath.GetBGGDLXConfigPath(); XDocument xDoc = XDocument.Load(strPath); foreach (XElement xElement in xDoc.Descendants("Item")) { string gdlx = xElement.Attributes("GDLX").Single().Value; string gdpdjb = xElement.Attributes("GDPDJB").Single().Value; string strKcdlxs = xElement.Attributes("KCDLXS").Single().Value; decimal kcdlxs = Convert.ToDecimal(xElement.Attributes("KCDLXS").Single().Value == "" ? "0" : xElement.Attributes("KCDLXS").Single().Value); string key = string.Format("{0}-{1}", gdlx, gdpdjb); _kcxsDic.Add(key, kcdlxs); } gPParamClass.KCXSDic = _kcxsDic; if (gPParamClass.PrjInfo.ListZLXXInfo == null) gPParamClass.PrjInfo.ListZLXXInfo = new System.Collections.ObjectModel.ObservableCollection(); if (gPParamClass.ExeDLTB) { DLTB_IDGHelper helper = new DLTB_IDGHelper(); Console.WriteLine($"Msg:正在执行地类图斑数据提取"); Console.WriteLine($"Log:正在执行【{gPParamClass.PrjInfo.CodeName}_{gPParamClass.PrjInfo.ProjName}】变更成果数据提取"); helper.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; } } }