private async Task ExecuteRefreshCommandWMS() { try { int?wmsid = SelectedCommand?.WMSID; DataListCommand.Clear(); if (SelectedSubOrder != null) { var cmds = await _dbservicewms.GetHistCommandsWMSForOrder(SelectedOrder.ERPID, SelectedOrder.OrderID); DataListCommand.Clear(); foreach (var cmd in cmds) { DataListCommand.Add(new CommandWMSViewModel { WMSID = cmd.ID, OrderERPID = cmd.OrderERPID, OrderID = cmd.Order_ID, OrderOrderID = cmd.OrderOrderID, OrderSubOrderID = cmd.OrderSubOrderID, OrderSubOrderERPID = cmd.OrderSubOrderERPID, OrderSubOrderName = cmd.OrderSubOrderName, OrderSKUID = cmd.OrderSKUID, OrderSKUBatch = cmd.OrderSKUBatch, Operation = (EnumOrderOperation)cmd.Operation, BoxID = cmd.Box_ID, Source = cmd.Source, Target = cmd.Target, TUID = cmd.TU_ID, Time = cmd.Time, LastChange = cmd.LastChange, Status = (EnumCommandWMSStatus)cmd.Status, }); } foreach (var l in DataListCommand) { l.Initialize(_warehouse); } if (wmsid != null) { SelectedCommand = DataListCommand.FirstOrDefault(p => p.WMSID == wmsid); } } } 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)); } }