public Url_WorkbookDownload ( TableauServerSignIn, session, SiteWorkbook, contentInfo ) : string | ||
session | TableauServerSignIn, | |
contentInfo | SiteWorkbook, | |
return | string |
/// <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); }
/// <summary> /// Execute request for Workbooks /// </summary> public ICollection <SiteWorkbook> ExecuteRequest() { var statusLog = OnlineSession.StatusLog; var downloadedContent = new List <SiteWorkbook>(); if (_workbook == null) { statusLog.AddError("NULL workbook. Aborting download."); return(null); } //Depending on the HTTP download file type we want different file extensions var typeMapper = new DownloadPayloadTypeHelper("twbx", "twb"); //Local path save the workbook string urlDownload = _onlineUrls.Url_WorkbookDownload(OnlineSession, _workbook); statusLog.AddStatus("Starting Workbook download " + _workbook.Name + " " + _workbook.ToString()); try { //Generate the directory name we want to download into var pathToSaveTo = FileIOHelper.EnsureProjectBasedPath(_localSavePath, _workbook, StatusLog); var fileDownloaded = DownloadFile(urlDownload, pathToSaveTo, _workbook.Name, typeMapper); var fileDownloadedNoPath = System.IO.Path.GetFileName(fileDownloaded); statusLog.AddStatus("Finished Workbook download " + fileDownloadedNoPath); //Add to the list of our downloaded data sources if (!string.IsNullOrWhiteSpace(fileDownloaded)) { downloadedContent.Add(_workbook); } 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 " + _workbook.Name + "\r\n " + urlDownload + "\r\n " + ex.ToString()); } return(downloadedContent); }