示例#1
0
    /// <summary>
    /// Run the command
    /// </summary>
    /// <returns></returns>
    public string ExecuteRequest()
    {
        var statusLog     = _onlineSession.StatusLog;
        var workbook      = _workbook;
        var saveDirectory = _localSavePathRoot;

        if ((workbook == null) || (string.IsNullOrWhiteSpace(workbook.Id)))
        {
            statusLog.AddError("1025-851: NULL workbook. Aborting download.");
            return(null);
        }

        //Local path save the workbook
        string urlDownload = _onlineUrls.Url_WorkbookThumbnailDownload(_onlineSession, workbook);

        statusLog.AddStatus("Starting Workbook thumbnail download " + workbook.Name + " " + workbook.ToString());
        try
        {
            var fileDownloaded = this.DownloadFile(
                urlDownload,
                saveDirectory,
                workbook.Id,
                DownloadPayloadTypeHelper.CreateForImageDownload());
            var fileDownloadedNoPath = System.IO.Path.GetFileName(fileDownloaded);

            statusLog.AddStatus("Finished Workbook thumbnail download " + fileDownloadedNoPath);
            return(fileDownloaded);
        }
        catch (Exception ex)
        {
            statusLog.AddError("1025-1035: Error during Workbook thumbnial download " + workbook.Name + "\r\n  " + urlDownload + "\r\n  " + ex.ToString());
            return(null); //Thumbnail not downloaded
        }
    }