TableauServerUrls.Url_WorkbookDownload C# (CSharp) Method

Url_WorkbookDownload() public method

URL to download a workbook
public Url_WorkbookDownload ( TableauServerSignIn, session, SiteWorkbook, contentInfo ) : string
session TableauServerSignIn,
contentInfo SiteWorkbook,
return string
    public string Url_WorkbookDownload(TableauServerSignIn session, SiteWorkbook contentInfo)
    {
        string workingText = _urlDownloadWorkbookTemplate;
        workingText = workingText.Replace("{{iwsSiteId}}", session.SiteId);
        workingText = workingText.Replace("{{iwsRepositoryId}}", contentInfo.Id);

        ValidateTemplateReplaceComplete(workingText);
        return workingText;
    }

Usage Example

    /// <summary>
    ///
    /// </summary>
    /// <param name="serverName"></param>
    public ICollection <SiteWorkbook> ExecuteRequest()
    {
        var statusLog         = _onlineSession.StatusLog;
        var downloadedContent = new List <SiteWorkbook>();

        var workbooks = _workbooks;

        if (workbooks == null)
        {
            statusLog.AddError("NULL workbooks. Aborting download.");
            return(null);
        }

        //Depending on the HTTP download file type we want different file extensions
        var typeMapper = new DownloadPayloadTypeHelper("twbx", "twb");

        foreach (var contentInfo in workbooks)
        {
            //Local path save the workbook
            string urlDownload = _onlineUrls.Url_WorkbookDownload(_onlineSession, contentInfo);
            statusLog.AddStatus("Starting Workbook download " + contentInfo.Name + " " + contentInfo.ToString());
            try
            {
                //Generate the directory name we want to download into
                var pathToSaveTo = FileIOHelper.EnsureProjectBasedPath(
                    _localSavePath,
                    _downloadToProjectDirectories,
                    contentInfo,
                    this.StatusLog);

                var fileDownloaded       = this.DownloadFile(urlDownload, pathToSaveTo, contentInfo.Name, typeMapper);
                var fileDownloadedNoPath = System.IO.Path.GetFileName(fileDownloaded);
                statusLog.AddStatus("Finished Workbook download " + fileDownloadedNoPath);

                //Add to the list of our downloaded workbooks, and save metadata
                if (!string.IsNullOrWhiteSpace(fileDownloaded))
                {
                    downloadedContent.Add(contentInfo);

                    //Generate the metadata file that has additional server provided information about the workbook
                    if (_generateInfoFile)
                    {
                        WorkbookPublishSettings.CreateSettingsFile(contentInfo, fileDownloaded, _siteUserLookup);
                    }
                }
                else
                {
                    //We should never hit this code; just being defensive
                    statusLog.AddError("Download error, no local file path for downloaded content");
                }
            }
            catch (Exception ex)
            {
                statusLog.AddError("Error during Workbook download " + contentInfo.Name + "\r\n  " + urlDownload + "\r\n  " + ex.ToString());
            }
        } //foreach

        return(downloadedContent);
    }
All Usage Examples Of TableauServerUrls::Url_WorkbookDownload