protected override DTSExecResult ValidateCore(ITaskValidateContext context)
        {
            //Validate the connection
            var cm = context.Connections.TryGetConnection(ServerConnection);

            if (cm == null)
            {
                context.Events.LogError("Server connection could not be found.");
                return(DTSExecResult.Failure);
            }
            ;

            //Validate report path
            if (String.IsNullOrWhiteSpace(ReportPath))
            {
                context.Events.LogError("Report Path is required.");
                return(DTSExecResult.Failure);
            }
            ;

            //Validate report format
            if (String.IsNullOrWhiteSpace(ReportFormat))
            {
                context.Events.LogError("Report Format is required.");
                return(DTSExecResult.Failure);
            }
            ;

            //Validate the content
            if (!String.IsNullOrWhiteSpace(Content))
            {
                //Get the variable
                var variable = context.Variables.TryGetInfo(Content);
                if (variable == null)
                {
                    context.Events.LogError("Content variable does not exist.");
                    return(DTSExecResult.Failure);
                }
                ;

                //Must be an object
                if (variable.DataType != TypeCode.Object)
                {
                    context.Events.LogError("Content must be of type Object.");
                    return(DTSExecResult.Failure);
                }
                ;

                //Must be writable
                if (variable.ReadOnly)
                {
                    context.Events.LogError("Content must be writable.");
                    return(DTSExecResult.Failure);
                }
                ;
            }
            ;

            return(base.ValidateCore(context));
        }
示例#2
0
 /// <summary>Validates the task.</summary>
 /// <param name="context">The context.</param>
 /// <remarks>
 /// The method is wrapped in an exception handler to prevent unhandled exceptions from boiling up to the runtime.
 /// <para/>
 /// The default implementation calls the base implementation.
 /// </remarks>
 protected virtual DTSExecResult ValidateCore(ITaskValidateContext context)
 {
     return(base.Validate(context.Connections, context.Variables, context.Events, context.Log));
 }