예제 #1
0
    /// <summary>
    /// Run the command
    /// </summary>
    /// <returns></returns>
    public string ExecuteRequest()
    {
        var    statusLog     = _onlineSession.StatusLog;
        var    workbook      = _workbook;
        string viewId        = _viewId;
        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_WorkbookViewThumbnailDownload(_onlineSession, workbook, viewId);

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

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