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.
		
		
		
		
		
			
		
			
				
					
					
						
							81 lines
						
					
					
						
							3.1 KiB
						
					
					
				
			
		
		
	
	
							81 lines
						
					
					
						
							3.1 KiB
						
					
					
				using KGIS.Framework.Core.Services; | 
						|
using KGIS.Framework.Maps; | 
						|
using KGIS.Framework.Utils; | 
						|
using KGIS.Plugin.LayerProperty.Services; | 
						|
using Kingo.Core.Authorize; | 
						|
using System; | 
						|
using System.Collections.Generic; | 
						|
using System.Configuration; | 
						|
using System.Diagnostics; | 
						|
using System.Linq; | 
						|
using System.Reflection; | 
						|
using System.Runtime.InteropServices; | 
						|
using System.Text; | 
						|
using System.Threading.Tasks; | 
						|
using UIShell.OSGi; | 
						|
 | 
						|
namespace KGIS.Plugin.LayerProperty | 
						|
{ | 
						|
    public class Activator : IBundleActivator | 
						|
    { | 
						|
        ILayerPropertyService service = null; | 
						|
        public void Start(IBundleContext context) | 
						|
        { | 
						|
#if DEBUG | 
						|
            service = new LayerPropertyService(); | 
						|
            context.AddService(service); | 
						|
#else | 
						|
                ValidityVerification(context); | 
						|
#endif | 
						|
        } | 
						|
 | 
						|
        public void Stop(IBundleContext context) | 
						|
        { | 
						|
            if (service != null) | 
						|
            { | 
						|
                context.RemoveService<ILayerPropertyService>(service); | 
						|
            } | 
						|
        } | 
						|
        private void ValidityVerification(IBundleContext context) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                Attribute guid_attr = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(GuidAttribute)); | 
						|
                string guid = ((GuidAttribute)guid_attr).Value; | 
						|
                var type = ConfigurationManager.AppSettings.Get("LicenseType"); | 
						|
                if (!RunIDService2.Instance.Models.Contains(guid)) | 
						|
                { | 
						|
                    throw new Exception(string.Format("【{0}】插件未授权,加载失败", context.Bundle.Name)); | 
						|
                } | 
						|
                //if (type == "F") | 
						|
                //{ | 
						|
                //    if (!RunIDService2.Instance.Models.Contains(guid)) | 
						|
                //    { | 
						|
                //        throw new Exception(string.Format("【{0}】插件未授权,加载失败", context.Bundle.Name)); | 
						|
                //    } | 
						|
                //} | 
						|
                //else if (type == "D") | 
						|
                //{ | 
						|
                //    //AuthorizeHelper authorizeHelper = new AuthorizeHelper(AuthorizeType.单机授权, "MobileDataMake", "2x", ""); | 
						|
                //    //var state = authorizeHelper.GetAuthorizeModelInfo(); //.GetModelInfo("dlgtz2021", "2x", GetVersion(Assembly.GetExecutingAssembly().Location), TokenLibrary.VendorCode.Code);//.QuickCheckAuthorization("dlgtz2020", "1x", guid); | 
						|
                //    //if (state == null || !state.Contains(guid)) | 
						|
                //    //{ | 
						|
                //    //    throw new Exception(string.Format("【{0}】插件未授权,加载失败", context.Bundle.Name)); | 
						|
                //    //} | 
						|
                //} | 
						|
                service = new LayerPropertyService(); | 
						|
                context.AddService(service); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug(ex); | 
						|
                throw ex; | 
						|
            } | 
						|
        } | 
						|
        private string GetVersion(string fileName) | 
						|
        { | 
						|
            FileVersionInfo file1 = System.Diagnostics.FileVersionInfo.GetVersionInfo(fileName); | 
						|
            return String.Format("{0}{1}{2}", file1.ProductMajorPart, file1.ProductMinorPart, file1.ProductBuildPart); | 
						|
        } | 
						|
    } | 
						|
}
 | 
						|
 |