public static ReportLayout ReadReportLayout(this PBIFile pbiFile) { var reportLayoutFile = pbiFile.ArchiveEntries .FirstOrDefault(x => x.FullName == PbiFileContents.ReportLayout); if (reportLayoutFile == null) { throw new ContentNotFoundException("Unable to read Report Layout content."); } var reader = new StreamReader(reportLayoutFile.Open(), Encoding.Unicode); var reportLayoutFileContent = reader.ReadToEnd(); if (reportLayoutFileContent == null) { throw new ContentEmptyException("Report Layout is empty"); } var options = new JsonDocumentOptions { AllowTrailingCommas = true }; var report = JsonDocument.Parse(reportLayoutFileContent, options); var reportLayout = new ReportLayout { Id = GetReportId(report.RootElement), ReportPages = GetPages(report.RootElement), Configuration = GetConfiguration(report.RootElement) }; return(reportLayout); }
public static string ReadFileVersion(this PBIFile pbiFile) { var fileVersion = string.Empty; var versionFile = pbiFile.ArchiveEntries .FirstOrDefault(x => x.FullName == PbiFileContents.Version); if (versionFile != null) { var reader = new StreamReader(versionFile.Open(), Encoding.Unicode); fileVersion = reader.ReadToEnd(); } return(fileVersion.Trim()); }
public static DiagramLayout?ReadDiagramLayout(this PBIFile pbiFile) { var layoutFile = pbiFile.ArchiveEntries .FirstOrDefault(x => x.FullName == PbiFileContents.DiagramLayout); if (layoutFile == null) { throw new ContentNotFoundException("Unavle to read Diagram Layout content."); } var reader = new StreamReader(layoutFile.Open(), Encoding.Unicode); var layoutFileContent = reader.ReadToEnd(); if (layoutFileContent == null) { throw new ContentEmptyException("Diagram Layout is empty"); } var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; return(JsonSerializer.Deserialize <DiagramLayout>(layoutFileContent, options)); }