Ejemplo n.º 1
0
 public override void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services)
 {
     if (_mode.HasValue && services.Context.Mode != (int)_mode.Value)
     {
         Fail($"The plugin '{configuration.PluginType.Name}' must be invoked using mode '{_mode.ToString()}' but was invoked using mode '{Enum.ToObject(typeof(ExecutionMode), services.Context.Mode)}' instead.");
     }
 }
 public override void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services)
 {
     if (services.Context.InitiatingUserId != _initiatingUserId)
     {
         Fail($"The plugin '{configuration.PluginType.Name}' must be executed as user '{_initiatingUserId}' but was executed as user '{services.Context.InitiatingUserId}'.");
     }
 }
 public override void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services)
 {
     if (!services.Context.IsInTransaction)
     {
         Fail($"The plugin '{configuration.PluginType.Name}' must be registered as a step inside the database transaction.");
     }
 }
        public override void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services)
        {
            var contextStage = (PluginStage)Enum.ToObject(typeof(PluginStage), services.Context.Stage);

            if (_stage.HasValue)
            {
                switch (contextStage)
                {
                case PluginStage.PreValidation:
                    if ((_stage.Value & PluginStage.PreValidation) != PluginStage.PreValidation)
                    {
                        Fail($"The plugin '{configuration.PluginType.Name}' cannot be invoked in '{contextStage}'.");
                    }

                    break;

                case PluginStage.PreOperation:
                    if ((_stage.Value & PluginStage.PreOperation) != PluginStage.PreOperation)
                    {
                        Fail($"The plugin '{configuration.PluginType.Name}' cannot be invoked in '{contextStage}'.");
                    }

                    break;

                case PluginStage.PostOperation:
                    if ((_stage.Value & PluginStage.PostOperation) != PluginStage.PostOperation)
                    {
                        Fail($"The plugin '{configuration.PluginType.Name}' cannot be invoked in '{contextStage}'.");
                    }

                    break;
                }
            }
        }
 public override void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services)
 {
     if (!string.IsNullOrEmpty(_messageName))
     {
         if (string.Compare(services.Context.MessageName, _messageName, true) != 0)
         {
             Fail($"The plugin '{configuration.PluginType.Name}' must be registered on the message '{_messageName}'.");
         }
     }
 }
 public override void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services)
 {
     if (!string.IsNullOrEmpty(_imageName))
     {
         if (!services.Context.PostEntityImages.ContainsKey(_imageName))
         {
             Fail($"The plugin '{configuration.PluginType.Name}' must contain a post-entity image named '{_imageName}' to be invoked.");
         }
     }
 }
        public override void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services)
        {
            if (!string.IsNullOrEmpty(_entityName))
            {
                if (((_pluginEntityType & PluginEntityType.Primary) == PluginEntityType.Primary) &&
                    string.Compare(services.Context.PrimaryEntityName, _entityName, true) != 0)
                {
                    Fail($"The plugin '{configuration.PluginType.Name}' must be registered on the entity '{_entityName}' as the primary entity.");
                }

                if (((_pluginEntityType & PluginEntityType.Secondary) == PluginEntityType.Secondary) &&
                    string.Compare(services.Context.SecondaryEntityName, _entityName, true) != 0)
                {
                    Fail($"The plugin '{configuration.PluginType.Name}' must be registered on the entity '{_entityName}' as the secondary entity.");
                }
            }
        }
        public override void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services)
        {
            if (((_configurationType & PluginConfigurationType.Unsecure) == PluginConfigurationType.Unsecure) &&
                string.IsNullOrEmpty(configuration.UnsecureConfiguration))
            {
                Fail($"The plugin '{configuration.PluginType.Name}' must be registered with an unsecure configuration.  You must re-register the plugin with this configuration before you can execute it.");
            }

            if (((_configurationType & PluginConfigurationType.Secure) == PluginConfigurationType.Secure) &&
                string.IsNullOrEmpty(configuration.SecureConfiguration))
            {
                Fail($"The plugin '{configuration.PluginType.Name}' must be registered with a secure configuration.  You must re-register the plugin with this configuration before you can execute it.");
            }

            if (_configurationType == PluginConfigurationType.Both &&
                (string.IsNullOrEmpty(configuration.UnsecureConfiguration) || string.IsNullOrEmpty(configuration.SecureConfiguration)))
            {
                Fail($"The plugin '{configuration.PluginType.Name}' must be registered with both an unsecure and a secure configuration.  You must re-register the plugin with this configuration before you can execute it.");
            }
        }
        public override void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services)
        {
            if ((services.Context.InputParameters == null || !services.Context.InputParameters.Contains("Target")) &&
                _targetType != PluginContextTargetType.None)
            {
                Fail($"The plugin '{configuration.PluginType.Name}' must contain an input parameter named 'Target' to be invoked.");
            }

            if (services.Context.InputParameters != null &&
                services.Context.InputParameters.Contains("Target"))
            {
                if (_targetType == PluginContextTargetType.None)
                {
                    Fail($"The plugin '{configuration.PluginType.Name}' contains an input parameter named 'Target' but it should not.");
                }

                var targetIsEntity          = services.Context.InputParameters["Target"] is Entity;
                var targetIsEntityReference = services.Context.InputParameters["Target"] is EntityReference;

                if (!targetIsEntity &&
                    _targetType == PluginContextTargetType.Entity)
                {
                    Fail($"The plugin '{configuration.PluginType.Name}' contains an input parameter named 'Target' but it's type is not 'Entity'.");
                }

                if (!targetIsEntityReference &&
                    _targetType == PluginContextTargetType.EntityReference)
                {
                    Fail($"The plugin '{configuration.PluginType.Name}' contains an input parameter named 'Target' but it's type is not 'EntityReference'.");
                }

                if (!(targetIsEntity || targetIsEntityReference) &&
                    _targetType == (PluginContextTargetType.Entity | PluginContextTargetType.EntityReference))
                {
                    Fail($"The plugin '{configuration.PluginType.Name}' contains an input parameter named 'Target' but it's type is not 'Entity' or 'EntityReference'.");
                }
            }
        }
Ejemplo n.º 10
0
 public abstract void Validate(DynamicsPluginConfiguration configuration, DynamicsPluginServices services);
Ejemplo n.º 11
0
 internal DynamicsPlugin(Type type, string unsecure = null, string secure = null)
 {
     Configuration = new DynamicsPluginConfiguration(type, unsecure, secure);
 }