public void AppendFile(UsenetFile file) { XmlNode fileNode = xmlDoc.CreateElement("file"); XmlAttribute posterAttribute = xmlDoc.CreateAttribute("poster"); posterAttribute.Value = file.Poster; fileNode.Attributes.Append(posterAttribute); XmlAttribute dateAttribute = xmlDoc.CreateAttribute("date"); DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); dateAttribute.Value = (Math.Round((DateTime.Now - dtDateTime).TotalSeconds)).ToString(); fileNode.Attributes.Append(dateAttribute); XmlAttribute subjectAttribute = xmlDoc.CreateAttribute("subject"); subjectAttribute.Value = file.Subject; fileNode.Attributes.Append(subjectAttribute); appendGroups(fileNode, file.Groups); appendSegments(fileNode, file); rootNode.AppendChild(fileNode); }
private void appendSegments(XmlNode node, UsenetFile file) { XmlNode segmentsNode = xmlDoc.CreateElement("segments"); int cnt = 1; foreach (UsenetSegment t in file.Segments) { XmlNode segmentNode = xmlDoc.CreateElement("segment"); XmlAttribute bytesAttribute = xmlDoc.CreateAttribute("bytes"); bytesAttribute.Value = t.Size.ToString(); segmentNode.Attributes.Append(bytesAttribute); XmlAttribute numberAttribute = xmlDoc.CreateAttribute("number"); numberAttribute.Value = cnt.ToString(); segmentNode.Attributes.Append(numberAttribute); cnt++; segmentNode.InnerText = t.MessageId; segmentsNode.AppendChild(segmentNode); } node.AppendChild(segmentsNode); }