예제 #1
0
파일: Program.cs 프로젝트: prof79/PPCSDSA
        /// <summary>
        /// Helper method for <see cref="CallCenter2Demo"/>.
        /// </summary>
        private static void ConsultantAction(ICallCenter callCenter, string consultantName, ConsoleColor foregroundColor, CancellationToken ct = default(CancellationToken))
        {
            while (true)
            {
                if (ct.IsCancellationRequested)
                {
                    return;
                }

                var call = callCenter.Answer(consultantName);

                if (call != null)
                {
                    foregroundColor.UseFore(() =>
                                            $"Call #{call.Id} from {call.ClientId} is answered by {call.Consultant}.".Log()
                                            );

                    Thread.Sleep(_random.Next(1000, 10000));

                    callCenter.End(call);

                    foregroundColor.UseFore(() =>
                                            $"Call #{call.Id} from {call.ClientId} is ended by {call.Consultant}.".Log()
                                            );

                    Thread.Sleep(_random.Next(500, 1000));
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: prof79/PPCSDSA
        /// <summary>
        /// Helper method for <see cref="CallCenter2Demo"/>.
        /// </summary>
        private static void CallerAction(ICallCenter callCenter, CancellationToken ct = default(CancellationToken))
        {
            while (true)
            {
                if (ct.IsCancellationRequested)
                {
                    return;
                }

                var clientId = _random.Next(1, 10000);

                var waitingCount = callCenter.Call(clientId);

                $"Incoming call from #{clientId}, waiting in the queue: {waitingCount}".Log();

                Thread.Sleep(_random.Next(1000, 5000));
            }
        }
예제 #3
0
 public CallCenterHub(ICallCenter callCenter)
 {
     _callCenter = callCenter;
 }