Пример #1
0
        /// <summary>
        /// Construct each SubResult node and return Xml string.
        /// </summary>
        /// <returns></returns>
        public string OutputPerfResults()
        {
            string innerxml = null;

            // Based on Targets order listed in ErrorCodes.xml construct the Xml
            for (int i = 0; i < TargetsToList.Count; i++)
            {
                string targetname         = TargetsToList[i].ToString().ToLowerInvariant();
                IDictionaryEnumerator ide = subresults.GetEnumerator();
                while (ide.MoveNext())
                {
                    PerfSubResult perfsubresult = (PerfSubResult)ide.Value;
                    // Check targetname specified in ErrorCodes.xml with current targetname.
                    if (perfsubresult.SubResultName.ToLowerInvariant().Contains(targetname))
                    {
                        if (targetname.Contains(ReportNode.ToLowerInvariant()))
                        {
                            perfsubresult.ProjectFileName = this.projectname;
                            innerxml += perfsubresult.GetSubResultXml(bmainprojectfile);
                        }
                        else
                        {
                            innerxml += perfsubresult.GetSubResultXml(false);
                        }
                        break;
                    }
                }
            }

            return(innerxml);
        }
Пример #2
0
        /// <summary>
        /// Sets subresult node in Perf schema.
        /// </summary>
        /// <param name="subresultname"></param>
        /// <param name="subresultelapsedtime"></param>
        internal void SetSubResult(string subresultname, int subresultelapsedtime)
        {
            if (subresults == null)
            {
                subresults = new Hashtable();
            }

            PerfSubResult subresult;

            if (subresults.Count > 0 && subresults[subresultname] != null)
            {
                subresult = (PerfSubResult)subresults[subresultname];
                subresults.Remove(subresultname);
                subresult.SubResultTime = subresultelapsedtime;
                subresults.Add(subresultname, subresult);
            }
            else
            {
                subresult = new PerfSubResult();
                subresult.Initialize();
                subresult.SubResultName = subresultname;
                subresult.SubResultTime = subresultelapsedtime;
                subresults.Add(subresultname, subresult);
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="xmldatafile"></param>
        public bool ReadPerfResultsFromFile(string xmldatafile)
        {
            if (String.IsNullOrEmpty(xmldatafile))
            {
                return(false);
            }

            FileStreamSW fs = new FileStreamSW(xmldatafile, System.IO.FileMode.Open);

            if (fs.Length == 0)
            {
                fs.Close();
                return(false);
            }
            fs.Close();

            XmlDocumentSW xmldoc = new XmlDocumentSW();

            xmldoc.Load(xmldatafile);

            XmlNode subresultnode = xmldoc.CreateElement(Constants.PerfSubResultElement);

            XmlAttribute attrib = xmldoc.CreateAttribute("NAME");

            string mainprojectfilename = null;

            for (int i = 0; i < xmldoc.DocumentElement.ChildNodes.Count; i++)
            {
                if (xmldoc.DocumentElement.ChildNodes[i].Name == PerfDatumElement)
                {
                    subresultnode.InnerXml += xmldoc.DocumentElement.ChildNodes[i].OuterXml;
                }

                if (xmldoc.DocumentElement.ChildNodes[i].NodeType == XmlNodeType.Comment)
                {
                    mainprojectfilename = xmldoc.DocumentElement.ChildNodes[i].Value;
                    attrib.Value        = "(" + ReportNode + ")";
                }
            }

            subresultnode.Attributes.Append(attrib);

            PerfSubResult psr = new PerfSubResult();

            psr.ReadSubResult(subresultnode);

            subresults = new Hashtable();
            subresults.Add(mainprojectfilename + psr.SubResultName, psr);

            XmlNodeList subresultslist = xmldoc.DocumentElement.GetElementsByTagName(Constants.PerfSubResultElement);

            if (subresultslist.Count == 0)
            {
                return(false);
            }

            List <string> projectslist = new List <string>();

            for (int i = 0; i < subresultslist.Count; i++)
            {
                psr = new PerfSubResult();
                if (psr.ReadSubResult(subresultslist[i]))
                {
                    subresults.Add(psr.SubResultName, psr);
                    if (projectslist.Contains(psr.ProjectFileName) == false)
                    {
                        projectslist.Add(psr.ProjectFileName);
                    }
                }
                psr = null;
            }

            perfresultslist = new Hashtable(projectslist.Count);

            for (int i = 0; i < projectslist.Count; i++)
            {
                PerfResult pr = new PerfResult();
                pr.projectname = projectslist[i];
                if (projectslist[i] == mainprojectfilename)
                {
                    bmainprojectfile = true;
                }

                IDictionaryEnumerator ide = subresults.GetEnumerator();
                while (ide.MoveNext())
                {
                    if (ide.Key.ToString().StartsWith(pr.projectname))
                    {
                        if (pr.subresults == null)
                        {
                            pr.subresults = new Hashtable();
                        }

                        pr.subresults.Add(ide.Key, ide.Value);
                    }
                }

                perfresultslist.Add(pr.projectname, pr);
            }

            return(true);
        }