public void ProcessRegistration() { try { var Document = Licensing.LicenseKeyCodeToDocument(this.TxtKeyCode.Text); var License = Licensing.ExtractValidLicense(Document, AppExec.ApplicationVersionMajorNumber); AppExec.CurrentLicenseUserName = License.Item1; AppExec.CurrentLicenseType = AppExec.LicenseTypes.GetByTechName(License.Item2); AppExec.CurrentLicenseEdition = AppExec.LicenseEditions.GetByTechName(License.Item3); AppExec.CurrentLicenseMode = AppExec.LicenseModes.GetByTechName(License.Item4); AppExec.CurrentLicenseExpiration = License.Item5; General.StringToFile(AppExec.LicenseFilePath, this.TxtKeyCode.Text); this.TxtLicensedUser.Text = AppExec.CurrentLicenseUserName; this.TxtLicType.Text = AppExec.CurrentLicenseType.Name; this.TxtLicEdition.Text = AppExec.CurrentLicenseEdition.Name; this.TxtLicMode.Text = AppExec.CurrentLicenseMode.Name; this.TxtLicExpiration.Text = (AppExec.CurrentLicenseExpiration == General.EMPTY_DATE ? "NEVER" : AppExec.CurrentLicenseExpiration.ToShortDateString()); this.BrdLicense.Background = Brushes.Honeydew; Display.DialogMessage("Attention!", "Product License has been successfully registered!", EMessageType.Information); } catch (Exception Problem) { Display.DialogMessage("Attention!", "Cannot validate and register License.\nProblem: " + Problem.Message, EMessageType.Error); } //? Display.GetCurrentWindow().Close(); }
private void BtnValDocAndTransToKey_Click(object sender, RoutedEventArgs e) { if (!Licensing.SignedDocumentIsValid(this.TxtLicenseDocument.Text)) { Display.DialogMessage("Attention!", "License Document (XML) is not Valid.", EMessageType.Error); return; } // IMPORTANT: Document (XML) and Key Code must be equivalent always to avoid mistakes. var Info = Licensing.ExtractValidLicense(this.TxtLicenseDocument.Text, "1"); this.TxtUser.Text = Info.Item1; this.CbxType.SelectedItem = AppExec.LicenseTypes.FirstOrDefault(item => item.TechName == Info.Item2); this.CbxEdition.SelectedItem = AppExec.LicenseEditions.FirstOrDefault(item => item.TechName == Info.Item3); this.CbxMode.SelectedItem = AppExec.LicenseModes.FirstOrDefault(item => item.TechName == Info.Item4); this.TxtExpiration.Text = Info.Item5.ToString("yyyyMMdd"); this.TxtLicenseKeyCode.Text = Licensing.LicenseDocumentToKeyCode(this.TxtLicenseDocument.Text); /* * var ValBytes = this.TxtLicenseDocument.Text.StringToBytes(); * var ValCompZip = BytesHandling.Compress(ValBytes, true); * var ValCompDef = BytesHandling.Compress(ValBytes, false); * var ValBase64Zip = Convert.ToBase64String(ValCompZip); * var ValBase64Def = Convert.ToBase64String(ValCompDef); * * Display.DialogMessage("Sizes...", "Original =" + this.TxtLicenseDocument.Text.Length + * "\nBytes UTF8=" + ValBytes.Length + * "\nComp Zip=" + ValCompZip.Length + * "\nComp Def=" + ValCompDef.Length + * "\nCompB64Zip=" + ValBase64Zip.Length + * "\nCompB64Def=" + ValBase64Def.Length); */ }