public BugReport BugDetails(string id, string file) { BugReport bug = new BugReport(); BugReport bug1 = new BugReport(); try { XDocument doc = XDocument.Load(file); var query = from row in doc.Elements("BugReport").Elements("Bug") select row; foreach (var q in query) { bug.BugId = q.Element("BugId").Value.ToString(); if (bug.BugId == id) { bug1.BugId = q.Element("BugId").Value.ToString(); bug1.BugWorkPacId = q.Element("BugWorkPack").Value.ToString(); bug1.BugTitle = q.Element("BugTitle").Value.ToString(); bug1.BugDate = q.Element("BugDate").Value.ToString(); bug1.BugIssue = q.Element("BugIssue").Value.ToString(); bug1.BugResolution = q.Element("BugResolution").Value.ToString(); } } } catch { return null; } return bug1; }
public IEnumerable<BugReport> Fill(string path) { try { XDocument doc = XDocument.Load(path); var query = from row in doc.Elements("BugReport").Elements("Bug") select row; foreach (var ent in query) { BugReport bug = new BugReport(); bug.BugId = ent.Element("BugId").Value.ToString(); bug.BugWorkPacId = ent.Element("BugWorkPack").Value.ToString(); bug.BugTitle = ent.Element("BugTitle").Value.ToString(); bug.BugDate = ent.Element("BugDate").Value.ToString(); bug.BugIssue = ent.Element("BugIssue").Value.ToString(); bug.BugResolution = ent.Element("BugResolution").Value.ToString(); BugReports.Add(bug); } } catch { return null; } return BugReports; }
public List<string> LoadBugId() { BugReport bug = new BugReport(); List<string> list = new List<string>(); try { HttpContext context = HttpContext.Current; string Path = context.Server.MapPath("~\\App_Data\\XMLFile1.xml"); XDocument doc = XDocument.Load(Path); var query = from row in doc.Elements("BugReport").Elements("Bug") select row; foreach (var elem in query) { bug.BugId = elem.Element("BugId").Value; list.Add(bug.BugId); } } catch (Exception) { return null; } return list; }