public byte[] GetReportDefinition(string reportPath) { if (string.IsNullOrEmpty(reportPath)) { throw new ArgumentException("reportPath"); } this.mLogger.Debug("GetReportDefinition - reportPath = {0}", reportPath); byte[] def = this.mReportingService.GetReportDefinition(reportPath); string reportDefinition = SSRSUtil.ByteArrayToString(def); if (reportDefinition.Substring(0, 1) != "<") { reportDefinition = reportDefinition.Substring(1, reportDefinition.Length - 1); } def = SSRSUtil.StringToByteArray(reportDefinition); //this.mLogger.Debug("GetReportDefinition - Definition = {0}", reportDefinition); return(def); }
public List <ReportItem> GetSubReports(string reportDefinition) { if (string.IsNullOrEmpty(reportDefinition)) { throw new ArgumentException("reportDefinition"); } List <ReportItem> subReports = new List <ReportItem>(); XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; if (reportDefinition.Substring(0, 1) != "<") { reportDefinition = reportDefinition.Substring(1, reportDefinition.Length - 1); } doc.LoadXml(reportDefinition); XmlNodeList subReportNodes = doc.GetElementsByTagName("Subreport"); foreach (XmlNode node in subReportNodes) { foreach (XmlNode nameNode in node.ChildNodes) { if (nameNode.Name == "ReportName") { string subReportPath = nameNode.InnerText; int subReportNameIndex = subReportPath.LastIndexOf('/') + 1; CatalogItem subReportItem = this.GetItem( subReportPath.Substring(subReportNameIndex, subReportPath.Length - subReportNameIndex), subReportPath, ItemTypeEnum.Report); if (subReportItem != null) { byte[] def = this.GetReportDefinition(subReportItem.Path); ReportItem subReport = this.mDataMapper.GetReport(subReportItem); subReport.Definition = def; string subReportDefinition = SSRSUtil.ByteArrayToString(subReport.Definition); List <ReportItem> subReportsInner = this.GetSubReports(subReportDefinition); foreach (ReportItem subReportInner in subReportsInner) { if (!subReports.Contains(subReportInner)) { subReports.Add(subReportInner); } } if (!subReports.Contains(subReport)) { subReports.Add(subReport); continue; } } } } } return(subReports); }