Beispiel #1
0
        /// <summary>
        ///     Loads the menu item.
        /// </summary>
        /// <returns>The menu item.</returns>
        public async Task LoadMenuItem(LocationMenuItem item)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            if (item != null)
            {
                if (ListCompletedItems)
                {
                    var record = HandleItemClick(item);

                    if (record != null)
                    {
                        MessagingCenter.Send(new ShowReviewMessage(record, item), HaccpConstant.ReviewMessage);
                    }
                }
                else
                {
                    IsReviewItemVisible = false;
                    IsBackNavigation    = false;

                    await Page.NavigateToWithSelectedObject(PageEnum.RecordItem, true, item);
                }
            }


            IsBusy = false;
        }
Beispiel #2
0
 /// <summary>
 ///     Records the location item.
 /// </summary>
 /// <param name="item">Item.</param>
 public void RecordLocationItem(LocationMenuItem item)
 {
     lock (Locker)
     {
         Database.Update(item);
     }
 }
Beispiel #3
0
 /// <summary>
 ///     Gets the item temperature.
 /// </summary>
 /// <returns>The item temperature.</returns>
 /// <param name="item">Item.</param>
 public ItemTemperature GetItemTemperature(LocationMenuItem item)
 {
     lock (Locker)
     {
         return(Database.Table <ItemTemperature>().FirstOrDefault(x => x.ItemID == item.ItemId));
     }
 }
Beispiel #4
0
        /// <summary>
        ///     Initializes a new instance of the <see /> class.
        /// </summary>
        /// <param name="page">Page.</param>
        /// <param name="item"></param>
        public RecordTempViewModel(IPage page, LocationMenuItem item)
            : base(page)
        {
            dataStore    = new SQLiteDataStore();
            SelectedItem = item;

            IsManualEntryOn = Settings.RecordingMode == RecordingMode.Manual;

            TemperatureUnit = HaccpAppSettings.SharedInstance.DeviceSettings.TempScale == 0
                ? TemperatureUnit.Fahrenheit
                : TemperatureUnit.Celcius;

            var min = HACCPUtil.ConvertToDouble(SelectedItem.Min);
            var max = HACCPUtil.ConvertToDouble(SelectedItem.Max);

            MinimumTemperature = TemperatureUnit == TemperatureUnit.Celcius
                ? Math.Round(HACCPUtil.ConvertFahrenheitToCelsius(min)).ToString()
                : SelectedItem.Min;
            MaximumTemperature = TemperatureUnit == TemperatureUnit.Celcius
                ? Math.Round(HACCPUtil.ConvertFahrenheitToCelsius(max)).ToString()
                : SelectedItem.Max;

            MessagingCenter.Subscribe <WindowsScanningStatusMessage>(this, HaccpConstant.WindowsScanningStatus, sender =>
            {
                if (sender.IsScanning && ConnectionStatus != HACCPUtil.GetResourceString("ConnectionStatusDisconnect"))
                {
                    ConnectionStatus = HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("Connecting"), false);
                }
                else
                {
                    ConnectionStatus =
                        HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanBlue2"), false);
                }
            });

            MessagingCenter.Subscribe <BleTemperatureReadingMessage>(this, HaccpConstant.BletemperatureReading, sender =>
            {
                bool connected;

                connected = HaccpAppSettings.SharedInstance.IsWindows
                    ? WindowsBLEManager.SharedInstance.HasAnyPairedDevice
                    : BLEManager.SharedInstance.IsConnected;

                if (connected)
                {
                    var msg = sender;
                    if (msg != null)
                    {
                        OnPropertyChanged("IsWakeButtonVisible");
                        if (msg.IsSleeping)
                        {
                            DisplayBlue2Temperature = HACCPUtil.GetResourceString("Blue2SleepString");
                            LineBreakMode           = LineBreakMode.TailTruncation;
                        }
                        else if (msg.IsHigh)
                        {
                            DisplayBlue2Temperature = HACCPUtil.GetResourceString("Blue2HighString");
                            LineBreakMode           = LineBreakMode.TailTruncation;
                        }
                        else if (msg.IsLow)
                        {
                            DisplayBlue2Temperature = HACCPUtil.GetResourceString("Blue2LowString");
                            LineBreakMode           = LineBreakMode.TailTruncation;
                        }
                        else if (msg.IsBatteryLow)
                        {
                            DisplayBlue2Temperature = HACCPUtil.GetResourceString("Blue2BatteryString");
                            LineBreakMode           = LineBreakMode.TailTruncation;
                        }
                        else
                        {
                            var temp = msg.TempValue;
                            var unit = msg.TempUnit;
                            if (TemperatureUnit == TemperatureUnit.Celcius && unit != 0)
                            {
                                temp = HACCPUtil.ConvertFahrenheitToCelsius(temp);
                            }
                            else if (TemperatureUnit == TemperatureUnit.Fahrenheit && unit != 1)
                            {
                                temp = HACCPUtil.ConvertCelsiusToFahrenheit(temp);
                            }

                            DisplayTemperatureReading(temp, msg.ShouldRecord);
                        }
                    }
                }
            });


            MessagingCenter.Subscribe <WindowsBleConnectionStatusMessage>(this, HaccpConstant.BleconnectionStatus,
                                                                          sender =>
            {
                OnPropertyChanged("IsWakeButtonVisible");

                if (!WindowsBLEManager.SharedInstance.HasAnyPairedDevice)
                {
                    ConnectionStatus =
                        HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanBlue2"),
                                                         false);
                    Blue2ButtonStyle        = Application.Current.Resources["Blue2ButtonNotActiveStyle"] as Style;
                    Blue2Id                 = string.Empty;
                    DisplayBlue2Temperature = HACCPUtil.GetResourceString("ConnectBlue2Label");
                    LineBreakMode           = LineBreakMode.TailTruncation;
                }
                //else
                //{
                //    ConnectionStatus = HACCPUtil.GetResourceString("ConnectionStatusDisconnect");
                //    Blue2ButtonStyle = Application.Current.Resources["Blue2ButtonActiveStyle"] as Style;
                //    DisplayBlue2Temperature = string.Empty;
                //    LineBreakMode = LineBreakMode.NoWrap;
                //}
            });


            MessagingCenter.Subscribe <BleConnectionStatusMessage>(this, HaccpConstant.BleconnectionStatus,
                                                                   async sender =>
            {
                OnPropertyChanged("IsWakeButtonVisible");
                if (BLEManager.SharedInstance.IsConnected)
                {
                    ConnectionStatus        = HACCPUtil.GetResourceString("ConnectionStatusDisconnect");
                    Blue2ButtonStyle        = Application.Current.Resources["Blue2ButtonActiveStyle"] as Style;
                    DisplayBlue2Temperature = string.Empty;
                    LineBreakMode           = LineBreakMode.NoWrap;
                }
                else
                {
                    ConnectionStatus =
                        HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanBlue2"),
                                                         false);
                    Blue2ButtonStyle        = Application.Current.Resources["Blue2ButtonNotActiveStyle"] as Style;
                    Blue2Id                 = string.Empty;
                    DisplayBlue2Temperature = HACCPUtil.GetResourceString("ConnectBlue2Label");
                    LineBreakMode           = LineBreakMode.TailTruncation;

                    if (!BLEManager.SharedInstance.Adapter.IsBluetoothEnabled && !IsManualEntryOn)
                    {
                        // bluetooth in phone is disabled
                        if (!isAlertActive)
                        {
                            isAlertActive = true;
                            await
                            page.ShowAlert(string.Empty,
                                           HACCPUtil.GetResourceString("TurnONBluetoothonyourdevice"));
                            isAlertActive = false;
                        }
                    }
                }
            });

            MessagingCenter.Subscribe <BLEBlue2SettingsUpdatedMessage>(this, HaccpConstant.Bleblue2SettingsUpdate,
                                                                       sender =>
            {
                if (HaccpAppSettings.SharedInstance.IsWindows && WindowsBLEManager.SharedInstance.Settings != null)
                {
                    LoadWindowsBlue2Settings();
                }

                else if (BLEManager.SharedInstance.Settings != null)
                {
                    Blue2Id = BLEManager.SharedInstance.Settings.SNo;
                }
            });

            MessagingCenter.Subscribe <BleConnectionTimeOutMessage>(this, HaccpConstant.BleconnectionTimeout,
                                                                    async sender =>
            {
                await page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("Blue2TurnOnMessage"));
            });

            MessagingCenter.Subscribe <BleScanCompleteMessage>(this, HaccpConstant.Blue2ScanComplete,
                                                               sender =>
            {
                ConnectionStatus =
                    HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanBlue2"), false);
            });
        }
Beispiel #5
0
 /// <summary>
 ///     Handles the item click.
 /// </summary>
 public ItemTemperature HandleItemClick(LocationMenuItem item)
 {
     return(_dataStore.GetTemperatureRecordById(item.ItemId, item.LocationId));
 }