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); } }
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; } } } }
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; } } }
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; } } }
protected virtual void OnRinging(PortDefaultEventArgs e) { EventHandler<PortDefaultEventArgs> handler = Ringing; if (handler != null) { handler(this, e); } }
protected virtual void OnEndedCall(PortDefaultEventArgs e) { EventHandler<PortDefaultEventArgs> handler = EndedCall; if (handler != null) { handler(this, e); } }
protected virtual void OnAnswered(PortDefaultEventArgs e) { EventHandler<PortDefaultEventArgs> handler = Answered; if (handler != null) { handler(this, e); } }