FetchFileAsync() public method

Gets the data for a given blob from R-Host. Saves the data to filePath. This method adds the blob for clean up by default.
public FetchFileAsync ( IRBlobInfo blob, string filePath, bool doCleanUp, IProgress progress, CancellationToken cancellationToken ) : Task
blob IRBlobInfo Blob from which the data is to be retrieved.
filePath string Path to the file where the retrieved data will be written.
doCleanUp bool true to add blob upon transfer for cleanup on dispose, false to ignore it after transfer.
progress IProgress
cancellationToken System.Threading.CancellationToken
return Task
Exemplo n.º 1
0
 private async Task RMarkdownRenderAsync(IRSession session, IFileSystem fs, string inputFilePath, string outputFilePath, string format, int codePage, IApplicationShell appShell) {
     using (var fts = new DataTransferSession(session, fs)) {
         string currentStatusText = string.Empty;
         uint cookie = 0;
         IVsStatusbar statusBar = null;
         appShell.DispatchOnUIThread(() => {
             statusBar = appShell.GetGlobalService<IVsStatusbar>(typeof(SVsStatusbar));
             statusBar.GetText(out currentStatusText);
             statusBar.Progress(ref cookie, 1, "", 0, 0);
         });
         
         try {
             // TODO: progress and cancellation handling
             appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownSendingInputFile.FormatInvariant(Path.GetFileName(inputFilePath)), 0, 3); });
             var rmd = await fts.SendFileAsync(inputFilePath, true, null, CancellationToken.None);
             appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishingFile.FormatInvariant(Path.GetFileName(inputFilePath)), 1, 3); });
             var publishResult = await session.EvaluateAsync<ulong>($"rtvs:::rmarkdown_publish(blob_id = {rmd.Id}, output_format = {format.ToRStringLiteral()}, encoding = 'cp{codePage}')", REvaluationKind.Normal);
             appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownGetOutputFile.FormatInvariant(Path.GetFileName(outputFilePath)), 2, 3); });
             await fts.FetchFileAsync(new RBlobInfo(publishResult), outputFilePath, true, null, CancellationToken.None);
             appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishComplete.FormatInvariant(Path.GetFileName(outputFilePath)), 3, 3); });
         } finally {
             appShell.DispatchOnUIThread(() => {
                 statusBar?.Progress(ref cookie, 0, "", 0, 0);
                 statusBar?.SetText(currentStatusText);
             });
         }
     }
 }
Exemplo n.º 2
0
 private async Task ExportAsync(string outputFilePath, Task<ulong> exportTask) {
     try {
         var result = await exportTask;
         using(DataTransferSession dts = new DataTransferSession(InteractiveWorkflow.RSession, _fileSystem)) {
             // TODO: add progress indication and cancellation
             await dts.FetchFileAsync(new RBlobInfo(result), outputFilePath, true, null, CancellationToken.None);
         }
     } catch (IOException ex) {
         throw new RPlotManagerException(ex.Message, ex);
     } catch (RException ex) {
         throw new RPlotManagerException(string.Format(CultureInfo.InvariantCulture, Resources.Plots_EvalError, ex.Message), ex);
     }
 }