Exemplo n.º 1
0
        public void BuildRuleControlList(RESOClientSettings settings)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(settings.GetSetting(RESOClientLibrary.settings.rulescontrolfile));

            //XmlNode node = doc.DocumentElement.SelectSingleNode("/rulescontrol");
            RuleControl record = null;

            foreach (XmlNode node in doc.DocumentElement.ChildNodes)
            {
                if (node.HasChildNodes)
                {
                    foreach (XmlNode childnode in node)
                    {
                        string name  = childnode.Name;
                        string value = childnode.InnerText;
                        if (name == "rulename")
                        {
                            if (record != null)
                            {
                                rulecontrol[value] = record;
                            }
                            record          = new RuleControl();
                            record.rulename = value;
                        }
                        if (name == "notes")
                        {
                            record.notes = value;
                        }
                        if (name == "cert_tr")
                        {
                            record.cert_tr = value;
                        }
                        if (name == "cert_impact")
                        {
                            record.cert_impact = value;
                        }
                        if (name == "ttt_testing_results")
                        {
                            record.ttt_testing_results = value;
                        }
                        if (name == "category")
                        {
                            record.category = value;
                        }
                    }
                }
                //string text = node.InnerXml;
                //string json = JsonConvert.SerializeXmlNode(node);
                //RuleControl record = JsonConvert.DeserializeObject<RuleControl>(json);
            }
        }
Exemplo n.º 2
0
 protected override void AddData(string filename, string[] columns, int row)
 {
     if (row > 0)
     {
         if (rulecontrollist[columns[6] as string] == null)
         {
             RuleControl rule = new RuleControl();
             rule.notes                  = columns[0] as string;
             rule.cert_tr                = columns[1] as string;
             rule.cert_impact            = columns[2] as string;
             rule.ttt_testing_results    = columns[3] as string;
             rule.parameters             = columns[4] as string;
             rule.category               = columns[5] as string;
             rule.rulename               = columns[6] as string;
             rulecontrollist[columns[6]] = rule;
         }
     }
 }
Exemplo n.º 3
0
        protected override void FinalizeData()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<rulecontrols>\r\n");
            foreach (DictionaryEntry item in rulecontrollist)
            {
                string key = item.Key as string;
                //key = key.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
                RuleControl   value  = item.Value as RuleControl;
                StringBuilder record = new StringBuilder();
                record.Append("<rulecontrol>\r\n");
                record.Append("<rulename>" + value.rulename + "</rulename >\r\n");
                record.Append("<notes>" + value.notes + "</notes >\r\n");
                record.Append("<cert_tr>" + value.cert_tr + "</cert_tr >\r\n");
                record.Append("<cert_impact>" + value.cert_impact + "</cert_impact >\r\n");
                record.Append("<ttt_testing_results>" + value.ttt_testing_results + "</ttt_testing_results >\r\n");
                record.Append("<category>" + value.category + "</category >\r\n");

                record.Append("</rulecontrol>\r\n");
                sb.Append(record.ToString());
            }

            sb.Append("</rulecontrols>\r\n");

            if (File.Exists(outputpath + "\rulecontrol.xml"))
            {
                File.Delete(outputpath + "\rulecontrol.xml");
            }

            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(outputpath + "\\rulecontrol.xml", false))
            {
                file.WriteLine(sb.ToString());
            }
        }