public ActionResult GetEquipmentState(string equipmentCode) { string stateName = string.Empty; //根据生产线和工序获取设备。 using (EquipmentServiceClient client = new EquipmentServiceClient()) { MethodReturnResult <Equipment> result = client.Get(equipmentCode); if (result.Code <= 0 && result.Data != null) { stateName = result.Data.StateName; } } string stateColor = string.Empty; if (!string.IsNullOrEmpty(stateName)) { using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { MethodReturnResult <EquipmentState> result = client.Get(stateName); if (result.Code <= 0 && result.Data != null) { stateColor = result.Data.StateColor; } } } return(Json(new { StateName = stateName, StateColor = stateColor }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> SaveModify(EquipmentStateViewModel model) { using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { MethodReturnResult <EquipmentState> result = await client.GetAsync(model.Name); if (result.Code == 0) { result.Data.StateColor = model.StateColor; result.Data.Type = model.Type; result.Data.Category = model.Category; result.Data.Description = model.Description; result.Data.Editor = User.Identity.Name; result.Data.EditTime = DateTime.Now; MethodReturnResult rst = await client.ModifyAsync(result.Data); if (rst.Code == 0) { rst.Message = string.Format(FMMResources.StringResource.EquipmentState_SaveModify_Success , model.Name); } return(Json(rst)); } return(Json(result)); } }
// // GET: /FMM/EquipmentState/Detail public async Task <ActionResult> Detail(string key) { using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { MethodReturnResult <EquipmentState> result = await client.GetAsync(key); if (result.Code == 0) { EquipmentStateViewModel viewModel = new EquipmentStateViewModel() { Name = result.Data.Key, Category = result.Data.Category, Type = result.Data.Type, StateColor = result.Data.StateColor, CreateTime = result.Data.CreateTime, Creator = result.Data.Creator, Description = result.Data.Description, Editor = result.Data.Editor, EditTime = result.Data.EditTime }; return(PartialView("_InfoPartial", viewModel)); } else { ModelState.AddModelError("", result.Message); } } return(PartialView("_InfoPartial")); }
public async Task <ActionResult> Save(EquipmentStateViewModel model) { using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { EquipmentState obj = new EquipmentState() { Key = model.Name, Category = model.Category, Type = model.Type, StateColor = model.StateColor, Description = model.Description, Editor = User.Identity.Name, EditTime = DateTime.Now, CreateTime = DateTime.Now, Creator = User.Identity.Name }; MethodReturnResult rst = await client.AddAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(FMMResources.StringResource.EquipmentState_Save_Success , model.Name); } return(Json(rst)); } }
// // GET: /FMM/EquipmentChangeState/ public async Task <ActionResult> Index() { using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { IsPaging = false, OrderBy = "Type,Key" }; MethodReturnResult <IList <EquipmentState> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.StateList = result.Data; } else { ModelState.AddModelError("", result.Message); } }); } using (EquipmentChangeStateServiceClient client = new EquipmentChangeStateServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { IsPaging = false }; MethodReturnResult <IList <EquipmentChangeState> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.ChangeStateList = result.Data; } else { ModelState.AddModelError("", result.Message); } }); } if (Request.IsAjaxRequest()) { return(PartialView("_ListPartial")); } else { return(View()); } }
public async Task <ActionResult> Query(EquipmentStateQueryViewModel model) { if (ModelState.IsValid) { using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { if (!string.IsNullOrEmpty(model.Name)) { where.AppendFormat(" {0} Key LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Name); } if (model.Type != null) { where.AppendFormat(" {0} Type = '{1}'" , where.Length > 0 ? "AND" : string.Empty , Convert.ToInt32(model.Type)); } if (model.Category != null) { where.AppendFormat(" {0} Category = '{1}'" , where.Length > 0 ? "AND" : string.Empty , Convert.ToInt32(model.Category)); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Type,Key", Where = where.ToString() }; MethodReturnResult <IList <EquipmentState> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
public async Task <ActionResult> Query(EquipmentLayoutDetailQueryViewModel model) { using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient()) { MethodReturnResult <EquipmentLayout> result = await client.GetAsync(model.LayoutName ?? string.Empty); ViewBag.EquipmentLayout = result.Data; } using (EquipmentLayoutDetailServiceClient client = new EquipmentLayoutDetailServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format(" Key.LayoutName = '{0}'" , model.LayoutName) }; MethodReturnResult <IList <EquipmentLayoutDetail> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { IsPaging = false }; MethodReturnResult <IList <EquipmentState> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.StateList = result.Data; } }); } return(PartialView("_ListPartial", new EquipmentLayoutDetailViewModel() { LayoutName = model.LayoutName })); }
public async Task <ActionResult> Delete(string key) { MethodReturnResult result = new MethodReturnResult(); using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { result = await client.DeleteAsync(key); if (result.Code == 0) { result.Message = string.Format(FMMResources.StringResource.EquipmentState_Delete_Success , key); } return(Json(result)); } }
// // GET: /FMM/EquipmentState/ public async Task <ActionResult> Index() { using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "Type,Key" }; MethodReturnResult <IList <EquipmentState> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new EquipmentStateQueryViewModel())); }
public ActionResult GetEquipmentStateColor(string stateName) { string stateColor = string.Empty; string description = string.Empty; //根据设备状态获取设备状态。 using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { MethodReturnResult <EquipmentState> result = client.Get(stateName); if (result.Code <= 0 && result.Data != null) { stateColor = result.Data.StateColor; description = result.Data.Description; } } return(Json(new { StateName = stateName, StateColor = stateColor, Description = description }, JsonRequestBehavior.AllowGet)); }
public IEnumerable <SelectListItem> GetEquipmentStateList() { using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false }; MethodReturnResult <IList <EquipmentState> > result = client.Get(ref cfg); if (result.Code <= 0) { return(from item in result.Data select new SelectListItem() { Text = item.Key, Value = item.Key }); } } return(new List <SelectListItem>()); }
public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize) { if (ModelState.IsValid) { int pageNo = currentPageNo ?? 0; int pageSize = currentPageSize ?? 20; if (Request["PageNo"] != null) { pageNo = Convert.ToInt32(Request["PageNo"]); } if (Request["PageSize"] != null) { pageSize = Convert.ToInt32(Request["PageSize"]); } using (EquipmentStateServiceClient client = new EquipmentStateServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <EquipmentState> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }