Esempio n. 1
0
        private static void ProcessTests(ref Audit currentAudit, XmlNodeList auditTests)
        {
            int nodeCount = 0;
            int counter = 0;

            counter = auditTests.Count;

            for (nodeCount = 0; nodeCount < counter; nodeCount++)
            {
                var newTest = new AuditTest();

                XmlNode columnNode = auditTests[nodeCount];

                newTest.ColumnName = columnNode["column"].InnerText;
                newTest.Operator = columnNode["operator"].InnerText;
                newTest.Criteria = columnNode["criteria"].InnerText;
                newTest.WhereClause = newTest.ColumnName + " " + newTest.Operator + " " + newTest.Criteria;
                newTest.TestReturnedRows = Convert.ToBoolean(columnNode["testreturnedrows"].InnerText);
                newTest.UseCriteria = Convert.ToBoolean(columnNode["usecriteria"].InnerText);

                if (newTest.Criteria.ToUpper() == "COUNTROWS")
                {
                    newTest.RowCount = Convert.ToInt32(columnNode["rowcount"].InnerText);
                }

                newTest.FailIfConditionIsTrue = Convert.ToBoolean(columnNode["failiftrue"].InnerText);

                var xmlElement = columnNode["instructions"];
                if (xmlElement != null)
                {
                newTest.Instructions = columnNode["instructions"].InnerText;
                }

                xmlElement = columnNode["sendReport"];
                if (xmlElement != null)
                {
                    newTest.SendReport = Convert.ToBoolean(columnNode["sendReport"].InnerText);
                }

                xmlElement = columnNode["multipleResults"];
                if (xmlElement != null)
                {
                    newTest.MultipleResults = Convert.ToBoolean(columnNode["multipleResults"].InnerText);

                    if (newTest.MultipleResults)
                    {
                        xmlElement = columnNode["tableNames"];
                        if (xmlElement != null)
                        {
                            int tableCount;

                            string[] stringSeparators = new[] {"::"};
                            var tableCounter = xmlElement.InnerText.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);

                            for (tableCount = 0; tableCount < tableCounter.Length; tableCount++)
                            {
                                newTest.TableNames.Add(tableCounter[tableCount]);
                            }
                        }
                    }
                }

                xmlElement = columnNode["reportTemplate"];
                if (xmlElement != null)
                {
                    string templateName = columnNode["reportTemplate"].InnerText;

                    EmailTableTemplate currTemplate = TableTemplates.FirstOrDefault(t => t.Name.ToLower() == templateName.ToLower());

                    newTest.TemplateColorScheme = currTemplate;
                }
                else
                {
                    newTest.TemplateColorScheme = AuditUtils.GetDefaultTemplate();
                }

                currentAudit.Tests.Add(newTest);
            }
        }
 /// <summary>
 /// Inserts the specified index.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="item">The item.</param>
 public void Insert(int index, AuditTest item)
 {
     List.Insert(index, item);
 }
 /// <summary>
 /// Adds the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>System.Int32.</returns>
 public int Add(AuditTest item)
 {
     return List.Add(item);
 }
 /// <summary>
 /// Determines whether [contains] [the specified item].
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns><c>true</c> if [contains] [the specified item]; otherwise, <c>false</c>.</returns>
 public bool Contains(AuditTest item)
 {
     return List.Contains(item);
 }
 /// <summary>
 /// Removes the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Remove(AuditTest item)
 {
     List.Remove(item);
 }