64 lines
2.2 KiB
C#
64 lines
2.2 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 JinanCementFactoryAPI.Controllers.api
|
|
{
|
|
/// <summary>
|
|
/// 摄像头列表
|
|
/// </summary>
|
|
public class GetCameraListController : ApiController
|
|
{
|
|
DataServer.BLL.camera_monitoring bll = new DataServer.BLL.camera_monitoring();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get(string type = "")
|
|
{
|
|
var res = new get_camera_list();
|
|
try
|
|
{
|
|
|
|
var list = bll.GetModelList("");
|
|
var alist = new List<camera_listData>();
|
|
if (type == "生产监控系统")
|
|
{
|
|
var blist=list.Where(x=>x.CameraType==1).ToList();
|
|
foreach (var item in blist)
|
|
{
|
|
var model = new camera_listData();
|
|
model.CameraName = item.CameraName;
|
|
model.time = DateTime.Now.ToString("HH:mm:ss");
|
|
alist.Add(model);
|
|
}
|
|
}
|
|
if (type == "配电室监控系统")
|
|
{
|
|
var blist = list.Where(x => x.CameraType == 2).ToList();
|
|
foreach (var item in blist)
|
|
{
|
|
var model = new camera_listData();
|
|
model.CameraName = item.CameraName;
|
|
model.time = DateTime.Now.ToString("HH:mm:ss");
|
|
alist.Add(model);
|
|
}
|
|
}
|
|
res.code = 200;
|
|
res.msg = "成功";
|
|
res.data = alist;
|
|
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
} |