protected override LicensePublisherResponse GetLicense(CultureInfo cultureInfo, string product, Version version, LicenseKey licenseKey, string category, string userName, string company, string emailAddress, string data) { if (category == "Distributable") { AssemblyLicense license = new AssemblyLicense(); license.Product = product; license.Category = category; license.UserName = userName; license.Company = company; license.Data = data; license.Items.Add(new LicenseItem(LicenseItems.Feature1)); license.Items.Add(new LicenseItem(LicenseItems.Feature2)); license.SetUpgradeExpirationDate(new DateTime(2999, 12, 31)); return(new LicensePublisherResponse(license)); } else { MachineLicense license = new MachineLicense(); license.Product = product; license.Category = category; license.UserName = userName; license.Company = company; license.Data = data; license.Items.Add(new LicenseItem(LicenseItems.Feature1)); license.Items.Add(new LicenseItem(LicenseItems.Feature2)); if (category == "Evaluation") { license.SetExpirationDate(DateTime.UtcNow.AddMonths(3)); } license.SetUpgradeExpirationDate(new DateTime(2999, 12, 31)); return(new LicensePublisherResponse(license)); } }
private void Get_Click(object sender, RoutedEventArgs e) { string assemblyData; try { assemblyData = AssemblyLicense.GetAssemblyData(AssemblyPath); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (assemblyData == LicenseConsoleData.Singleton.AssemblyData) { MessageBox.Show(Strings.FormatDistributableLicenseForSelfComponent(assemblyData)); return; } if (LicenseMethod == LicenseMethod.WebService) { License license = GetDistributableLicense(assemblyData); if (license == null) { MessageBox.Show(Data.LastErrorMessage); } else { License = license.SignedString; } } else { EmailLicenseRequestWindow.Show(this, AssemblyPath, assemblyData); } }
internal static int GetAndSaveLicense(string assemblyPath, string outputPath, out string message) { AssemblyName callerAssembly; try { callerAssembly = AssemblyName.GetAssemblyName(assemblyPath); } catch (Exception ex) { message = ex.Message; return(1); } License license = Data.GetDistributableLicense(AssemblyLicense.GetAssemblyData(assemblyPath)); if (license == null) { message = Data.LastErrorMessage; return(2); } try { string filePath = Path.Combine(outputPath, LicenseFileName); File.WriteAllText(filePath, license.SignedString); message = Strings.FormatDistributableLicenseSaved(LicenseFileName, outputPath); } catch (Exception ex) { message = ex.Message; return(3); } return(0); }