private async Task ExecuteRefresh() { try { string id = SelectedBoxID?.ID; var BoxIDs = await _dbservicewms.GetBoxIDs(ExcludeWout); BoxIDList.Clear(); foreach (var p in BoxIDs) { BoxIDList.Add(new BoxIDViewModel { ID = p.BoxID, SKUID = p.SKUID, Batch = p.Batch, TUID = p.TUID ?? 0 }); } foreach (var l in BoxIDList) { l.Initialize(_warehouse); } if (id != null) { SelectedBoxID = BoxIDList.FirstOrDefault(p => p.ID == id); } if (SelectedBoxID == null) { SelectedBoxID = BoxIDList.FirstOrDefault(); } } 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)); } }