コード例 #1
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);
        }