ReportVisual IReportVisualService.GetReportVisual(ReportSearchCriteria reportSearchCriteria) { var iReportVisualService = this as IReportVisualService; var root = iReportVisualService.GetReportFolderTreeRoot(reportSearchCriteria); ReportVisual matchingReportVisual = null; var id = reportSearchCriteria.ReportId; root.Walk((node, depth) => { var currentFolderReports = node.Data.Reports; if (!currentFolderReports.Any()) { return; } foreach (var report in currentFolderReports) { if (id == report.Id || id == report.ParentId) { matchingReportVisual = report; return; } } }); return(matchingReportVisual); }
private static IReportVisual Merge(ITableauReportVisual tableauReportVisual, ReportMetaData reportMetaData) { Requires.NonNull(reportMetaData.ReportDetails.Description, nameof(reportMetaData.ReportDetails.Description)); const string siteIdKey = "SiteId"; var metadataWorkbookName = reportMetaData.ReportDetails.Parameters?.SingleOrDefault(x => x.Key == nameof(tableauReportVisual.WorkbookName)).Value ?? tableauReportVisual.WorkbookName; var metadataWorkbookId = reportMetaData.ReportDetails.Parameters?.SingleOrDefault( x => x.Key == nameof(tableauReportVisual.WorkbookId)).Value ?? tableauReportVisual.WorkbookId; var metadataViewId = reportMetaData.ReportDetails.Parameters?.SingleOrDefault(x => x.Key == nameof(tableauReportVisual.Id)) .Value ?? tableauReportVisual.Id; var metadataViewName = reportMetaData.ReportDetails.Parameters?.SingleOrDefault( x => x.Key == nameof(tableauReportVisual.ViewName)).Value ?? tableauReportVisual.ViewName; var metadataWorksheetName = reportMetaData.ReportDetails.Parameters?.SingleOrDefault( x => x.Key == nameof(tableauReportVisual.WorksheetName)).Value; var workbookName = new KeyValuePair <string, string>(nameof(tableauReportVisual.WorkbookName), metadataWorkbookName); var workbookId = new KeyValuePair <string, string>(nameof(tableauReportVisual.WorkbookId), metadataWorkbookId); var viewId = new KeyValuePair <string, string>(nameof(tableauReportVisual.Id), metadataViewId); var viewName = new KeyValuePair <string, string>(nameof(tableauReportVisual.ViewName), metadataViewName); var worksheetName = new KeyValuePair <string, string>(nameof(tableauReportVisual.WorksheetName), metadataWorksheetName); var siteId = new KeyValuePair <string, string>(siteIdKey, reportMetaData.TenantId.ToString()); var parameters = new Collection <KeyValuePair <string, string> > { workbookName, workbookId, viewId, viewName, siteId, worksheetName }; var visual = new ReportVisual(); ((IReportVisual)visual).CanExport = reportMetaData.ReportDetails.CanExport; ((IReportVisual)visual).ContainsPhi = reportMetaData.ReportDetails.ContainsPhi; ((IReportVisual)visual).Description = reportMetaData.ReportDetails.Description ?? "No description available"; ((IReportVisual)visual).ExternalReportKey = tableauReportVisual.Id; ((IReportVisual)visual).Favorite = reportMetaData.ReportDetails.Favorite; ((IReportVisual)visual).FolderPath = reportMetaData.ReportDetails.FolderPath ?? "/"; ((IReportVisual)visual).Id = reportMetaData.ReportMetaDataId; ((IReportVisual)visual).LastEdit = reportMetaData.ReportDetails.LastEdit; ((IReportVisual)visual).LastEditedField = reportMetaData.ReportDetails.LastEditedField; ((IReportVisual)visual).OwnerContactId = reportMetaData.OwnerContactId; ((IReportVisual)visual).Parameters = parameters; ((IReportVisual)visual).ParentId = reportMetaData.ParentReportMetaDataId; ((IReportVisual)visual).PreviewImageUrl = reportMetaData.ReportDetails.PreviewImageUrl ?? $"/Reporting/PreviewImage/{tableauReportVisual.WorkbookId}/{tableauReportVisual.Id}"; ((IReportVisual)visual).Shared = reportMetaData.ReportDetails.Shared; ((IReportVisual)visual).Tags = reportMetaData.ReportDetails.Tags; ((IReportVisual)visual).Title = reportMetaData.ReportDetails.Title ?? tableauReportVisual.ViewName; ((IReportVisual)visual).VisualContext = reportMetaData.ReportDetails.VisualContext; ((IReportVisual)visual).RenderingAttributes = reportMetaData.ReportDetails.RenderingAttributes; return(visual); }