private static void PopulateElementAttributes(PageMapping file, IEnumerable <XElement> rootElements) { foreach (var rootElement in rootElements) { rootElement.Add(new XAttribute("dataFileId", file.DataFileId)); rootElement.Add(new XAttribute("pageId", file.PageId)); rootElement.Add(new XAttribute("placeholderName", file.PlaceholderName)); rootElement.Add(new XAttribute("pageTemplateName", file.PageTemplateName)); rootElement.Add(new XAttribute("label", file.Label)); rootElement.Add(new XAttribute("nodeId", file.NodeId)); rootElement.Add(new XAttribute("url", file.NamePath)); } }
private string GetFileContent(PageMapping row) { var getFileClient = CreateClient(); var downloadDirectory = GetDownloadDirectory(); var filePath = Path.Combine(downloadDirectory, $"{row.DataFileId}.xml"); string xml; if (File.Exists(filePath)) { _logger.Debug($"Reading file from cache: {filePath}"); xml = File.ReadAllText(filePath); } else { _logger.Debug($"Downloading file to cache: {filePath}"); var file = getFileClient.GetFileByID(row.PageId, null, new IdcProperty[] { }); xml = StripByteOrderMark(Encoding.UTF8.GetString(file.downloadFile.fileContent)); File.WriteAllText(filePath, xml); } return(xml); }