Exemplo n.º 1
0
        public bool InstallNewLicense()
        {
            OpenFileDialog dlg      = new System.Windows.Forms.OpenFileDialog();
            string         fileName = FindLicenseFile();

            dlg.InitialDirectory = new FileInfo(fileName).DirectoryName;
            dlg.FileName         = fileName;
            dlg.Filter           = "License (" + _LicenseFileName + ")|" + _LicenseFileName +
                                   "|All files (*.*)|*.*";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string[] tmp = File.ReadAllLines(dlg.FileName);
                    File.WriteAllLines(LicenseName, tmp);
                    //File.Copy(dlg.FileName, LicenseName, true); // save unmodifyed file
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Can't install new license: " + ex.Message);
                }

                if (LoadLicense())
                {
                    //todo: check activations here
                    currentLicense.SetValue("CPU ID", VWACommon.GetCPUID());
                    //LicenseCipher.SetValue("CPU ID", VWACommon.GetCPUID());
                    currentLicense.SaveLicense(LicenseName);
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        public bool CheckLicense()
        {
            string cpu = VWACommon.GetCPUID();

            if (!LicenseManager.IsInited())
            {
                LoadLicense();
            }
            //if (LicenseCipher.IsActivated())
            //{
            string license_cpu = currentLicense.GetValue("CPU ID");

            if (!license_cpu.Equals(cpu) || license_cpu.Trim().Equals(""))
            {
                if (MessageBox.Show("This License was already activated for another CPU.\n Do you want to load another licence?",
                                    "Wrong CPU", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    return(InstallNewLicense());
                }
                return(false);
            }
            return(true);

            //}

            frmEnterActivationCode frm = new frmEnterActivationCode();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                string code = LicenseManager.GenerateActivationCode(cpu, currentLicense.GetValue("License Serial Number"), currentLicense.GetValue("Expiration Date"));
                if (code.Equals(frm.ActivationCode))
                {
                    currentLicense.SetValue("Is Activated", true.ToString());
                    currentLicense.SetValue("Activation Code", code);
                    currentLicense.SetValue("CPU ID", cpu);
                    currentLicense.SaveLicense(LicenseName);
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
 public frmEnterActivationCode()
 {
     InitializeComponent();
     lblCPUID.Text = VWACommon.GetCPUID();
 }