예제 #1
0
        public async Task <int[]> GenerateTownStats(DateTime statDate)
        {
            var end   = statDate.AddDays(1);
            var item2 = _townRrcRepository.Count(x => x.StatTime >= statDate && x.StatTime < end);

            if (item2 < 44)
            {
                var townRrcList = _rrcService.GetTownRrcStats(statDate);
                foreach (var stat in townRrcList.GetPositionMergeStats(statDate))
                {
                    var subItem = _townRrcRepository.FirstOrDefault(
                        x => x.StatTime >= statDate && x.StatTime < end && x.TownId == stat.TownId);
                    if (subItem == null)
                    {
                        await _townRrcRepository.InsertAsync(stat);
                    }
                    else
                    {
                        var oldId = subItem.Id;
                        stat.MapTo(subItem);
                        subItem.Id = oldId;
                    }
                }
                item2 += _townRrcRepository.SaveChanges();
            }
            var item6 = _townQciRepository.Count(x => x.StatTime >= statDate && x.StatTime < end);

            if (item6 < 44)
            {
                var townQciList = _qciService.GetTownQciStats(statDate);
                foreach (var stat in townQciList.GetPositionMergeStats(statDate))
                {
                    var subItem = _townQciRepository.FirstOrDefault(
                        x => x.StatTime >= statDate && x.StatTime < end && x.TownId == stat.TownId);
                    if (subItem == null)
                    {
                        await _townQciRepository.InsertAsync(stat);
                    }
                    else
                    {
                        var oldId = subItem.Id;
                        stat.MapTo(subItem);
                        subItem.Id = oldId;
                    }
                }
                item6 += _townQciRepository.SaveChanges();
            }
            return(new [] { item2, item6 });
        }
예제 #2
0
        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));
        }