48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using DataServer.api;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Web.Http;
|
|
|
|
namespace DongYingAPI.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 照明-单控
|
|
/// </summary>
|
|
public class GetSingleControlController : ApiController
|
|
{
|
|
DataServer.BLL.lighting_control bll = new DataServer.BLL.lighting_control();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get()
|
|
{
|
|
var res = new get_single_control();
|
|
try
|
|
{
|
|
var data = new List<single_controlData>();
|
|
var list = bll.GetModelList("");
|
|
foreach (var item in list)
|
|
{
|
|
var model = new single_controlData();
|
|
model.SingleName = item.LightingName;
|
|
model.SingleState= item.LightingState;
|
|
model.SingleIlluminance = item.LightingBrightness;
|
|
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;
|
|
}
|
|
}
|
|
} |