Пример #1
0
        private void DropStation(object sender, EventArgs e)
        {
            if (sender is IPort port)
            {
                var currentSession = _sessionContainer.GetByAny(port);
                if (currentSession != null)
                {
                    if (currentSession.State == SessionState.Connected)
                    {
                        currentSession.Source.StateCall = PortStateCall.Free;
                        currentSession.Target.StateCall = PortStateCall.Free;
                        currentSession.State            = SessionState.Close;

                        OnCallEnded(new ConnectInfo(currentSession.Source.Number, currentSession.Target.Number, currentSession.Start, DateTime.Now, ConnectInfoState.Accepted));

                        _sessionContainer.Remove(currentSession);

                        Console.WriteLine("Current call is completed");
                    }
                    else
                    {
                        currentSession.Source.StateCall = PortStateCall.Free;
                        currentSession.Target.StateCall = PortStateCall.Free;
                        currentSession.State            = SessionState.Close;

                        OnCallEnded(new ConnectInfo(currentSession.Source.Number, currentSession.Target.Number, currentSession.Start, currentSession.Start, ConnectInfoState.Unaccepted));

                        _sessionContainer.Remove(currentSession);

                        Console.WriteLine("Current dialing is interrupted");
                    }
                }
                else
                {
                    Console.WriteLine("Session not found");
                }
            }
        }