Example #1
0
        private void btnActivate_Click(object sender, EventArgs e)
        {
            if (tbVKey.Text == "" || tbLCode.Text == "" || tbLURL.Text == "")
            {
                MessageBox.Show("All fields need to be filled.");
                return;
            }

            // Verify license code
            CryptoLicense license = new CryptoLicense();

            license.ValidationKey     = tbVKey.Text.TrimEnd('\r', '\n');
            license.LicenseCode       = tbLCode.Text.TrimEnd('\r', '\n');
            license.LicenseServiceURL = tbLURL.Text.TrimEnd('\r', '\n');

            // The license will be loaded from/saved to the registry
            license.StorageMode          = LicenseStorageMode.ToRegistry;
            license.UseHashedMachineCode = false;

            // Validate license...
            if (license.Status != LicenseStatus.Valid)
            {
                if (license.Status == LicenseStatus.SignatureInvalid)
                {
                    MessageBox.Show("Invalid license.  Please check your entries and try again.");
                }
                else if (license.Status == LicenseStatus.ActivationFailed)
                {
                    if (license.GetCurrentActivationCount() == license.MaxActivations)
                    {
                        MessageBox.Show("License Server has reached maximum usage. Please contact your administrator.");
                    }
                    else
                    {
                        MessageBox.Show("License activation failed.  Please contact your administrator.");
                    }
                }
                else
                {
                    MessageBox.Show("Invalid license: " + license.Status.ToString());
                }
            }
            else
            {
                licCode = license.LicenseCode;

                license.Save();

                // write to RoadCare.LoginNP.txt
                UpdateInfoFile();

                DumpFloatingLicense(license);

                this.Close();
                Application.Restart();
            }
        }