public void LogRequest(DomainLog requestInfo)
 {
     _domainLog.GetInformation(new RequestLog()
     {
         UniversityIP = requestInfo.UniversityIP,
         Controller   = requestInfo.Controller,
         Request      = requestInfo.Request
     });
 }
Esempio n. 2
0
        protected override void When(DomainEvent @event)
        {
            DomainLog?.Invoke(".", false);

            // Temporary add the latest
            var latestChanges = LastChanges
                                .Cast <RecordData>()
                                .ToList();

            switch (@event)
            {
            // Handle arrival event stats
            case TransportArrival arrivalEvent:
            {
                Location             = arrivalEvent.Location;
                CumulativeDelay     += arrivalEvent.Delay;
                AverageDelayLastWeek = TimeSpan.FromMinutes(
                    latestChanges
                    .FilterCast <TransportArrival>()
                    .Take(7)
                    .Average(evt => evt.Delay.TotalMinutes));
                AverageFatigueLastWeek = latestChanges
                                         .FilterCast <TransportArrival>()
                                         .Take(7)
                                         .Average(d => d.Fatigue);
                AverageFatigueLast30Days = latestChanges
                                           .FilterCast <TransportArrival>()
                                           .Take(30)
                                           .Average(d => d.Fatigue);
                TotalAccidents = latestChanges
                                 .FilterCast <TransportArrival>()
                                 .Count(evt => evt.HadAccident);

                break;
            }

            case TransportDeparture departureEvent:
            {
                Location = "-";
                break;
            }
            }
        }