52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using DataService.api;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Web.Http;
|
|
|
|
namespace LonglslandExhibitionCenter.Controllers.api
|
|
{
|
|
/// <summary>
|
|
/// 总览-气象站
|
|
/// </summary>
|
|
public class GetMeteorologicalStationController : ApiController
|
|
{
|
|
|
|
DataService.BLL.meteorological_station bll = new DataService.BLL.meteorological_station();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get()
|
|
{
|
|
var res = new get_meteorological_station();
|
|
try
|
|
{
|
|
var data = new List<meteorological_stationData>();
|
|
var list = bll.GetModelList("");
|
|
var time=Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:00:00"));
|
|
var alist=list.Where(x=>x.EntireTime==time).ToList();
|
|
foreach (var item in alist)
|
|
{
|
|
var model = new meteorological_stationData();
|
|
model.name = item.MeteorologicalName;
|
|
model.value = Convert.ToString(item.MeteorologicalValue);
|
|
data.Add(model);
|
|
}
|
|
res.code = 200;
|
|
res.msg = "成功";
|
|
res.data = data;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
res.code = 500;
|
|
res.msg = ex.Message;
|
|
}
|
|
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(res), Encoding.GetEncoding("UTF-8"), "application/json") };
|
|
return result;
|
|
}
|
|
}
|
|
} |