using System;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Http.Description;
using ESCG = EShang.Common.GeneralMethod;
using ESCM = EShang.Common.Model;
using Newtonsoft.Json;
using HZQR.Common;
namespace EShangApiMain.Controllers
{
///
/// 机器基础信息表相关接口
///
public class MACHINEBASEINFOController : BaseController
{
#region 获取机器基础信息表列表
///
/// 获取机器基础信息表列表
///
/// 查询条件对象
///
[Route("Equipment/GetMACHINEBASEINFOList")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg>))]
public IHttpActionResult GetMACHINEBASEINFOList(ESCM.SearchModel searchModel)
{
string Parameter = "入参信息:" + JsonConvert.SerializeObject(searchModel);
try
{
int TotalCount = 0;
//获取机器基础信息表列表
List MACHINEBASEINFOList = ESCG.MACHINEBASEINFOHelper.GetMACHINEBASEINFOList(
transaction, ref TotalCount, searchModel);
//转化json形式
Models.JsonList jsonList = Models.JsonList.Success(
MACHINEBASEINFOList, TotalCount, searchModel.PageIndex, searchModel.PageSize);
return Ok(Models.JsonMsg>.Success(jsonList, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetMACHINEBASEINFOList");
return Ok(Method.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region 获取机器基础信息表明细
///
/// 获取机器基础信息表明细
///
/// 机器基础信息表内码
///
[Route("Equipment/GetMACHINEBASEINFODetail")]
[AcceptVerbs("GET")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult GetMACHINEBASEINFODetail(int MACHINEBASEINFOId)
{
string Parameter = "入参信息:机器基础信息表内码【" + MACHINEBASEINFOId + "】";
try
{
//获取机器基础信息表明细
ESCM.MACHINEBASEINFOModel machinebaseinfoModel = ESCG.MACHINEBASEINFOHelper.GetMACHINEBASEINFODetail(transaction, MACHINEBASEINFOId);
return Ok(Models.JsonMsg.Success(machinebaseinfoModel, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetMACHINEBASEINFODetail");
return Ok(Method.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region 同步机器基础信息表
///
/// 同步机器基础信息表
///
///
///
[Route("Equipment/SynchroMACHINEBASEINFO")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult SynchroMACHINEBASEINFO(ESCM.MACHINEBASEINFOModel machinebaseinfoModel)
{
try
{
//新增机器基础信息表
bool SynchroFlag = ESCG.MACHINEBASEINFOHelper.SynchroMACHINEBASEINFO(transaction, machinebaseinfoModel);
if (SynchroFlag)
{
return Ok(Method.Common.ReturnJson(100, "同步成功"));
}
else
{
return Ok(Method.Common.ReturnJson(200, "更新失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "同步失败!失败原因:" + ex.Message,
DateTime.Now.ToString("yyyyMMdd") + "_SynchroMACHINEBASEINFO");
return Ok(Method.Common.ReturnJson(999, "同步失败" + ex.Message));
}
}
#endregion
#region 删除机器基础信息表
///
/// 删除机器基础信息表
///
/// 机器基础信息表内码
///
[Route("Equipment/DeleteMACHINEBASEINFO")]
[AcceptVerbs("GET", "POST")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult DeleteMACHINEBASEINFO(int MACHINEBASEINFOId)
{
string Parameter = "入参信息:机器基础信息表内码【" + MACHINEBASEINFOId + "】";
try
{
//删除机器基础信息表
bool DeleteFlag = ESCG.MACHINEBASEINFOHelper.DeleteMACHINEBASEINFO(transaction, MACHINEBASEINFOId);
if (DeleteFlag)
{
return Ok(Method.Common.ReturnJson(100, "删除成功"));
}
else
{
return Ok(Method.Common.ReturnJson(200, "删除失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "删除失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_DeleteMACHINEBASEINFO");
return Ok(Method.Common.ReturnJson(999, "删除失败" + ex.Message));
}
}
#endregion
}
}