using IWareDataAccess.Entity.Alert;
|
using IWareDataAccess.ReturnEntity;
|
using IWareDataAccess.ReturnEntity.Alert;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web;
|
using System.Web.Http;
|
|
namespace WebApi_QQJF.Controllers
|
{
|
public class AlertController : ApiController
|
{
|
/// <summary>
|
/// 统一对象,读取值
|
/// </summary>
|
/// <returns></returns>
|
private AlertWebEntity GetEntity()
|
{
|
AlertWebEntity model = new AlertWebEntity();
|
HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context
|
HttpRequestBase request = context.Request;//定义传统request对象
|
|
WebHelper.WebHelper.GetRequest(request, model);
|
|
return model;
|
}
|
|
|
[HttpPost, Route("Alert/Search")]
|
public IHttpActionResult Search(int page)
|
{
|
int onePageNum = 20;
|
return SearchFunc(page, onePageNum);
|
}
|
|
[HttpPost, Route("Alert/Search")]
|
public IHttpActionResult Search(int page, int onePageNum)
|
{
|
return SearchFunc(page, onePageNum);
|
}
|
|
private IHttpActionResult SearchFunc(int page, int onePageNum)
|
{
|
string msg = "";
|
AlertWebEntity model = new AlertWebEntity();
|
model = GetEntity();
|
//调用查询方法
|
ReturnSearchAlertView returnData = new ReturnSearchAlertView();
|
returnData.data = IWareDataAccess.Alert.ALERT.AlertSqlFunc.SearchView(model, page, onePageNum, out msg);
|
returnData.code = 0;
|
returnData.num = IWareDataAccess.Alert.ALERT.AlertSqlFunc.SearchViewNum(model);
|
returnData.page = page;
|
returnData.pageNum = (returnData.num - 1) / 20 + 1;
|
returnData.msg = msg;
|
//返回JSON结果
|
return Json(returnData);
|
}
|
|
[HttpPost, Route("Alert/AddOrUpdate")]
|
public IHttpActionResult AddOrUpdate()
|
{
|
string msg = "";
|
AlertWebEntity model = new AlertWebEntity();
|
model = GetEntity();
|
//调用查询方法
|
bool result = IWareDataAccess.Alert.ALERT.AlertSqlFunc.AddOrUpdate(model, out msg);
|
ReturnResultAndMsg returnData = new ReturnResultAndMsg();
|
returnData.code = result ? 0 : 1;
|
returnData.msg = msg;
|
//返回JSON结果
|
return Json(returnData);
|
}
|
|
[HttpPost, Route("Alert/Delete")]
|
public IHttpActionResult Delete()
|
{
|
string msg = "";
|
AlertWebEntity model = new AlertWebEntity();
|
model = GetEntity();
|
//调用查询方法
|
bool result = IWareDataAccess.Alert.ALERT.AlertSqlFunc.Delete(model, out msg);
|
ReturnResultAndMsg returnData = new ReturnResultAndMsg();
|
returnData.code = result ? 0 : 1;
|
returnData.msg = msg;
|
//返回JSON结果
|
return Json(returnData);
|
|
}
|
|
|
[HttpPost, Route("Alert/GetCode")]
|
public IHttpActionResult GetCode()
|
{
|
string msg = "";
|
AlertWebEntity model = new AlertWebEntity();
|
model = GetEntity();
|
//调用查询方法
|
string result = IWareDataAccess.Alert.ALERT.AlertSqlFunc.GetCode();
|
//返回JSON结果
|
return Json(result);
|
|
}
|
|
[HttpPost, Route("Alert/GetAllAlarmInfo")]
|
public IHttpActionResult GetAllAlarmInfo()
|
{
|
string msg = "";
|
AlertWebEntity model = new AlertWebEntity();
|
model = GetEntity();
|
|
var data = IWareDataAccess.Alert.ALERT.AlertSqlFunc.GetAllAlarmInfo(model);
|
//if (data.Count == 0)
|
//{
|
// IWareDataAccess.EF.View_ALERT_ALERT ob = new IWareDataAccess.EF.View_ALERT_ALERT();
|
// ob.id=1;
|
// ob.alertName="无故障";
|
// ob.deviceName = "全设备";
|
// ob.alertDes = "全设备";
|
// ob.createTime = DateTime.Now;
|
// ob.finishTime=DateTime.Now;
|
// ob.totalTime=0;
|
// ob.alertCode="";
|
// data.Add(ob);
|
//}
|
//返回JSON结果
|
return Json(data);
|
|
}
|
}
|
}
|