private static void ThrowIfItemRemovalIsNotPermitted(TItem item) { if (item is WorkItem) { throw new ArgumentException(Properties.Resources.NoRemoveWorkItemFromManagedObjectCollection, "item"); } if (item is Command) { Command cmd = item as Command; throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.RemoveCommandFromWorkItemIsNotPermitted, cmd.Name), "item"); } if (item is EventTopic) { EventTopic topic = item as EventTopic; throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.RemoveEventTopicFromWorkItemIsNotPermitted, topic.Name), "item"); } }
public void OnChooseDefaultOutputManagerDialog(object sender, EventArgs args) { try { IChooseDefaultOutputManagerView chooseOutputManager = WorkItem.SmartParts.AddNew <ChooseDefaultOutputManagerView>(); UXSettingsService settingsServiceLoad = WorkItem.Items.AddNew <UXSettingsService>("IChooseDefaultOutputManagerView"); settingsServiceLoad.ContainerName = "IChooseDefaultOutputManagerView"; settingsServiceLoad.AddProvider(chooseOutputManager, new ChooseDefaultOutputManagerSettingsProvider()); settingsServiceLoad.LoadSettings(); WorkItem.Items.Remove(settingsServiceLoad); if (chooseOutputManager.ShowDialog() == true) { _OutputManagerUserSessionService.OutputManagerId = chooseOutputManager.SelectedOutputManagerId; UXSettingsService settingsService = WorkItem.Items.AddNew <UXSettingsService>("IChooseDefaultOutputManagerView"); settingsService.ContainerName = "IChooseDefaultOutputManagerView"; settingsService.AddProvider(chooseOutputManager, new ChooseDefaultOutputManagerSettingsProvider()); settingsService.SaveSettings(); WorkItem.Items.Remove(settingsService); EventTopic userSettingsTopic = WorkItem.EventTopics.Get(Imi.SupplyChain.UX.UXEventTopicNames.UserSettingsChangedTopic); if (userSettingsTopic != null) { UserSettingsChangedEventArgs userSettingsChangedEventArgs = new UserSettingsChangedEventArgs(true); userSettingsTopic.Fire(this, userSettingsChangedEventArgs, WorkItem, PublicationScope.Descendants); } } } finally { if (_OutputManagerUserSessionService.OutputManagerId == null) { ShellInteractionService.ShowMessageBox(LocalResources.ChangeUserSettings_Caption, LocalResources.ChangeUserSettings_Message, null, Imi.SupplyChain.UX.Infrastructure.MessageBoxButton.Ok, Imi.SupplyChain.UX.Infrastructure.MessageBoxImage.Warning); } } }
public void EmptyTopicsGetsUnregistered() { EventTopic topic = new EventTopic(); workItem.EventTopics.Add(topic, "GlobalEvent"); Mocks.GlobalEventPublisher publisher = new Mocks.GlobalEventPublisher(); Mocks.GlobalEventHandler subscriber = new Mocks.GlobalEventHandler(); EventInspector.Register(publisher, workItem); Assert.AreEqual(1, topic.PublicationCount); EventInspector.Register(subscriber, workItem); Assert.AreEqual(1, topic.SubscriptionCount); EventInspector.Unregister(publisher, workItem); Assert.AreEqual(0, topic.PublicationCount); Assert.AreEqual(1, topic.SubscriptionCount); EventInspector.Unregister(subscriber, workItem); Assert.AreEqual(0, topic.PublicationCount); Assert.AreEqual(0, topic.SubscriptionCount); }
private void HyperlinkExecutedEventHandler(object sender, HyperlinkExecutedEventArgs e) { //Set user data. [Dashboard compliance] if (omsSessionContext.ClientProgram == null) { EventTopic userSettingsTopic = WorkItem.EventTopics.Get(Imi.SupplyChain.UX.Modules.OrderManagement.Views.Constants.EventTopicNames.ShowChooseUserDialog); userSettingsTopic.Fire(this, new EventArgs(), WorkItem, PublicationScope.Global); } // A program is called from an application outside the container string programName = e.Hyperlink.Data.ContainsKey("DialogId") ? e.Hyperlink.Data["DialogId"] : null; string programArgument = e.Hyperlink.Data.ContainsKey("Parameters") ? e.Hyperlink.Data["Parameters"] : null; string programType = e.Hyperlink.Data.ContainsKey("ProgramType") ? e.Hyperlink.Data["ProgramType"] : null; string programDescription = e.Hyperlink.Data.ContainsKey("DialogDescription") ? e.Hyperlink.Data["DialogDescription"] : null; if (programType == null || programType.Equals("trim")) { StartTrimProgram(programName, programArgument); } else if (programType.Equals("anywhere")) { StartWebView(programName, programDescription, programArgument); } }
public void SelectAndClose(UserWarehouse selectedWarehouse, UserCompany selectedCompany) { if ((selectedWarehouse != null) && (selectedCompany != null)) { try { UserSettingsChangedEventArgs args = new UserSettingsChangedEventArgs(); EventTopic userSettingsTopic = WorkItem.EventTopics.Get(Imi.SupplyChain.UX.UXEventTopicNames.UserSettingsChangedTopic); if (userSettingsTopic != null) { userSettingsTopic.Fire(this, args, WorkItem, PublicationScope.Descendants); if (args.OpenDialogs.Count > 0) { if (ShellInteractionService.ShowMessageBox(this.View.Title, string.Format(LocalResources.ChangeUserSettings_CloseAll, string.Join("\n", args.OpenDialogs)), null, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { Close(false); return; } } } ShellInteractionService.ShowProgress(); // Get the application IShellModule module = WorkItem.Items.FindByType <IShellModule>().First(); LogonParameters logonParameters = new LogonParameters(); logonParameters.UserIdentity = UserSessionService.UserId; logonParameters.CompanyIdentity = selectedCompany.CompanyIdentity; logonParameters.WarehouseIdentity = selectedCompany.WarehouseIdentity; logonParameters.TerminalIdentity = UserSessionService.TerminalId; logonParameters.ApplicationIdentity = module.Id; LogonRequest logonRequest = new LogonRequest(); logonRequest.LogonParameters = logonParameters; LogonResponse response = Service.Logon(logonRequest); // Set the selected Warehouse and ClientId on statusrow in container ShellInteractionService.ContextInfo = string.Format(LocalResources.STATUSBAR_WH_CLIENT, selectedWarehouse.WarehouseIdentity, selectedWarehouse.WarehouseName, selectedCompany.CompanyIdentity, selectedCompany.CompanyName); Close(true); } catch (Exception ex) { ShellInteractionService.HideProgress(); ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, ex.ToString(), MessageBoxButton.Ok, MessageBoxImage.Error); } finally { ShellInteractionService.HideProgress(); } } }
public void StartMenuItemExecutedEventHandler(object sender, StartMenuItemExecutedEventArgs e) { ShellMenuItem shellMenuItem = new ShellMenuItem(); shellMenuItem.Id = e.MenuItem.Id; shellMenuItem.EventTopic = e.MenuItem.EventTopic; shellMenuItem.Caption = e.MenuItem.Caption; shellMenuItem.IsAuthorized = e.MenuItem.IsAuthorized; shellMenuItem.IsEnabled = e.MenuItem.IsEnabled; shellMenuItem.Parameters = e.MenuItem.Parameters; shellMenuItem.Operation = e.MenuItem.Operation; shellMenuItem.AssemblyFile = e.MenuItem.AssemblyFile; if (!shellMenuItem.IsAuthorized) { IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>(); messageBoxView.Show(StringResources.Authorization_NotAuhtorized , StringResources.Authorization_Message , null , Infrastructure.MessageBoxButton.Ok , Infrastructure.MessageBoxImage.Warning); return; } try { _shellView.ShowProgress(); try { if (!string.IsNullOrEmpty(shellMenuItem.AssemblyFile)) { ModuleInfo info = new ModuleInfo(shellMenuItem.AssemblyFile); ModuleLoaderService.Load(ShellModuleService.GetWorkItem(e.Module), info); } MenuItemExecutedEventArgs mappedEventArgs = new MenuItemExecutedEventArgs(); mappedEventArgs.MenuItem = shellMenuItem; mappedEventArgs.OpenInNewWindow = (e.StartOption == StartOption.NewWindow || e.StartOption == StartOption.Dashboard); ShellInteractionService interactionService = ShellModuleService.GetWorkItem(e.Module).Services.Get <IShellInteractionService>() as ShellInteractionService; interactionService.OnMenuItemExecuted(mappedEventArgs); if (!string.IsNullOrEmpty(shellMenuItem.EventTopic)) { EventTopic itemTopic = WorkItem.RootWorkItem.EventTopics.Get(shellMenuItem.EventTopic); if (itemTopic != null) { itemTopic.Fire(this, mappedEventArgs, WorkItem.RootWorkItem, PublicationScope.Global); } } } finally { _shellView.HideProgress(); } } catch (Exception ex) { IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>(); messageBoxView.Show(StringResources.ActionException_Text, ex.Message, ex.ToString(), Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error); } }
public void ContainsPublisherNullSubscriberThrows() { EventTopic topic = new EventTopic(); topic.ContainsPublication(null, "Test"); }
public void RemoveSubscriberNullSubscriberThrows() { EventTopic topic = new EventTopic(); topic.RemoveSubscription(null, "Test"); }
public void RemovePublisherNullPublisherThrows() { EventTopic topic = new EventTopic(); topic.RemovePublication(null, "Test"); }
public AggregationsWriter(ICommandDispatcher dispatcher) { Topic = EventTopic.CalcData; this.dispatcher = dispatcher; }
public void Setup() { item = new TestableRootWorkItem(); topic = new EventTopic(); }
public RawTelemetryWriter(ICommandDispatcher dispatcher) { Topic = EventTopic.RawData; this.dispatcher = dispatcher; }
public void SelectAndClose(UserWarehouse selectedWarehouse) { if (selectedWarehouse != null) { try { UserSettingsChangedEventArgs args = new UserSettingsChangedEventArgs(); EventTopic userSettingsTopic = WorkItem.EventTopics.Get(Imi.SupplyChain.UX.UXEventTopicNames.UserSettingsChangedTopic); if (userSettingsTopic != null) { userSettingsTopic.Fire(this, args, WorkItem, PublicationScope.Descendants); if (args.OpenDialogs.Count > 0) { if (ShellInteractionService.ShowMessageBox(this.View.Title, string.Format(LocalResources.ChangeUserSettings_CloseAll, string.Join("\n", args.OpenDialogs)), null, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { Close(); return; } } } ShellInteractionService.ShowProgress(); UserSessionService.WarehouseId = selectedWarehouse.WarehouseIdentity; ModifyUserDetailsParameters modifyUserDetailsParameters = new ModifyUserDetailsParameters(); modifyUserDetailsParameters.UserIdentity = UserSessionService.UserId; modifyUserDetailsParameters.LastLogonTime = DateTime.Now; modifyUserDetailsParameters.RecentWarehouseIdentity = selectedWarehouse.WarehouseIdentity; ModifyUserDetailsRequest serviceRequest = new ModifyUserDetailsRequest(); serviceRequest.ModifyUserDetailsParameters = modifyUserDetailsParameters; Service.ModifyUserDetails(serviceRequest); if (userSettingsTopic != null) { UserSettingsChangedEventArgs userSettingsChangedEventArgs = new UserSettingsChangedEventArgs(true); userSettingsTopic.Fire(this, userSettingsChangedEventArgs, WorkItem, PublicationScope.Descendants); } // Set the selected Warehouse and ClientId on statusrow in container ShellInteractionService.ContextInfo = string.Format(LocalResources.STATUSBAR_WH, selectedWarehouse.WarehouseIdentity, selectedWarehouse.WarehouseName); Close(); } catch (Exception ex) { ShellInteractionService.HideProgress(); ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, ex.ToString(), MessageBoxButton.Ok, MessageBoxImage.Error); } finally { ShellInteractionService.HideProgress(); } } }
public AggregationsNotifier(IHubContext <AggregationsHub> hubContext) { Topic = EventTopic.CalcData; this.hubContext = hubContext; }