示例#1
0
        /// <summary>
        /// 驗證序號完整性,包括1.序號格式 2.綁定PC機械碼 3.是否過期
        /// </summary>
        /// <param name="SN"></param>
        /// <param name="GoldKey">解密金鑰</param>
        /// <returns></returns>
        private ValidateResult ValidateKeyFull(string SN, string GoldKey)
        {
            KeyValidate Validator = new KeyValidate();

            Validator.secretPhase = GoldKey;
            Validator.Key         = SN;

            //先驗證序號合不合法;//
            if (Validator.IsValid == false)
            {
                return(ValidateResult.eVALIDATE_SN_INVALID);
            }

            //驗證是否為同台機械碼;//
            if (Validator.IsOnRightMachine == false)
            {
                return(ValidateResult.eVALIDATE_NOT_RIGHT_MACHINE);
            }

            //驗證是否過期;//
            if (Validator.IsExpired == true)
            {
                return(ValidateResult.eVALIDATE_EXPIRED);
            }

            return(ValidateResult.eVALIDATE_SUCCESS);
        }
示例#2
0
        /// <summary>
        /// 驗證指定序號的合法性,驗證合法性及機械碼,不驗證日期
        /// </summary>
        /// <param name="SN">要驗證的序號</param>
        /// <returns></returns>
        public bool ValidateKey(string SN)
        {
            if (SN == null ||
                SN.Length <= 0)
            {
                return(false);
            }

            KeyValidate Validator = new KeyValidate();

            Validator.secretPhase = KeyPhase.Phase + KeyGold.Gold;
            Validator.Key         = SN;

            //驗證合法性性;//
            if (Validator.IsValid == false)
            {
                return(false);
            }

            //驗證是否為相同的機械碼;//
            if (Validator.IsOnRightMachine == false)
            {
                return(false);
            }

            return(true);
        }
示例#3
0
        internal KeyValidate ValidateGenKey(string SN)
        {
            KeyValidate Validator = new KeyValidate();

            Validator.secretPhase = KeyPhase.Phase + KeyGold.Gold;
            Validator.Key         = SN;

            return(Validator);
        }
示例#4
0
        /// <summary>
        /// 回傳指定序號可試用天數
        /// </summary>
        /// <param name="SN">要驗證的序號</param>
        /// <returns>
        /// 小於0天,表示無序號
        /// 大於999天,表示為無限期使用
        /// 0~999,表示剩餘可用天數
        /// </returns>
        public int GetTrialExp(string SN)
        {
            KeyValidate Validator = new KeyValidate();

            Validator.secretPhase = KeyPhase.Phase + KeyGold.Gold;
            Validator.Key         = SN;

            if (Validator.IsValid == false)
            {
                return(0);
            }

            if (Validator.IsOnRightMachine == false)
            {
                return(0);
            }

            return(Validator.DaysLeft);
        }
示例#5
0
        /// <summary>
        /// 回傳本機儲存的序號剩餘可試用天數,
        /// </summary>
        /// <returns>
        /// 小於0天,表示無序號
        /// 大於999天,表示為無限期使用
        /// 0~999,表示剩餘可用天數
        /// </returns>
        public int GetTrialExp()
        {
            string SN = this.GetExistKey();

            //判斷有無序號,回傳-1;//
            if (SN == null)
            {
                return(-1);
            }

            KeyValidate Validator = new KeyValidate();

            Validator.secretPhase = KeyPhase.Phase + KeyGold.Gold;
            Validator.Key         = SN;

            //序號驗證錯誤,回傳0天使用期限;//
            if (Validator.IsValid == false)
            {
                return(0);
            }

            //驗證機械碼錯誤,回傳0天使用期;//
            if (Validator.IsOnRightMachine == false)
            {
                return(0);
            }

            //序號已到期,回傳0天使用期限;//
            if (Validator.IsExpired == true)
            {
                return(0);
            }

            //回傳剩餘天數;//
            return(Validator.DaysLeft);
        }