示例#1
0
        public static void AddModule(string application, bool enable, string module, SerialType sType, DateTime expiration, string serial)
        {
            SerialModule sd = new SerialModule();

            sd.Application = application;
            sd.Module      = module;
            sd.Enable      = enable.ToString();
            sd.SerialType  = sType.ToString();
            sd.Expiration  = expiration.ToShortDateString();
            sd.SerialNo    = serial;

            SerialData.Modules.Add(sd);
        }
示例#2
0
        private static bool CheckSerialType(SerialModule sm)
        {
            int pos = 1;

            string[] parts = sm.SerialNo.Split(new char[] { '-' });

            SerialType sType = (SerialType)Enum.Parse(typeof(SerialType), sm.SerialType);

            if (sType.HasFlag(SerialType.LICENSE_NAME))
            {
                if (parts[pos++] != ConvertString(SerialData.License))
                {
                    return(false);
                }
            }

            if (sType.HasFlag(SerialType.MAC_ADDRESS))
            {
                if (parts[pos++] != ConvertMacAddress(macAddres))
                {
                    return(false);
                }
            }

            if (sType.HasFlag(SerialType.EXPIRATION_DATE))
            {
                if (ConvertFromString(parts[pos++]) < (UInt64)(GlobalInfo.CurrentDate.Year * 365 + GlobalInfo.CurrentDate.Month * 31 + GlobalInfo.CurrentDate.Day))
                {
                    return(false);
                }
            }

            if (sType.HasFlag(SerialType.PEN_DRIVE))
            {
                string letter = USBSerialNumber.GetDriveLetterFromName(SerialData.PenDrive);
                if (letter == string.Empty || parts[pos++] != ConvertSerialNumber(USBSerialNumber.getSerialNumberFromDriveLetter(letter)))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#3
0
        public static bool IsActivate(string application, string module)
        {
            SerialModule sm = SerialData.Modules.Find(p => (p.Application == application && p.Module == module));

            if (sm == null || sm.Enable == bool.FalseString)
            {
                return(false);
            }

            if (!SerialFormatIsOk(sm.SerialNo, sm.Application, sm.Module))
            {
                return(false);
            }

            if (!CheckSerialType(sm))
            {
                return(false);
            }

            return(true);
        }