57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using DataServer.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 DongYingAPI.Controllers.api
|
|
{
|
|
/// <summary>
|
|
/// 照明-照明策略
|
|
/// </summary>
|
|
public class GetLightingStrategyController : ApiController
|
|
{
|
|
DataServer.BLL.lighting_strategy bll = new DataServer.BLL.lighting_strategy();
|
|
public HttpResponseMessage Get()
|
|
{
|
|
var res = new get_lighting_strategy();
|
|
try
|
|
{
|
|
var data = new List<lighting_strategyData>();
|
|
var list = bll.GetModelList("");
|
|
foreach (var item in list)
|
|
{
|
|
var model=new lighting_strategyData();
|
|
model.StrategyName = item.StrategyName;
|
|
if (item.StrategyState == "开")
|
|
{
|
|
model.StrategyState = 1;
|
|
}
|
|
if (item.StrategyState == "关")
|
|
{
|
|
model.StrategyState = 0;
|
|
}
|
|
//model.StrategyState = item.StrategyState;
|
|
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;
|
|
}
|
|
}
|
|
} |