/// <summary> /// If it connects to remote debugger tool successfully, go to ListProcess step. /// Otherwise go to enalbe remote powershell port step that later it goes to install, start remote tool step. /// </summary> protected override async Task <IAttachDebuggerStep> GetNextStep() { SetStage(Stage.CheckingConnectivity); if (!(await Context.DebuggerPort.ConnectivityTest(CancelToken))) { return(EnablePowerShellPortStepViewModel.CreateStep(Context)); } else { return(ListProcessStepViewModel.CreateStep(Context)); } }
public override async Task <IAttachDebuggerStep> OnStartAsync() { IsCancelButtonEnabled = true; ProgressMessage = Resources.AttachDebuggerInstallSetupProgressMessage; bool installed = false; var startTimestamp = DateTime.Now; // The following try catch is for adding Analytics in failure case. try { installed = await _installer.Install(CancelToken); } catch (PowerShellFailedToConnectException) { UserPromptUtils.ErrorPrompt( message: Resources.AttachDebuggerConnectionFailedMessage, title: Resources.UiDefaultPromptTitle); } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { Debug.WriteLine($"{ex}"); UserPromptUtils.ErrorPrompt( message: Resources.AttachDebuggerInstallerError, title: Resources.UiDefaultPromptTitle, errorDetails: ex.Message); } if (installed) { EventsReporterWrapper.ReportEvent(RemoteDebuggerRemoteToolsInstalledEvent.Create( CommandStatus.Success, DateTime.Now - startTimestamp)); } else if (!CancelToken.IsCancellationRequested) { EventsReporterWrapper.ReportEvent( RemoteDebuggerRemoteToolsInstalledEvent.Create(CommandStatus.Failure)); } if (installed) { // Reset start time to measure performance of starting remote tools startTimestamp = DateTime.Now; RemoteToolSession session; // The following try catch is for adding analytics where there is exception try { session = new RemoteToolSession( Context.PublicIp, Context.Credential.User, Context.Credential.Password, GoogleCloudExtensionPackage.Instance.SubscribeClosingEvent, GoogleCloudExtensionPackage.Instance.UnsubscribeClosingEvent); } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { EventsReporterWrapper.ReportEvent( RemoteDebuggerRemoteToolsStartedEvent.Create(CommandStatus.Failure)); throw; } ProgressMessage = String.Format( Resources.AttachDebuggerTestConnectPortMessageFormat, Context.DebuggerPort.Description, Context.PublicIp, Context.DebuggerPort.PortInfo.Port); Stopwatch watch = Stopwatch.StartNew(); while (!CancelToken.IsCancellationRequested && watch.Elapsed < s_waitConnectionTimeout && !session.IsStopped) { if (await Context.DebuggerPort.ConnectivityTest(CancelToken)) { EventsReporterWrapper.ReportEvent(RemoteDebuggerRemoteToolsStartedEvent.Create( CommandStatus.Success, DateTime.Now - startTimestamp)); return(ListProcessStepViewModel.CreateStep(Context)); } await Task.Delay(500); } EventsReporterWrapper.ReportEvent( RemoteDebuggerRemoteToolsStartedEvent.Create(CommandStatus.Failure)); } return(HelpStepViewModel.CreateStep(Context)); }