private void ButtonAddStep_Click(object sender, RoutedEventArgs e) { var type = (CrmPluginType)ListPluginTypes.SelectedItem; var newStep = new CrmTypeStep { Type = type }; new Thread(() => { TypeStep dialogue = null; Dispatcher.Invoke(() => { dialogue = new TypeStep(newStep, context); dialogue.ShowDialog(); }); try { if (!dialogue.IsUpdate) { return; } var filter = CrmDataHelper.MessageList .FirstOrDefault(messageQ => messageQ.EntityName == newStep.Entity && messageQ.MessageName == newStep.Message); newStep.FilterId = filter?.FilteredId ?? Guid.Empty; var message = CrmDataHelper.MessageList .First(messageQ => messageQ.MessageName == newStep.Message); newStep.MessageId = message.MessageId; assemblyRegistration.CreateTypeStep(newStep); Dispatcher.Invoke(() => type.Children.Add(newStep)); } catch (Exception exception) { PopException(exception); } finally { HideBusy(); } }).Start(); }
private void ButtonEditStep_Click(object sender, RoutedEventArgs e) { var type = (CrmPluginType)ListPluginTypes.SelectedItem; var step = (CrmTypeStep)ListTypeSteps.SelectedItem; var clone = step.Clone <CrmTypeStep>(); new Thread(() => { try { if (!clone.IsUpdated) { UpdateStatus("Updating step info ...", true); // only basic info exists in the step when it is loaded through the type class clone.UpdateInfo(context); UpdateStatus("-- Finished updating step info.", false); } } catch (Exception exception) { PopException(exception); } finally { UpdateStatus("", false); } TypeStep dialogue = null; Dispatcher.Invoke(() => { dialogue = new TypeStep(clone, context); dialogue.ShowDialog(); }); try { if (!dialogue.IsUpdate) { return; } var filter = CrmDataHelper.MessageList .FirstOrDefault(messageQ => messageQ.EntityName == clone.Entity && messageQ.MessageName == clone.Message); clone.FilterId = filter?.FilteredId ?? Guid.Empty; var message = CrmDataHelper.MessageList .First(messageQ => messageQ.MessageName == clone.Message); clone.MessageId = message.MessageId; assemblyRegistration.UpdateTypeStep(clone); Dispatcher.Invoke(() => { type.Children.Remove(step); type.Children.Add(clone); }); } catch (Exception exception) { PopException(exception); } finally { HideBusy(); } }).Start(); }