public LicenseActivationService(ILicenseKeyService licenseKeyService, IPackingService packingService, ILicenseActiviationProvider licenseActiviationProvider, IClientLicenseService clientLicenseService) { _licenseKeyService = licenseKeyService; _packingService = packingService; _licenseActiviationProvider = licenseActiviationProvider; _clientLicenseService = clientLicenseService; }
public ServicesService(IServicesRepository servicesRepository, IServiceStatusProvider serviceStatusProvider, IPackingService packingService, ILicenseActiviationProvider licenseActiviationProvider, ILicenseKeyService licenseKeyService, ILicenseService licenseService, ILicenseSetService licenseSetService, IClientLicenseService clientLicenseService, IProductsProvider productsProvider) { _servicesRepository = servicesRepository; _serviceStatusProvider = serviceStatusProvider; _packingService = packingService; _licenseActiviationProvider = licenseActiviationProvider; _licenseKeyService = licenseKeyService; _licenseService = licenseService; _licenseSetService = licenseSetService; _clientLicenseService = clientLicenseService; _productsProvider = productsProvider; }
private void btnGenerateKeys_Click(object sender, System.Windows.RoutedEventArgs e) { if (IsGenerationFormValid()) { loadingAnimation.Visibility = Visibility.Visible; BackgroundWorker worker = new BackgroundWorker(); LicenseGenerationOptions licenseGenerationOptions = new LicenseGenerationOptions(); int keysToGenerate = int.Parse(txtKeysToGenerate.Text); if (cboSingleUser.IsChecked.HasValue && cboSingleUser.IsChecked.Value) { licenseGenerationOptions.LicenseKeyType = LicenseKeyTypes.SingleUser; } else if (cboMultiUser.IsChecked.HasValue && cboMultiUser.IsChecked.Value) { licenseGenerationOptions.LicenseKeyType = LicenseKeyTypes.MultiUser; } else if (cboHardwareLock.IsChecked.HasValue && cboHardwareLock.IsChecked.Value) { licenseGenerationOptions.LicenseKeyType = LicenseKeyTypes.HardwareLock; } else if (cboUnlimited.IsChecked.HasValue && cboUnlimited.IsChecked.Value) { licenseGenerationOptions.LicenseKeyType = LicenseKeyTypes.Unlimited; } else if (cboEnterprise.IsChecked.HasValue && cboEnterprise.IsChecked.Value) { licenseGenerationOptions.LicenseKeyType = LicenseKeyTypes.Enterprise; } else if (cboHardwareLockLocal.IsChecked.HasValue && cboHardwareLockLocal.IsChecked.Value) { licenseGenerationOptions.LicenseKeyType = LicenseKeyTypes.HardwareLockLocal; licenseGenerationOptions.HardwareFingerprint = txtHardwareKeyData.Text; keysToGenerate = 1; // Can only generate 1 local hardware locked key at a time. } licenseGenerationOptions.LicenseSetId = ((LicenseSet)cboLicenseSet.SelectedValue).LicenseSetId; worker.DoWork += delegate(object s, DoWorkEventArgs args) { object[] data = args.Argument as object[]; ISmallKeyGenerator smallKeygen = ObjectLocator.GetInstance <ISmallKeyGenerator>(); ILargeKeyGenerator largeKeygen = ObjectLocator.GetInstance <ILargeKeyGenerator>(); ILicenseActiviationProvider licenseActiviationProvider = ObjectLocator.GetInstance <ILicenseActiviationProvider>(); IPackingService packingService = ObjectLocator.GetInstance <IPackingService>(); IClientLicenseService clientLicenseService = ObjectLocator.GetInstance <IClientLicenseService>(); if ((string)data[2] == InstanceNames.SmallKeyGenerator) { ((LicenseGenerationOptions)data[0]).GeneratorType = KeyGeneratorTypes.StaticSmall; } else { ((LicenseGenerationOptions)data[0]).GeneratorType = KeyGeneratorTypes.StaticLarge; } LicenseKeyService service = new LicenseKeyService(smallKeygen, largeKeygen, packingService, clientLicenseService); List <string> keys = service.GenerateLicenseKeys(UIContext.License.KeyPair.PrivateKey, UIContext.License, (LicenseGenerationOptions)data[0], int.Parse(data[1].ToString())); args.Result = keys; }; worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { LicenseKeys = new BindingList <string>((List <string>)args.Result); lstLicenseKeys.ItemsSource = LicenseKeys; loadingAnimation.Visibility = Visibility.Collapsed; }; worker.RunWorkerAsync(new object[] { licenseGenerationOptions, keysToGenerate, GetGeneratorName() }); } else { MessageBox.Show("Please select a license set, license type to generate and a amount."); } }