コード例 #1
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var vm = new IdlePageViewModel(NavService);

            NavService.ShowPage(PageType.IDLE_PAGE, false, vm);
            vm.Initialize();
        }
コード例 #2
0
        private void ExecuteCloseCommand()
        {
            var vm = new IdlePageViewModel(NavService);

            NavService.ShowPage(PageType.IDLE_PAGE, false, vm);
            vm.Initialize();
        }
コード例 #3
0
 private void ExitToIdlePage()
 {
     if (!_canceled)
     {
         _canceled = true;
         var vm = new IdlePageViewModel(NavService);
         NavService.ShowPage(PageType.IDLE_PAGE, false, vm);
         vm.Initialize();
     }
 }
コード例 #4
0
        protected override void HandleSettingsSavedMessage(SettingsSavedMessage msg)
        {
            base.HandleSettingsSavedMessage(msg);

            if (msg.IsFirstLaunch)
            {
                var vm = new IdlePageViewModel(NavService);
                NavService.ShowPage(PageType.IDLE_PAGE, false, vm);
                vm.Initialize();
            }
        }
コード例 #5
0
        protected override void OpenStartPage()
        {
            Task.Run(() =>
            {
                BridgeSyncProcessHelper.Init("BridgeApp");
            });

            IdlePageViewModel vm = new IdlePageViewModel(NavService);

            NavService.ShowPage(PageType.IDLE_PAGE, false, vm);
            vm.Initialize();
        }
コード例 #6
0
 private void ExecuteCancelCommand()
 {
     if (!_popPageOnSave)
     {
         var vm = new IdlePageViewModel(NavService);
         NavService.ShowPage(PageType.IDLE_PAGE, false, vm);
         vm.Initialize();
     }
     else
     {
         NavService.Pop();
     }
 }
コード例 #7
0
 private void handleInactiveMessage(InactiveMessage msg)
 {
     if (!_popPageOnSave)
     {
         SaveForm(true);
         var vm = new IdlePageViewModel(NavService);
         NavService.ShowPage(PageType.IDLE_PAGE, false, vm);
         vm.Initialize();
     }
     else
     {
         NavService.Pop();
     }
 }
コード例 #8
0
        private void ExecuteSaveCommand()
        {
            ClearErrors();
            if (ValidateForm())
            {
                if (_isManualEdit)
                {
                    Messenger.Default.Send <BusyMessage>(new BusyMessage {
                        IsBusy = true, Message = "Saving..."
                    });
                }
                SaveForm(false);
                if (_isManualEdit)
                {
                    Messenger.Default.Send <BusyMessage>(new BusyMessage {
                        IsBusy = false, Message = "Saving..."
                    });

                    if (!_popPageOnSave)
                    {
                        var vm = new IdlePageViewModel(NavService);
                        NavService.ShowPage(PageType.IDLE_PAGE, false, vm);
                        vm.Initialize();
                    }
                    else
                    {
                        NavService.Pop();
                    }
                }
                else
                {
                    var vm = new ExitScalePageViewModel(NavService);
                    NavService.ShowPage(PageType.EXIT_SCALE_PAGE, false, vm);
                    vm.Initialize();
                }
            }
        }
コード例 #9
0
        public void Initialize(string serialNumber, string epc, bool goToIdleOnExistingSerial)
        {
            try
            {
                using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork())
                {
                    var ownerships    = dp.ModuleOwnershipRepository.FindMatching(m => m.Name == serialNumber).ToList().OrderBy(t => t.LastCreatedOrUpdated);
                    var lastOwnership = ownerships.LastOrDefault();
                    var bridgeID      = dp.SettingsRepository.GetSettingWithDefault(BridgeSettingKeys.BRIDGE_ID, "");
                    var existingScan  = dp.FeederScanRepository.FindSingle(s => s.Name == serialNumber);

                    if (existingScan != null) //ignore serial numbers already scanned
                    {
                        if (goToIdleOnExistingSerial)
                        {
                            var vm = new IdlePageViewModel(NavService);
                            NavService.ShowPage(PageType.IDLE_PAGE, false, vm);
                            vm.Initialize();
                            return;
                        }
                        else
                        {
                            return;
                        }
                    }

                    FeederScanEntity newScan = new FeederScanEntity();
                    newScan.BridgeID  = bridgeID;
                    newScan.Latitude  = dp.SettingsRepository.GetSettingDoubleValue(BridgeSettingKeys.LATITUDE);
                    newScan.Longitude = dp.SettingsRepository.GetSettingDoubleValue(BridgeSettingKeys.LONGITUDE);

                    var status = dp.SettingsRepository.GetSettingWithDefault(BridgeSettingKeys.TARGET_STATUS, "AT GIN");
                    if (status == "AT GIN")
                    {
                        newScan.TargetStatus = ModuleStatus.AT_GIN;
                    }
                    else
                    {
                        newScan.TargetStatus = ModuleStatus.ON_FEEDER;
                    }

                    newScan.EPC           = epc;
                    newScan.Processed     = false;
                    newScan.SyncedToCloud = false;
                    newScan.Source        = InputSource.TRUCK;
                    newScan.Name          = serialNumber;
                    dp.FeederScanRepository.Save(newScan);
                    dp.SaveChanges();
                    ScanTime = newScan.Created.ToLocalTime().ToString("MM/dd/yyyy hh:mm:ss tt");

                    //load view model
                    if (lastOwnership != null)
                    {
                        BridgeLoadNumber    = lastOwnership.BridgeLoadNumber > 0 ? lastOwnership.BridgeLoadNumber.ToString() : "";
                        GinTicketLoadNumber = lastOwnership.GinTagLoadNumber;
                        Client  = lastOwnership.Client;
                        Farm    = lastOwnership.Farm;
                        Field   = lastOwnership.Field;
                        Variety = lastOwnership.Variety;
                    }
                    else
                    {
                        BridgeLoadNumber    = "";
                        GinTicketLoadNumber = "";
                        Variety             = Client = Farm = Field = "";
                    }

                    SerialNumber = serialNumber;
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
            }
        }
コード例 #10
0
        private async void ExecuteSave()
        {
            Messenger.Default.Send <BusyMessage>(new BusyMessage {
                IsBusy = true, Message = "Validating settings..."
            });
            if (!await ValidateForm())
            {
                Messenger.Default.Send <BusyMessage>(new BusyMessage {
                    IsBusy = false, Message = ""
                });
                return;
            }

            Messenger.Default.Send <BusyMessage>(new BusyMessage {
                IsBusy = true, Message = "Saving..."
            });

            await Task.Run(() =>
            {
                try
                {
                    Settings settings = TagDataProvider.GetDefaultSettings();

                    if (settings != null)
                    {
                        settings.Antennas.TxPowerMax       = false;
                        settings.Antennas.RxSensitivityMax = false;
                        settings.HoldReportsOnDisconnect   = false;
                        settings.Report.Mode = ReportMode.Individual;
                        settings.SearchMode  = SearchMode.DualTarget;
                        settings.ReaderMode  = ReaderMode.AutoSetStaticDRM;
                        settings.Report.IncludeFirstSeenTime      = true;
                        settings.Report.IncludeLastSeenTime       = true;
                        settings.Report.IncludeSeenCount          = true;
                        settings.Keepalives.Enabled               = true;
                        settings.Keepalives.EnableLinkMonitorMode = true;
                        settings.Keepalives.LinkDownThreshold     = 5;
                        settings.Keepalives.PeriodInMs            = 3000;

                        settings.Antennas.GetAntenna(1).RxSensitivityInDbm = (double)_antenna1ReceivePower;
                        settings.Antennas.GetAntenna(1).TxPowerInDbm       = (double)_antenna1TransmitPower;

                        settings.Antennas.GetAntenna(2).RxSensitivityInDbm = (double)_antenna2ReceivePower;
                        settings.Antennas.GetAntenna(2).TxPowerInDbm       = (double)_antenna2TransmitPower;

                        settings.Antennas.GetAntenna(3).RxSensitivityInDbm = (double)_antenna3ReceivePower;
                        settings.Antennas.GetAntenna(3).TxPowerInDbm       = (double)_antenna3TransmitPower;

                        settings.Antennas.GetAntenna(4).RxSensitivityInDbm = (double)_antenna4ReceivePower;
                        settings.Antennas.GetAntenna(4).TxPowerInDbm       = (double)_antenna4TransmitPower;

                        TagDataProvider.ApplySettings(settings);

                        Messenger.Default.Send <BusyMessage>(new BusyMessage {
                            IsBusy = true, Message = "Settings saved."
                        });
                        System.Threading.Thread.Sleep(3000);
                    }
                    else
                    {
                        Messenger.Default.Send <BusyMessage>(new BusyMessage {
                            IsBusy = true, Message = "Unable to save reader settings. Reader disconnected?"
                        });
                        System.Threading.Thread.Sleep(3000);
                    }


                    using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork())
                    {
                        if (PortName == "NONE")
                        {
                            PortName = "";
                        }
                        if (BarcodePortName == "NONE")
                        {
                            BarcodePortName = "";
                        }

                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.SCALE_COM_PORT, PortName);
                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.BARCODE_COM_PORT, BarcodePortName);

                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.BRIDGE_ID, BridgeID);
                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.GIN_NAME, ScreenTitle);
                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.DOCUMENTDB_ENDPOINT, DocumentDbEndpoint);
                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.DOCUMENT_DB_KEY, DocumentDbConnection);
                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.LATITUDE, Latitude);
                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.LONGITUDE, Longitude);
                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.TARGET_STATUS, TargetStatus);
                        dp.SettingsRepository.UpsertSetting(BridgeSettingKeys.DATA_SYNC_INTERVAL, DataSyncInterval.ToString());
                        dp.SaveChanges();
                    }

                    /*if (portChanged)
                     * {
                     *  System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
                     *  {
                     *      System.Windows.MessageBox.Show("Please close and restart the application for new scale setting to take effect");
                     *  }));
                     * }*/
                }
                catch (Exception exc)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
                    {
                        System.Windows.MessageBox.Show("An error occurred saving settings. " + exc.Message);
                    }));
                    Logging.Logger.Log(exc);
                }
                finally
                {
                    Messenger.Default.Send <BusyMessage>(new BusyMessage {
                        IsBusy = false, Message = ""
                    });
                    Messenger.Default.Send <SettingsSavedMessage>(new SettingsSavedMessage {
                        GinName = ScreenTitle
                    });
                }

                if (IsFirstLaunch)
                {
                    var vm = new IdlePageViewModel(NavService);
                    NavService.ShowPage((int)PageType.IDLE_PAGE, false, vm);
                    vm.Initialize();
                }
            });
        }