Exemplo n.º 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;
            sd.Expiration  = expiration.ToShortDateString();
            sd.SerialNo    = serial;

            SerialData.Modules.Add(sd);
        }
Exemplo n.º 2
0
        public static ActivationState 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(ActivationState.NotActivate);
            }

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

            if (!CheckSerialType(sm))
            {
                return(ActivationState.NotActivate);
            }

            return(sm.SerialType.HasFlag(SerialType.TRIAL)
                ? ActivationState.Trial
                : ActivationState.Activate);
        }
Exemplo n.º 3
0
        private static bool CheckSerialType(SerialModule sm)
        {
            int pos   = 1;
            var parts = sm.SerialNo.Split(new char[] { '-' });

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

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

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

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

            return(true);
        }