Beispiel #1
0
        public IHttpActionResult GetSiteList()
        {
            //ISiteService siteService = EngineContext.Current.Resolve<ISiteService>();
            IAqiManager      aqiManager   = EngineContext.Current.Resolve <IAqiManager>();
            IAqiGradeService gradeService = EngineContext.Current.Resolve <IAqiGradeService>();

            var allSite = aqiManager.GetAllStation();

            List <SiteGroup> gp = new List <SiteGroup>();

            List <SiteModel> result = new List <SiteModel>();

            foreach (var site in allSite)
            {
                SiteGroup g = gp.Where(p => p.GroupName == site.FirstPinyin).FirstOrDefault();
                if (null == g)
                {
                    g = new SiteGroup()
                    {
                        GroupName = site.FirstPinyin
                    };
                    gp.Add(g);
                }
                SiteModel sm = new SiteModel();
                sm.Id        = site.StationCode;
                sm.Name      = site.StationName;
                sm.Group     = site.FirstPinyin;
                sm.Latitude  = site.Latitude;
                sm.Longitude = site.Longitude;
                sm.Aqi       = aqiManager.GetSiteCurrentAqi(site.StationCode)[0];
                sm.Grade     = gradeService.CalcGrade(sm.Aqi).Grade;
                g.Items.Add(sm);
            }
            return(Ok(gp.OrderBy(g => g.GroupName).ToList()));
        }
Beispiel #2
0
 public AqiManager(ICacheManager cacheManager,
                   IRepository <UpdateTime> updateTimeRepository,
                   IRepository <DataRTSite> siteDataRepository,
                   IEntityService <Parameter> parameterRepository,
                   IEntityService <Site> siteService,
                   IAqiGradeService aqiGradeService,
                   IRepository <DataRTGroup> groupDataRepository)
 {
     _updateTimeRepository = updateTimeRepository;
     _siteDataRepository   = siteDataRepository;
     _parameterRepository  = parameterRepository;
     _siteService          = siteService;
     _cacheManager         = cacheManager;
     _aqiGradeService      = aqiGradeService;
     _groupDataRepository  = groupDataRepository;
 }
Beispiel #3
0
 public RestAqiManager(ICacheManager cacheManager, IAqiGradeService aqiGradeService, ISettingService settingService)
 {
     _cacheManager    = cacheManager;
     _aqiGradeService = aqiGradeService;
     _settingService  = settingService;
 }