public PreciseRegionDateView QueryLastDateStat(DateTime initialDate, string city) { var beginDate = initialDate.AddDays(-100); var endDate = initialDate.AddDays(1); var query = _statRepository.GetAllList(beginDate, endDate); var result = (from q in query join t in _townRepository.GetAll(city) on q.TownId equals t.Id select q).ToList(); if (result.Count == 0) { return(null); } var maxDate = result.Max(x => x.StatTime); var townViews = result.Where(x => x.StatTime == maxDate) .Select(x => TownPreciseView.ConstructView(x, _townRepository)) .ToList(); return(new PreciseRegionDateView { StatDate = maxDate, TownPreciseViews = townViews, DistrictPreciseViews = Merge(townViews) }); }
public IEnumerable <PreciseRegionDateView> QueryDateViews(DateTime begin, DateTime end, string city) { var query = _statRepository.GetAllList(begin, end); var result = (from q in query join t in _townRepository.GetAll(city) on q.TownId equals t.Id select q).ToList(); var townViews = result.Select(x => TownPreciseView.ConstructView(x, _townRepository)).ToList(); return(from view in townViews group view by view.StatTime into g select new PreciseRegionDateView { StatDate = g.Key, TownPreciseViews = g.Select(x => x), DistrictPreciseViews = Merge(g.Select(x => x)) }); }
public void UploadItems(StreamReader reader) { try { var items = CsvContext.Read <PreciseCoverage4GCsv>(reader, CsvFileDescription.CommaDescription).ToList(); var statTime = items[0].StatTime; var stats = Mapper.Map <List <PreciseCoverage4GCsv>, List <PreciseCoverage4G> >(items); PreciseCoverage4Gs = new Stack <PreciseCoverage4G>(); foreach (var stat in stats) { PreciseCoverage4Gs.Push(stat); } var townStats = GetTownStats(stats); var mergeStats = GetMergeStats(townStats, statTime); TownPreciseViews = mergeStats.Select(x => TownPreciseView.ConstructView(x, _townRepository)).ToList(); } catch { // ignored TownPreciseViews = new List <TownPreciseView>(); } }
public List <TownPreciseView> Get(DateTime statTime, int stamp) { return(_service.GetMergeStats(_service.GetTownStats(PreciseImportService.PreciseCoverage4Gs.ToList()), statTime).Select(x => TownPreciseView.ConstructView(x, _townRepository)).ToList()); }