Exemple #1
0
        public void Call(int clientId)
        {
            IncommingCall call = new IncommingCall()
            {
                Id       = _count++,
                ClientId = clientId,
                CallTime = DateTime.Now
            };

            Calls.Enqueue(call);
        }
Exemple #2
0
        public IncommingCall Answer(string consultant)
        {
            if (this.Calls.Count <= 0)
            {
                return(null);
            }
            IncommingCall call = Calls.Dequeue();

            call.Consultant = consultant;
            call.StartTime  = DateTime.Now;
            return(call);
        }
        static void Main(string[] args)
        {
            Random     random = new Random();
            CallCenter center = new CallCenter();

            center.Call(1234);
            center.Call(5678);
            center.Call(1468);
            center.Call(9641);

            while (center.AreWaitingCalls())
            {
                IncommingCall call = center.Answer("Marcin");
                Log($"Call #{call.Id} from {call.ClientId} is answered by {call.Consultant}.");
                Thread.Sleep(random.Next(1000, 10000));
                center.End(call);
                Log($"Call #{call.Id} from {call.ClientId} is ended by {call.Consultant}.");
            }
        }
Exemple #4
0
 public void End(IncommingCall call)
 {
     call.EndTime = DateTime.Now;
 }