コード例 #1
0
ファイル: TownKpiService.cs プロジェクト: yanzj/BackGround
        public async Task <int[]> GenerateTownPrbs(DateTime statTime)
        {
            var end    = statTime.AddDays(1);
            var count0 = _townPrbRepository.Count(x =>
                                                  x.StatTime >= statTime && x.StatTime < end && x.FrequencyBandType == FrequencyBandType.All);

            if (count0 == 0)
            {
                var townPrbList = _prbService.GetTownPrbStats(statTime);
                foreach (var stat in townPrbList.GetPositionMergeStats(statTime))
                {
                    stat.FrequencyBandType = FrequencyBandType.All;
                    await _townPrbRepository.InsertAsync(stat);
                }
                count0 = _townPrbRepository.SaveChanges();
            }

            var count1 = _townPrbRepository.Count(x =>
                                                  x.StatTime >= statTime && x.StatTime < end && x.FrequencyBandType == FrequencyBandType.Band2100);

            if (count1 == 0)
            {
                var townPrbList = _prbService.GetTownPrbStats(statTime, FrequencyBandType.Band2100);
                foreach (var stat in townPrbList.GetPositionMergeStats(statTime))
                {
                    stat.FrequencyBandType = FrequencyBandType.Band2100;
                    await _townPrbRepository.InsertAsync(stat);
                }
                count1 = _townPrbRepository.SaveChanges();
            }
            var count2 = _townPrbRepository.Count(x => x.StatTime >= statTime && x.StatTime < end && x.FrequencyBandType == FrequencyBandType.Band1800);

            if (count2 == 0)
            {
                var townPrbList = _prbService.GetTownPrbStats(statTime, FrequencyBandType.Band1800);
                foreach (var stat in townPrbList.GetPositionMergeStats(statTime))
                {
                    stat.FrequencyBandType = FrequencyBandType.Band1800;
                    await _townPrbRepository.InsertAsync(stat);
                }
                count2 = _townPrbRepository.SaveChanges();
            }
            var count3 = _townPrbRepository.Count(x => x.StatTime >= statTime && x.StatTime < end && x.FrequencyBandType == FrequencyBandType.Band800VoLte);

            if (count3 == 0)
            {
                var townPrbList = _prbService.GetTownPrbStats(statTime, FrequencyBandType.Band800VoLte);
                foreach (var stat in townPrbList.GetPositionMergeStats(statTime))
                {
                    stat.FrequencyBandType = FrequencyBandType.Band800VoLte;
                    await _townPrbRepository.InsertAsync(stat);
                }
                count3 = _townPrbRepository.SaveChanges();
            }
            return(new[] { count0, count1, count2, count3 });
        }
コード例 #2
0
ファイル: TownKpiService.cs プロジェクト: xuhaoa/LtePlatform
        public async Task <Tuple <int, int, int, int, int, int, int> > GenerateTownStats(DateTime statDate)
        {
            var end   = statDate.AddDays(1);
            var item1 =
                _townFlowRepository.Count(
                    x => x.StatTime >= statDate && x.StatTime < end && x.FrequencyBandType == FrequencyBandType.All);

            if (item1 == 0)
            {
                var townStatList = GetTownFlowStats(statDate);
                foreach (var stat in townStatList.GetPositionMergeStats(statDate))
                {
                    await _townFlowRepository.InsertAsync(stat);
                }
                item1 = _townFlowRepository.SaveChanges();
            }
            var item2 = _townRrcRepository.Count(x => x.StatTime >= statDate && x.StatTime < end);

            if (item2 == 0)
            {
                var townRrcList = GetTownRrcStats(statDate);
                foreach (var stat in townRrcList.GetPositionMergeStats(statDate))
                {
                    await _townRrcRepository.InsertAsync(stat);
                }
                item2 = _townRrcRepository.SaveChanges();
            }
            var item3 =
                _townFlowRepository.Count(
                    x => x.StatTime >= statDate && x.StatTime < end && x.FrequencyBandType == FrequencyBandType.Band2100);

            if (item3 == 0)
            {
                var townStatList = GetTownFlowStats(statDate, FrequencyBandType.Band2100);
                foreach (var stat in townStatList.GetPositionMergeStats(statDate))
                {
                    stat.FrequencyBandType = FrequencyBandType.Band2100;
                    await _townFlowRepository.InsertAsync(stat);
                }
                item3 = _townFlowRepository.SaveChanges();
            }
            var item4 =
                _townFlowRepository.Count(
                    x => x.StatTime >= statDate && x.StatTime < end && x.FrequencyBandType == FrequencyBandType.Band1800);

            if (item4 == 0)
            {
                var townStatList = GetTownFlowStats(statDate, FrequencyBandType.Band1800);
                foreach (var stat in townStatList.GetPositionMergeStats(statDate))
                {
                    stat.FrequencyBandType = FrequencyBandType.Band1800;
                    await _townFlowRepository.InsertAsync(stat);
                }
                item4 = _townFlowRepository.SaveChanges();
            }
            var item5 =
                _townFlowRepository.Count(
                    x => x.StatTime >= statDate && x.StatTime < end && x.FrequencyBandType == FrequencyBandType.Band800VoLte);

            if (item5 == 0)
            {
                var townStatList = GetTownFlowStats(statDate, FrequencyBandType.Band800VoLte);
                foreach (var stat in townStatList.GetPositionMergeStats(statDate))
                {
                    stat.FrequencyBandType = FrequencyBandType.Band800VoLte;
                    await _townFlowRepository.InsertAsync(stat);
                }
                item5 = _townFlowRepository.SaveChanges();
            }
            var item6 = _townQciRepository.Count(x => x.StatTime >= statDate && x.StatTime < end);

            if (item6 == 0)
            {
                var townQciList = GetTownQciStats(statDate);
                foreach (var stat in townQciList.GetPositionMergeStats(statDate))
                {
                    await _townQciRepository.InsertAsync(stat);
                }
                item6 = _townQciRepository.SaveChanges();
            }
            var item7 = _townPrbRepository.Count(x => x.StatTime >= statDate && x.StatTime < end);

            if (item7 == 0)
            {
                var townPrbList = GetTownPrbStats(statDate);
                foreach (var stat in townPrbList.GetPositionMergeStats(statDate))
                {
                    await _townPrbRepository.InsertAsync(stat);
                }
                item7 = _townPrbRepository.SaveChanges();
            }
            return(new Tuple <int, int, int, int, int, int, int>(item1, item2, item3, item4, item5, item6, item7));
        }