private async Task ExecuteRefresh() { try { var order = _dbservicewms.GetCurrentOrderForRamp(_ramp); var suborder = _dbservicewms.GetCurrentSubOrderForRamp(_ramp); var orderCount = await _dbservicewms.GetCurrentOrderActivity(order); var suborderCount = await _dbservicewms.GetCurrentSubOrderActivity(suborder); // orderviewmodel OrderInfo.ERPID = ""; OrderInfo.Operation = ""; OrderInfo.OrderID = ""; OrderInfo.StatusOrder = ""; OrderInfo.PortionSubOrder = ""; OrderInfo.SubOrderID = ""; OrderInfo.SubOrderName = ""; OrderInfo.StatusSubOrder = ""; OrderInfo.PortionCommand = ""; OrderInfo.TruckPlate = ""; OrderInfo.TruckType = ""; OrderInfo.TruckNumber = ""; if (order != null) { if (order.ERP_ID != null) { OrderInfo.OrderID = order.SubOrderERPID.ToString(); string[] split = order.SubOrderName.Split('#'); if (split.Length >= 5) { OrderInfo.Operation = split[1]; OrderInfo.TruckType = split[2]; OrderInfo.TruckPlate = split[3]; OrderInfo.TruckNumber = split[4]; } } else { OrderInfo.OrderID = order.OrderID.ToString(); } } OrderInfo.RightVisibility = order == null ? Visibility.Hidden : Visibility.Visible; if (orderCount != null) { OrderInfo.StatusOrder = OrderStatus[(int)orderCount.Status]; OrderInfo.PortionSubOrder = $"{_active} {orderCount.Active}/{orderCount.All} {_done} {orderCount.Done}/{orderCount.All}"; OrderInfo.SuborderTotal = orderCount.All.ToString(); OrderInfo.SuborderActive = orderCount.Active.ToString(); OrderInfo.SuborderDone = orderCount.Done.ToString(); } OrderInfo.SubOrderID = "-"; OrderInfo.PalletVisibility = Visibility.Hidden; if (suborder != null) { string[] split = suborder.SubOrderName.Split('#'); string customer = ""; if (split.Length >= 5) { customer = split[2]; } OrderInfo.SubOrderID = suborder.SubOrderID.ToString(); OrderInfo.SubOrderName = $"{customer}"; } if (suborderCount != null) { OrderInfo.StatusSubOrder = OrderStatus[(int)suborderCount.Status]; OrderInfo.PortionCommand = $"{_active} {suborderCount.Active}/{suborderCount.All} {_done} {suborderCount.Done}/{suborderCount.All}"; OrderInfo.CommandTotal = suborderCount.All.ToString(); OrderInfo.CommandDone = suborderCount.Done.ToString(); OrderInfo.CommandActive = suborderCount.Active.ToString(); OrderInfo.PalletVisibility = suborderCount.Active == 0 ? Visibility.Hidden : Visibility.Visible; } // laneviewmodel var lanes = _dbservicewms.GetLastPallets(_ramp); for (int i = 0; i < 4; i++) { Lane[i].NumTU = 0; Lane[i].FirstTU = null; } foreach (var l in lanes) { if (l != null) { TUViewModel last = new TUViewModel(); if (l.FirstTUID != null) { last.TUID = $"{l.FirstTUID:d9}"; if (l.SKU != null) { last.SKUID = l.SKU.SKU; last.SKUBatch1 = l.SKU.SKUBatch; last.SKUQty = l.SKU.SKUQty; } if (l.Suborder != null) { last.SubOrderID = l.Suborder.SubOrderID; last.SubOrderBrush = SubOrderColor[(last.SubOrderID - 1 + 8) % 8]; string[] s = l.Suborder.SubOrderName.Split('#'); last.SubOrderName = s.Length > 0 ? s[0].Trim() : l.Suborder.SubOrderName; } } Lane[l.LaneID - 1].NumTU = l.Count; Lane[l.LaneID - 1].FirstTU = last; } } } catch (Exception ex) { throw new Exception(string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, ex.Message)); } }