Exemple #1
0
        private FullDataRes GetDatatracking(int roomId)
        {
            // First, check the cache
            var trackingdata = _cache.Get("InfoRoom") as FullDataRes;

            // If it's not in the cache, we need to read it from the repository
            if (trackingdata == null)
            {
                //kiem tra thong bao trong ngay
                FullDataRes result = new FullDataRes();

                using (var multi = _readOnlyRepository.Value.Connection.QueryMultiple(@"EXEC SP_Room_GetInfo;
                EXEC SP_Room_GetInfoChart @RoomId", new
                {
                    RoomId = roomId
                }))
                {
                    result.InfoRooms  = multi.Read <InfoRoomRes>().ToList();
                    result.InfoCharts = multi.Read <TransactionRes>().ToList();
                }

                trackingdata = result;

                if (trackingdata.InfoRooms.Any())
                {
                    // Put this data into the cache for 300 minutes
                    _cache.Set("InfoRoom", trackingdata); // 300 minute
                }
            }
            return(trackingdata);
        }
Exemple #2
0
        public FundingSummaryModel BuildWithFundLine(string title, FM81Global fm81Global, List <string> validLearners, string fundLine, string[] attributes, int period)
        {
            FundingSummaryModel fundingSummaryModel = new FundingSummaryModel(title);

            if (fm81Global?.Learners == null || validLearners == null)
            {
                return(fundingSummaryModel);
            }

            LearningDelivery[] learningDeliveries = _cacheProviderService.Get(fundLine);
            if (learningDeliveries == null)
            {
                FM81Learner[] learners =
                    fm81Global.Learners.Where(x => validLearners.Contains(x.LearnRefNumber)).ToArray();

                learningDeliveries = learners.SelectMany(x => x.LearningDeliveries)
                                     .Where(x => string.Equals(fundLine, x.LearningDeliveryValues.FundLine, StringComparison.OrdinalIgnoreCase)).ToArray();

                _cacheProviderService.Set(fundLine, learningDeliveries);
            }

            LearningDeliveryPeriodisedValue[] periodisedValues = learningDeliveries.SelectMany(x => x.LearningDeliveryPeriodisedValues)
                                                                 .Where(x => attributes.Contains(x.AttributeName)).ToArray();

            fundingSummaryModel.Period1  = periodisedValues.Sum(x => x.Period1 ?? 0);
            fundingSummaryModel.Period2  = periodisedValues.Sum(x => x.Period2 ?? 0);
            fundingSummaryModel.Period3  = periodisedValues.Sum(x => x.Period3 ?? 0);
            fundingSummaryModel.Period4  = periodisedValues.Sum(x => x.Period4 ?? 0);
            fundingSummaryModel.Period5  = periodisedValues.Sum(x => x.Period5 ?? 0);
            fundingSummaryModel.Period6  = periodisedValues.Sum(x => x.Period6 ?? 0);
            fundingSummaryModel.Period7  = periodisedValues.Sum(x => x.Period7 ?? 0);
            fundingSummaryModel.Period8  = periodisedValues.Sum(x => x.Period8 ?? 0);
            fundingSummaryModel.Period9  = periodisedValues.Sum(x => x.Period9 ?? 0);
            fundingSummaryModel.Period10 = periodisedValues.Sum(x => x.Period10 ?? 0);
            fundingSummaryModel.Period11 = periodisedValues.Sum(x => x.Period11 ?? 0);
            fundingSummaryModel.Period12 = periodisedValues.Sum(x => x.Period12 ?? 0);

            fundingSummaryModel.Period1_8 =
                fundingSummaryModel.Period1 + fundingSummaryModel.Period2 + fundingSummaryModel.Period3 +
                fundingSummaryModel.Period4 + fundingSummaryModel.Period5 + fundingSummaryModel.Period6 +
                fundingSummaryModel.Period7 + fundingSummaryModel.Period8;
            fundingSummaryModel.Period9_12 =
                fundingSummaryModel.Period9 + fundingSummaryModel.Period10 + fundingSummaryModel.Period11 +
                fundingSummaryModel.Period12;

            fundingSummaryModel.YearToDate = GetYearToDate(fundingSummaryModel, period - 1);
            fundingSummaryModel.Total      = GetYearToDate(fundingSummaryModel, 12);

            return(fundingSummaryModel);
        }
Exemple #3
0
        public FundingSummaryModel BuildWithFundLine(string title, FM36Global fm36Global, List <string> validLearners, string[] fundLines, string[] attributes, int period)
        {
            FundingSummaryModel fundingSummaryModel = new FundingSummaryModel(title);

            if (fm36Global?.Learners == null || validLearners == null)
            {
                return(fundingSummaryModel);
            }

            LearningDelivery[] learningDeliveries = _cacheProviderService.Get(fundLines.GetHashCode());
            if (learningDeliveries == null)
            {
                FM36Learner[] learners = fm36Global.Learners.Where(x => validLearners.Contains(x.LearnRefNumber)).ToArray();

                learningDeliveries = learners.SelectMany(x => x.LearningDeliveries).Where(x => fundLines.Contains(x.LearningDeliveryValues.LearnDelInitialFundLineType)).ToArray();

                _cacheProviderService.Set(fundLines.GetHashCode(), learningDeliveries);
            }

            var periodisedValues = learningDeliveries.SelectMany(x => x.LearningDeliveryPeriodisedValues)
                                   .Where(x => attributes.Contains(x.AttributeName)).ToArray();

            fundingSummaryModel.Period1  = periodisedValues.Sum(x => x.Period1 ?? 0);
            fundingSummaryModel.Period2  = periodisedValues.Sum(x => x.Period2 ?? 0);
            fundingSummaryModel.Period3  = periodisedValues.Sum(x => x.Period3 ?? 0);
            fundingSummaryModel.Period4  = periodisedValues.Sum(x => x.Period4 ?? 0);
            fundingSummaryModel.Period5  = periodisedValues.Sum(x => x.Period5 ?? 0);
            fundingSummaryModel.Period6  = periodisedValues.Sum(x => x.Period6 ?? 0);
            fundingSummaryModel.Period7  = periodisedValues.Sum(x => x.Period7 ?? 0);
            fundingSummaryModel.Period8  = periodisedValues.Sum(x => x.Period8 ?? 0);
            fundingSummaryModel.Period9  = periodisedValues.Sum(x => x.Period9 ?? 0);
            fundingSummaryModel.Period10 = periodisedValues.Sum(x => x.Period10 ?? 0);
            fundingSummaryModel.Period11 = periodisedValues.Sum(x => x.Period11 ?? 0);
            fundingSummaryModel.Period12 = periodisedValues.Sum(x => x.Period12 ?? 0);

            fundingSummaryModel.Period1_8 =
                fundingSummaryModel.Period1 + fundingSummaryModel.Period2 + fundingSummaryModel.Period3 +
                fundingSummaryModel.Period4 + fundingSummaryModel.Period5 + fundingSummaryModel.Period6 +
                fundingSummaryModel.Period7 + fundingSummaryModel.Period8;
            fundingSummaryModel.Period9_12 =
                fundingSummaryModel.Period9 + fundingSummaryModel.Period10 + fundingSummaryModel.Period11 +
                fundingSummaryModel.Period12;

            fundingSummaryModel.YearToDate = GetYearToDate(fundingSummaryModel, period - 1);
            fundingSummaryModel.Total      = GetYearToDate(fundingSummaryModel, 12);

            return(fundingSummaryModel);
        }
Exemple #4
0
        public IEnumerable <DB_LOG> GetDatatracking()
        {
            // First, check the cache
            var trackingdata = _cacheProviderService.Get("TrackingLOG") as IDictionary <int, DB_LOG>;

            // If it's not in the cache, we need to read it from the repository
            if (trackingdata == null)
            {
                //kiem tra thong bao trong ngay
                trackingdata = _unitOfWork.dbLogRepository.GetAll().ToDictionary(v => v.Id);

                if (trackingdata.Any())
                {
                    // Put this data into the cache for 300 minutes
                    _cacheProviderService.Set("TrackingLOG", trackingdata); // 300 minute
                }
            }
            return(trackingdata.Values);
        }