/// <summary>
        /// fill the table for the improvable categories 
        /// </summary>
        /// <param name="caNumber">index number of the categorie eg. 1. Bildaufbau</param>
        /// <param name="rowCount">Number of the row which has to fill</param>
        /// <param name="table2">table to fill</param>
        /// <param name="ca">category to check</param>
        private void addImprovableCategoriesToTable(int caNumber, ref  int rowCount, ref XTextTable table2, Category ca)
        {            
            bool lastRowColSpan2 = false;
            int crNumber = 1;
            bool CategoryHeaderWasMade = false;

            //WriterDoc.AppendNewStyledTextParagraphAndGetTextRange(caNumber +". "+ ca.Name, WriterDocument.ParaStyleName.HEADING);
            foreach (Criterion cr in ca.Criteria)
            {


                if (cr.Res.resultType == ResultType.passwithwarning)
                {
                    if (CategoryHeaderWasMade == false)
                    {
                        WriterDocument.AddRowToTable(ref table2);
                        rowCount++;
                        WriterDocument.DoColSpan(ref table2, "A" + rowCount, 3);
                        lastRowColSpan2 = true;
                        SetCellCriterionTextValue(ref table2, "A" + rowCount, caNumber + "." + ca.Name);
                        CategoryHeaderWasMade = true;
                    }

                    if (lastRowColSpan2 == true)
                    {
                        WriterDocument.AddRowToTable(ref table2, 1, -1, 4);
                        FillColWithText(ref table2, ++rowCount, cr, crNumber, caNumber);
                        lastRowColSpan2 = false;
                    }
                    else
                    {
                        WriterDocument.AddRowToTable(ref table2);
                        FillColWithText(ref table2, ++rowCount, cr, crNumber, caNumber);
                    }


                }
                crNumber++;
            }
        }
예제 #2
0
        /// <summary>
        /// Parses the specified criteria catalog at the given path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public static List<Category> Parse(string path)
        {

            List<Category> categories = new List<Category>();
            Dictionary<String, Category> catDict = new Dictionary<string, Category>();

            if (!System.IO.File.Exists(path)) return categories;

            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(path);

                XmlNodeList nodes = xDoc.DocumentElement.SelectNodes("category");


                foreach (XmlNode node in nodes)
                {
                    if (node == null) continue;
                    Category ca = new Category();
                    List<Criterion> crlist = new List<Criterion>();
                    XmlNodeList criterions = node.SelectNodes("criterion");

                    foreach (XmlNode node2 in criterions)
                    {
                        if (node2 == null) continue;

                        Recommendation rec = new Recommendation();

                        var helpNode7 = node2.SelectSingleNode("recommendation");
                        if (helpNode7 != null)
                        {
                            var helpNode8 = helpNode7.Attributes["type"];
                            CriterionType type = CriterionType.unknown;
                            if (helpNode8 != null)
                            {
                                try
                                {
                                    if (Enum.IsDefined(typeof(CriterionType), helpNode8.Value))
                                    {
                                        type = (CriterionType)Enum.Parse(typeof(CriterionType), helpNode8.Value);

                                    }
                                }
                                catch { }
                                rec.Type = type;
                            }
                        }
                        Criterion cr = new Criterion(rec);

                        var helpNode = node2.SelectSingleNode("help");
                        if (helpNode != null)
                        {
                            cr.Help = helpNode.InnerText;
                        }

                        var helpNode2 = node2.Attributes["name"];
                        if (helpNode2 != null)
                        {
                            cr.Name = helpNode2.Value;
                        }

                        var helpNode3 = node2.Attributes["id"];
                        if (helpNode3 != null)
                        {
                            cr.Id = helpNode3.Value;
                        }

                        var helpNode4 = node2.Attributes["mode"];
                        if (helpNode4 != null)
                        {
                            cr.Mode = helpNode4.Value;
                        }

                        var helpNode5 = node2.Attributes["priority"];
                        if (helpNode5 != null)
                        {
                            cr.Priority = Convert.ToInt32(helpNode5.Value);
                        }
                        var helpNode6 = node2.Attributes["relation"];
                        if (helpNode6 != null)
                        {
                            cr.Relation = helpNode6.Value;
                        }


                        var helpNode0 = node2.SelectSingleNode("desc");
                        if (helpNode0 != null)
                        {
                            cr.Desc = helpNode0.InnerText;

                        }

                        XmlNodeList items = node2.SelectSingleNode("recommendation").SelectNodes("item");
                        foreach (XmlNode node3 in items)
                        {

                            if (node3 == null) continue;

                            Item i = new Item();
                            var helpNode30 = node3.Attributes["role"];
                            if (helpNode30 != null)
                            {
                                i.Role = helpNode30.Value;
                                if (helpNode30.Value == "rating")
                                {
                                    cr.Rec.Type = CriterionType.rating;

                                }

                            }

                            var helpNode9 = node3.SelectSingleNode("desc");
                            if (helpNode9 != null)
                            {
                                i.Desc = helpNode9.InnerText;
                            }

                            XmlNodeList vars = node3.SelectNodes("var");
                            if (vars.Count == 0)
                            {
                                cr.Rec.Items.Add(i);

                            }
                            else
                            {
                                foreach (XmlNode var in vars)
                                {
                                    Variable v = new Variable();


                                    var helpNode10 = var.Attributes["name"];
                                    if (helpNode10 != null)
                                    {
                                        v.Name = helpNode10.Value;
                                    }

                                    var helpNode11 = var.Attributes["max"];
                                    if (helpNode11 != null)
                                    {
                                        v.Max = helpNode11.Value;
                                    }

                                    var helpNode12 = var.Attributes["min"];
                                    if (helpNode12 != null)
                                    {
                                        v.Min = helpNode12.Value;
                                    }

                                    var helpNode13 = var.Attributes["value"];
                                    if (helpNode13 != null)
                                    {
                                        v.Value = helpNode13.Value;
                                    }

                                    var helpNode14 = var.Attributes["media"];
                                    if (helpNode14 != null)
                                    {
                                        if (helpNode14.Value.Equals("all")) v.MediaType = MediaType.All;
                                        if (helpNode14.Value.Equals("Tiger")) v.MediaType = MediaType.Tiger;
                                        if (helpNode14.Value.Equals("Schwellpapier")) v.MediaType = MediaType.Schwellpapier;
                                    }
                                    //System.Console.WriteLine(v.Value + v.Max + v.Min);
                                    i.Var.Add(v);
                                    //TODO: IS not the best solution because when a item has more then one variable, it will repeatedly added
                                    

                                }
                                cr.Rec.Items.Add(i);
                            }
                        }
                        
                        //System.Console.WriteLine(cr.Id);
                        //System.Console.WriteLine(cr.Priority);
                        cr.CA = ca;
                        cr.setResult();
                        crlist.Add(cr);
                    }

                    var helpNode33 = node.Attributes["name"];
                    if (helpNode33 != null)
                    {
                        ca.Name = helpNode33.Value;
                    }

                    var helpNode15 = node.Attributes["id"];
                    if (helpNode15 != null)
                    {
                        ca.Id = helpNode15.Value;
                    }

                    var helpNode16 = node.SelectSingleNode("desc");
                    if (helpNode16 != null)
                    {
                        ca.Desc = helpNode16.InnerText;
                    }

                    var helpNode17 = node.SelectSingleNode("help");
                    if (helpNode17 != null)
                    {
                        ca.Help = helpNode17.InnerText;
                    }

                    ca.Criteria = crlist;
                    categories.Add(ca);
                    catDict.Add(ca.Id, ca);

                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception in criteria parsing:\r\n" + ex);
            }

            AllCategories = categories;
            AllCategoriesDict = catDict;
            return categories;
        }
예제 #3
0
        internal void createRequirementResult(Category ca, bool pass)
        {

            XmlElement result = earl.CreateElement("earl", "TestResult", nsmgr.LookupNamespace("earl"));
            result.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            result.SetAttribute("ID", "result_" + ca.Id);
            root.AppendChild(result);

           

            switch (pass)
            {
                case true:
                    XmlElement passed = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
                    passed.AppendChild(earl.CreateTextNode("Die Kategorie: " + ca.Name.Normalize() + " wurde erfüllt"));
                    result.AppendChild(passed);

                    XmlElement earlOutcomePass = earl.CreateElement("earl", "outcome", nsmgr.LookupNamespace("earl"));
                    earlOutcomePass.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    earlOutcomePass.SetAttribute("resource", "http://www.w3.org/ns/earl#passed");
                    result.AppendChild(earlOutcomePass);
                    break;

                case false:
                    XmlElement fail = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
                    fail.AppendChild(earl.CreateTextNode("Die Kategorie: " + ca.Name.Normalize() + " wurde nicht erfüllt"));
                    result.AppendChild(fail);

                    XmlElement earlOutcomeFail = earl.CreateElement("earl", "outcome", nsmgr.LookupNamespace("earl"));
                    earlOutcomeFail.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    earlOutcomeFail.SetAttribute("resource", "http://www.w3.org/ns/earl#failed");
                    result.AppendChild(earlOutcomeFail);
                    break;
            }

            createAssertionCategorie(ca, result);

        }
예제 #4
0
        private void createAssertionCategorie(Category ca, XmlElement result)
        {

            XmlElement test = earl.CreateElement("earl", "Assertion", nsmgr.LookupNamespace("earl"));
            test.SetAttributeNode("about", nsmgr.LookupNamespace("rdf"));
            test.SetAttribute("about", "finalassertion_" + ca.Id);
            root.AppendChild(test);

            XmlElement tester = earl.CreateElement("earl", "assertedBy", nsmgr.LookupNamespace("earl"));
            tester.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
            tester.SetAttribute("resource","#"+ group.GetAttribute("ID", nsmgr.LookupNamespace("rdf")));
            test.AppendChild(tester);

            XmlElement subject = earl.CreateElement("earl", "subject", nsmgr.LookupNamespace("earl"));
            subject.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
            subject.SetAttribute("resource","#"+ testsubject.GetAttribute("ID", nsmgr.LookupNamespace("rdf")));
            test.AppendChild(subject);

            XmlElement test1 = earl.CreateElement("earl", "test", nsmgr.LookupNamespace("earl"));
            test1.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
            test1.SetAttribute("resource", baseUri + "#" + ca.Id);
            test.AppendChild(test1);

            XmlElement res = earl.CreateElement("earl", "result", nsmgr.LookupNamespace("earl"));
            res.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
            res.SetAttribute("resource","#"+ result.GetAttribute("ID", nsmgr.LookupNamespace("rdf")));
            test.AppendChild(res);
           
        }
            //if (actwarningCount > 0)
            //{
            //    ca.resultType = ResultType.passwithwarning;
            //}
            //if (actErrorCount > 0)
            //{
            //    ca.resultType = ResultType.fail;
            //}
            //else
            //{
            //    ca.resultType = ResultType.pass;
            //}
            public void createCategoryResult(Category ca)
            {
            bool pass = true;
            ResultType resulttypeCategorie = ResultType.pass;
            foreach (Criterion cr in ca.Criteria)
            {
                if (cr.Res.resultType == ResultType.fail)
                {
                    pass = false;
                    resulttypeCategorie = ResultType.fail;
                    
                    break;
                }
                if (cr.Res.resultType == ResultType.passwithwarning)
                {
                    resulttypeCategorie = ResultType.pass;
                        
                }


            }
            ca.resultType = resulttypeCategorie;
            earl.createRequirementResult(ca, pass);
        }