Beispiel #1
0
        private bool RunValidationCheck(Configuration configuration, IConfigurationValidation validator, string name, ref int row, IConfigurationErrorProcesser errorProcesser)
        {
            bool isValid = true;

            try
            {
                validator.Validate(configuration, ConfigurationTrace.Start(configuration), errorProcesser);
            }
            catch (Exception error)
            {
                var message = string.Format("Internal validation failed for {0}: {1}",
                            name,
                            error.Message);
                HtmlAttribute rowClass = new HtmlAttribute("class", (row % 2) == 1 ? "even" : "odd");
                myBodyEl.AppendChild(
                    GenerateElement("div",
                        rowClass,
                        GenerateElement("div",
                        new HtmlAttribute("class", "error"),
                        message)));
                LogMessage(message);
                isValid = false;
                row++;
            }
            return isValid;
        }
Beispiel #2
0
        private object ValidateElement(HtmlElement tableEl, XmlNode node, int row, Configuration configuration)
        {
            HtmlAttribute rowClass = new HtmlAttribute("class", (row % 2) == 1 ? "even" : "odd");
            object loadedItem = null;
            try
            {
                loadedItem = myConfigReader.Read(node);
                this.configurationHierarchy.Add(loadedItem);
                if (loadedItem is IProject)
                {
                    IProject project = loadedItem as IProject;
                    configuration.AddProject(project);
                    tableEl.AppendChild(
                        GenerateElement("tr",
                            rowClass,
                            GenerateElement("td", project.Name),
                            GenerateElement("td", "Project"),
                            GenerateElement("td", "Yes")));
                    LogMessage(string.Format("Loaded project '{0}'", project.Name));
                }
                else if (loadedItem is IQueueConfiguration)
                {
                    IQueueConfiguration queueConfig = loadedItem as IQueueConfiguration;
                    configuration.QueueConfigurations.Add(queueConfig);
                    tableEl.AppendChild(
                        GenerateElement("tr",
                            rowClass,
                            GenerateElement("td", queueConfig.Name),
                            GenerateElement("td", "Queue"),
                            GenerateElement("td", "Yes")));
                    LogMessage(string.Format("Loaded queue '{0}'", queueConfig.Name));
                }
                else if (loadedItem is ISecurityManager)
                {
                    ISecurityManager securityManager = loadedItem as ISecurityManager;
                    configuration.SecurityManager = securityManager as ISecurityManager;
                    LogMessage("Loaded security manager");
                }
                else
                {
                    tableEl.AppendChild(
                        GenerateElement("tr",
                            rowClass,
                            GenerateElement("td", (node as XmlElement).GetAttribute("name")),
                            GenerateElement("td", node.Name),
                            GenerateElement("td", "No")));
                    var message = "Unknown configuration type: " + loadedItem.GetType().Name;
                    tableEl.AppendChild(
                        GenerateElement("tr",
                            rowClass,
                            GenerateElement("td",
                                new HtmlAttribute("colspan", "3"),
                                GenerateElement("div",
                                    new HtmlAttribute("class", "error"),
                                    message))));
                    LogMessage(message);
                    isConfigValid = false;
                }
            }
            catch (Exception error)
            {
                string errorMsg = error.Message;
                int index = errorMsg.IndexOf("Xml Source");
                if (index >= 0) errorMsg = errorMsg.Substring(0, index - 1);
                tableEl.AppendChild(
                    GenerateElement("tr",
                        rowClass,
                        GenerateElement("td", (node as XmlElement).GetAttribute("name")),
                        GenerateElement("td", node.Name),
                        GenerateElement("td", "No")));
                tableEl.AppendChild(
                    GenerateElement("tr",
                        rowClass,
                        GenerateElement("td",
                            new HtmlAttribute("colspan", "3"),
                            GenerateElement("div",
                                new HtmlAttribute("class", "error"),
                                errorMsg))));
                isConfigValid = false;
                LogMessage(error.Message);
            }

            return loadedItem;
        }
Beispiel #3
0
        private object ValidateElement(HtmlElement tableEl, XmlNode node, int row, Configuration configuration)
        {
            HtmlAttribute rowClass   = new HtmlAttribute("class", (row % 2) == 1 ? "even" : "odd");
            object        loadedItem = null;

            try
            {
                loadedItem = myConfigReader.Read(node);
                this.configurationHierarchy.Add(loadedItem);
                if (loadedItem is IProject)
                {
                    IProject project = loadedItem as IProject;
                    configuration.AddProject(project);
                    tableEl.AppendChild(
                        GenerateElement("tr",
                                        rowClass,
                                        GenerateElement("td", project.Name),
                                        GenerateElement("td", "Project"),
                                        GenerateElement("td", "Yes")));
                    LogMessage(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Loaded project '{0}'", project.Name));
                }
                else if (loadedItem is IQueueConfiguration)
                {
                    IQueueConfiguration queueConfig = loadedItem as IQueueConfiguration;
                    configuration.QueueConfigurations.Add(queueConfig);
                    tableEl.AppendChild(
                        GenerateElement("tr",
                                        rowClass,
                                        GenerateElement("td", queueConfig.Name),
                                        GenerateElement("td", "Queue"),
                                        GenerateElement("td", "Yes")));
                    LogMessage(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Loaded queue '{0}'", queueConfig.Name));
                }
                else if (loadedItem is ISecurityManager)
                {
                    ISecurityManager securityManager = loadedItem as ISecurityManager;
                    configuration.SecurityManager = securityManager as ISecurityManager;
                    LogMessage("Loaded security manager");
                }
                else
                {
                    tableEl.AppendChild(
                        GenerateElement("tr",
                                        rowClass,
                                        GenerateElement("td", (node as XmlElement).GetAttribute("name")),
                                        GenerateElement("td", node.Name),
                                        GenerateElement("td", "No")));
                    var message = "Unknown configuration type: " + loadedItem.GetType().Name;
                    tableEl.AppendChild(
                        GenerateElement("tr",
                                        rowClass,
                                        GenerateElement("td",
                                                        new HtmlAttribute("colspan", "3"),
                                                        GenerateElement("div",
                                                                        new HtmlAttribute("class", "error"),
                                                                        message))));
                    LogMessage(message);
                    isConfigValid = false;
                }
            }
            catch (Exception error)
            {
                string errorMsg = error.Message;
                int    index    = errorMsg.IndexOf("Xml Source");
                if (index >= 0)
                {
                    errorMsg = errorMsg.Substring(0, index - 1);
                }
                tableEl.AppendChild(
                    GenerateElement("tr",
                                    rowClass,
                                    GenerateElement("td", (node as XmlElement).GetAttribute("name")),
                                    GenerateElement("td", node.Name),
                                    GenerateElement("td", "No")));
                tableEl.AppendChild(
                    GenerateElement("tr",
                                    rowClass,
                                    GenerateElement("td",
                                                    new HtmlAttribute("colspan", "3"),
                                                    GenerateElement("div",
                                                                    new HtmlAttribute("class", "error"),
                                                                    errorMsg))));
                isConfigValid = false;
                LogMessage(error.Message);
            }

            return(loadedItem);
        }