Esempio n. 1
0
        public static List <ApproachSplitFailAggregation> GetApproachAggregationRecords(Approach approach,
                                                                                        SignalAggregationMetricOptions options)
        {
            var Repo = ApproachSplitFailAggregationRepositoryFactory.Create();

            if (approach != null)
            {
                //List<ApproachSplitFailAggregation> aggregations =
                //    Repo.GetApproachSplitFailAggregationByApproachIdAndDateRange(
                //        approach.ApproachID, options.StartDate, options.EndDate);
                //return aggregations;
            }
            return(null);
        }
Esempio n. 2
0
        protected override void LoadBins(Approach approach, ApproachAggregationMetricOptions options,
                                         bool getProtectedPhase,
                                         AggregatedDataType dataType)
        {
            var splitFailAggregationRepository =
                ApproachSplitFailAggregationRepositoryFactory.Create();
            var splitFails =
                splitFailAggregationRepository.GetApproachSplitFailsAggregationByApproachIdAndDateRange(
                    approach.ApproachID, options.StartDate, options.EndDate, getProtectedPhase);

            if (splitFails != null)
            {
                var concurrentBinContainers = new ConcurrentBag <BinsContainer>();
                //foreach (var binsContainer in binsContainers)
                Parallel.ForEach(BinsContainers, binsContainer =>
                {
                    var tempBinsContainer =
                        new BinsContainer(binsContainer.Start, binsContainer.End);
                    var concurrentBins = new ConcurrentBag <Bin>();
                    //foreach (var bin in binsContainer.Bins)
                    Parallel.ForEach(binsContainer.Bins, bin =>
                    {
                        if (splitFails.Any(s => s.BinStartTime >= bin.Start && s.BinStartTime < bin.End))
                        {
                            var splitFailCount = 0;
                            switch (dataType.DataName)
                            {
                            case "SplitFails":
                                splitFailCount =
                                    splitFails.Where(s => s.BinStartTime >= bin.Start && s.BinStartTime < bin.End)
                                    .Sum(s => s.SplitFailures);
                                break;

                            default:

                                throw new Exception("Unknown Aggregate Data Type for Split Failure");
                            }

                            concurrentBins.Add(new Bin
                            {
                                Start   = bin.Start,
                                End     = bin.End,
                                Sum     = splitFailCount,
                                Average = splitFailCount
                            });
                        }
                        else
                        {
                            concurrentBins.Add(new Bin
                            {
                                Start   = bin.Start,
                                End     = bin.End,
                                Sum     = 0,
                                Average = 0
                            });
                        }
                    });
                    tempBinsContainer.Bins = concurrentBins.OrderBy(c => c.Start).ToList();
                    concurrentBinContainers.Add(tempBinsContainer);
                });
                BinsContainers = concurrentBinContainers.OrderBy(b => b.Start).ToList();
            }
        }