public void dontAllow(LicensingCode code, string message) { //LicensingCode enum: //RETRY, LICENSED, NOT_LICENSED, STORE_NOT_SUPPORT Debug.Log("license check failed: code: " + code + " message: " + message); Show("license check failed: code: " + code + " message: " + message); //some meaningful message }
private void MetroWindow_Loaded(object sender, RoutedEventArgs e) { if (SystemClass.CheckConnection()) { ImusCityHallEntities db = new ImusCityHallEntities(); var licenseList = from p in db.LicensingCodes select new { p.ActivatedDate, p.ExpirationDate, p.SubModule, LicenseKey = p.LicenseKey.Replace("\r\n", string.Empty), p.IsDemo }; var licenseCode = licenseList.FirstOrDefault(m => m.SubModule.Acronym == "CDS" && m.LicenseKey == App.LicenseKey && m.ActivatedDate != null); LicensingCode license = new LicensingCode(); if (licenseCode != null) { license.ActivatedDate = licenseCode.ActivatedDate; license.LicenseKey = licenseCode.LicenseKey; license.ExpirationDate = licenseCode.ExpirationDate; license.SubModule = licenseCode.SubModule; } if (licenseCode == null) { MessageBox.Show("The system is not yet activated. Please contact your administrator"); LicenseCodeWindow lc = new LicenseCodeWindow(); lc.subModuleCode = "CDS"; lc.ShowDialog(); this.Close(); } else if (licenseCode.ExpirationDate < DateTime.Now) { MessageBox.Show("This license that have been issued is expired! Please input new license"); LicenseCodeWindow lc = new LicenseCodeWindow(); lc.subModuleCode = "CDS"; lc.ShowDialog(); this.Close(); } else { if (licenseCode.IsDemo == true) { this.Title = "Check Disbursement Module (DEMO)"; } else { this.Title = "Check Disbursement Module"; } } } else { MessageBox.Show(SystemClass.DBConnectionErrorMessage); } }
private void acceptbtn_Click(object sender, RoutedEventArgs e) { if (SystemClass.CheckConnection()) { ImusCityHallEntities db = new ImusCityHallEntities(); var licenseList = from p in db.LicensingCodes select new { p.LicenseId, p.ExpirationDate, p.SubModule, LicenseKey = p.LicenseKey.Replace("\r\n", string.Empty) }; if (String.IsNullOrEmpty(licensekey.Text)) { MessageBox.Show("The license key field is empty"); return; } var licenseCode = licenseList.FirstOrDefault(m => m.LicenseKey == licensekey.Text); LicensingCode license = new LicensingCode() { LicenseId = licenseCode.LicenseId, LicenseKey = licenseCode.LicenseKey, ExpirationDate = licenseCode.ExpirationDate, SubModule = licenseCode.SubModule }; if (license != null && license.ExpirationDate > DateTime.Now.Date && license.SubModule.Acronym == subModuleCode && license.LicenseKey == App.LicenseKey) { LicensingCode dbLicense = db.LicensingCodes.Find(license.LicenseId); //license.MachineName = Environment.MachineName; //license.UserID = App.EmployeeID; dbLicense.ActivatedDate = DateTime.Now; db.SaveChanges(); MessageBox.Show("License key applied"); this.Close(); } else if (String.IsNullOrEmpty(licensekey.Text)) { MessageBox.Show("The license key field is empty"); } else if (license == null) { MessageBox.Show("Please enter a valid license key."); } else if (license.ExpirationDate < DateTime.Now) { MessageBox.Show("The license that youve entering is expired!"); } else if (licensekey.Text != App.LicenseKey) { MessageBox.Show("Please enter a valid license key."); } else if (license.SubModule.Acronym != subModuleCode && license != null) { MessageBox.Show("The license that you are applying is not meant for the specified module"); } //else if (license.LicenseKey == licensekey.Text && license.UserID == App.EmployeeID) //{ // MessageBox.Show("This license is associated with another user"); //} } else { MessageBox.Show(SystemClass.DBConnectionErrorMessage); } }