public static void PscFailedAndSucceededBagsPerFlight(StatisticsData data, ConcurrentBag <Baggage> baggages)
        {
            var bagsGroupedPerFlight = baggages.GroupBy(b => b.Flight.FlightNumber);

            if (data.PscSucceededBagsPerFlight != null && data.PscSucceededBagsPerFlight.Count() > 0)
            {
                data.PscSucceededBagsPerFlight.Clear();
                data.PscFailedBagsPerFlight.Clear();
            }
            foreach (var group in bagsGroupedPerFlight)
            {
                var succeededBagsPerFlight = group.Where(b => b.Logs.Any(log => log.Description.Contains(LoggingConstants.PrimarySecurityCheckSucceeded))).ToList();
                var failedBagsPerFlight    = group.Where(b => b.Logs.Any(log => log.Description.Contains(LoggingConstants.PrimarySecurityCheckFailed))).ToList();

                data.PscSucceededBagsPerFlight.Add(group.Key, succeededBagsPerFlight.Count());
                data.PscFailedBagsPerFlight.Add(group.Key, failedBagsPerFlight.Count());
            }
        }
        public static StatisticsData CalculateStatistics()
        {
            var baggages       = Baggage.AllBaggage;
            var statisticsData = new StatisticsData();

            try
            {
                SetTransferdBagsCount(statisticsData, baggages);
                SetPscFailedAndSucceededBags(statisticsData, baggages);
                BagsPerFlight(statisticsData, baggages);
                BagsTimesDispatchedAndCollectedStats(statisticsData, baggages);
                ElapsedTimeForeachFlight(statisticsData, baggages);
                PscFailedAndSucceededBagsPerFlight(statisticsData, baggages);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(statisticsData);
        }
        //not in use
        public static void AverageTimeCheckInDropOff(StatisticsData data, ConcurrentBag <Baggage> baggages)
        {
            List <long?> timeList = new List <long?>();

            data.TotalBagsTransfered = baggages
                                       .Where(bag => bag.Logs.Any(log => log.Description.Contains("drop off processing"))).ToList();
            foreach (Baggage b in data.TotalBagsTransfered)
            {
                long dateTime       = DateTime.Now.Ticks;
                long?TimeDifference = b.TransportationStartTime - dateTime;
                timeList.Add(TimeDifference);
            }
            long?averageTime = 0;
            int  n           = timeList.Count;

            foreach (long?t in timeList)
            {
                averageTime += t;
            }
            long?meanTime = averageTime / n;

            data.AverageTimeOfTottalBags = meanTime;
        }
        public static void ElapsedTimeForeachFlight(StatisticsData data, ConcurrentBag <Baggage> baggages)
        {
            if (data.TotalBagsTransfered == null)
            {
                return;
            }

            data.ElapsedTimesGroupedPerFlight = data.TotalBagsTransfered.GroupBy(b => b.Flight.FlightNumber);

            foreach (var group in data.ElapsedTimesGroupedPerFlight)
            {
                var orderedByFirstBag = group.OrderBy(b => b.Logs.FirstOrDefault().LogCreated).ToList();

                var firstBagDispached = orderedByFirstBag.FirstOrDefault().Logs.FirstOrDefault().LogCreated.Minutes;
                var lastBagCollected  = orderedByFirstBag.LastOrDefault().Logs.LastOrDefault().LogCreated.Minutes;

                var timeElapsed = (lastBagCollected - firstBagDispached).ToString();

                data.ElapsedTimesPerFlight.Add(group.Key, timeElapsed);
            }

            data.SimulationTimeElapsed = data.ElapsedTimesPerFlight.Max(b => b.Value);
        }
 public static void SetAVGWaitingTimePerTransporter(StatisticsData data, ConcurrentBag <Baggage> baggages)
 {
     var primarySecurityNodes = NodeCreationService.Nodes.OfType <IPrimarySecurity>().ToList();
 }
 public static void SetPscFailedAndSucceededBags(StatisticsData data, ConcurrentBag <Baggage> baggages)
 {
     data.BagsSucceededPsc = baggages.Where(bag => bag.Logs.Any(log => log.Description.Contains(LoggingConstants.PrimarySecurityCheckSucceeded))).ToList();
     data.BagsFailedPsc    = baggages.Where(bag => bag.Logs.Any(log => log.Description.Contains(LoggingConstants.PrimarySecurityCheckFailed))).ToList();
 }