public void ConnectionCompletion(object sender, ICallInfo callInfo) { try { IConnection connection = OnlineConnections.FirstOrDefault(x => x.ClientNumberOfTelephone == callInfo.ClientNumberOfTelephone && x.OutgoingNumber == callInfo.OutgoingNumber); if (connection != null) { connection.FinishConnection = DateTime.Now; connection.DurationConnection = connection.FinishConnection - connection.StartConnection; OnlineConnections.Remove(connection); СompletedConnections.Add(connection); SaveConnection?.Invoke(sender, connection); IPort port1 = PortController_.Ports.FirstOrDefault(x => x.Terminal.ClientNumberOfTelephone == callInfo.ClientNumberOfTelephone); IPort port2 = PortController_.Ports.FirstOrDefault(x => x.Terminal.ClientNumberOfTelephone == callInfo.OutgoingNumber); port1.RidPort(); port2.RidPort(); MessageHandler(this, $"Завершено соединение абонента {callInfo.ClientNumberOfTelephone} с абонентом {callInfo.OutgoingNumber}"); } } catch { throw new Exception("Exception on method ConnectionCompletion"); } }
public void ConnectionCreator(object sender, ICallInfo callInfo) { OnlineConnections.Add(new Connection(callInfo.ClientNumberOfTelephone, callInfo.OutgoingNumber, DateTime.Now)); }