/// <summary> /// Updates the statistics that are affected by a Completed Service event /// </summary> /// <param name="completedServiceEvent">The event that occured</param> /// <exception cref="System.ArgumentNullException">Thrown when the given event is null</exception> private void ServiceComplete(CompletedServiceEvent completedServiceEvent) { //Check that the given event is not null if (completedServiceEvent != null) { Call c = completedServiceEvent.Entity; //If the call spent time waiting if (c.BeginWait != DateTime.MinValue) { //Calculate the time the call spent waiting TimeSpan waiting = c.BeganProcessing - c.BeginWait; //If that time is greater than the sims threshold value if (waiting >= sim.ExcessiveWaitTime) { //Increase the excessive wait counter for the calls product type excessiveWaitCounts[c.ProductType]++; } } //Increase the number of completed calls of the given product type completedProductCount[c.ProductType]++; //Calculate the time this call spent processing TimeSpan processingTime = completedServiceEvent.EventTime - c.BeganProcessing; //Add this processingTime to the totalTimeProcessing for the SalesReps type totalTimeProcessing[c.ProcessedBy.RepType] += processingTime; } else // given event was null throw exception { throw new ArgumentNullException("completedServiceEvent", "Attempted to pass null CompletedServiceEvent to StatisticsManager.ServiceComplete"); } }
/// <summary> /// Creates an Event of the designated type, to occure at a specified time, and bound to a given entity /// </summary> /// <param name="eventType">The type of event to create</param> /// <param name="eventTime">The time the event will occur</param> /// <param name="entity">The Call this event is bound to (Can be null)</param> /// <returns></returns> public Event CreateEvent(EEventType eventType, DateTime eventTime, Call entity) { //Create an event to return Event eve = null; //Switch on the possible event types switch (eventType) { case EEventType.CallArrive: eve = new CallArriveEvent(entity, eventTime); break; case EEventType.SwitchCompleted: eve = new SwitchCompletedEvent(entity, eventTime); break; case EEventType.CompletedService: eve = new CompletedServiceEvent(entity, eventTime); break; case EEventType.EndReplication: eve = new EndReplicationEvent(eventTime); break; } return(eve); }