49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using DataService.api;
|
|
using Microsoft.Ajax.Utilities;
|
|
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 LonglslandExhibitionCenter.Controllers.api
|
|
{
|
|
/// <summary>
|
|
/// 照明-故障情况
|
|
/// </summary>
|
|
public class GetFaultConditionController : ApiController
|
|
{
|
|
DataService.BLL.lighting_info bll = new DataService.BLL.lighting_info();
|
|
public HttpResponseMessage Get()
|
|
{
|
|
var res = new get_fault_condition();
|
|
try
|
|
{
|
|
var data = new List<fault_conditionData>();
|
|
var list = bll.GetModelList("");
|
|
var alist = list.Where(x => x.LightingMalfunction=="1").ToList();
|
|
var blist = list.Where(x => x.LightingMalfunction == "0").ToList();
|
|
var model = new fault_conditionData()
|
|
{
|
|
Amount = list.Count(),
|
|
Normality = alist.Count(),
|
|
Malfunction=blist.Count()
|
|
};
|
|
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;
|
|
}
|
|
}
|
|
} |