Ejemplo n.º 1
0
        private async Task SendProjectAsync(EnvDTE.Project project, string remotePath, string filterString)
        {
            ProgressOutputWriter.WriteLine("Preparing to transfer project.");

            var projectDir  = Path.GetDirectoryName(project.FullName);
            var projectName = Path.GetFileNameWithoutExtension(project.FullName);

            string[] filterSplitter = { ";" };
            Matcher  matcher        = new Matcher(StringComparison.InvariantCultureIgnoreCase);

            matcher.AddIncludePatterns(filterString.Split(filterSplitter, StringSplitOptions.RemoveEmptyEntries));

            ProgressOutputWriter.WriteLine($"Remote destination: {remotePath}");
            ProgressOutputWriter.WriteLine($"File filter applied: {filterString}");
            ProgressOutputWriter.WriteLine("Compressing project files for transfer: ");

            var compressedFilePath = FileSystem.CompressDirectory(projectDir, matcher, new Progress <string>((p) => {
                ProgressOutputWriter.WriteLine($"Compressing: {p}");
            }), CancellationToken.None);

            using (var fts = new FileTransferSession(Session, FileSystem)) {
                ProgressOutputWriter.Write("Transferring project to remote host...");
                var remoteFile = await fts.SendFileAsync(compressedFilePath);

                await Session.EvaluateAsync <string>($"rtvs:::save_to_project_folder({remoteFile.Id}, {projectName.ToRStringLiteral()}, '{remotePath.ToRPath()}')", REvaluationKind.Normal);
            }

            ProgressOutputWriter.WriteLine(" done.");
        }
Ejemplo n.º 2
0
        private async Task RMarkdownRenderAsync(IRSession session, IFileSystem fs, string inputFilePath, string outputFilePath, string format, int codePage)
        {
            using (var fts = new FileTransferSession(session, fs)) {
                var rmd = await fts.SendFileAsync(inputFilePath);

                var publishResult = await session.EvaluateAsync <byte[]>($"rtvs:::rmarkdown_publish(blob_id = {rmd.Id}, output_format = {format.ToRStringLiteral()}, encoding = 'cp{codePage}')", REvaluationKind.Normal);

                File.WriteAllBytes(outputFilePath, publishResult);
            }
        }