示例#1
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var parentProject = parent.GetAncestorValue <Project>();

            if (parentProject != null)
            {
                // Attempt to find this publisher in the publishers section
                var isPublisher = false;
                foreach (var task in parentProject.Publishers)
                {
                    if (task == this)
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // If not found then throw a validation exception
                if (!isPublisher)
                {
                    errorProcesser.ProcessWarning(
                        "Email publishers are best placed in the publishers section of the configuration");
                }
            }
            else
            {
                errorProcesser.ProcessError(new CruiseControlException("This publisher can only belong to a project"));
            }

            // Make sure the xslFiles are not empty
            if (this.xslFiles != null && this.XslFiles.Any(f => string.IsNullOrEmpty(f)))
            {
                errorProcesser.ProcessError("xslFiles cannot contain empty or null filenames");
            }
        }
        /// <summary>
        /// Validates this task.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="parent"></param>
        /// <param name="errorProcesser"></param>
        public override void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            base.Validate(configuration, parent, errorProcesser);
            var project = parent.GetAncestorValue <Project>();

            if (project != null)
            {
                // Check if this task is set in the publishers section
                var isPublisher = false;
                foreach (var publisher in project.Publishers)
                {
                    if (object.ReferenceEquals(publisher, this))
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // Display a warning
                if (isPublisher)
                {
                    errorProcesser.ProcessWarning("Putting the parallel task in the publishers section may cause unpredictable results");
                }
            }
        }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            // Get the name of the executable
            var canCheck = true;
            var fileName = this.GetProcessFilename().Trim();

            if (!Path.IsPathRooted(fileName))
            {
                var project = parent.GetAncestorValue <Project>();
                if (project != null)
                {
                    var result    = ConfigurationValidationUtils.GenerateResultForProject(project);
                    var directory = this.GetProcessBaseDirectory(result);
                    fileName = Path.Combine(directory, fileName);
                }
                else
                {
                    // Can't generate the path, therefore can't check for the file
                    canCheck = false;
                }
            }

            // See if it exists - shortcut the process if there is an exact match (the remainder uses pattern matching to try and find the file)
            if (canCheck && !this.IOSystemActual.FileExists(fileName))
            {
                var fileExists = false;

                // This needs to be from the filename, just in case the path is a relative path and it has been joined to the base directory
                var directory = Path.GetDirectoryName(fileName);
                if (this.IOSystemActual.DirectoryExists(directory))
                {
                    // Get all the files and check each file
                    var files           = this.IOSystemActual.GetFilesInDirectory(directory);
                    var executableName1 = Path.GetFileNameWithoutExtension(fileName);
                    var executableName2 = Path.GetFileName(fileName);
                    foreach (var file in files)
                    {
                        // Strip the extension so we can compare partial file names (since Windows does not need the .exe extension)
                        var fileToTest = Path.GetFileNameWithoutExtension(file);

                        // Need to perform two checks here as some Windows names have two multiple dots - therefore GetFileNameWithoutExtension will strip the last part,
                        // whether or not it is an extension
                        if (string.Equals(fileToTest, executableName1, StringComparison.InvariantCultureIgnoreCase) ||
                            string.Equals(fileToTest, executableName2, StringComparison.InvariantCultureIgnoreCase))
                        {
                            fileExists = true;
                            break;
                        }
                    }
                }

                if (!fileExists)
                {
                    errorProcesser.ProcessWarning("Unable to find executable '" + fileName + "'");
                }
            }
        }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            // Get the name of the executable
            var canCheck = true;
            var fileName = this.GetProcessFilename();
            if (!Path.IsPathRooted(fileName))
            {
                var project = parent.GetAncestorValue<Project>();
                if (project != null)
                {
                    var result = ConfigurationValidationUtils.GenerateResultForProject(project);
                    var directory = this.GetProcessBaseDirectory(result);
                    fileName = Path.Combine(directory, fileName);
                }
                else
                {
                    // Can't generate the path, therefore can't check for the file
                    canCheck = false;
                }
            }

            // See if it exists - shortcut the process if there is an exact match (the remainder uses pattern matching to try and find the file)
            if (canCheck && !this.IOSystemActual.FileExists(fileName))
            {
                var fileExists = false;

                // This needs to be from the filename, just in case the path is a relative path and it has been joined to the base directory
                var directory = Path.GetDirectoryName(fileName);
                if (this.IOSystemActual.DirectoryExists(directory))
                {
                    // Get all the files and check each file
                    var files = this.IOSystemActual.GetFilesInDirectory(directory);
                    var executableName1 = Path.GetFileNameWithoutExtension(fileName);
                    var executableName2 = Path.GetFileName(fileName);
                    foreach (var file in files)
                    {
                        // Strip the extension so we can compare partial file names (since Windows does not need the .exe extension)
                        var fileToTest = Path.GetFileNameWithoutExtension(file);

                        // Need to perform two checks here as some Windows names have two multiple dots - therefore GetFileNameWithoutExtension will strip the last part,
                        // whether or not it is an extension
                        if (string.Equals(fileToTest, executableName1, StringComparison.InvariantCultureIgnoreCase) ||
                            string.Equals(fileToTest, executableName2, StringComparison.InvariantCultureIgnoreCase))
                        {
                            fileExists = true;
                            break;
                        }
                    }
                }

                if (!fileExists)
                {
                    errorProcesser.ProcessWarning("Unable to find executable '" + fileName + "'");
                }
            }
        }
        void IConfigurationValidation.Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            string projectName = "(Unknown)";

            var project = parent.GetAncestorValue <Project>();

            if (project != null)
            {
                projectName = project.Name;
            }

            if (integrationTime.Minutes + RandomOffSetInMinutesFromTime >= 60)
            {
                errorProcesser.ProcessError("Scheduled time {0}:{1} + randomOffSetInMinutesFromTime {2} would exceed the hour, this is not allowed. Conflicting project {3}", integrationTime.Hours, integrationTime.Minutes, RandomOffSetInMinutesFromTime, projectName);
            }
        }
示例#6
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var parentProject = parent.GetAncestorValue<Project>();
            if (parentProject != null)
            {
                // Attempt to find this publisher in the publishers section
                var isPublisher = false;
                foreach (var task in parentProject.Publishers)
                {
                    if (task == this)
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // If not found then throw a validation exception
                if (!isPublisher)
                {
                    errorProcesser.ProcessWarning("Email publishers are best placed in the publishers section of the configuration");
                }
            }
            else
            {
                errorProcesser.ProcessError(
                    new CruiseControlException("This publisher can only belong to a project"));
            }
        }
示例#7
0
        /// <summary>
        /// Validates this task.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="parent"></param>
        /// <param name="errorProcesser"></param>
        public override void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            base.Validate(configuration, parent, errorProcesser);
            var project = parent.GetAncestorValue<Project>();

            if (project != null)
            {
                // Check if this task is set in the publishers section
                var isPublisher = false;
                foreach (var publisher in project.Publishers)
                {
                    if (object.ReferenceEquals(publisher, this))
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // Display a warning
                if (isPublisher)
                {
                    errorProcesser.ProcessWarning("Putting the parallel task in the publishers section may cause unpredictable results");
                }
            }
        }
        void IConfigurationValidation.Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            string projectName = "(Unknown)";

            var project = parent.GetAncestorValue<Project>();
            if (project != null)
            {
                projectName = project.Name;
            }

            if (integrationTime.Minutes + RandomOffSetInMinutesFromTime >= 60)
            {
                errorProcesser.ProcessError("Scheduled time {0}:{1} + randomOffSetInMinutesFromTime {2} would exceed the hour, this is not allowed. Conflicting project {3}", integrationTime.Hours, integrationTime.Minutes, RandomOffSetInMinutesFromTime, projectName);
            }
        }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var parentProject = parent.GetAncestorValue<Project>();
            if (parentProject != null)
            {
                // Attempt to find this publisher in the publishers section
                var isPublisher = false;
                foreach (var task in parentProject.Publishers)
                {
                    if (task == this)
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // If not found then throw a validation exception
                if (!isPublisher)
                {
                    errorProcesser.ProcessWarning(
                        "Email publishers are best placed in the publishers section of the configuration");
                }
            }
            else
            {
                errorProcesser.ProcessError(new CruiseControlException("This publisher can only belong to a project"));
            }

            // Make sure the xslFiles are not empty
            if (this.xslFiles != null &&  this.XslFiles.Any(f => string.IsNullOrEmpty(f)))
            {
                errorProcesser.ProcessError("xslFiles cannot contain empty or null filenames");
            }
        }