protected override object ProcessResult(bool hasResult, string result)
 {
     if (ScriptSessionManager.GetSessionIfExists(SessionKey) is ScriptSession session)
     {
         session.Host.EndNestedPromptSuspension();
     }
     return(base.ProcessResult(hasResult, result));
 }
Beispiel #2
0
 protected void PrintOutput(ClientPipelineArgs args)
 {
     if (ScriptSessionManager.GetSessionIfExists(Monitor.SessionID) is ScriptSession session)
     {
         var result = session.Output.GetHtmlUpdate();
         PrintSessionUpdate(result);
     }
 }
Beispiel #3
0
 protected virtual void BreakpointAction(ClientPipelineArgs args)
 {
     if (ScriptSessionManager.GetSessionIfExists(Monitor.SessionID) is ScriptSession session)
     {
         session.TryInvokeInRunningSession(args.Parameters["action"]);
         SheerResponse.Eval("$ise(function() { cognifide.powershell.breakpointHandled(); });");
         InBreakpoint = false;
     }
 }
Beispiel #4
0
        protected virtual void ToggleRuntimeBreakpoint(ClientPipelineArgs args)
        {
            var line  = Int32.Parse(args.Parameters["Line"]) + 1;
            var state = args.Parameters["State"] == "true";

            if (ScriptSessionManager.GetSessionIfExists(Monitor.SessionID) is ScriptSession session)
            {
                var bPointScript = state
                    ? $"Set-PSBreakpoint -Script {session.DebugFile} -Line {line}"
                    : $"Get-PSBreakpoint -Script {session.DebugFile} | ? {{ $_.Line -eq {line}}} | Remove-PSBreakpoint";
                bPointScript += " | Out-Null";
                session.TryInvokeInRunningSession(bPointScript);
                InBreakpoint = false;
            }
        }
Beispiel #5
0
        protected virtual void JobAbort(ClientPipelineArgs args)
        {
            if (ScriptSessionManager.GetSessionIfExists(Monitor.SessionID) is ScriptSession currentSession)
            {
                currentSession.Abort();

                if (currentSession.AutoDispose)
                {
                    currentSession.Dispose();
                }
            }
            else
            {
                ScriptRunning = false;
                UpdateRibbon();
            }
            Monitor.SessionID = string.Empty;
            ScriptRunning     = false;
        }
Beispiel #6
0
        public string DisposeScriptSession(string userName, string password, string sessionId)
        {
            if (!WebServiceSettings.IsEnabled(WebServiceSettings.ServiceRemoting))
            {
                return(string.Empty);
            }

            if (!Login(userName, password))
            {
                return("login failed");
            }

            PowerShellLog.Info($"Session '{sessionId}' disposed by user: '******'");

            if (ScriptSessionManager.GetSessionIfExists(sessionId) is ScriptSession session)
            {
                ScriptSessionManager.RemoveSession(session);
                return("removed");
            }

            return("not found");
        }