示例#1
0
        public static ValidResult ValidRegInfo(RegInfo regInfo)
        {
            ValidResult result = new ValidResult();

            result.RegInfo = regInfo;

            //验证机器码
            List <string> list  = GetMachineCode();
            bool          bFlag = false;

            foreach (var item in list)
            {
                if (!regInfo.PcSn.ToUpper().Equals(item.ToUpper()))
                {
                    bFlag = true;
                    break;
                }
            }
            if (!bFlag)
            {
                result.Message = "非本机器注册码";
                return(result);
            }


            //验证时间
            DateTime tmCurrent = DateTime.Now;

            if (regInfo.LifeEndTime.CompareTo(tmCurrent) < 0)
            {
                result.Message = "注册码已经过期";
                return(result);
            }

            if (regInfo.LifeStartTime.CompareTo(tmCurrent) > 0)
            {
                result.Message = "注册码尚未生效";
                return(result);
            }

            result.Message = "注册码有效期为:" +
                             result.RegInfo.LifeStartTime.ToString("yyyy-MM-dd hh:mm:ss") +
                             " 至 " +
                             result.RegInfo.LifeEndTime.ToString("yyyy-MM-dd hh:mm:ss");

            result.IsValid = true;
            return(result);
        }
示例#2
0
        public static ValidResult ValidRegInfo(RegInfo regInfo)
        {
            ValidResult result = new ValidResult();

            result.RegInfo = regInfo;

            //验证机器码
            List<string> list = GetMachineCode();
            bool bFlag = false;
            foreach (var item in list)
            {
                if (!regInfo.PcSn.ToUpper().Equals(item.ToUpper()))
                {
                    bFlag = true;
                    break;
                }
            }
            if (!bFlag)
            {
                result.Message = "非本机器注册码";
                return result;
            }

            //验证时间
            DateTime tmCurrent = DateTime.Now;

            if (regInfo.LifeEndTime.CompareTo(tmCurrent) < 0)
            {
                result.Message = "注册码已经过期";
                return result;
            }

            if (regInfo.LifeStartTime.CompareTo(tmCurrent) > 0)
            {
                result.Message = "注册码尚未生效";
                return result;
            }

            result.Message = "注册码有效期为:" +
                result.RegInfo.LifeStartTime.ToString("yyyy-MM-dd hh:mm:ss") +
                " 至 " +
                result.RegInfo.LifeEndTime.ToString("yyyy-MM-dd hh:mm:ss");

            result.IsValid = true;
            return result;
        }