/// <summary> /// Executes this commmand. /// </summary> /// <remarks></remarks> public override void Execute() { // Verify all [Required] and [Import]ed properties have valid values. this.ValidateObject(); var events = CurrentElement.Parent.Parent.Parent.Service.SelectMany(s => s.Contract.Events.Event); // Filter those events that already processed by the component events = events.Where(e => !CurrentElement.Subscribes.SubscribedEventLinks.Any(el => el.EventReference.Value == e)); // Get event names var existingEventNames = events.Select(e => e.InstanceName).ToList(); var viewModel = new EventReadOnlyPickerViewModel(existingEventNames); var picker = WindowFactory.CreateDialog <EventReadOnlyPicker>(viewModel); using (new MouseCursor(Cursors.Arrow)) { if (picker.ShowDialog().GetValueOrDefault()) { foreach (var selectedElement in viewModel.SelectedItems) { var selectedEvent = events.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase)); CurrentElement.Subscribes.CreateLink(selectedEvent); } SagaHelper.CheckAndPromptForSagaUpdate(CurrentElement, MessageBoxService, WindowFactory); } } // 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(); var events = CurrentElement.Parent.Parent.Parent.Service.SelectMany(s => s.Contract.Events.Event); // Filter those events that already processed by the component events = events.Where(e => !CurrentElement.Subscribes.SubscribedEventLinks.Any(el => el.EventReference.Value == e)); // Get event names var existingEventNames = events.Select(e => e.InstanceName).ToList(); var viewModel = new EventReadOnlyPickerViewModel(existingEventNames); var picker = WindowFactory.CreateDialog<EventReadOnlyPicker>(viewModel); using (new MouseCursor(Cursors.Arrow)) { if (picker.ShowDialog().GetValueOrDefault()) { foreach (var selectedElement in viewModel.SelectedItems) { var selectedEvent = events.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase)); CurrentElement.Subscribes.CreateLink(selectedEvent); } SagaHelper.CheckAndPromptForSagaUpdate(CurrentElement, MessageBoxService, WindowFactory); } } // 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 }