Exemplo n.º 1
0
        private void CheckLcaConnection()
        {
            Boolean wasConnected = false;

            while (_continueRunning)
            {
                try
                {
                    Thread.Sleep(5 * 1000);
                }
                catch (Exception e)
                {
                    TpsLogManager <MessageServer> .Error(e.Message);
                }
                finally
                {
                    if (!wasConnected && IsConnectedToLca())
                    {
                        TpsLogManager <MessageServer> .Info("Connection to Local Control Agent reconnected.");

                        SetStatus(_lastStatus);
                        wasConnected = true;
                        _isLcaConnectedThreadRunning = true;
                    }
                    else if (wasConnected && !IsConnectedToLca())
                    {
                        TpsLogManager <MessageServer> .Warn("Connection to Local Control Agent lost.");

                        wasConnected = false;
                        _isLcaConnectedThreadRunning = false;
                    }
                }
            }
            _isLcaConnectedThreadRunning = false;
        }
Exemplo n.º 2
0
        internal string ReturnExitedSecureMode(string webSocket)
        {
            if (webSocket == null)
            {
                TpsLogManager <Semafone> .Warn("sendExitedSecureMode : Client has either been disconnected or doesn't exist for " + webSocket + ".");

                return(jsonErrorMessage(webSocket, "9", "Client has either been disconnected or doesn't exist for " + webSocket + ".", ErrorSeverity.Error));
            }
            try
            {
                SemafoneExitSecureModeHandset semafoneHandset = new SemafoneExitSecureModeHandset();
                semafoneHandset.Semafone = new SemafoneExitSecureMode()
                {
                    Exitsecuremode = true
                };
                string   message = JsonConvert.SerializeObject(semafoneHandset);
                Semafone semaphoneInstance;
                SemafoneClients.TryRemove(webSocket, out semaphoneInstance);
                TpsLogManager <Semafone> .Info("Exit secure mode semafone message has been sent for " + webSocket);

                TpsLogManager <Semafone> .Info(message);

                return(message);
            }
            catch (Exception e)
            {
                TpsLogManager <Semafone> .Error("Error sendExitedSecureMode : " + e.Message + e.StackTrace);

                return(jsonErrorMessage(webSocket, "8", "Error during ReturnExitedSecureMode for " + webSocket + ".", ErrorSeverity.Error));
            }
        }
Exemplo n.º 3
0
        internal string ProcessPciExitSecureMode(string webSocket)
        {
            if (webSocket == null)
            {
                TpsLogManager <Semafone> .Warn("processPCIExitSecureMode : Client has either been disconnected or doesn't exist");

                return("Client has either been disconnected or doesn't exist");
            }
            try
            {
                bool     success  = false;
                Semafone semafone = GetSemafone(webSocket);
                if (semafone != null)
                {
                    // exit secure mode and logout from Semafone to ensure no more events come through
                    success = semafone.StopListeningForEvents();
                    if (!success)
                    {
                        TpsLogManager <Semafone> .Error("processPCIExitSecureMode : Could not stop listening for Semafone events for " + webSocket + ".");
                    }
                    success = semafone.ExitSecureMode();
                    if (!success)
                    {
                        TpsLogManager <Semafone> .Error("processPCIExitSecureMode : Could not request to exit Semafone secure mode for " + webSocket + ".");
                    }
                    success = semafone.Logout();
                    if (!success)
                    {
                        TpsLogManager <Semafone> .Error("processPCIExitSecureMode : Could not logout to exit Semafone secure mode for " + webSocket + ".");
                    }

                    if (success)
                    {
                        return(ReturnExitedSecureMode(webSocket));
                    }
                    else
                    {
                        return(jsonErrorMessage(webSocket, "8", "Failed to exit secure mode for " + webSocket + ".", ErrorSeverity.Error));
                    }
                }
                else
                {
                    return(jsonErrorMessage(webSocket, "8", "Failed to exit secure mode for " + webSocket + ".", ErrorSeverity.Error));
                }
            }
            catch (Exception ex)
            {
                TpsLogManager <Semafone> .Error(ex.Message);

                return(jsonErrorMessage(webSocket, "8", "Error during exit secure mode for " + webSocket + ".", ErrorSeverity.Error));
            }
        }
Exemplo n.º 4
0
        private string ProcessPciResetCvc(string webSocket)
        {
            if (webSocket == null)
            {
                TpsLogManager <Semafone> .Warn("processPCIResetCVC : Client has either been disconnected or doesn't exist");

                return("");
            }
            try
            {
                Semafone semafone = GetSemafone(webSocket);
                if (semafone != null)
                {
                    if (semafone.ResetCvc())
                    {
                        SemafoneResetCvcHandset semafoneHandset = new SemafoneResetCvcHandset();
                        semafoneHandset.Semafone = new SemafoneResetCvc()
                        {
                            Cvcreset = true
                        };
                        string message = JsonConvert.SerializeObject(semafoneHandset);

                        TpsLogManager <Semafone> .Info("Reset CVC semafone message has been sent to webSocket " + webSocket);

                        TpsLogManager <Semafone> .Info(message);

                        return(message);
                    }
                    else
                    {
                        TpsLogManager <Semafone> .Error("Failed to reset cvc for " + webSocket);

                        return(jsonErrorMessage(webSocket, "10", "Failed to reset pan for " + webSocket + ".", ErrorSeverity.Error));
                    }
                }
                else
                {
                    TpsLogManager <Semafone> .Error("Failed to reset cvc for " + webSocket);

                    return(jsonErrorMessage(webSocket, "10", "Failed to reset pan for " + webSocket + ".", ErrorSeverity.Error));
                }
            }
            catch (Exception ex)
            {
                TpsLogManager <Semafone> .Error("Failed to reset cvc for " + webSocket + " due to Error: " + ex.Message);

                return(jsonErrorMessage(webSocket, "10", "Failed to reset pan for " + webSocket + ".", ErrorSeverity.Error));
            }
        }
Exemplo n.º 5
0
        private void OnEventChangeExecutionMode(IMessage message)
        {
            var @event = (EventChangeExecutionMode)message;

            _localControlAgentProtocol.ExecutionMode = @event.ExecutionMode;

            var response = ResponseExecutionModeChanged.Create();

            response.ExecutionMode = _localControlAgentProtocol.ExecutionMode;

            _localControlAgentProtocol.Send(response);

            if (_localControlAgentProtocol.ExecutionMode == ApplicationExecutionMode.Exiting)
            {
                TpsLogManager <MessageServer> .Warn("Application told to exit from solution control server!");

                Environment.Exit(0);
            }
        }
Exemplo n.º 6
0
        internal static void SendSemafoneMaskedDtmf(string webSocket, SemafoneDtmf semafoneDtmf)
        {
            if (string.IsNullOrEmpty(webSocket))
            {
                TpsLogManager <Semafone> .Warn("sendSemafoneMaskedDTMF : Client has either been disconnected or doesn't exist");
            }
            try
            {
                string message = JsonConvert.SerializeObject(semafoneDtmf);;
                SemafoneConnection.SemafoneConnectionInstance.SendWebSocketMessage(webSocket, message);
                TpsLogManager <Semafone> .Info("SemafoneMaskedDTMF semafone message sent to " + webSocket);

                TpsLogManager <Semafone> .Info(message);
            }
            catch (Exception ex)
            {
                SemafoneConnection.SemafoneConnectionInstance.SendWebSocketMessage(webSocket, ex.Message);
                TpsLogManager <Semafone> .Error("sendSemafoneMaskedDTMF : " + ex.Message);
            }
        }