/// <summary> /// Executes this commmand. /// </summary> /// <remarks></remarks> public override void Execute() { // Verify all [Required] and [Import]ed properties have valid values. this.ValidateObject(); if (!CurrentElement.ProcessesMultipleMessages) { CurrentElement.Subscribes.ProcessedCommandLinks.ForEach(x => x.StartsSaga = true); CurrentElement.Subscribes.SubscribedEventLinks.ForEach(x => x.StartsSaga = true); CurrentElement.IsSaga = true; return; } var existingMessageNames = new List <string>(); existingMessageNames.AddRange(CurrentElement.Subscribes.ProcessedCommandLinks.Select(x => x.CommandReference.Value.InstanceName)); existingMessageNames.AddRange(CurrentElement.Subscribes.SubscribedEventLinks.Select(x => x.EventReference.Value.InstanceName)); // Filter those events that already processed by the component var existingMessageSagaStarterNames = new List <string>(); existingMessageSagaStarterNames.AddRange(CurrentElement.Subscribes.ProcessedCommandLinks.Where(x => x.StartsSaga).Select(x => x.CommandReference.Value.InstanceName)); existingMessageSagaStarterNames.AddRange(CurrentElement.Subscribes.SubscribedEventLinks.Where(x => x.StartsSaga).Select(x => x.EventReference.Value.InstanceName)); var viewModel = new SagaStarterViewModel(existingMessageNames) { SelectedItems = existingMessageSagaStarterNames }; var picker = WindowFactory.CreateDialog <SagaStarterPicker>(viewModel); using (new MouseCursor(Cursors.Arrow)) { if (picker.ShowDialog().GetValueOrDefault()) { foreach (var cl in CurrentElement.Subscribes.ProcessedCommandLinks) { cl.StartsSaga = viewModel.SelectedItems.Contains(cl.CommandReference.Value.InstanceName); } foreach (var el in CurrentElement.Subscribes.SubscribedEventLinks) { el.StartsSaga = viewModel.SelectedItems.Contains(el.EventReference.Value.InstanceName); } } } CurrentElement.IsSaga = true; // TODO: Implement command automation code // TODO: Use tracer.Warning() to note expected and recoverable errors // TODO: Use tracer.Verbose() to note internal execution logic decisions // TODO: Use tracer.Info() to note key results of execution // TODO: Raise exceptions for all other errors }
/// <summary> /// Executes this commmand. /// </summary> /// <remarks></remarks> public override void Execute() { // Verify all [Required] and [Import]ed properties have valid values. this.ValidateObject(); if (!CurrentElement.ProcessesMultipleMessages) { CurrentElement.Subscribes.ProcessedCommandLinks.ForEach(x => x.StartsSaga = true); CurrentElement.Subscribes.SubscribedEventLinks.ForEach(x => x.StartsSaga = true); CurrentElement.IsSaga = true; return; } var existingMessageNames = new List<string>(); existingMessageNames.AddRange(CurrentElement.Subscribes.ProcessedCommandLinks.Select(x => x.CommandReference.Value.InstanceName)); existingMessageNames.AddRange(CurrentElement.Subscribes.SubscribedEventLinks.Select(x => x.EventReference.Value.InstanceName)); // Filter those events that already processed by the component var existingMessageSagaStarterNames = new List<string>(); existingMessageSagaStarterNames.AddRange(CurrentElement.Subscribes.ProcessedCommandLinks.Where(x => x.StartsSaga).Select(x => x.CommandReference.Value.InstanceName)); existingMessageSagaStarterNames.AddRange(CurrentElement.Subscribes.SubscribedEventLinks.Where(x => x.StartsSaga).Select(x => x.EventReference.Value.InstanceName)); var viewModel = new SagaStarterViewModel(existingMessageNames) { SelectedItems = existingMessageSagaStarterNames }; var picker = WindowFactory.CreateDialog<SagaStarterPicker>(viewModel); using (new MouseCursor(Cursors.Arrow)) { if (picker.ShowDialog().GetValueOrDefault()) { foreach (var cl in CurrentElement.Subscribes.ProcessedCommandLinks) { cl.StartsSaga = viewModel.SelectedItems.Contains(cl.CommandReference.Value.InstanceName); } foreach (var el in CurrentElement.Subscribes.SubscribedEventLinks) { el.StartsSaga = viewModel.SelectedItems.Contains(el.EventReference.Value.InstanceName); } } } CurrentElement.IsSaga = true; // TODO: Implement command automation code // TODO: Use tracer.Warning() to note expected and recoverable errors // TODO: Use tracer.Verbose() to note internal execution logic decisions // TODO: Use tracer.Info() to note key results of execution // TODO: Raise exceptions for all other errors }