private async Task ExecuteRefreshOrder() { try { int?erpid = SelectedOrder?.ERPID; int?orderid = SelectedOrder?.OrderID; _suborderid = SelectedSubOrder?.SubOrderID; var orders = await _dbservicewms.GetHistOrdersDistinct(DateFrom.TimeStamp, DateTo.TimeStamp, -1); DataListOrder.Clear(); foreach (var p in orders) { DataListOrder.Add(new ReleaseOrderViewModel { ERPID = p.ERPID, ERPIDref = p.ERPIDStokbar, OrderID = p.OrderID, Destination = p.Destination, ReleaseTime = p.ReleaseTime, LastChange = p.LastChange, Portion = $"{p.CountActive}/{p.CountAll} - {p.CountMoveDone}/{p.CountAll} - {p.CountFinished}/{p.CountAll}", Status = (EnumWMSOrderStatus)p.Status }); } foreach (var l in DataListOrder) { l.Initialize(_warehouse); } Records = DataListOrder.Count(); if (orderid != null) { SelectedOrder = DataListOrder.FirstOrDefault(p => p.ERPID == erpid && p.OrderID == orderid); } } catch (Exception e) { _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception, string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message)); } }