Esempio n. 1
0
        /// <summary>
        /// Проверить поля ProductKey и ComponyName в USB ключе и реестре
        /// </summary>
        public static void CheckLicenseInformation()
        {
            timer.Enabled   = false;
            _isUsbKeyFound  = false;
            _isLicenseFound = false;
            var windowsRegistryLicenseInformation = WindowsRegistryDataManager.GetRegistryInformation();

            if (windowsRegistryLicenseInformation == null)
            {
                CASMessage.Show(MessageType.LicenseInformationNotEqual);
                Environment.Exit(Environment.ExitCode);
            }

            _isLicenseFound = true;


            if (DateTime.Now.Date > windowsRegistryLicenseInformation.Expires.Date)
            {
                CASMessage.Show(MessageType.LicenseExpired);
                Environment.Exit(Environment.ExitCode);
            }

            if (DateTime.Now.Date < windowsRegistryLicenseInformation.Expires.Date &&
                (windowsRegistryLicenseInformation.Expires.Date - DateTime.Now.Date).TotalDays > 180)
            {
                CASMessage.Show(MessageType.LicenseViolation);
                Environment.Exit(Environment.ExitCode);
            }

            form.Text = new GlobalTermsProvider()["SystemName"] + ". Evaluation copy. Valid till " +
                        windowsRegistryLicenseInformation.Expires.ToString(
                new GlobalTermsProvider()["DateFormat"].ToString());

            timer.Enabled = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Проверить поля ProductKey и ComponyName в USB ключе и реестре
        /// </summary>
        public static void CheckLicenseInformation()
        {
            timer.Enabled  = false;
            isUSBKeyFound  = false;
            isLicenseFound = false;
            LicenseInformation windowsRegistryLicenseInformation =
                WindowsRegistryDataManager.GetRegistryInformation();

            if (windowsRegistryLicenseInformation == null)
            {
                CASMessage.Show(MessageType.LicenseInformationNotEqual);
                Environment.Exit(Environment.ExitCode);
            }
            LicenseInformation usbLicenseInformation = USBKeyDataManager.GetUSBKeyData();

            if (usbLicenseInformation == null)
            {
                isLicenseFound = true;


                if (DateTime.Now.Date > windowsRegistryLicenseInformation.Expires.Date)
                {
                    CASMessage.Show(MessageType.LicenseExpired);
                    Environment.Exit(Environment.ExitCode);
                    return;
                }

                if (DateTime.Now.Date < windowsRegistryLicenseInformation.Expires.Date && (windowsRegistryLicenseInformation.Expires.Date - DateTime.Now.Date).TotalDays > 45)
                {
                    CASMessage.Show(MessageType.LicenseViolation);
                    Environment.Exit(Environment.ExitCode);
                    return;
                }

                form.Text = new TermsProvider()["SystemName"] + ". Evaluation copy. Valid till " +
                            windowsRegistryLicenseInformation.Expires.ToString(
                    new TermsProvider()["DateFormat"].ToString());
            }
            else
            {
                if (usbLicenseInformation.Company != windowsRegistryLicenseInformation.Company)
                {
                    form.Enabled = false;
                    if (messageForm != null)
                    {
                        messageForm.Close();
                    }
                    messageForm = new MessageForm();

                    messageForm.MessageText =
                        string.Format(new MessageInfoProvider()[MessageType.USBKeyNotValid.ToString()].ToString(),
                                      windowsRegistryLicenseInformation.Company);
                    messageForm.Text = MessageType.USBKeyNotValid.ToString();
                    messageForm.ShowDialog();
                    form.Enabled = true;
                    if (messageForm.IsRetryButtonPushed)
                    {
                        CheckLicenseInformation();
                        return;
                    }
                    ConnectionManager.Disconnect();
                    Environment.Exit(Environment.ExitCode);
                }
                isUSBKeyFound = true;

                if (messageForm != null)
                {
                    messageForm.Close();
                }
                form.Text = new TermsProvider()["SystemName"] + ". Licensed to " +
                            windowsRegistryLicenseInformation.Company;
            }
            timer.Enabled = true;
        }