示例#1
0
        public static void ReadRegInfo()
        {
            MachineKey = ZPCrypto.GetMachineKey(MachineHardwareType.CPU | MachineHardwareType.HARDDISK | MachineHardwareType.MAINBOARD);

            Parameter p = BuilderFactory.DefaultBulder(getConnectString()).Load <Parameter, ParameterPK>(new ParameterPK {
                ParameterId = PIKey_Sys_Registrar
            });

            if (p.ParameterId != null)
            {
                RegInfo = JsonConvert.DeserializeObject <RegInfoToValidate>(p.ParameterValue);
            }
        }
示例#2
0
        static void PrepareAppEnvironment()
        {
            Assembly assem = Assembly.GetExecutingAssembly();

            log4net.Config.XmlConfigurator.Configure(assem.GetManifestResourceStream("SmartLife.Client.PensionAgency.SelfService.log4net.config"));
            SettingsVar.BindingPACode     = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INT_KEY_BINDING_PA_CODE, Common.INI_FILE_PATH);
            SettingsVar.BindingPAName     = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INT_KEY_BINDING_PA_NAME, Common.INI_FILE_PATH);
            SettingsVar.DataExchangePoint = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INT_KEY_DATA_EXCHANGE_POINT, Common.INI_FILE_PATH);
            SettingsVar.RunMode           = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_RUN_MODE, Common.INI_FILE_PATH);
            if (SettingsVar.RunMode == "")
            {
                SettingsVar.RunMode = "0";
                INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_RUN_MODE, SettingsVar.RunMode, Common.INI_FILE_PATH);
            }

            Common.MachineKey = ZPCrypto.GetMachineKey(MachineHardwareType.CPU | MachineHardwareType.HARDDISK | MachineHardwareType.MAINBOARD);
        }
示例#3
0
        public static void Activiate()
        {
            if (GlobalManager.RegInfo == null)
            {
                verifyInfo = new RegInfoValidated {
                    IsExpire = true, IsValid = false, ED = DateTime.Now.AddDays(-1), Msg = "没有注册主体信息", MK = MachineKey
                };
                return;
            }

            string licx2Directory = HttpContext.Current.Server.MapPath("~") + @"\..\licx2\";
            string licx2Path      = Path.Combine(licx2Directory, RegInfo.CP + '-' + RegInfo.PN + ".licx2");
            bool   licx2exist     = win.core.utils.FileAdapter.Exists(licx2Path);

            if (!licx2exist)
            {
                licx2Path  = Path.Combine(licx2Directory, "dev.licx2");
                licx2exist = win.core.utils.FileAdapter.Exists(licx2Path);
            }
            if (!licx2exist)
            {
                licx2Directory = HttpContext.Current.Server.MapPath("~") + @"\..\..\licx2\";
                licx2Path      = Path.Combine(licx2Directory, RegInfo.CP + '-' + RegInfo.PN + ".licx2");
            }
            licx2exist = win.core.utils.FileAdapter.Exists(licx2Path);
            if (!licx2exist)
            {
                licx2Path  = Path.Combine(licx2Directory, "dev.licx2");
                licx2exist = win.core.utils.FileAdapter.Exists(licx2Path);
            }
            if (!licx2exist)
            {
                verifyInfo = new RegInfoValidated {
                    IsExpire = true, IsValid = false, ED = DateTime.Now.AddDays(-1), Msg = "没有licx2文件", MK = MachineKey
                };
                return;
            }

            using (StreamReader sr = new StreamReader(licx2Path))
            {
                string cryptoedString = sr.ReadToEnd();

                VerifyStruct vs = ZPCrypto.Activiate(cryptoedString, RegInfo.CP, RegInfo.PN, (MachineHardwareType)RegInfo.MachineType, licx2Directory);

                verifyInfo = new RegInfoValidated {
                    IsExpire = vs.Expired, IsValid = vs.Valid, ED = vs.ED, Msg = "", MK = MachineKey
                };
                TimeSpan ts   = vs.ED.Subtract(DateTime.Now);
                int      days = ts.Days;
                if (days < 15)
                {
                    if (days > 0)
                    {
                        verifyInfo.Msg = string.Format("系统即将在{0}天后过期,请联系管理员延长使用效期", days.ToString());
                    }
                    else
                    {
                        verifyInfo.Msg = string.Format("系统即将在{0}小时{1}分后过期,请联系管理员延长使用效期", ts.Hours, ts.Minutes);
                    }
                }

                if (vs.Valid && verifyInfo.Msg != "")
                {
                    verifyInfo.needRemind = true;
                }
            }
        }