public async Task <ActionResult> SaveModify(ShiftViewModel model) { using (ShiftServiceClient client = new ShiftServiceClient()) { MethodReturnResult <Shift> result = await client.GetAsync(model.Name); if (result.Code == 0) { result.Data.StartTime = model.StartTime; result.Data.EndTime = model.EndTime; result.Data.IsOverDay = model.IsOverDay; 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.Shift_SaveModify_Success , model.Name); } return(Json(rst)); } return(Json(result)); } }
public async Task <ActionResult> Query(ShiftQueryViewModel model) { if (ModelState.IsValid) { using (ShiftServiceClient client = new ShiftServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { if (!string.IsNullOrEmpty(model.Name)) { where.AppendFormat(" Key LIKE '{0}%'", model.Name); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <Shift> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
// // GET: /FMM/Shift/Detail public async Task <ActionResult> Detail(string key) { using (ShiftServiceClient client = new ShiftServiceClient()) { MethodReturnResult <Shift> result = await client.GetAsync(key); if (result.Code == 0) { ShiftViewModel viewModel = new ShiftViewModel() { Name = result.Data.Key, StartTime = result.Data.StartTime, EndTime = result.Data.EndTime, IsOverDay = result.Data.IsOverDay, 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(ShiftViewModel model) { using (ShiftServiceClient client = new ShiftServiceClient()) { Shift obj = new Shift() { Key = model.Name, EndTime = model.EndTime, IsOverDay = model.IsOverDay, StartTime = model.StartTime, 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.Shift_Save_Success , model.Name); } return(Json(rst)); } }
public Shift GetShift(string shiftName) { Shift obj = HttpContext.Current.Cache.Get(shiftName) as Shift; if (obj != null) { return(obj); } using (ShiftServiceClient client = new ShiftServiceClient()) { MethodReturnResult <Shift> result = client.Get(shiftName); if (result.Code <= 0) { HttpContext.Current.Cache.Add(shiftName , result.Data , null , DateTime.Now.AddSeconds(5) , System.Web.Caching.Cache.NoSlidingExpiration , System.Web.Caching.CacheItemPriority.Normal , null); return(result.Data); } } return(null); }
public async Task <ActionResult> Delete(string key) { MethodReturnResult result = new MethodReturnResult(); using (ShiftServiceClient client = new ShiftServiceClient()) { result = await client.DeleteAsync(key); if (result.Code == 0) { result.Message = string.Format(FMMResources.StringResource.Shift_Delete_Success , key); } return(Json(result)); } }
// // GET: /FMM/Shift/ public async Task <ActionResult> Index() { using (ShiftServiceClient client = new ShiftServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "Key" }; MethodReturnResult <IList <Shift> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new ShiftQueryViewModel())); }
public IEnumerable <SelectListItem> GetShiftNames() { using (ShiftServiceClient client = new ShiftServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false }; MethodReturnResult <IList <Shift> > result = client.Get(ref cfg); if (result.Code <= 0) { IEnumerable <SelectListItem> lst = from item in result.Data select new SelectListItem() { Text = item.Key, Value = item.Key }; return(lst); } } 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 (ShiftServiceClient client = new ShiftServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <Shift> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
public ActionResult Query(WIPMoveQueryViewModel model) { DataTable dtData = new DataTable(); //获取工序MOVE数据。 using (WIPMoveServiceClient client = new WIPMoveServiceClient()) { MethodReturnResult <DataSet> rst = client.Get(new WIPMoveGetParameter() { LocationName = model.LocationName, MaterialCode = model.MaterialCode, OrderNumber = model.OrderNumber, ShiftName = model.ShiftName, StartDate = model.StartDate, EndDate = model.EndDate }); if (rst.Code <= 0 && rst.Data != null && rst.Data.Tables.Count > 0) { dtData = rst.Data.Tables[0]; } } //获取工序数据。 IList <RouteOperation> lstRouteOperation = new List <RouteOperation>(); using (RouteOperationServiceClient client = new RouteOperationServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = "Status=1", OrderBy = "SortSeq" }; MethodReturnResult <IList <RouteOperation> > rst = client.Get(ref cfg); if (rst.Code <= 0 && rst.Data != null) { lstRouteOperation = rst.Data; } } //获取班次数据。 IList <Shift> lstShift = new List <Shift>(); using (ShiftServiceClient client = new ShiftServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false }; if (!string.IsNullOrEmpty(model.ShiftName)) { cfg.Where = string.Format("Key='{0}'", model.ShiftName); } MethodReturnResult <IList <Shift> > rst = client.Get(ref cfg); if (rst.Code <= 0) { lstShift = rst.Data; } } string [] columns = new string[] { "CUR_DAY", "SHIFT_NAME", "ACTIVITY" }; //组织新表数据结构 DataTable dtNew = new DataTable(); for (int i = 0; i < columns.Length; i++) { DataColumn dc = dtNew.Columns.Add(columns[i]); dc.Caption = dicColumn[dc.ColumnName]; } //添加工序列 for (int i = 0; i < lstRouteOperation.Count; i++) { string colName = lstRouteOperation[i].Key; DataColumn col = new DataColumn(colName); col.DataType = typeof(double); dtNew.Columns.Add(col); } //添加合计列 DataColumn dcSum = dtNew.Columns.Add("SUM_VALUE"); dcSum.DataType = typeof(double); dcSum.Caption = dicColumn[dcSum.ColumnName]; //填充数据 //添加合计行。 foreach (Shift shift in lstShift) { for (int i = 0; i < activities.Length; i++) { DataRow dr = dtNew.NewRow(); dr["CUR_DAY"] = "合计"; dr["SHIFT_NAME"] = shift.Key; dr["ACTIVITY"] = Convert.ToInt32(activities[i]); dtNew.Rows.Add(dr); } } //添加日期行。 for (DateTime start = model.StartDate; start <= model.EndDate; start = start.AddDays(1)) { foreach (Shift shift in lstShift) { for (int i = 0; i < activities.Length; i++) { DataRow dr = dtNew.NewRow(); dr["CUR_DAY"] = start; dr["SHIFT_NAME"] = shift.Key; dr["ACTIVITY"] = Convert.ToInt32(activities[i]); dtNew.Rows.Add(dr); } } } for (int i = 0; i < dtNew.Rows.Count; i++) { string curDay = Convert.ToString(dtNew.Rows[i]["CUR_DAY"]); string shiftName = Convert.ToString(dtNew.Rows[i]["SHIFT_NAME"]); int activity = Convert.ToInt32(dtNew.Rows[i]["ACTIVITY"]); double sumQty = 0; for (int j = 0; j < lstRouteOperation.Count; j++) { string colName = lstRouteOperation[j].Key; double qty = 0; if (curDay == "合计") { var lnq = from row in dtData.AsEnumerable() where Convert.ToString(row["SHIFT_NAME"]) == shiftName && Convert.ToInt32(row["ACTIVITY"]) == activity && Convert.ToString(row["ROUTE_STEP_NAME"]) == colName select Convert.ToDouble(row["QUANTITY"]); qty = lnq.Sum(); } else { var lnq = from row in dtData.AsEnumerable() where Convert.ToString(row["CUR_DAY"]) == curDay && Convert.ToString(row["SHIFT_NAME"]) == shiftName && Convert.ToInt32(row["ACTIVITY"]) == activity && Convert.ToString(row["ROUTE_STEP_NAME"]) == colName select Convert.ToDouble(row["QUANTITY"]); qty = lnq.Sum(); } dtNew.Rows[i][colName] = qty; sumQty += qty; } dtNew.Rows[i]["SUM_VALUE"] = sumQty; } //缓存数据。 string key = Convert.ToString(Session.SessionID); string routeOperationKey = string.Format("{0}_RouteOperation", key); HttpContext.Cache[key] = dtData; HttpContext.Cache[routeOperationKey] = lstRouteOperation; ViewBag.ListData = dtNew; ViewBag.Key = key; if (Request.IsAjaxRequest()) { return(PartialView("_ListPartial", model)); } else { return(View(model)); } }