Beispiel #1
0
        public void CancelCommand()
        {
            PowwaEvents.PowwaEVENT_DEBUG_LOG0("CancelCommand(): Enter");
            try
            {
                lock (this.cancelCommandLock)
                {
                    lock (this.sessionStateLock)
                    {
                        PowwaSession.SessionState state = this.State;
                        switch (state)
                        {
                        case PowwaSession.SessionState.Available:
                        case PowwaSession.SessionState.CancellingCommand:
                        {
                            return;
                        }

                        case PowwaSession.SessionState.ExecutingCommand:
                        {
                            this.State = PowwaSession.SessionState.CancellingCommand;
                            this.executingCommandPowerShell.BeginStop(null, null);
                            this.messageQueue.CommandCancelled();
                            return;
                        }
                        }
                        throw new InvalidOperationException();
                    }
                }
            }
            finally
            {
                PowwaEvents.PowwaEVENT_DEBUG_LOG0("CancelCommand(): Exit");
            }
        }
Beispiel #2
0
        public PowwaSessionStatusInfo GetSessionStatus()
        {
            PowwaSessionStatusInfo powwaSessionStatusInfo;

            PowwaEvents.PowwaEVENT_DEBUG_LOG0("GetSessionStatus(): Enter");
            try
            {
                lock (this.clientRequestLock)
                {
                    lock (this.sessionStateLock)
                    {
                        PowwaSession.SessionState state = this.State;
                        switch (state)
                        {
                        case PowwaSession.SessionState.Available:
                        {
                            powwaSessionStatusInfo = new PowwaSessionStatusInfo(PowwaSessionStatus.Available, null);
                            return(powwaSessionStatusInfo);
                        }

                        case PowwaSession.SessionState.ExecutingCommand:
                        {
                            if (!this.messageQueue.WaitingForUserReply)
                            {
                                powwaSessionStatusInfo = new PowwaSessionStatusInfo(PowwaSessionStatus.Executing, null);
                                return(powwaSessionStatusInfo);
                            }
                            else
                            {
                                powwaSessionStatusInfo = new PowwaSessionStatusInfo(PowwaSessionStatus.Prompting, this.messageQueue.PendingInputMessage);
                                return(powwaSessionStatusInfo);
                            }
                        }

                        case PowwaSession.SessionState.CancellingCommand:
                        {
                            powwaSessionStatusInfo = new PowwaSessionStatusInfo(PowwaSessionStatus.Cancelling, null);
                            return(powwaSessionStatusInfo);
                        }

                        case PowwaSession.SessionState.Closed:
                        {
                            powwaSessionStatusInfo = new PowwaSessionStatusInfo(PowwaSessionStatus.Closed, null);
                            return(powwaSessionStatusInfo);
                        }
                        }
                        throw new InvalidOperationException();
                    }
                }
            }
            finally
            {
                PowwaEvents.PowwaEVENT_DEBUG_LOG0("GetSessionStatus(): Exit");
            }
            return(powwaSessionStatusInfo);
        }
Beispiel #3
0
        public ClientMessage[] GetClientMessages()
        {
            ClientMessage[] messages;
            lock (this.clientRequestLock)
            {
                bool flag = false;
                lock (this.sessionStateLock)
                {
                    PowwaSession.SessionState state = this.State;
                    switch (state)
                    {
                    case PowwaSession.SessionState.Available:
                    {
                        break;
                    }

                    case PowwaSession.SessionState.ExecutingCommand:
                    case PowwaSession.SessionState.CancellingCommand:
                    {
                        flag = true;
                        break;
                    }

                    case PowwaSession.SessionState.Closed:
                    {
                        throw PowwaException.CreateInvalidSessionException();
                    }

                    default:
                    {
                        break;
                    }
                    }
                }
                if (flag)
                {
                    this.messageQueue.WaitForMessages();
                }
                lock (this.sessionStateLock)
                {
                    if (this.State != PowwaSession.SessionState.Closed)
                    {
                        messages = this.messageQueue.GetMessages();
                    }
                    else
                    {
                        PowwaEvents.PowwaEVENT_DEBUG_LOG1("GetClientMessages() Invalid Session State", "SessionState", this.State.ToString());
                        throw PowwaException.CreateInvalidSessionException();
                    }
                }
            }
            return(messages);
        }