private void Activation_Load(object sender, EventArgs e)
        {
            Size = new Size(Size.Width, 168);
            if (Settings.Default.ProductKey.Equals("Unlicensed"))
            {
                info = LicenseInfo.CreateUnlicensedInfo();
                lblActivationStatus.Text = "Status: No valid product key was found.";
            }
            else
            {
                info = LicenseEngine.GetLicenseInfo(Settings.Default.ProductKey);
                if (info.IsEmpty)
                {
                    lblActivationStatus.Text = "Status: No valid product key was found.";
                }
                else
                {
                    txtProductKey.Text       = Settings.Default.ProductKey.Substring(0, 15) + "******-******-...";
                    lblActivationStatus.Text = "Status: Product activated. No further action needed.";
                    Size = new Size(Size.Width, 370);
                }
            }

            infoPropGrid.SelectedObject = info;
        }
Beispiel #2
0
        private void AboutWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            Settings @default = Settings.Default;

            this.TextBlock_VersionNumber.Text = AssemblyUtilities.Version;
            if (!string.IsNullOrEmpty(@default.App_LicenseEmail) && !string.IsNullOrEmpty(@default.App_LicenseKey))
            {
                LicenseEngine licenseEngine = new LicenseEngine();
                licenseEngine.VerifyLicense(@default.App_LicenseKey, @default.App_LicenseEmail);
                this.TextBlock_LicensedTo.Text = licenseEngine.LicensedToMessage;
            }
        }
Beispiel #3
0
        public void shouldReturnInvalidLicense()
        {
            IDbSet <license> licenseDbSet = getLicenseDbSet();
            IDbSet <company> companyDbSet = getCompanyDbSet();

            IRepositoryContext repositoryContext = Substitute.For <IRepositoryContext>();

            repositoryContext.Licenses.Returns(licenseDbSet);
            repositoryContext.Companies.Returns(companyDbSet);

            string nip           = "333 22 22 222";
            var    licenseEngine = new LicenseEngine(repositoryContext);


            bool isValidLicense = licenseEngine.CheckValidityLicenseByNip(nip);


            Assert.IsFalse(isValidLicense);;
        }
        private void btnFinish_Click(object sender, EventArgs e)
        {
            if (txtProductKey.Text.Length <= 0)
            {
                CMessageBox.Show("Product Key cannot be empty!", "Error", MessageBoxButtons.OK, Resources.error_64x64);
                lblActivationStatus.Text = "Status: The product key was empty.";
                Size = new Size(Size.Width, 168);
                return;
            }

            LicenseInfo temp = LicenseEngine.GetLicenseInfo(txtProductKey.Text);

            if (!temp.IsEmpty)
            {
                if (temp.Type == utility.Licensing.LicenseType.Trial)
                {
                    if (DateTime.Now.Date >= temp.ExpirationDate.Date)
                    {
                        CMessageBox.Show($"Trial key is no longer valid for use. " +
                                         $"It expired on: {temp.ExpirationDate.Date.ToShortDateString()}. " +
                                         "You can request a new one by using the \"Purchase New Product Key\" button.", "Error", MessageBoxButtons.OK, Resources.error_64x64);
                        lblActivationStatus.Text = "Status: Invalid trial key; expired.";
                        return;
                    }
                }

                lblActivationStatus.Text    = "Status: Successful!";
                Settings.Default.ProductKey = txtProductKey.Text;
                Settings.Default.Save();
                info = temp;

                infoPropGrid.SelectedObject = info;
                Size = new Size(Size.Width, 370);
            }
            else
            {
                CMessageBox.Show("Invalid product key!", "Error", MessageBoxButtons.OK, Resources.error_64x64);
                lblActivationStatus.Text = "Status: The product key you entered was invalid.";
                Size = new Size(Size.Width, 168);
                return;
            }
        }
        public bool CheckValidityLicenseByNip(string nip)
        {
            var licenseEngine = new LicenseEngine();

            return(licenseEngine.CheckValidityLicenseByNip(nip));
        }