public void FromXML(string xml) { XmlDocument root = new XmlDocument(); root.LoadXml(xml); XmlNode projectNode = root.DocumentElement.SelectSingleNode("Project"); this.Project = projectNode.InnerText; XmlNode statusNode = root.DocumentElement.SelectSingleNode("Status"); this.Status = statusNode.InnerText; XmlNode files = root.DocumentElement.SelectSingleNode("Files"); foreach (XmlNode node in files.ChildNodes) { ReportFile item = new ReportFile(); item.FromXML(node); this.Files.Add(item); } }
private List<ReportFile> GetFiles() { List<ReportFile> reportFiles = new List<ReportFile>(); for (int index = 0; index < this.Request.Files.Count; index++) { HttpPostedFileBase file = Request.Files[index] as HttpPostedFileBase; if (file == null || file.ContentLength == 0) continue; ReportFile reportFile = new ReportFile(); reportFile.Guid = Guid.NewGuid().ToString(); string mimeType = Request.Files[index].ContentType; Stream fileStream = Request.Files[index].InputStream; reportFile.FileName = Path.GetFileName(Request.Files[index].FileName); int fileLength = Request.Files[index].ContentLength; byte[] fileData = new byte[fileLength]; fileStream.Read(fileData, 0, fileLength); fileStream.Close(); reportFiles.Add(reportFile); } return reportFiles; }