private static void ConsultantAction(CallCenter center, string name, ConsoleColor color) { Random random = new Random(); while (true) { IncomingCalls call = center.Answer(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); } } }
public IncomingCalls Answer(string consultant) { if (Calls.Count > 0) { IncomingCalls call = Calls.Dequeue(); call.Consultant = consultant; call.StartTime = DateTime.Now; return(call); } return(null); }
public int Call(int clientId) { IncomingCalls call = new IncomingCalls() { Id = ++_counter, ClientId = clientId, CallTime = DateTime.Now }; Calls.Enqueue(call); return(Calls.Count); }
public void End(IncomingCalls call) { call.EndTime = DateTime.Now; }