Exemplo n.º 1
0
Arquivo: PBX.cs Projeto: choob207/Epam
        void EndedCallHandler(object sender, PortDefaultEventArgs e)
        {
            if (sender is PBXPort && e != null)
            {
                var firstNumber = ((PBXPort) sender).PhoneNumber;
                var secondNumber = _activeRings.GetSecondNumberByNumber(firstNumber);
                Disconnect(secondNumber);

                var activeRing = _activeRings.GetActiveTalkByNumber(firstNumber);
                if (activeRing != null)
                {
                    _billingSystem.AddCallStatistics(activeRing.PhoneSource, activeRing.PhoneDestination,activeRing.RingTime, System.DateTime.Now);
                }

                _activeRings.DeleteByPhoneNumber(firstNumber);

            }
        }
Exemplo n.º 2
0
Arquivo: PBX.cs Projeto: choob207/Epam
 void AnsweredHandler(object sender, PortDefaultEventArgs e)
 {
     if (sender is PBXPort && e != null)
     {
         if (e.PortStateArg == PortState.Busy && e.TerminalStateArg == TerminalState.Ring)
         {
             var activeRingBuff = _activeRings.FirstOrDefault(x => x.PhoneDestination == ((PBXPort) sender).PhoneNumber);
             if (activeRingBuff != null)
             {
                 activeRingBuff.SetStateAnswer(System.DateTime.Now);
                 e.TerminalStateArg = TerminalState.Busy;
             }
             else
             {
                 e.PortStateArg = PortState.Available;
                 e.TerminalStateArg = TerminalState.Available;
             }
         }
     }
 }
Exemplo n.º 3
0
        private void EndedCallHandler(object sender, TerminalDefaultEventArg e)
        {
            if (sender is PBXTerminal && e != null)
            {
                if (State != PortState.Disabled)
                {
                    PortDefaultEventArgs portDefaultEventArgs = new PortDefaultEventArgs();
                    portDefaultEventArgs.TerminalStateArg = e.TerminalStateArg;
                    portDefaultEventArgs.PortStateArg = State;

                    OnEndedCall(portDefaultEventArgs);

                    _state = PortState.Available;
                }
            }
        }
Exemplo n.º 4
0
        private void AnsweredHandler(object sender, TerminalDefaultEventArg e)
        {
            if (sender is PBXTerminal && e != null)
            {
                if (State == PortState.Busy)
                {
                    PortDefaultEventArgs portDefaultEventArgs = new PortDefaultEventArgs();
                    portDefaultEventArgs.TerminalStateArg = e.TerminalStateArg;
                    portDefaultEventArgs.PortStateArg = State;

                    OnAnswered(portDefaultEventArgs);

                    _state = portDefaultEventArgs.PortStateArg;
                    e.TerminalStateArg = portDefaultEventArgs.TerminalStateArg;
                }
            }
        }
Exemplo n.º 5
0
 protected virtual void OnRinging(PortDefaultEventArgs e)
 {
     EventHandler<PortDefaultEventArgs> handler = Ringing;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Exemplo n.º 6
0
 protected virtual void OnEndedCall(PortDefaultEventArgs e)
 {
     EventHandler<PortDefaultEventArgs> handler = EndedCall;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Exemplo n.º 7
0
 protected virtual void OnAnswered(PortDefaultEventArgs e)
 {
     EventHandler<PortDefaultEventArgs> handler = Answered;
     if (handler != null)
     {
         handler(this, e);
     }
 }