public override BugDictionary CreateBugs(string xmlfile, Progress progress) { #region Pre Condition Debug.Assert(xmlfile != null); #if DEBUG System.Console.WriteLine("CreateBugs(" + xmlfile + ")"); #endif #endregion BugDictionary bugs = new BugDictionary(); XmlDocument doc = new XmlDocument(); doc.XmlResolver = null; // Prevents it from searching for the bugzilla dtd (incase it is not accessible. doc.Load(xmlfile); foreach (XmlNode node in doc.SelectNodes("/bugzilla/bug")) { Bug bug = new Bug(); bug.Id = int.Parse(node.SelectNodes("bug_id")[0].InnerText); bug.Status = node.SelectNodes("bug_status")[0].InnerText; if (null != node.SelectNodes("resolution")[0]) { bug.Resolution = node.SelectNodes("resolution")[0].InnerText; } if (null != node.SelectNodes("target_milestone")[0]) { bug.Milestone = node.SelectNodes("target_milestone")[0].InnerText; } if (null != node.SelectNodes("rep_platform")[0]) { bug.Platform = node.SelectNodes("rep_platform")[0].InnerText; } if (null != node.SelectNodes("keywords")[0]) { bug.Keywords = node.SelectNodes("keywords")[0].InnerText; } if (null != node.SelectNodes("op_sys")[0]) { bug.OS = node.SelectNodes("op_sys")[0].InnerText; } if (null != node.SelectNodes("qa_contact")[0]) { bug.QAContact = node.SelectNodes("qa_contact")[0].InnerText; } bug.Summary = node.SelectNodes("short_desc")[0].InnerText; bug.Owner = node.SelectNodes("assigned_to")[0].Attributes[0].InnerText; bug.Priority = node.SelectNodes("priority")[0].InnerText; bug.CreationDate = node.SelectNodes("creation_ts")[0].InnerText; bug.Severity = node.SelectNodes("bug_severity")[0].InnerText; bug.Product = node.SelectNodes("product")[0].InnerText; bug.Component = node.SelectNodes("component")[0].InnerText; bug.Version = node.SelectNodes("version")[0].InnerText; bug.Reporter = node.SelectNodes("reporter")[0].InnerText; #region Actual Time, Estimated Time, Remaining Time if (node.SelectNodes("actual_time").Count > 0) { bug.ActualTime = Convert.ToDouble(node.SelectNodes("actual_time")[0].InnerText); } else { bug.ActualTime = Convert.ToDouble(Config.GetSystem("DefaultBugDuration")); } if (node.SelectNodes("estimated_time").Count > 0) { bug.OriginalTimeEstimate = Convert.ToDouble(node.SelectNodes("estimated_time")[0].InnerText); } else { bug.OriginalTimeEstimate = Convert.ToDouble(Config.GetSystem("DefaultBugDuration")); } if (node.SelectNodes("remaining_time").Count > 0) { bug.RemainingTime = Convert.ToDouble(node.SelectNodes("remaining_time")[0].InnerText); } else { bug.RemainingTime = Convert.ToDouble(Config.GetSystem("DefaultBugDuration")); } #endregion foreach (XmlNode depNode in node.SelectNodes("dependson")) { bug.DependsOn.Add(Convert.ToInt32(depNode.InnerText)); } foreach (XmlNode depNode in node.SelectNodes("blocked")) { bug.Blocks.Add(Convert.ToInt32(depNode.InnerText)); } bugs.Add(bug.Id, bug); if (null != progress) { progress.UpdateProgress(1, "Reading " + bug.Id + " from " + xmlfile + "."); } } #region Post Condition Debug.Assert(bugs != null); #endregion return(bugs); }
public override BugDictionary CreateBugs(string csvfile, Progress progress) { Dictionary <int, string> Headers; DataTable csvTable; BugDictionary bugs; Bug bug; #region Pre Condition Debug.Assert("" != csvfile); #endregion Headers = new Dictionary <int, string>(); csvTable = CSVParse(csvfile); bugs = new BugDictionary(); #region Header // Use the header row to make a map of where stuff goes //string[] csvHeaders = csvTable[0]; int index = 0; foreach (string header in csvTable.Rows[0].ItemArray) { Headers.Add(index, header); index++; } #endregion #region Verification // Write code to ensure that we have enough of the fields #endregion #region Data Row Parse DataRow row; for (int i = 1; i < csvTable.Rows.Count; i++) { row = csvTable.Rows[i]; bug = new Bug(); for (int j = 0; j < row.ItemArray.Length; j++) { if (Headers.ContainsKey(j) && (null != row.ItemArray[j]) && (false == (row.ItemArray[j] is System.DBNull)) && (null != row.ItemArray[j]) && ("" != (string)row.ItemArray[j])) { CSVBugPopulate(bug, Headers[j], (string)row.ItemArray[j]); } } // This deals with the case of null rows at the end. if (0 != bug.Id) { bugs.Add(bug.Id, bug); } if (null != progress) { progress.UpdateProgress(1, "Reading " + bug.Id + " from " + csvfile + "."); } } #endregion #region Post Condition foreach (KeyValuePair <int, Bug> kvp in bugs) { bug = ((Bug)kvp.Value); Debug.Assert(0 != bug.Id); Debug.Assert((null != bug.Summary) && ("" != bug.Summary)); } #endregion return(bugs); }