public static EnsureProjectBasedPath ( string basePath, IProjectsList projectList, IHasProjectId project, TaskStatusLogs, statusLog ) : string | ||
basePath | string | |
projectList | IProjectsList | |
project | IHasProjectId | |
statusLog | TaskStatusLogs, | |
return | string |
/// <summary> /// /// </summary> /// <param name="serverName"></param> public List <SiteDatasource> ExecuteRequest() { var downloadedContent = new List <SiteDatasource>(); //Depending on the HTTP download file type we want different file extensions var typeMapper = new DownloadPayloadTypeHelper("tdsx", "tds"); var datasources = Datasources; if (datasources == null) { Login.Logger.Error("NULL datasources. Aborting download."); return(null); } //For each datasource, download it and save it to the local file system foreach (var dsInfo in datasources) { //Local path save the workbook string urlDownload = Urls.Url_DatasourceDownload(Login, dsInfo); Login.Logger.Information("Starting Datasource download " + dsInfo.Name); try { //Generate the directory name we want to download into var pathToSaveTo = FileIOHelper.EnsureProjectBasedPath( LocalSavePath, DownloadToProjectDirectories, dsInfo, Login.Logger); var fileDownloaded = this.DownloadFile(urlDownload, pathToSaveTo, dsInfo.Name, typeMapper); var fileDownloadedNoPath = System.IO.Path.GetFileName(fileDownloaded); Login.Logger.Information("Finished Datasource download " + fileDownloadedNoPath); //Add to the list of our downloaded data sources if (!string.IsNullOrEmpty(fileDownloaded)) { downloadedContent.Add(dsInfo); //Generate the metadata file that has additional server provided information about the workbook if (GenerateInfoFile) { Helpers.DatasourcePublishSettings.CreateSettingsFile(dsInfo, fileDownloaded, SiteUserLookup); } } else { //We should never hit this code; just being defensive Login.Logger.Error("Download error, no local file path for downloaded content"); } } catch (Exception ex) { Login.Logger.Error("Error during Datasource download " + dsInfo.Name + "\r\n " + urlDownload + "\r\n " + ex.ToString()); } } //Return the set of successfully downloaded content return(downloadedContent); }
/// <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 the REST API call for a list of data sources /// </summary> public List <SiteDatasource> ExecuteRequest() { var statusLog = OnlineSession.StatusLog; var downloadedContent = new List <SiteDatasource>(); //Depending on the HTTP download file type we want different file extensions var typeMapper = new DownloadPayloadTypeHelper("tdsx", "tds"); var datasources = _datasources; if (datasources == null) { statusLog.AddError("NULL datasources. Aborting download."); return(null); } //For each datasource, download it and save it to the local file system foreach (var dsInfo in datasources) { //Local path save the workbook string urlDownload = _onlineUrls.Url_DatasourceDownload(OnlineSession, dsInfo); statusLog.AddStatus("Starting Datasource download " + dsInfo.Name); try { //Generate the directory name we want to download into var pathToSaveTo = FileIOHelper.EnsureProjectBasedPath( _localSavePath, _downloadToProjectDirectories, dsInfo, this.StatusLog); var fileDownloaded = this.DownloadFile(urlDownload, pathToSaveTo, dsInfo.Name, typeMapper); var fileDownloadedNoPath = System.IO.Path.GetFileName(fileDownloaded); statusLog.AddStatus("Finished Datasource download " + fileDownloadedNoPath); //Add to the list of our downloaded data sources if (!string.IsNullOrEmpty(fileDownloaded)) { downloadedContent.Add(dsInfo); } 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 Datasource download " + dsInfo.Name + "\r\n " + urlDownload + "\r\n " + ex.ToString()); } } //foreach //Return the set of successfully downloaded content 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); }