internal void UpdateTypeStep(CrmTypeStep step) { lock (ActionLock) { _UpdateStep(step); } }
internal void CreateTypeStep(CrmTypeStep step) { lock (ActionLock) { _CreateStep(step); } }
public TypeStep(CrmTypeStep crmStep, XrmServiceContext context) { Context = context; CrmStep = crmStep; InitializeComponent(); }
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 _UpdateStep(CrmTypeStep step) { UpdateStatus($"Updating step '{step.Name}' in type ... ", 1); //var updatedStep = Context.SdkMessageProcessingStepSet.FirstOrDefault(entity => entity.SdkMessageProcessingStepId == step.Id) // ?? new SdkMessageProcessingStep(); //if (updatedStep.Id == Guid.Empty) //{ // updatedStep.Id = step.Id; //} var updatedStep = new SdkMessageProcessingStep { Id = step.Id, SdkMessageId = new EntityReference(SdkMessage.EntityLogicalName, step.MessageId), FilteringAttributes = step.Attributes ?? "", Name = step.Name, Rank = step.ExecutionOrder, Description = step.Description ?? "", Stage = step.Stage.ToOptionSetValue(), Mode = step.Mode.ToOptionSetValue(), SupportedDeployment = step.Deployment.ToOptionSetValue(), AsyncAutoDelete = step.IsDeleteJob, Configuration = step.UnsecureConfig ?? "" }; if (step.UserId == Guid.Empty) { updatedStep.ImpersonatingUserId = null; } else { updatedStep.ImpersonatingUserId = new EntityReference(SystemUser.EntityLogicalName, step.UserId); } if (step.FilterId == Guid.Empty) { updatedStep.SdkMessageFilterId = null; } else { updatedStep.SdkMessageFilterId = new EntityReference(SdkMessageFilter.EntityLogicalName, step.FilterId); } var secureId = step.SecureId; if (string.IsNullOrEmpty(step.SecureConfig)) { secureId = Guid.Empty; } else { if (secureId == Guid.Empty) { secureId = step.SecureId = ((CreateResponse)Context.Execute( new CreateRequest { Target = new SdkMessageProcessingStepSecureConfig { SecureConfig = step.SecureConfig } })).id; } else { //var updatedSecure = Context.SdkMessageProcessingStepSecureConfigSet.FirstOrDefault( // entity => entity.SdkMessageProcessingStepSecureConfigId == step.SecureId) // ?? new SdkMessageProcessingStepSecureConfig(); //if (updatedSecure.Id == Guid.Empty) //{ // updatedSecure.Id = step.SecureId; //} var updatedSecure = new SdkMessageProcessingStepSecureConfig { Id = step.SecureId, SecureConfig = step.SecureConfig }; //Context.ConfirmAttached(updatedSecure); //Context.UpdateObject(updatedSecure); UpdateStatus("Updated secure config ... "); Service.Update(updatedSecure); } } if (secureId == Guid.Empty) { updatedStep.SdkMessageProcessingStepSecureConfigId = null; } else { updatedStep.SdkMessageProcessingStepSecureConfigId = new EntityReference(SdkMessageProcessingStepSecureConfig.EntityLogicalName, secureId); } //Context.ConfirmAttached(updatedStep); //Context.UpdateObject(updatedStep); UpdateStatus("Updated step ... "); Service.Update(updatedStep); //UpdateStatus("Saving updated step to CRM ... "); //Context.SaveChanges(); UpdateStatus($"Finished updating step '{step.Name}'.", -1); }
private void _CreateStep(CrmTypeStep step) { UpdateStatus($"Creating step '{step.Name}' in type ... ", 1); var secureId = Guid.Empty; if (!string.IsNullOrEmpty(step.SecureConfig)) { secureId = step.SecureId = ((CreateResponse)Context.Execute( new CreateRequest { Target = new SdkMessageProcessingStepSecureConfig { SecureConfig = step.SecureConfig } })).id; } var newStep = new SdkMessageProcessingStep { SdkMessageId = new EntityReference(SdkMessage.EntityLogicalName, step.MessageId), Name = step.Name, FilteringAttributes = step.Attributes ?? "", Rank = step.ExecutionOrder, Description = step.Description ?? "", Stage = step.Stage.ToOptionSetValue(), Mode = step.Mode.ToOptionSetValue(), SupportedDeployment = step.Deployment.ToOptionSetValue(), AsyncAutoDelete = step.IsDeleteJob, Configuration = step.UnsecureConfig ?? "", EventHandler = new EntityReference(PluginType.EntityLogicalName, step.Type.Id) }; if (step.UserId != Guid.Empty) { newStep.ImpersonatingUserId = new EntityReference(SystemUser.EntityLogicalName, step.UserId); } if (step.FilterId != Guid.Empty) { newStep.SdkMessageFilterId = new EntityReference(SdkMessageFilter.EntityLogicalName, step.FilterId); } if (secureId != Guid.Empty) { newStep.SdkMessageProcessingStepSecureConfigId = new EntityReference(SdkMessageProcessingStepSecureConfig.EntityLogicalName, secureId); } //Context.AddObject(newStep); UpdateStatus("Saving new step to CRM ... "); step.Id = Service.Create(newStep); //Context.SaveChanges(); //step.Id = newStep.Id; UpdateStatus($"Finished creating step '{step.Name}'.", -1); }