using System.Web.Http; using Model; using System.Collections.Generic; using System; using BLL; namespace WebAPI.Controllers.TestRun { public class DriverRunController : ApiController { // // 质量巡检 // GET: /Draw/ [HttpGet] public ResponseData> Index(string projectId, int index, int page, string state) { ResponseData> res = new ResponseData>(); res.successful = true; res.resultValue = BLL.DriverRunService.GetListDataForApi(state, projectId, index, page); return res; } [HttpGet] public ResponseData> Search(string state, string projectId, int index, int page) { ResponseData> res = new ResponseData>(); res.successful = true; res.resultValue = BLL.DriverRunService.GetListDataForApi(state, projectId, index, page); return res; } /// /// 根据code获取详情 /// /// /// public ResponseData GetDriverRun(string code) { ResponseData res = new ResponseData(); DriverRun_DriverRun DriverRun = BLL.DriverRunService.GetDriverRunForApi(code); res.successful = true; res.resultValue = BeanUtil.CopyOjbect(DriverRun, true); return res; } /// /// 根据code获取 审核记录 /// /// /// public ResponseData> GetApproveByCode(string code) { ResponseData> res = new ResponseData>(); res.successful = true; res.resultValue = BLL.DriverRunApproveService.GetListDataByCodeForApi(code); return res; } public ResponseData GetCurrApproveByCode(string code) { ResponseData res = new ResponseData(); res.successful = true; res.resultValue = BeanUtil.CopyOjbect(BLL.DriverRunApproveService.getCurrApproveForApi(code), true); return res; } [HttpPost] public ResponseData AddDriverRun([FromBody]Model.DriverRun_DriverRun DriverRun) { ResponseData res = new ResponseData(); try { if (string.IsNullOrEmpty(DriverRun.DriverRunId)) { DriverRun.DriverRunId = Guid.NewGuid().ToString(); BLL.DriverRunService.AddDriverRunForApi(DriverRun); SaveAttachFile(DriverRun.DriverRunId, BLL.Const.CheckListMenuId, DriverRun.AttachUrl); res.resultValue = DriverRun.DriverRunId; } else { BLL.DriverRunService.UpdateDriverRunForApi(DriverRun); SaveAttachFile(DriverRun.DriverRunId, BLL.Const.CheckListMenuId, DriverRun.AttachUrl); res.resultValue = DriverRun.DriverRunId; } res.successful = true; } catch (Exception e) { res.resultHint = e.StackTrace; res.successful = false; } return res; } /// /// /// public static void SaveAttachFile(string dataId, string menuId, string url) { Model.ToDoItem toDoItem = new Model.ToDoItem { MenuId = menuId, DataId = dataId, UrlStr = url, }; APIUpLoadFileService.SaveAttachUrl(toDoItem); } [HttpPost] public ResponseData AddApprove([FromBody]Model.DriverRun_DriverRunApprove approve) { ResponseData res = new ResponseData(); try { Model.DriverRun_DriverRun DriverRun = new Model.DriverRun_DriverRun(); DriverRun.DriverRunId = approve.DriverRunId; DriverRun.State = approve.ApproveType; BLL.DriverRunService.UpdateDriverRunForApi(DriverRun); res.resultValue = BLL.DriverRunApproveService.AddDriverRunApproveForApi(approve); res.successful = true; } catch (Exception e) { res.resultHint = e.StackTrace; res.successful = false; } return res; } [HttpPost] public ResponseData UpdateApprove([FromBody]Model.DriverRun_DriverRunApprove approve) { ResponseData res = new ResponseData(); try { approve.ApproveDate = DateTime.Now; BLL.DriverRunApproveService.UpdateDriverRunApproveForApi(approve); res.successful = true; } catch (Exception e) { res.resultHint = e.StackTrace; res.successful = false; } return res; } // GET: /Draw/ [HttpGet] public ResponseData see(string dataId, string userId) { ResponseData res = new ResponseData(); res.successful = true; BLL.DriverRunApproveService.See(dataId, userId); return res; } } }