private void ExecuteOverrideCommand() { t.Stop(); //stop refresh timer HandleRefreshTimer(); //run refresh to see if bad serials are still on truck if (BadSerials.Count() > 0) { //show correction window UnloadCorrectionViewModel vm = SimpleIoc.Default.GetInstance <UnloadCorrectionViewModel>(); vm.ActiveListID = this.ActiveListID; vm.Initialize(); _windowService.ShowModalWindow(WindowType.UnloadCorrectionWindow, vm); } }
public void HandleRefreshTimer() { if (!_windowService.IsWindowOpen(WindowType.WaitingForUnloadWindow)) { return; } _windowService.FocusLast(WindowType.WaitingForUnloadWindow); lock (activeList) { var snsOnTruck = AggregateDataProvider.SerialNumbersOnTruck; var snsInBuffer = AggregateDataProvider.SerialNumbersInBuffer; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { var modulesToRemove = ModulesOnTruck.Where(m => !snsOnTruck.Any(t => t == m.SerialNumber)).ToList(); foreach (var m in modulesToRemove) { ModulesOnTruck.Remove(m); } modulesToRemove = BadSerials.Where(m => !snsOnTruck.Any(t => t == m.SerialNumber)).ToList(); foreach (var m in modulesToRemove) { BadSerials.Remove(m); } //add all modules on truck foreach (var sn in snsOnTruck) { if (!ModulesOnTruck.Any(m => m.SerialNumber == sn)) { ModulesOnTruck.Add(new ViewModels.ModuleViewModel { SerialNumber = sn }); } } //determine modules that shouldn't be on truck foreach (var sn in snsOnTruck) { if (!activeList.AssignedModules.Any(m => m.Name == sn) && !BadSerials.Any(m => m.SerialNumber == sn)) { BadSerials.Add(new ModuleViewModel { SerialNumber = sn, BackgroundColor = "Red", ForegroundColor = "White" }); } } //set background color of modules seen //TagDataProvider.GetTagsFirstSeenInTimeRange foreach (var badSerial in BadSerials) { if (snsInBuffer.Any(m => m == badSerial.SerialNumber)) { badSerial.BackgroundColor = "PaleVioletRed"; badSerial.ForegroundColor = "White"; } else { badSerial.BackgroundColor = "Red"; badSerial.ForegroundColor = "White"; } } if (BadSerials.Count() == 0) //no incorrect serials were found { t.Stop(); _windowService.CloseModalWindow(WindowType.WaitingForUnloadWindow); } })); } lastIntervalStart = DateTime.UtcNow; }