private void generateKeyButton_Click(object sender, EventArgs e) { if (this.machineIDTextBox.Text == string.Empty) { this.machineIDTextBox.Text = StockToolKit.GetMachineUID(); } StockLicense stockLicense = new StockLicense(this.expiryDateTimePicker.Value, this.pseudoTextBox.Text, this.machineIDTextBox.Text, this.featureTextBox.Lines.ToList(), int.Parse(this.majorVersionTextBox.Text), int.Parse(this.minorVersionTextBox.Text)); this.licenseKeyTextBox.Text = stockLicense.LicenseKey; }
private void verifyKeyButton_Click(object sender, EventArgs e) { try { StockLicense stockLicense = new StockLicense(this.expiryDateTimePicker.Value, this.pseudoTextBox.Text, this.machineIDTextBox.Text, this.featureTextBox.Lines.ToList(), int.Parse(this.majorVersionTextBox.Text), int.Parse(this.minorVersionTextBox.Text)); if (this.licenseKeyTextBox.Text == stockLicense.LicenseKey) { MessageBox.Show("Congratulations your license key is valid !!!" + System.Environment.NewLine + System.Environment.NewLine + "Expiry date:\t" + stockLicense.ExpiryDate + System.Environment.NewLine + "Version:\t\t" + stockLicense.MajorVerion + "." + stockLicense.MinorVerion + System.Environment.NewLine + "User ID:\t\t" + stockLicense.UserID + System.Environment.NewLine + "Machine ID:\t" + stockLicense.MachineID, "Success"); } else { StockLicense otherLicense = new StockLicense(this.pseudoTextBox.Text, this.licenseKeyTextBox.Text); if (otherLicense.UserID == stockLicense.UserID && otherLicense.ExpiryDate == stockLicense.ExpiryDate && otherLicense.MachineID == stockLicense.MachineID) { MessageBox.Show("Your algo is crap"); } else { MessageBox.Show("Expiry date:\t" + otherLicense.ExpiryDate + System.Environment.NewLine + "User ID: \t" + otherLicense.UserID + System.Environment.NewLine + "Machine ID:\t" + otherLicense.MachineID, "License Key Error"); } } } catch { MessageBox.Show("Exception creating the license objet"); } }
private bool CheckLicense() { return true; StockLicense stockLicense = null; // Check on local disk in license is found string licenseFileName = Settings.Default.RootFolder + @"\license.dat"; if (File.Exists(licenseFileName)) { string fileName = licenseFileName; using (StreamReader sr = new StreamReader(fileName)) { try { stockLicense = new StockLicense(Settings.Default.UserId, sr.ReadLine()); } catch { this.DeactivateGraphControls(Localisation.UltimateChartistStrings.LicenseCorrupted); return false; } if (stockLicense.UserID != Settings.Default.UserId) { this.DeactivateGraphControls(Localisation.UltimateChartistStrings.LicenseInvalidUserId); return false; } if (Settings.Default.MachineID == string.Empty) { Settings.Default.MachineID = StockToolKit.GetMachineUID(); Settings.Default.Save(); } if (stockLicense.MachineID != Settings.Default.MachineID) { this.DeactivateGraphControls(Localisation.UltimateChartistStrings.LicenseInvalidMachineId); return false; } if (stockLicense.ExpiryDate < DateTime.Today) { this.DeactivateGraphControls(Localisation.UltimateChartistStrings.LicenseExpired); return false; } if (Assembly.GetExecutingAssembly().GetName().Version.Major > stockLicense.MajorVerion) { this.DeactivateGraphControls(Localisation.UltimateChartistStrings.LicenseWrongVersion); return false; } } } else { this.DeactivateGraphControls(Localisation.UltimateChartistStrings.LicenseNoFile); } return true; }