public CreatePdfOptions(ITableauReportVisual reportVisual, int pixelWidth = 1024,
                         int pixelHeight = 768)
 {
     Requires.NonNull(reportVisual.WorkbookName, nameof(reportVisual.WorkbookName));
     Requires.NonNull(reportVisual.ViewName, nameof(reportVisual.ViewName));
     Requires.NonNull(reportVisual.WorksheetName, nameof(reportVisual.WorksheetName));
     WorkbookName  = reportVisual.WorkbookName;
     ViewName      = reportVisual.ViewName;
     WorksheetName = reportVisual.WorksheetName;
     PixelWidth    = pixelWidth;
     PixelHeight   = pixelHeight;
 }
Example #2
0
        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);
        }