예제 #1
0
        public void NewModuleLoaded(string serialNumber, bool onList)
        {
            try
            {
                foreach (var sn in AggregateDataProvider.SerialNumbersOnTruckIncludingBuffered)
                {
                    if (sn != serialNumber && !ModulesOnTruck.Any(t => t.SerialNumber == sn))
                    {
                        ModulesOnTruck.Add(new ModuleViewModel {
                            SerialNumber = sn
                        });
                    }
                }

                if (!ModulesOnTruck.Any(t => t.SerialNumber == serialNumber))
                {
                    ModulesOnTruck.Add(new ModuleViewModel {
                        SerialNumber = serialNumber
                    });
                }

                if (!onList && !BadSerials.Any(t => t.SerialNumber == serialNumber))
                {
                    BadSerials.Add(new ModuleViewModel {
                        SerialNumber = serialNumber
                    });
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
            }
        }
예제 #2
0
        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;
        }
예제 #3
0
        public void Initialize()
        {
            using (var uow = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork())
            {
                NewFarmText     = "";
                ListName        = "";
                NewProducerText = "";
                NewFieldText    = "";

                ShowFarmCombo  = false;
                ShowFieldCombo = false;
                ShowListCombo  = false;

                var list = uow.PickupListRepository.GetById(ActiveListID, "Field.Farm.Client");


                var clients = uow.ClientRepository.GetAll(new string[] { "Farms.Fields" }).OrderBy(t => t.Name);
                var lists   = uow.PickupListRepository.GetAll();

                ErrorMessages = new ObservableCollection <string>();
                Producers     = new ObservableCollection <ComboBoxItemViewModel>();
                Producers.Add(new ComboBoxItemViewModel {
                    ID = "-1", DisplayText = "-- Select One --"
                });
                Producers.Add(new ComboBoxItemViewModel {
                    ID = "", DisplayText = "-- Add New --"
                });

                Farms = new ObservableCollection <FarmComboBoxItemViewModel>();
                Farms.Add(new FarmComboBoxItemViewModel {
                    ID = "-1", ClientID = "", DisplayText = "-- Select One --"
                });
                Farms.Add(new FarmComboBoxItemViewModel {
                    ID = "", ClientID = "", DisplayText = "-- Add New --"
                });

                Fields = new ObservableCollection <FieldComboBoxItemViewModel>();
                Fields.Add(new FieldComboBoxItemViewModel {
                    ID = "-1", ClientID = "", DisplayText = "-- Select One --"
                });
                Fields.Add(new FieldComboBoxItemViewModel {
                    ID = "", ClientID = "", DisplayText = "-- Add New --"
                });

                PickupLists   = new ObservableCollection <PickupListComboBoxItemViewModel>();
                CurrentClient = list.Field.Farm.Client.Name;
                CurrentFarm   = list.Field.Farm.Name;
                CurrentField  = list.Field.Name;
                CurrentList   = list.Name;

                if (list.Id == GUIDS.UNASSIGNED_LIST_ID)
                {
                    CurrentClient = "Unassigned";
                    CurrentFarm   = "";
                    CurrentField  = "";
                    CurrentList   = "";
                }

                foreach (var client in clients.Where(c => c.Id != GUIDS.UNASSIGNED_CLIENT_ID))
                {
                    var producer = new ComboBoxItemViewModel {
                        ID = client.Id, DisplayText = client.Name
                    };
                    Producers.Add(producer);
                }

                SelectedProducer = Producers[0];

                ModulesOnTruck.Clear();

                foreach (var sn in AggregateDataProvider.SerialNumbersOnTruck)
                {
                    ModulesOnTruck.Add(new ViewModels.ModuleViewModel {
                        SerialNumber = sn
                    });
                }
            }
        }