private void UpdateStatus(ProjectLicenseGroup licenseGroup) { LicenseState licenseState = LicensingHelper.ProjectTypeLicense(licenseGroup, this.services); this.currentState = this.targetState; this.targetState = licenseState; this.licensingAllowsNewProject = !licenseState.IsExpired; if (this.currentState != null || this.targetState != null) { this.LicenseStatusText.Text = this.GenerateLicenseBarText(licenseState, licenseGroup); } bool flag = (this.currentState == null ? false : !this.currentState.FullyLicensed); if (flag != (this.targetState == null ? false : !this.targetState.FullyLicensed)) { if (!flag) { this.LicenseStatusBarBorder.Visibility = Visibility.Visible; } else { this.LicenseStatusBarBorder.Visibility = Visibility.Collapsed; } } this.OnPropertyChanged("CanCreateNewProject"); this.OnPropertyChanged("DialogPadding"); this.OnPropertyChanged("LicenseButtonText"); this.OnPropertyChanged("LicenseButtonCommand"); }
protected IEnumerable <INamedProject> CreateNewProject() { IEnumerable <INamedProject> namedProjects; LicensingHelper.SuppressDialogForSession(); using (IDisposable disposable = TemporaryCursor.SetWaitCursor()) { List <TemplateArgument> templateArguments = new List <TemplateArgument>(); if (this.targetFrameworkVersion != null) { templateArguments.Add(new TemplateArgument("targetframeworkversion", this.targetFrameworkVersion.Value)); templateArguments.Add(new TemplateArgument("clientprofile", "True")); } IEnumerable <INamedProject> namedProjects1 = this.ProjectManager().CreateProjectTemplate(this.projectFolder, this.projectName, this.projectTemplate, templateArguments); if (this.targetFrameworkVersion != null) { this.configurationObject.SetProperty(BaseNewProjectCommand.LastProjectTargetFrameworkCreated, this.targetFrameworkVersion.Value); } if (this.projectTemplate != null) { this.configurationObject.SetProperty(BaseNewProjectCommand.LastProjectTemplateCreated, this.projectTemplate.Identifier); } this.configurationObject.SetProperty(BaseNewProjectCommand.LastProjectLanguageCreated, this.projectFilter); namedProjects = namedProjects1; } return(namedProjects); }
private void ProjectTemplateListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { IProjectTemplate item; if (this.ProjectTemplate == null) { ICollectionView view = ((CollectionViewSource)this.OuterPanel.Resources["ProjectTemplateViewSource"]).View; if (view != null && !view.IsEmpty && view.CurrentItem == null) { view.MoveCurrentToFirst(); return; } } if (this.ProjectTemplate != null) { if (e == null || e.RemovedItems.Count <= 0) { item = null; } else { item = e.RemovedItems[0] as IProjectTemplate; } IProjectTemplate projectTemplate = item; if (projectTemplate == null || this.ProjectName.StartsWith(projectTemplate.DefaultName, StringComparison.CurrentCulture)) { if (!PathHelper.IsValidPath(this.ProjectPath)) { this.ProjectName = this.ProjectTemplate.DefaultName; } else { string defaultName = this.ProjectTemplate.DefaultName; string str = null; string projectPath = this.ProjectPath; this.ProjectName = PathHelper.GetAvailableFileOrDirectoryName(defaultName, str, projectPath, true); } this.Description = this.ProjectTemplate.Description; } } if (this.ProjectTemplate != null) { this.UpdateStatus(LicensingHelper.GetLicenseGroup(this.ProjectTemplate)); } this.OnPropertyChanged("CanCreateNewProject"); if (this.ProjectTemplate != null) { this.TargetFrameworkVersion = this.targetFrameworkTracker.GetValidSelectedItem(this.ProjectTemplate.ValidPropertyValues("TargetFrameworkVersion"), this.ProjectTemplate.PreferredPropertyValue("TargetFrameworkVersion")); } this.UpdateLanguageList(); }
protected override void Run() { SafeToExit = false; if (Connection.IsConnected) { if (!File.Exists(Filepath)) { throw new Exception(Messages.LICENSE_FILE_DOES_NOT_EXIST); } if (new FileInfo(Filepath).Length > 1048576) { throw new Exception(Messages.LICENSE_FILE_TOO_LARGE); } string encodedContent = Convert.ToBase64String(File.ReadAllBytes(Filepath)); // PR-1102: catch the host's license data, before applying the new one, so it can be sent later to the licensing server LicensingHelper.LicenseDataStruct previousLicenseData = new LicensingHelper.LicenseDataStruct(this.Host); this.Description = string.Format(Messages.APPLYLICENSE_APPLYING, Filepath); log.DebugFormat("Applying license to server {0}", this.Host.Name); RelatedTask = XenAPI.Host.async_license_apply(this.Session, this.Host.opaque_ref, encodedContent); PollToCompletion(); this.Description = Messages.APPLYLICENSE_APPLIED; // PR-1102: send licensing data to the activation server Dictionary <Host, LicensingHelper.LicenseDataStruct> hosts = new Dictionary <Host, LicensingHelper.LicenseDataStruct>(); hosts.Add(this.Host, previousLicenseData); if (ActivateFreeLicense) { LicensingHelper.SendActivationData(hosts); } else { LicensingHelper.SendLicenseEditionData(hosts, ""); } } }
public static void Run(payload geto365userlicense, TraceWriter log) { log.Info($"C# HTTP trigger function processed a request. Command used={geto365userlicense.Command}"); double graphApiVersion = double.Parse(GenericHelper.GetEnvironmentVariable("graphApiVersion")); string clientId = GenericHelper.GetEnvironmentVariable("clientId"); string clientSecret = GenericHelper.GetEnvironmentVariable("clientSecret"); string tenantId = GenericHelper.GetEnvironmentVariable("tenantId"); string allowedChannelName = GenericHelper.GetEnvironmentVariable("allowedChannelName"); // assign the Slack payload "text" to be the UPN of the user that needs the license string username = geto365userlicense.Text; string encUserName = Uri.UnescapeDataString(username); log.Info(encUserName); // assign the Slack payload "channel_name" to the allowed channel name for this code to be called from string channelName = geto365userlicense.Channel_Name; if (channelName == allowedChannelName) { // acquire Bearer Token for AD Application user through Graph API string token = AuthenticationHelperRest.AcquireTokenBySpn(tenantId, clientId, clientSecret); string bearerToken = "Bearer " + token; string skuPartNumber = LicensingHelper.GetUserLicenseInfo(graphApiVersion, encUserName, bearerToken, log); var uri = Uri.UnescapeDataString(geto365userlicense.Response_Url); log.Info("in_channel response"); var jsonPayload = new { response_type = "in_channel", text = $"{encUserName} is licensed with the {skuPartNumber} license." }; GenericHelper.SendMessageToSlack(uri, jsonPayload); } }
public CreateProjectDialog(IEnumerable <IProjectTemplate> creatableProjectTemplates, ITemplateManager templateManager, string title, string defaultProjectPath, bool willCreateNewSolution, IServiceProvider services) { this.InitializeComponent(); this.services = services; base.Style = (Style)base.Resources["CreateProjectDialogStyle"]; this.TemplateManager = templateManager; this.defaultProjectPath = defaultProjectPath; this.projectPath = defaultProjectPath; this.creatableProjectTemplates = creatableProjectTemplates; base.Activated += new EventHandler(this.OnCreateProjectDialogActivated); this.willCreateNewSolution = willCreateNewSolution; this.pathValidator = new MessageBubbleValidator <string, TextChangedEventArgs>(() => this.PathTextBox.Text, new Func <string, string>(ProjectPathHelper.ValidatePath)); this.projectPathMessageBubble = new MessageBubbleHelper(this.PathTextBox, this.pathValidator); this.PathTextBox.TextChanged += new TextChangedEventHandler(this.pathValidator.EventHook); this.nameValidator = new MessageBubbleValidator <string, TextChangedEventArgs>(() => this.NameTextBox.Text, new Func <string, string>(ProjectPathHelper.ValidateProjectFileName)); this.projectNameMessageBubble = new MessageBubbleHelper(this.NameTextBox, this.nameValidator); this.NameTextBox.TextChanged += new TextChangedEventHandler(this.nameValidator.EventHook); this.solutionValidator = new MessageBubbleValidator <string, TextChangedEventArgs>(() => this.SolutionPathFileName, new Func <string, string>(ProjectPathHelper.ValidateNewSolutionPathFileName)); this.solutionMessageBubble = new MessageBubbleHelper(this.NameTextBox, this.solutionValidator); this.NameTextBox.TextChanged += new TextChangedEventHandler(this.solutionValidator.EventHook); base.Title = title; base.SizeToContent = SizeToContent.Height; base.Width = 550; base.DataContext = this; this.projectTemplateCategoryTreeRoot = new ProjectTemplateCategoryTreeItem(string.Empty, creatableProjectTemplates, this) { IsExpanded = true }; this.projectTemplateCategoryFlattener = new VirtualizingTreeItemFlattener <ProjectTemplateCategoryTreeItem>(this); this.projectTemplateCategorySelection = this.projectTemplateCategoryTreeRoot; this.IsCategoryTreeVisible = false; this.projectTemplateCategoryTreeRoot.IsSelected = true; this.UpdateLanguageList(); this.OnPropertyChanged("LicenseButtonCommand"); this.OnPropertyChanged("LicenseButtonText"); this.LicenseStatusBarBorder.Visibility = (this.ProjectTemplate == null || LicensingHelper.ProjectLicense(this.ProjectTemplate, this.services).FullyLicensed ? Visibility.Collapsed : Visibility.Visible); }
protected override void Run() { // PR-1102: hosts that have been updated, plus the previous edition information - this data will be sent to the licensing server Dictionary <Host, LicensingHelper.LicenseDataStruct> updatedHosts = new Dictionary <Host, LicensingHelper.LicenseDataStruct>(); this.Description = Messages.LICENSE_UPDATING_LICENSES; foreach (IXenObject xo in xos) { Connection = xo.Connection; if (!Connection.IsConnected) { continue; } Host host = null; Pool pool = null; if (xo is Host) { host = xo as Host; } if (xo is Pool) { pool = xo as Pool; host = xo.Connection.Resolve(pool.master); } string previousLicenseServerAddress = null; string previousLicenseServerPort = null; CollectionChangeEventHandler alertsChangeHandler = null; string alertText = null; object lck = new object(); if (host != null && host.license_server.ContainsKey("address")) { previousLicenseServerAddress = host.license_server["address"]; } if (host != null && host.license_server.ContainsKey("port")) { previousLicenseServerPort = host.license_server["port"]; } try { if (pool != null) { pool.Connection.Cache.Hosts.ToList().ForEach(h => SetLicenseServer(h, _licenseServerAddress, _licenseServerPort)); } else { SetLicenseServer(host, _licenseServerAddress, _licenseServerPort); } IXenObject xoClosure = xo; alertsChangeHandler = delegate(object sender, CollectionChangeEventArgs e) { if (e.Action == CollectionChangeAction.Add) { lock (lck) { Alert alert = (Alert)e.Element; Message.MessageType messageType; // if this is a message alert, its Name property will contain the MessageType if (host != null && host.uuid == alert.HostUuid && Enum.TryParse(alert.Name, out messageType)) { switch (messageType) { case Message.MessageType.LICENSE_NOT_AVAILABLE: case Message.MessageType.LICENSE_SERVER_UNREACHABLE: case Message.MessageType.LICENSE_SERVER_VERSION_OBSOLETE: alertText = string.Format(Message.FriendlyBody(alert.Name), xoClosure.Name()); break; case Message.MessageType.GRACE_LICENSE: alertText = string.Empty; break; } } } } }; Alert.RegisterAlertCollectionChanged(alertsChangeHandler); // PR-1102: catch the host's license data, before applying the new one, so it can be sent later to the licensing server LicensingHelper.LicenseDataStruct previousLicenseData = new LicensingHelper.LicenseDataStruct(host); if (xo is Host && host != null) { Host.apply_edition(host.Connection.Session, host.opaque_ref, Host.GetEditionText(_edition), false); // PR-1102: populate the list of updated hosts updatedHosts.Add(host, previousLicenseData); } if (xo is Pool) { Pool.apply_edition(xo.Connection.Session, pool.opaque_ref, Host.GetEditionText(_edition)); xo.Connection.Cache.Hosts.ToList().ForEach(h => updatedHosts.Add(h, previousLicenseData)); } Description = Messages.APPLYLICENSE_UPDATED; } catch (Failure e) { for (int i = 0; i < 50; i++) { Thread.Sleep(100); lock (lck) { if (alertText != null) { break; } } } LicenseFailures.Add(new LicenseFailure(host, alertText ?? e.Message)); if (pool != null) { pool.Connection.Cache.Hosts.ToList().ForEach(h => SetLicenseServer(h, previousLicenseServerAddress, previousLicenseServerPort)); } else { SetLicenseServer(host, previousLicenseServerAddress, previousLicenseServerPort); } } finally { Alert.DeregisterAlertCollectionChanged(alertsChangeHandler); } } // PR-1102: Send licensing data to the activation server if (updatedHosts.Count > 0) { LicensingHelper.SendLicenseEditionData(updatedHosts, Host.GetEditionText(_edition)); } if (LicenseFailures.Count > 0) { string exceptionText = LicenseFailures.Count == 1 ? string.Format(Messages.LICENSE_ERROR_1, LicenseFailures[0].Host.Name()) : string.Format(Messages.LICENSE_ERROR_MANY, LicenseFailures.Count, new List <IXenObject>(xos).Count); if (DoOnLicensingFailure != null) { DoOnLicensingFailure(LicenseFailures, exceptionText); } throw new InvalidOperationException(exceptionText); } }
public override ConversionType GetVersion(ConversionTarget project) { ConversionType conversionType; this.silverlightSolution = false; this.sketchFlowSolution = false; this.frameworkSolution = false; if (!project.IsSolution) { return(ConversionType.Unknown); } using (IEnumerator <IProjectStore> enumerator = this.contextProjectStores.GetEnumerator()) { do { if (!enumerator.MoveNext()) { break; } IProjectStore current = enumerator.Current; FrameworkName targetFrameworkName = ProjectStoreHelper.GetTargetFrameworkName(current); if (targetFrameworkName == null) { continue; } if (!this.frameworkSolution && targetFrameworkName.Identifier == ".NETFramework") { this.frameworkSolution = true; } if (!this.silverlightSolution && targetFrameworkName.Identifier == "Silverlight") { this.silverlightSolution = true; } if (this.sketchFlowSolution || !ProjectStoreHelper.IsSketchFlowProject(current)) { continue; } this.sketchFlowSolution = true; }while (!this.silverlightSolution || !this.sketchFlowSolution || !this.frameworkSolution); } if (!this.silverlightSolution && !this.frameworkSolution) { return(ConversionType.Unknown); } ILicenseService service = base.Services.GetService <ILicenseService>(); if (this.sketchFlowSolution && service != null && !LicensingHelper.IsSketchFlowLicensed(service)) { return(ConversionType.Unknown); } using (IEnumerator <ConversionTarget> enumerator1 = this.GetConversionTargets().GetEnumerator()) { while (enumerator1.MoveNext()) { ConversionTarget conversionTarget = enumerator1.Current; if (!ConversionHelper.CheckAndAddFile(conversionTarget, this.Converters, this.VersionMapping, true).Any <UpgradeAction>()) { continue; } conversionType = ConversionType.SolutionBlendV3; return(conversionType); } return(ConversionType.SolutionBlendV4); } return(conversionType); }
public static void Run(payload deallocatee3o365, TraceWriter log) { log.Info($"C# HTTP trigger function processed a request. Command used={deallocatee3o365.Command}"); double graphApiVersion = double.Parse(GenericHelper.GetEnvironmentVariable("graphApiVersion")); string clientId = GenericHelper.GetEnvironmentVariable("clientId"); string clientSecret = GenericHelper.GetEnvironmentVariable("clientSecret"); string tenantId = GenericHelper.GetEnvironmentVariable("tenantId"); string allowedChannelName = GenericHelper.GetEnvironmentVariable("allowedChannelName"); // assign the Slack payload "text" to be the UPN of the user that needs the license string username = deallocatee3o365.Text; log.Info(username); // assign the Slack payload "channel_name" to the allowed channel name for this code to be called from string channelName = deallocatee3o365.Channel_Name; if (channelName == allowedChannelName && deallocatee3o365.User_Name == "david") { // acquire Bearer Token for AD Application user through Graph API string token = AuthenticationHelperRest.AcquireTokenBySpn(tenantId, clientId, clientSecret); string bearerToken = "Bearer " + token; log.Info("Getting License SKUs..."); // get information about all the O365 SKUs available JArray skus = LicensingHelper.GetO365Skus(graphApiVersion, bearerToken); JObject e1SkuObject = SubscriptionHelper.FilterSkusByPartNumber(skus, "STANDARDPACK"); JObject e3SkuObject = SubscriptionHelper.FilterSkusByPartNumber(skus, "ENTERPRISEPACK"); string e1SkuId = (string)e1SkuObject["skuId"]; string e3SkuId = (string)e3SkuObject["skuId"]; int usedLicenses = e1SkuObject.GetValue("consumedUnits").Value <int>(); int purchasedLicenses = e1SkuObject.SelectToken(@"prepaidUnits.enabled").Value <int>(); // check if enough licenses available if (usedLicenses < purchasedLicenses) { // enough licenses, so do it log.Info("Setting License..."); string returnedUserName = LicensingHelper.SetO365LicensingInfo(graphApiVersion, bearerToken, username, e1SkuId, e3SkuId); var uri = Uri.UnescapeDataString(deallocatee3o365.Response_Url); var jsonPayload = new { response_type = "in_channel", text = $"There are {purchasedLicenses} available E1 licenses and {usedLicenses} already used. You have just used one more." + $"Successfully assigned *E1* license to {returnedUserName}" }; GenericHelper.SendMessageToSlack(uri, jsonPayload); } else { // not enough licenses, notify user log.Info( $"There are {purchasedLicenses} available E1 licenses and {usedLicenses} already used. No licenses available for E1. Please log on to portal.office.com and buy new licenses."); var uri = Uri.UnescapeDataString(deallocatee3o365.Response_Url); var jsonPayload = new { response_type = "in_channel", text = $"There are {purchasedLicenses} available E1 licenses and {usedLicenses} already used. No licenses available for E1. Please log on to portal.office.com and buy new licenses." }; GenericHelper.SendMessageToSlack(uri, jsonPayload); } } }
public static void Run(payload allocatevisio, TraceWriter log) { log.Info($"C# Queue trigger function processed: {allocatevisio.User_Name}"); double graphApiVersion = double.Parse(GenericHelper.GetEnvironmentVariable("graphApiVersion")); string clientId = GenericHelper.GetEnvironmentVariable("clientId"); string clientSecret = GenericHelper.GetEnvironmentVariable("clientSecret"); string tenantId = GenericHelper.GetEnvironmentVariable("tenantId"); // assign the Slack payload "text" to be the UPN of the user that needs the license string username = allocatevisio.Text; log.Info(username); // acquire Bearer Token for AD Application user through Graph API string token = AuthenticationHelperRest.AcquireTokenBySpn(tenantId, clientId, clientSecret); string bearerToken = "Bearer " + token; log.Info("Getting License SKUs..."); // get information about all the O365 SKUs available JArray skus = LicensingHelper.GetO365Skus(graphApiVersion, bearerToken); JObject visioSkuObject = SubscriptionHelper.FilterSkusByPartNumber(skus, "VISIOCLIENT"); string visioSkuId = (string)visioSkuObject["skuId"]; int usedLicenses = visioSkuObject.GetValue("consumedUnits").Value <int>(); int purchasedLicenses = visioSkuObject.SelectToken(@"prepaidUnits.enabled").Value <int>(); // check if enough licenses available if (usedLicenses < purchasedLicenses) { // enough licenses, so do it log.Info("Setting License..."); string returnedUserName = LicensingHelper.SetO365LicensingInfo(graphApiVersion, bearerToken, username, visioSkuId, ""); var uri = Uri.UnescapeDataString(allocatevisio.Response_Url); var jsonPayload = new { response_type = "in_channel", text = $"There are {purchasedLicenses} available VISIO licenses and {usedLicenses} already used. You have just used one more. Successfully assigned *VISIO* license to {returnedUserName}" }; GenericHelper.SendMessageToSlack(uri, jsonPayload); } else { // not enough licenses, notify user log.Info( $"There are {purchasedLicenses} available VISIO licenses and {usedLicenses} already used. No licenses available for VISIO. Please log on to portal.office.com and buy new licenses."); var uri = Uri.UnescapeDataString(allocatevisio.Response_Url); log.Info(uri); var jsonPayload = new { response_type = "in_channel", text = $"There are {purchasedLicenses} available VISIO licenses and {usedLicenses} already used. No licenses available for VISIO. Please log on to portal.office.com and buy new licenses." }; GenericHelper.SendMessageToSlack(uri, jsonPayload); } }
protected override void Run() { List <LicenseFailure> licenseFailures = new List <LicenseFailure>(); // PR-1102: hosts that have been updated, plus the previous edition information - this data will be sent to the licensing server Dictionary <Host, LicensingHelper.LicenseDataStruct> updatedHosts = new Dictionary <Host, LicensingHelper.LicenseDataStruct>(); this.Description = Messages.LICENSE_UPDATING_LICENSES; foreach (IXenObject xo in xos) { Connection = xo.Connection; if (!Connection.IsConnected) { continue; } Host host = null; Pool pool = null; if (xo is Host) { host = xo as Host; } if (xo is Pool) { pool = xo as Pool; host = xo.Connection.Resolve(pool.master); } string previousLicenseServerAddress = null; string previousLicenseServerPort = null; CollectionChangeEventHandler alertsChangeHandler = null; string alertText = null; object lck = new object(); if (host != null && host.license_server.ContainsKey("address")) { previousLicenseServerAddress = host.license_server["address"]; } if (host != null && host.license_server.ContainsKey("port")) { previousLicenseServerPort = host.license_server["port"]; } try { if (pool != null) { pool.Connection.Cache.Hosts.ToList().ForEach(h => SetLicenseServer(h, _licenseServerAddress, _licenseServerPort)); } else { SetLicenseServer(host, _licenseServerAddress, _licenseServerPort); } IXenObject xoClosure = xo; alertsChangeHandler = delegate(object sender, CollectionChangeEventArgs e) { if (e.Action == CollectionChangeAction.Add) { lock (lck) { Alert alert = (Alert)e.Element; if (host != null && host.uuid == alert.HostUuid) { if (alert.Title == PropertyManager.GetFriendlyName("Message.name-license_not_available")) { // the license server reported there were no licenses available. alertText = string.Format(PropertyManager.GetFriendlyName("Message.body-license_not_available"), xoClosure.Name); } else if (alert.Title == PropertyManager.GetFriendlyName("Message.name-license_server_unreachable")) { // couldn't check out license because couldn't contact license server alertText = string.Format(PropertyManager.GetFriendlyName("Message.body-license_server_unreachable"), xoClosure.Name); } else if (alert.Title == PropertyManager.GetFriendlyName("Message.name-grace_license")) { alertText = string.Empty; } } } } }; Alert.XenCenterAlerts.CollectionChanged += alertsChangeHandler; // PR-1102: catch the host's license data, before applying the new one, so it can be sent later to the licensing server LicensingHelper.LicenseDataStruct previousLicenseData = new LicensingHelper.LicenseDataStruct(host); if (xo is Host && host != null) { if (Helpers.ClearwaterOrGreater(host)) { Host.apply_edition(host.Connection.Session, host.opaque_ref, Host.GetEditionText(_edition), false); } else { Host.apply_edition(host.Connection.Session, host.opaque_ref, Host.GetEditionText(_edition)); } // PR-1102: populate the list of updated hosts updatedHosts.Add(host, previousLicenseData); } if (xo is Pool) { if (!Helpers.ClearwaterOrGreater(xo.Connection)) { foreach (Host poolHost in xo.Connection.Cache.Hosts) { Host.apply_edition(host.Connection.Session, poolHost.opaque_ref, Host.GetEditionText(_edition)); } } else { Pool.apply_edition(xo.Connection.Session, pool.opaque_ref, Host.GetEditionText(_edition)); //TODO: Look into why this is required. Event.Next returning late? XAPI returning before updated? Thread.Sleep(200); } xo.Connection.Cache.Hosts.ToList().ForEach(h => updatedHosts.Add(h, previousLicenseData)); } Description = Messages.APPLYLICENSE_UPDATED; } catch (Failure e) { for (int i = 0; i < 50; i++) { Thread.Sleep(100); lock (lck) { if (alertText != null) { break; } } } licenseFailures.Add(new LicenseFailure(host, alertText ?? e.Message)); if (pool != null) { pool.Connection.Cache.Hosts.ToList().ForEach(h => SetLicenseServer(h, previousLicenseServerAddress, previousLicenseServerPort)); } else { SetLicenseServer(host, previousLicenseServerAddress, previousLicenseServerPort); } } finally { Alert.XenCenterAlerts.CollectionChanged -= alertsChangeHandler; } } // PR-1102: Send licensing data to the activation server if (updatedHosts.Count > 0) { LicensingHelper.SendLicenseEditionData(updatedHosts, Host.GetEditionText(_edition)); } if (licenseFailures.Count > 0) { string exceptionText = licenseFailures.Count == 1 ? string.Format(Messages.LICENSE_ERROR_1, licenseFailures[0].Host.Name) : string.Format(Messages.LICENSE_ERROR_MANY, licenseFailures.Count, new List <IXenObject>(xos).Count); if (DoOnLicensingFailure != null) { DoOnLicensingFailure(licenseFailures, exceptionText); } throw new InvalidOperationException(exceptionText); } }
protected INamedProject InitializeProject(IProjectStore projectStore) { INamedProject namedProject; INamedProject unlicensedProject = null; try { IProjectType projectTypeForProject = this.Services.ProjectTypeManager().GetProjectTypeForProject(projectStore); if (projectTypeForProject != null) { IProjectCreateError projectCreateError = projectTypeForProject.CanCreateProject(projectStore); if (projectCreateError != null) { projectTypeForProject = this.Services.ProjectTypeManager().UnknownProjectType; } if (projectTypeForProject is UnknownProjectType && SolutionBase.IsReloadPromptEnabled()) { InvalidProjectStore invalidProjectStore = projectStore as InvalidProjectStore; if (invalidProjectStore == null || string.IsNullOrEmpty(invalidProjectStore.InvalidStateDescription)) { this.PromptWithUnsupportedProjectDetails(projectStore, projectCreateError); } else { IMessageDisplayService messageDisplayService = this.Services.MessageDisplayService(); ErrorArgs errorArg = new ErrorArgs(); CultureInfo currentUICulture = CultureInfo.CurrentUICulture; string unsupportedProjectWithDescription = StringTable.UnsupportedProjectWithDescription; object[] displayName = new object[] { projectStore.DocumentReference.DisplayName, invalidProjectStore.InvalidStateDescription }; errorArg.Message = string.Format(currentUICulture, unsupportedProjectWithDescription, displayName); errorArg.AutomationId = "OpenProjectErrorDialog"; messageDisplayService.ShowError(errorArg); } } LicenseState licenseState = LicensingHelper.IsProjectLicensed(projectStore, this.serviceProvider); if (!licenseState.IsExpired) { if (!licenseState.FullyLicensed) { LicensingHelper.UnlicensedProjectLoadAttempted(); } unlicensedProject = projectTypeForProject.CreateProject(projectStore, this.GetCodeDocumentTypeFromProject(projectStore), this.serviceProvider); } else { LicensingHelper.UnlicensedProjectLoadAttempted(); unlicensedProject = new UnlicensedProject(projectStore, this.serviceProvider); } return(unlicensedProject); } else { namedProject = null; } } catch (Exception exception) { if (unlicensedProject != null) { projectStore.Dispose(); unlicensedProject.Dispose(); unlicensedProject = null; } throw; } return(namedProject); }
public static bool IsLicensed(ILicenseService licenseService) { return(LicensingHelper.IsSketchFlowLicensed(licenseService)); }
public static void ResetCache() { LicensingHelper.ResetCache(); }