Ejemplo n.º 1
0
        /// <summary>
        /// 申请码生成规则:RSA(项目名称+申请日期+结束日期+硬盘序列号/CPU序列号+随机数+整个MD5)
        /// </summary>
        /// <param name="projectName"></param>
        /// <param name="requestDate"></param>
        /// <returns></returns>
        public static string GetRequestCode(string projectName, string requestDate, string endDate)
        {
            HardwareInfo hardwareInfo = new HardwareInfo();
            string       opersystem   = hardwareInfo.OperSystemDesc;

            string macAddress = hardwareInfo.GetMACAddress();

            //string idMd5 = MyMD5Helper.GetMD532(TGljZW5zZQInfo.SYMBOL + TGljZW5zZQInfo.SEMICOLON + hardDiskID);
            StringBuilder builder = new StringBuilder();

            builder.Append(projectName).Append(TGljZW5zZQInfo.SYMBOL);
            builder.Append(requestDate).Append(TGljZW5zZQInfo.SYMBOL);
            builder.Append(endDate).Append(TGljZW5zZQInfo.SYMBOL);
            builder.Append(opersystem).Append(TGljZW5zZQInfo.COMMA).Append(macAddress).Append(TGljZW5zZQInfo.SYMBOL);
            builder.Append(new Random().NextDouble());

            builder.Append(TGljZW5zZQInfo.SYMBOL).Append(builder.ToString().Md5());

            return(EncryptionDes.Encrypt(builder.ToString()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 校验注册码
        /// </summary>
        /// <param name="projectName"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public RegisterInfo CheckLicense(string projectName)
        {
            RegisterInfo registerInfo = new RegisterInfo();

            //QUxMUFJPSkVDVA 表示“所有项目”, 如果是所有项目,则不校验
            if (this.ProjectName != "QUxMUFJPSkVDVA" && this.ProjectName != projectName)
            {
                registerInfo.RegisterState   = EnumRegisterState.UnRegister;
                registerInfo.RegisterMessage = "注册的项目名称不符合";
                return(registerInfo);
            }

            if (this.Version == VERSION_DEVELOP)
            {
                DateTime endDate = DateTime.ParseExact(this.EndDate, "yyyy-MM-dd HH:mm:ss", null);
                TimeSpan ts      = endDate.Subtract(DateTime.Now);
                registerInfo.ExpireWhenTrial         = ts.Days;
                registerInfo.ExpireDateTimeWhenTrial = this.EndDate;
                if (registerInfo.ExpireWhenTrial > 0)
                {
                    registerInfo.RegisterState   = EnumRegisterState.Develop;
                    registerInfo.RegisterMessage = "可注册为开发版,到期时间为" + this.EndDate;
                }
                else
                {
                    registerInfo.RegisterState   = EnumRegisterState.UnRegister;
                    registerInfo.RegisterMessage = "开发版已过期,请重新注册。";
                }
                registerInfo.AuthoredModules = this.ModulePerm;
                registerInfo.ProjectName     = this.ProjectName;
            }
            else
            {
                HardwareInfo hardwareInfo = new HardwareInfo();
                string       operSystem   = hardwareInfo.OperSystemDesc;

                string macAddress = hardwareInfo.GetMACAddress();

                if (this.UniqueId != operSystem + COMMA + macAddress)
                {
                    registerInfo.RegisterState   = EnumRegisterState.UnRegister;
                    registerInfo.RegisterMessage = "注册码的唯一ID不正确";
                    return(registerInfo);
                }

                if (string.Compare(this.StartDate, DateTimeUtils.CurrentDateTimeStr) > 0)
                {
                    registerInfo.RegisterState   = EnumRegisterState.UnRegister;
                    registerInfo.RegisterMessage = "注册码还未生效";
                    return(registerInfo);
                }

                if (string.Compare(this.EndDate, DateTimeUtils.CurrentDateTimeStr) < 0)
                {
                    registerInfo.RegisterState   = EnumRegisterState.UnRegister;
                    registerInfo.RegisterMessage = "注册码已失效";
                    return(registerInfo);
                }

                if (this.Version == VERSION_TRIAL) //试用版
                {
                    if (!string.IsNullOrWhiteSpace(this.EndDate))
                    {
                        registerInfo.RegisterState = EnumRegisterState.Trial;

                        DateTime endDate = DateTime.ParseExact(this.EndDate, "yyyy-MM-dd HH:mm:ss", null);
                        TimeSpan ts      = endDate.Subtract(DateTime.Now);
                        registerInfo.ExpireWhenTrial         = ts.Days;
                        registerInfo.ExpireDateTimeWhenTrial = this.EndDate;

                        registerInfo.RegisterMessage = "可注册为试用版,到期时间为" + this.EndDate;
                    }
                    else
                    {
                        registerInfo.RegisterState   = EnumRegisterState.UnRegister;
                        registerInfo.RegisterMessage = "没有到期时间";
                    }
                }
                else if (this.Version == VERSION_RELEASE) //正式版
                {
                    registerInfo.RegisterState   = EnumRegisterState.Release;
                    registerInfo.RegisterMessage = "可注册为正式版";
                }

                registerInfo.AuthoredModules = this.ModulePerm;
                registerInfo.ProjectName     = this.ProjectName;
            }
            return(registerInfo);
        }