Beispiel #1
0
        private async Task ConnectAsync(CancellationToken ct)
        {
            var provider = _services.GetService <IRInteractiveWorkflowProvider>();

            _workflow = provider.GetOrCreate();
            _ui       = _services.GetService <IHostUIService>();
            _ui.SetLogLevel(MessageType.Info);

            var e = GetREngine();

            if (e == null)
            {
                return;
            }

            var log   = _services.Log();
            var info  = BrokerConnectionInfo.Create("(local)", e.InstallPath, e.Architecture, string.Empty);
            var start = DateTime.Now;

            _ui.LogMessageAsync($"Starting R Process with {e.InstallPath}...", MessageType.Info).DoNotWait();

            try {
                if (await _workflow.RSessions.TrySwitchBrokerAsync("(local)", info, ct))
                {
                    try {
                        await _workflow.RSession.StartHostAsync(new RHostStartupInfo(), new RSessionCallback(), _services.UI(), Debugger.IsAttached? 1000000 : 20000, ct);
                    } catch (Exception ex) {
                        _ui.ShowMessageAsync($"Unable to start Microsoft.R.Host process. Exception: {ex.Message}", MessageType.Error).DoNotWait();
                        return;
                    }

                    // Start package building
                    _ui.LogMessageAsync($"complete in {FormatElapsed(DateTime.Now - start)}", MessageType.Info).DoNotWait();
                    start = DateTime.Now;
                    _ui.LogMessageAsync("Building IntelliSense index...", MessageType.Info).DoNotWait();

                    _packageIndex = _services.GetService <IPackageIndex>();
                    _packageIndex.BuildIndexAsync(ct).ContinueWith(t => {
                        _ui.LogMessageAsync($"complete in {FormatElapsed(DateTime.Now - start)}", MessageType.Info).DoNotWait();
                    }, ct, TaskContinuationOptions.None, TaskScheduler.Default).DoNotWait();
                }
                else
                {
                    _ui.ShowMessageAsync($"Unable to connect to broker.", MessageType.Error).DoNotWait();
                }
            } catch (Exception ex) {
                _ui.ShowMessageAsync($"Unable to connect to broker. Exception: {ex.Message}", MessageType.Error).DoNotWait();
            }
        }
Beispiel #2
0
        private async Task ConnectAsync(CancellationToken ct)
        {
            var provider = _services.GetService <IRInteractiveWorkflowProvider>();

            _workflow = provider.GetOrCreate();
            _ui       = _services.GetService <IUIService>();
            _ui.SetLogLevel(MessageType.Info);

            var e = GetREngine();

            if (e == null)
            {
                return;
            }

            var log  = _services.Log();
            var info = BrokerConnectionInfo.Create(_services.Security(), "VSCR", e.InstallPath, string.Empty, false);

            var start   = DateTime.Now;
            var message = $"Starting R Process with {e.InstallPath}...";

            _ui.LogMessageAsync(message, MessageType.Info).DoNotWait();

            log.Write(LogVerbosity.Normal, MessageCategory.General, $"Switching local broker to {e.InstallPath}");
            if (await _workflow.RSessions.TrySwitchBrokerAsync("VSCR", info, ct))
            {
                try {
                    await _workflow.RSession.StartHostAsync(new RHostStartupInfo(), new RSessionCallback(), Debugger.IsAttached? 100000 : 20000, ct);
                } catch (Exception ex) {
                    _ui.ShowMessageAsync($"Unable to start R process. Exception: {ex.Message}", MessageType.Error).DoNotWait();
                    return;
                }

                // Start package building
                _ui.LogMessageAsync($"complete in {FormatElapsed(DateTime.Now - start)}", MessageType.Info).DoNotWait();
                start = DateTime.Now;
                _ui.LogMessageAsync("Building IntelliSense index...", MessageType.Info).DoNotWait();

                _packageIndex = _services.GetService <IPackageIndex>();
                _packageIndex.BuildIndexAsync(ct).ContinueWith(t => {
                    _ui.LogMessageAsync($"complete in {FormatElapsed(DateTime.Now - start)}", MessageType.Info).DoNotWait();
                }, ct, TaskContinuationOptions.None, TaskScheduler.Default).DoNotWait();
            }
            else
            {
                _ui.ShowMessageAsync("Unable to start R process", MessageType.Error).DoNotWait();
            }
        }
Beispiel #3
0
 private void BuildFunctionIndex()
 {
     _packageIndex = VsAppShell.Current.ExportProvider.GetExportedValue <IPackageIndex>();
     _packageIndex.BuildIndexAsync().DoNotWait();
 }
Beispiel #4
0
 public static Task InitializeAsync(this IPackageIndex packageIndex, IFunctionIndex functionIndex)
 {
     RToolsSettings.Current = new TestRToolsSettings();
     return(packageIndex.BuildIndexAsync());
 }
Beispiel #5
0
        public async Task InitializeAsync()
        {
            await _workflow.RSessions.TrySwitchBrokerAsync(GetType().Name);

            await _packageIndex.BuildIndexAsync();
        }