/// <summary> /// Method to Unregister a Plugin. /// </summary> /// <param name="xrmPlugin">The Plugin to Unregister.</param> /// <returns>Result.</returns> internal bool UnregisterPlugin(string xrmServerDetails, XrmPlugin xrmPlugin, Collection <string> errors, SolutionComponentType solutionComponentType) { try { Result = RegistrationService.Unregister(xrmServerDetails, PluginType.EntityLogicalName, xrmPlugin.PluginId, errors, solutionComponentType); return(Result); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
/// <summary> /// Method to Unregister an Image. /// </summary> /// <param name="xrmPluginImage">The Image to Unregister.</param> /// <returns>Result.</returns> internal bool UnregisterImage(string xrmServerDetails, XrmPluginImage xrmPluginImage, Collection <string> errors, SolutionComponentType solutionComponentType) { try { Result = RegistrationService.Unregister(xrmServerDetails, SdkMessageProcessingStepImage.EntityLogicalName, xrmPluginImage.ImageId.Value, errors, solutionComponentType); return(Result); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
/// <summary> /// Method to Register an Image. /// </summary> /// <param name="xrmPluginImage">The Image to Register.</param> /// <returns>The newly Registered Image Identifier.</returns> internal Guid RegisterImage(string xrmServerDetails, XrmPluginImage xrmPluginImage) { try { using (xrmService = RegistrationService.GetService(xrmServerDetails)) { SdkMessageProcessingStepImage sdkMessageProcessingStepImage = GetPluginImage(xrmPluginImage); return(xrmService.Create(sdkMessageProcessingStepImage)); } } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
/// <summary> /// Method to Register an Assembly. /// </summary> /// <param name="xrmPluginAssembly">The Assembly to Register.</param> /// <returns>The Identifier of the newly Registered Assembly.</returns> internal Guid RegisterAssembly(string xrmServerDetails, XrmPluginAssembly xrmPluginAssembly) { try { using (xrmService = RegistrationService.GetService(xrmServerDetails)) { PluginAssembly pluginAssembly = GetPluginAssembly(xrmPluginAssembly); return(xrmService.Create(pluginAssembly)); } } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
/// <summary> /// Method to Update an Assembly Registration. /// </summary> /// <param name="xrmPluginAssembly">The Assembly to Update.</param> /// <returns>Result.</returns> internal bool UpdateAssembly(string xrmServerDetails, XrmPluginAssembly xrmPluginAssembly) { try { using (xrmService = RegistrationService.GetService(xrmServerDetails)) { PluginAssembly pluginAssembly = GetPluginAssembly(xrmPluginAssembly); xrmService.Update(pluginAssembly); } Result = true; return(Result); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
/// <summary> /// Method to Update a Plugin Registration. /// </summary> /// <param name="xrmPlugin">The Plugin to Update.</param> /// <returns>Result.</returns> internal bool UpdatePlugin(string xrmServerDetails, XrmPlugin xrmPlugin) { try { Result = false; using (xrmService = RegistrationService.GetService(xrmServerDetails)) { PluginType pluginType = GetPluginType(xrmPlugin); xrmService.Update(pluginType); } Result = true; return(Result); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
/// <summary> /// Method to Update an Image Registration. /// </summary> /// <param name="xrmPluginImage">The Image to Update.</param> /// <returns>Result.</returns> internal bool UpdateImage(string xrmServerDetails, XrmPluginImage xrmPluginImage) { try { Result = false; using (xrmService = RegistrationService.GetService(xrmServerDetails)) { SdkMessageProcessingStepImage sdkMessageProcessingStepImage = GetPluginImage(xrmPluginImage); xrmService.Update(sdkMessageProcessingStepImage); } Result = true; return(Result); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
/// <summary> /// Method to Update a Step. /// </summary> /// <param name="xrmPluginStep">The Step to Update.</param> /// <returns>Result.</returns> internal bool UpdateStep(string xrmServerDetails, XrmPluginStep xrmPluginStep) { try { Result = false; using (xrmService = RegistrationService.GetService(xrmServerDetails)) { SdkMessageProcessingStep sdkMessageProcessingStep = GetPluginStep(xrmPluginStep); AddSecureConfigIfMissing(xrmPluginStep, sdkMessageProcessingStep); xrmService.Update(sdkMessageProcessingStep); } Result = true; return(Result); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
/// <summary> /// Method to retrieve the list of Images specified in the Registration Object linked to the Step object and populate the XRM Plugin Step accordingly. /// </summary> /// <param name="registration">The Registration Object.</param> /// <param name="step">The Step Object.</param> /// <param name="xrmPluginStep">The XRM Plugin Step Object.</param> internal XrmPluginStep GetRegistrationImages(string xrmServerDetails, PluginStep step, XrmPluginStep xrmPluginStep) { try { foreach (Image image in step.Images) { ValidateImage(step, image); XrmPluginImage xrmPluginImage = new XrmPluginImage(); using (xrmService = RegistrationService.GetService(xrmServerDetails)) { string attributeCSV = GetAttributeCSV(new XrmMetadata(xrmServerDetails), image, step.PrimaryEntity); ItemExists imageDetails = GetImageId(xrmPluginStep, image, xrmService, attributeCSV); xrmPluginImage.ImageId = imageDetails.ItemId; xrmPluginImage.Exists = imageDetails.Exists; xrmPluginImage.StepId = xrmPluginStep.StepId; xrmPluginImage.ImageType = image.ImageType; if (!string.IsNullOrEmpty(attributeCSV)) { xrmPluginImage.Attributes = attributeCSV; } xrmPluginImage.EntityAlias = image.EntityAlias; xrmPluginImage.MessageProperty = image.MessageProperty; if (image.Merge.HasValue) { xrmPluginImage.MessagePropertyName = GetMessagePropertyName(step.PluginMessage, image.Merge.Value); } else { xrmPluginImage.MessagePropertyName = GetMessagePropertyName(step.PluginMessage); } xrmPluginStep.Images.Add(xrmPluginImage); } } return(xrmPluginStep); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
private ItemExists GetRegistrationPluginId(string pluginName, string xrmServerDetails) { using (xrmService = RegistrationService.GetService(xrmServerDetails)) { Plugin = new ItemExists(); QueryRegistrationPluginId = new QueryByAttribute(PluginType.EntityLogicalName); QueryRegistrationPluginId.ColumnSet = new ColumnSet(); QueryRegistrationPluginId.AddAttributeValue("typename", pluginName); ResultsRegistrationPluginId = xrmService.RetrieveMultiple(QueryRegistrationPluginId); if (ResultsRegistrationPluginId.Entities != null && ResultsRegistrationPluginId.Entities.Count > 0) { Plugin.ItemId = ResultsRegistrationPluginId.Entities[0].Id; Plugin.Exists = true; } else { Plugin.ItemId = Guid.NewGuid(); Plugin.Exists = false; } return(Plugin); } }
/// <summary> /// Method to Register a Plugin. /// </summary> /// <param name="xrmPlugin">The Plugin to Register.</param> /// <returns>The Identifier of the newly Registered Plugin.</returns> internal Guid RegisterPlugin(string xrmServerDetails, XrmPlugin xrmPlugin, Collection <string> errors) { try { using (xrmService = RegistrationService.GetService(xrmServerDetails)) { PluginType pluginType = GetPluginType(xrmPlugin); return(xrmService.Create(pluginType)); } } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> e) { if (e.Message == "Plug-in assembly does not contain the required types or assembly content cannot be updated.") { errors.Add("Attempt to register a Type in the Assembly failed because it is not a Plugin. Type is: " + xrmPlugin.Name); return(Guid.Empty); } else { throw; } } }
/// <summary> /// Method to retrieve Steps according to the Registration Object. /// </summary> /// <param name="plugin">The Registration Object, which indicates which Steps to retrieve.</param> /// <param name="xrmPlugin">The Plugin Object to populate with the Steps retrieved.</param> /// <param name="pluginName">The Name of the Plugin for which to retrieve Steps.</param> /// <param name="pluginExists">An object containing the Identifier of the Plugin and if the Plugin exists.</param> internal XrmPlugin GetPluginSteps(string xrmServerDetails, Plugin plugin, XrmPlugin xrmPlugin, string pluginName, ItemExists pluginExists) { try { foreach (PluginStep step in plugin.Steps) { if (plugin.PluginName == pluginName) { XrmPluginStep xrmPluginStep = new XrmPluginStep(); xrmPluginStep.PluginId = pluginExists.ItemId; if (!string.IsNullOrEmpty(step.Name)) { xrmPluginStep.Name = step.Name; } else { xrmPluginStep.Name = pluginName + ": " + step.PluginMessage + " of " + step.PrimaryEntity; if (!string.IsNullOrEmpty(step.SecondaryEntity)) { xrmPluginStep.Name += " and " + step.SecondaryEntity; } } if (!string.IsNullOrEmpty(step.Description)) { xrmPluginStep.Description = step.Description; } else { xrmPluginStep.Description = xrmPluginStep.Name; } using (xrmService = RegistrationService.GetService(xrmServerDetails)) { xrmPluginStep.MessageEntityId = GetSdkMessageEntityId(xrmServerDetails, step, xrmService); xrmPluginStep.MessageId = GetSdkMessageId(step, xrmService); xrmPluginStep.ImpersonatingUserId = GetImpersonatingUserId(step, xrmService); ItemExists stepDetails = GetStepId(step, xrmPluginStep, xrmService); xrmPluginStep.StepId = stepDetails.ItemId; xrmPluginStep.Exists = stepDetails.Exists; if (!string.IsNullOrEmpty(step.SecureConfiguration)) { xrmPluginStep.SecureConfiguration = new XrmSecureConfiguration(); xrmPluginStep.SecureConfiguration.SecureConfiguration = step.SecureConfiguration; xrmPluginStep.SecureConfiguration.SecureConfigurationId = stepDetails.SecureConfigId; } } xrmPluginStep.UnsecureConfiguration = step.UnsecureConfiguration; xrmPluginStep.FilteringAttributes = step.FilteringAttributes; xrmPluginStep.Mode = step.Mode; xrmPluginStep.Rank = step.Rank; xrmPluginStep.InvocationSource = step.InvocationSource; xrmPluginStep.Stage = step.Stage; xrmPluginStep.Deployment = step.Deployment; xrmPluginStep = ImageHelper.GetRegistrationImages(xrmServerDetails, step, xrmPluginStep); xrmPlugin.Steps.Add(xrmPluginStep); } } return(xrmPlugin); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }