public static void getResultGrouped(results Results, XmlWriter XWriter, params string[] Grouped) { if (Timing != null) { Timing.Start("getResultGrouped"); } try { /* * 1. organize results by grouped * 2. */ var list = new List <Grouped>(); var groupingValues = new Dictionary <string, string>(); getSubGroups(Results, list, null, 0, Grouped); list.Sort(); XWriter.WriteStartElement("results"); XWriter.WriteAttributeString("name", Results.name); XWriter.WriteAttributeString("ProjectSqlFile", Results.ProjectSqlFile); XWriter.WriteStartElement("schema"); XWriter.WriteRaw(Helper.StripXmlDecleration(Results.schema[0].Serialize())); XWriter.WriteEndElement(); XWriter.WriteStartElement("result"); if (Timing != null) { Timing.Start("writeResultsGrouped"); } writeResultsGrouped(XWriter, list); if (Timing != null) { Timing.End("writeResultsGrouped"); } XWriter.WriteEndElement(); XWriter.WriteEndElement(); } finally { Timing.End("getResultGrouped"); } }
public static void getResultGrouped_Original(results Results, XmlWriter XWriter, params string[] Grouped) { XWriter.WriteStartElement("results"); XWriter.WriteAttributeString("name", Results.name); XWriter.WriteAttributeString("ProjectSqlFile", Results.ProjectSqlFile); XWriter.WriteStartElement("schema"); XWriter.WriteRaw(Helper.StripXmlDecleration(Results.schema[0].Serialize())); XWriter.WriteEndElement(); XWriter.WriteStartElement("result"); var groupingValues = new Dictionary <string, string>(); foreach (var s in Grouped) { groupingValues.Add(s.Trim(), null); } int depth = 0; // check for differences - open element if null for (int x = 0; x < groupingValues.Count; x++) { foreach (var row in Results.result.row) { depth = x; string key = groupingValues.Keys.ElementAt(x); if (groupingValues[key] == null) { XWriter.WriteStartElement(key); XWriter.WriteAttributeString("value", row.AnyAttr.LookupValue(key)); groupingValues[key] = row.AnyAttr.LookupValue(key); continue; } if (!groupingValues[key].Equals(row.AnyAttr.LookupValue(key))) { // close elements for (int j = x; j < groupingValues.Count; j++) { XWriter.WriteEndElement(); } // open elements for (int k = x; k < groupingValues.Count; k++) { key = groupingValues.Keys.ElementAt(k); XWriter.WriteStartElement(key); XWriter.WriteAttributeString("value", row.AnyAttr.LookupValue(key)); groupingValues[key] = row.AnyAttr.LookupValue(key); } } getRowGrouped(row, XWriter); } } // close last grouping items for (int x = 0; x < groupingValues.Count; x++) { XWriter.WriteEndElement(); } XWriter.WriteEndElement(); XWriter.WriteEndElement(); }