protected override void OnSyncSelectionAction(SyncAction action, SyncStatus status) { status.CanCancel = true; string newPortalPoolName = string.Empty; int versionId = 0; // Request Information if (action == this.ChangePortalPool) { EditPortalPoolForm form = new EditPortalPoolForm(GetConfigurator(), SnapInResources.CompanyScopeNode_Action_ChangePortalPool_Select); if (this.SnapIn.Console.ShowDialog(form) != DialogResult.OK || string.IsNullOrEmpty(form.PortalPool)) { return; } newPortalPoolName = form.PortalPool; } else if (action == this.UpgradeAction) { CompanyScopeNode[] upgradeCompanyItems = (CompanyScopeNode[])this.SelectionData.SelectionObject; UpdateCompanyListForm form = new UpdateCompanyListForm(GetConfigurator(), upgradeCompanyItems); if (DialogResult.Retry == this.SnapIn.Console.ShowDialog(form)) { Process currentProcess = Process.GetCurrentProcess(); // Start a new Process ProcessStartInfo start = GetConfigurator().BuildUpdateCommandForCommonComponents(form.GetUpdateId(), currentProcess.Id); // Run Update Common Components Process.Start(start); // Close current process currentProcess.CloseMainWindow(); } return; } // Read Selected nodes CompanyScopeNode[] companyItems = (CompanyScopeNode[])this.SelectionData.SelectionObject; int workProcessed = 0; int totalWork = companyItems.Length; // ReportProgress 0, Len status.ReportProgress(workProcessed, totalWork, string.Empty); foreach (CompanyScopeNode company in companyItems) { string companyId = (string)company.Tag; string companyName = company.DisplayName; if (action == this.StartAction) { // ReportProgress Item, Len status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_Start_Progress, companyName)); OnStartCompany(companyId); company.IsActive = true; } else if (action == this.StopAction) { // ReportProgress Item, Len status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_Stop_Progress, companyName)); OnStopCompany(companyId); company.IsActive = false; } else if (action == this.EnableSchedulerServiceAction) { status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_EnableSchedulerService_Progress, companyName)); OnEnableSchedulerService(companyId); company.IsEnableShedulerService = true; } else if (action == this.DisableSchedulerServiceAction) { status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_DisableSchedulerService_Progress, companyName)); OnDisableSchedulerService(companyId); company.IsEnableShedulerService = false; } else if (action == this.ChangePortalPool) { status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_ChangePortalPool_Progress, companyName)); company.SubItemDisplayNames[9] = OnChangePortalPool(companyId, newPortalPoolName); } else if (action == this.UpgradeAction) { status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_Upgrade_Progress, companyName)); OnUpgradeAction(companyId, versionId); } company.RefreshCompanyStatus(); // Process Cancel if (status.IsCancelSignaled) { break; } // Increase Progress workProcessed++; } // ReportProgress Len, Len status.ReportProgress(totalWork, totalWork, string.Empty); // Refresh Selection Button OnSelectionChanged(null); }
protected override void OnSyncSelectionAction(SyncAction action, SyncStatus status) { status.CanCancel = true; string newPortalPoolName = string.Empty; int versionId = 0; // Request Information if (action == this.ChangePortalPool) { EditPortalPoolForm form = new EditPortalPoolForm(GetConfigurator(), SnapInResources.CompanyScopeNode_Action_ChangePortalPool_Select); if (this.SnapIn.Console.ShowDialog(form) != DialogResult.OK || string.IsNullOrEmpty(form.PortalPool)) return; newPortalPoolName = form.PortalPool; } else if (action == this.UpgradeAction) { CompanyScopeNode[] upgradeCompanyItems = (CompanyScopeNode[])this.SelectionData.SelectionObject; UpdateCompanyListForm form = new UpdateCompanyListForm(GetConfigurator(), upgradeCompanyItems); if (DialogResult.Retry == this.SnapIn.Console.ShowDialog(form)) { Process currentProcess = Process.GetCurrentProcess(); // Start a new Process ProcessStartInfo start = GetConfigurator().BuildUpdateCommandForCommonComponents(form.GetUpdateId(), currentProcess.Id); // Run Update Common Components Process.Start(start); // Close current process currentProcess.CloseMainWindow(); } return; } // Read Selected nodes CompanyScopeNode[] companyItems = (CompanyScopeNode[])this.SelectionData.SelectionObject; int workProcessed = 0; int totalWork = companyItems.Length; // ReportProgress 0, Len status.ReportProgress(workProcessed, totalWork, string.Empty); foreach (CompanyScopeNode company in companyItems) { string companyId = (string)company.Tag; string companyName = company.DisplayName; if (action == this.StartAction) { // ReportProgress Item, Len status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_Start_Progress, companyName)); OnStartCompany(companyId); company.IsActive = true; } else if (action == this.StopAction) { // ReportProgress Item, Len status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_Stop_Progress, companyName)); OnStopCompany(companyId); company.IsActive = false; } else if (action == this.EnableSchedulerServiceAction) { status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_EnableSchedulerService_Progress, companyName)); OnEnableSchedulerService(companyId); company.IsEnableShedulerService = true; } else if (action == this.DisableSchedulerServiceAction) { status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_DisableSchedulerService_Progress, companyName)); OnDisableSchedulerService(companyId); company.IsEnableShedulerService = false; } else if (action == this.ChangePortalPool) { status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_ChangePortalPool_Progress, companyName)); company.SubItemDisplayNames[9] = OnChangePortalPool(companyId, newPortalPoolName); } else if (action == this.UpgradeAction) { status.ReportProgress(workProcessed, totalWork, string.Format(SnapInResources.CompanyScopeNode_Action_Upgrade_Progress, companyName)); OnUpgradeAction(companyId, versionId); } company.RefreshCompanyStatus(); // Process Cancel if (status.IsCancelSignaled) break; // Increase Progress workProcessed++; } // ReportProgress Len, Len status.ReportProgress(totalWork, totalWork, string.Empty); // Refresh Selection Button OnSelectionChanged(null); }