private void CreateImage(SdkMessageProcessingStep crmStep, int pre1post2, int stage, bool async, string message, Models.Image imgDef) { var name = Kipon.Tools.Xrm.Reflection.PluginMethod.ImageSuffixFor(pre1post2, stage, async); var image = new SdkMessageProcessingStepImage { SdkMessageProcessingStepImageId = Guid.NewGuid(), SdkMessageProcessingStepId = new Microsoft.Xrm.Sdk.EntityReference(Entities.SdkMessageProcessingStep.EntityLogicalName, crmStep.SdkMessageProcessingStepId.Value), Name = name, EntityAlias = name, Description = name, ImageType = new Microsoft.Xrm.Sdk.OptionSetValue((pre1post2 - 1)), MessagePropertyName = this.MessagePropertyName(message), }; string filterAttr = null; if (!imgDef.AllAttributes && imgDef.FilteredAttributes != null && imgDef.FilteredAttributes.Length > 0) { filterAttr = string.Join(",", imgDef.FilteredAttributes); } if (!string.IsNullOrEmpty(filterAttr)) { image.Attributes1 = filterAttr; } uow.Create(image); messageService.Inform($"Created image {name} on step {crmStep.Name}"); }
private void Delete(Entities.PluginType pluginType) { var steps = (from s in uow.SdkMessageProcessingSteps.GetQuery() where s.EventHandler.Id == pluginType.PluginTypeId select s).ToArray(); foreach (var step in steps) { var images = (from i in uow.SdkMessageProcessingStepImages.GetQuery() where i.SdkMessageProcessingStepId.Id == step.SdkMessageProcessingStepId select i).ToArray(); foreach (var img in images) { uow.Delete(img); } uow.Delete(step); } uow.Delete(pluginType); messageService.Inform($"Removed plugin: {pluginType.Name}"); }