/// <summary>
        /// This function can be called twice.
        ///
        /// First time, it simply check connectivity with a short timeout.
        /// If it does not connect, there are two possibilities.
        ///   1) Firewall was just enabled, let's check for longer time.
        ///   2) Remote powershell is disabled on target machine etc.
        ///
        /// Since we are not clear which is the case, we return null. It will then show
        /// the dialog UI to ask user to choose if he wants to retry testing connectivity.
        ///
        /// If the user choose yes for retry, this method is called the second time.
        /// The second time, we keep testing connectivity with a longer period of time.
        ///
        /// Both times,
        /// if remote powershell can be connected, go to install, start remote debugger step.
        ///
        /// If it is determined it won't connect successfully,
        /// go to a help page with a link to our documentation.
        /// </summary>
        protected override async Task <IAttachDebuggerStep> GetNextStepAsync()
        {
            SetStage(Stage.CheckingConnectivity);
            var  port      = Context.RemotePowerShellPort;
            int  waitTime  = port.WaitForFirewallRuleTimeInSeconds();
            bool connected = waitTime > 0 && _askedToCheckConnectivityLater ?
                             // This is the second time, check connectivity with a longer wait time.
                             await ConnectivityTestUntillTimeoutAsync(waitTime) :
                             // This is the first time, we don't check "waitTime", test connectivity anyhow.
                             await port.ConnectivityTestAsync(CancelToken);

            if (connected)
            {
                return(InstallStartRemoteToolStepViewModel.CreateStep(Context));
            }
            // else: not connected

            // If this is first time call, then check if firewall was just enabled.
            if (!_askedToCheckConnectivityLater && port.WaitForFirewallRuleTimeInSeconds() > 0)
            {
                SetStage(Stage.AskToCheckConnectivityLater);
                _askedToCheckConnectivityLater = true;
                return(null);
            }
            else
            {
                return(HelpStepViewModel.CreateStep(Context));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the step that installs and starts debugger remote tool.
        /// </summary>
        public static InstallStartRemoteToolStepViewModel CreateStep(AttachDebuggerContext context)
        {
            var content = new InstallStartRemoteToolStepContent();
            var step    = new InstallStartRemoteToolStepViewModel(content, context);

            content.DataContext = step;
            return(step);
        }