コード例 #1
0
ファイル: Station.cs プロジェクト: IIITanbI/EpamProjects
 public void AddCallInfo(CallInfo callInfo)
 {
     _callCollection.Add(callInfo);
     OnCallInfoAdded(this, callInfo);
 }
コード例 #2
0
ファイル: Station.cs プロジェクト: IIITanbI/EpamProjects
        protected void InterruptConnection(CallInfo connection)
        {
            var sourceTerminal = GetTerminal(connection.Source);
            var sourcePort = GetPort(sourceTerminal);

            var targetTerminal = GetTerminal(connection.Target);
            var targetPort = GetPort(targetTerminal);

            var cl = GetLastConnectionInfo(connection.Target);
            if (connection == cl && targetPort.State != PortState.Off)
            {
                connection.Duration = DateTime.Now - connection.Started;
                SetPortStateWhenConnectionInterrupted(connection.Source, connection.Target);
            }
            else
                SetPortStateWhenConnectionInterrupted(connection.Source, default(PhoneNumber));

            this._connectionCollection.Remove(connection);
            AddCallInfo(connection);
        }
コード例 #3
0
ファイル: Station.cs プロジェクト: IIITanbI/EpamProjects
 protected virtual void OnCallInfoAdded(object sender, CallInfo e)
 {
     CallInfoAdded?.Invoke(sender, e);
 }
コード例 #4
0
ファイル: Station.cs プロジェクト: IIITanbI/EpamProjects
 protected void InterruptActiveCall(CallInfo connection)
 {
     connection.Duration = DateTime.Now - connection.Started;
     InterruptConnection(connection);
 }
コード例 #5
0
ファイル: Station.cs プロジェクト: IIITanbI/EpamProjects
        public void RegisterCall(Request request)
        {
            if (request.Source != default(PhoneNumber) && request.Target != default(PhoneNumber))
            {
                var sourceTerminal = GetTerminal(request.Source);
                var sourcePort = GetPort(sourceTerminal);

                var targetTerminal = GetTerminal(request.Target);
                var targetPort = GetPort(targetTerminal);

                var callInfo = new CallInfo()
                {
                    Source = request.Source,
                    Target = request.Target,
                    Started = DateTime.Now,
                    Duration = TimeSpan.Zero
                };

                var sourceConnection = GetLastConnectionInfo(request.Source);
                var targetConnection = GetLastConnectionInfo(request.Target);

                this._connectionCollection.Add(callInfo);

                if ((sourceConnection == null && targetConnection == null)
                    && (sourcePort.State != PortState.Off && targetPort.State != PortState.Off))
                {
                    sourcePort.State = PortState.Busy;
                    targetPort.State = PortState.Busy;

                    var incomingRequest = new Request(request.Source, request.Target, Request.IncomingCall);
                    targetTerminal.IncomingRequest(incomingRequest);
                }
                else
                {
                    InterruptConnection(callInfo);
                    Console.WriteLine("Drop");
                    sourceTerminal.IncomingRespond(new Respond(Respond.Drop, request));
                }
            }
        }
コード例 #6
0
 public void AddCallInfo(CallInfo callInfo)
 {
     _callCollection.Add(callInfo);
     OnCallInfoAdded(this, callInfo);
 }
コード例 #7
0
 protected void InterruptActiveCall(CallInfo connection)
 {
     connection.Duration = DateTime.Now - connection.Started;
     InterruptConnection(connection);
 }
コード例 #8
0
 protected virtual void OnCallInfoAdded(object sender, CallInfo e)
 {
     CallInfoAdded?.Invoke(sender, e);
 }