Ejemplo n.º 1
0
        private static void ConsultantAction(CallCenter center, string name, ConsoleColor color)
        {
            Random random = new Random();

            while (true)
            {
                IncomingCall call = center.AnswerCall(name);
                if (call != null)
                {
                    Console.ForegroundColor = color;
                    Log($"Call #{call.Id} from {call.ClientId} is answered by { call.Consultant}.");
                    Console.ForegroundColor = ConsoleColor.Gray;

                    Thread.Sleep(random.Next(1000, 10000));
                    center.End(call);

                    Console.ForegroundColor = color;
                    Log($"Call #{call.Id} from {call.ClientId} is ended by { call.Consultant}.");
                    Console.ForegroundColor = ConsoleColor.Gray;

                    Thread.Sleep(random.Next(500, 1000));
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
Ejemplo n.º 2
0
        public int Call(int clientid)
        {
            IncomingCall call = new IncomingCall()
            {
                Id       = ++_counter,
                ClientId = clientid,
                CallTime = DateTime.Now
            };

            Calls.Enqueue(call);
            return(Calls.Count);
        }
Ejemplo n.º 3
0
 public void End(IncomingCall call)
 {
     call.EndTime = DateTime.Now;
 }