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.

110 lines
4.2 KiB

using KGIS.Framework.Core.Services;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Helper;
using Kingo.Core.Authorize;
using System;
using System.Configuration;
using System.Reflection;
using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Windows;
using System.Windows.Forms;
namespace WpfApp1
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
LogAPI.Debug("开始:");
try
{
ServiceController sc = new ServiceController("ArcGIS License Manager");
if (!KGIS.Framework.AE.AELicense.AoInit(true) || sc.Status == ServiceControllerStatus.Stopped)
{
MessageHelper.Show("ArcGIS授权服务未启动或已到期,请检查ArcGIS授权!");
return;
}
}
catch (Exception EX)
{
MessageHelper.Show("ArcGIS授权服务未启动或已到期,请检查ArcGIS授权!");
LogAPI.Debug(EX.Message);
return;
}
Validity(this);
if (!v)
{
this.Close();
}
InitializeComponent();
UserControl1 control1 = new UserControl1();
Mainwindow.Children.Add(control1);
}
private bool v;
private void Validity(object obj)
{
try
{
//判断授权方式
var type = ConfigurationManager.AppSettings.Get("LicenseType");
if (type == "F")//本地授权
{
Attribute guid_attr = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(GuidAttribute));
string guid = ((GuidAttribute)guid_attr).Value;
try
{
string[] licpath = System.IO.Directory.GetFiles(System.Environment.CurrentDirectory, "*.lic", System.IO.SearchOption.TopDirectoryOnly);
if (licpath.Length == 0)
{
MessageHelper.ShowError("授权校验失败!");
}
if (licpath.Length == 0 || !KGIS.Framework.Core.Services.RunIDService2.Instance.Verify(AuthorizeType., "KGIS_LLFX", "100", "3x", "", "10eaa61"))
{
KGIS.PlatformPlugin.Views.License.LicenseView lic = new KGIS.PlatformPlugin.Views.License.LicenseView(obj, "KGIS_LLFX", "100", "3x");
lic.Code = "10eaa61";
//lic.DocValidity = Validity;
DialogResult dialog = lic.ShowDialog();
if (dialog != System.Windows.Forms.DialogResult.Yes && dialog != System.Windows.Forms.DialogResult.OK)
{
v = false;
return;
}
}
else
{
v = true;
return;
}
}
catch (Exception ex)
{
MessageHelper.Show(ex.Message);
LogAPI.Debug(ex);
KGIS.PlatformPlugin.Views.License.LicenseView lic = new KGIS.PlatformPlugin.Views.License.LicenseView(obj, "KGIS_LLFX", "100", "3x");
lic.Code = "10eaa61";
DialogResult dialog = lic.ShowDialog();
if (dialog != System.Windows.Forms.DialogResult.Yes || dialog != System.Windows.Forms.DialogResult.OK)
{
v = false;
return;
}
}
}
else
{
v = false;
return;
}
v = true;
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
}
}