コード例 #1
0
        /// <summary>
        ///     Loads the corrective actions.
        /// </summary>
        public void LoadCorrectiveActions()
        {
            var minTemp = HACCPUtil.ConvertToDouble(SelectedItem.Min);
            var maxTemp = HACCPUtil.ConvertToDouble(SelectedItem.Max);

            var temp = TemperatureValue;

            if (TemperatureUnit == TemperatureUnit.Celcius)
            {
                minTemp = Math.Round(HACCPUtil.ConvertFahrenheitToCelsius(minTemp));
                maxTemp = Math.Round(HACCPUtil.ConvertFahrenheitToCelsius(maxTemp));
                //temp = HACCPUtil.ConvertCelsiusToFahrenheit (TemperatureValue);
            }

            var actions = dataStore.GetCorrectiveAction().ToList();


//			foreach (var action in actions) {
//				if (action.CorrActionName.ToLower () == "none")
//					action.IsEnabled = temp >= minTemp && temp <= maxTemp;
//				else
//					action.IsEnabled = true;
//			}

            CorrectiveActions = new ObservableCollection <CorrectiveAction>(actions);


            foreach (var action in CorrectiveActions)
            {
                switch (action.CorrActionName)
                {
                case "Notify Manager":
                    action.CorrActionName = HACCPUtil.GetResourceString("NotifyManager");
                    break;

                case "Reheat to 165F":
                    action.CorrActionName = HACCPUtil.GetResourceString("Reheatto165F");
                    break;

                case "Rechill":
                    action.CorrActionName = HACCPUtil.GetResourceString("Rechill");
                    break;

                case "Discard":
                    action.CorrActionName = HACCPUtil.GetResourceString("Discard");
                    break;
                }
            }

            if (temp >= minTemp && temp <= maxTemp)
            {
                CorrectiveActions.Insert(0, new CorrectiveAction
                {
                    CorrActionId   = -1,
                    CorrActionName = HACCPUtil.GetResourceString("None")
                });
            }

            IsCorrectiveOptionsVisible = temp <minTemp || temp> maxTemp;
        }
コード例 #2
0
ファイル: BLEManager.cs プロジェクト: PVSPReddy/HACCP
        /// <summary>
        ///     Updates the BLE settings.
        /// </summary>
        public async void UpdateBLESettings(BLEChar blechar)
        {
            try {
                if (Settings != null && _temperatureService != null && _measurementScaleChar != null &&
                    _measurementTimeChar != null && _autooffIntervalChar != null && _sleepTimeChar != null)
                {
                    switch (blechar)
                    {
                    case BLEChar.Scale:
                        _measurementScaleChar.Write(Settings.Scale == 0 ? new byte[] { 0x43 } : new byte[] { 0x46 });
                        break;

                    case BLEChar.Time:
                        StopTemperatureReading = true;
                        _measurementTimeChar.Write(new[] { Convert.ToByte(Settings.MeasurementLevel) });
                        break;

                    case BLEChar.AutoOff:
                        _autooffIntervalChar.Write(new[] { Convert.ToByte(Settings.AutoOff) });
                        break;

                    case BLEChar.Sleep:
                        _sleepTimeChar.Write(new[] { Convert.ToByte(Settings.Sleep) });
                        break;

                    case BLEChar.Prob:
                        var bytes = HACCPUtil.GetBytesFromString(Settings.Prob);
                        _probeNameChar.Write(bytes);
                        break;
                    }
                }
            } catch (Exception) {
                Debug.WriteLine("Error on updating BLE settings");
            }
        }
コード例 #3
0
ファイル: BaseViewModel.cs プロジェクト: PVSPReddy/HACCP
 /// <summary>
 ///     Shows the logout confirm.
 /// </summary>
 /// <returns>The logout confirm.</returns>
 protected async Task <bool> ShowLogoutConfirm()
 {
     return
         (await
          Page.ShowConfirmAlert(HACCPUtil.GetResourceString("Logout"),
                                HACCPUtil.GetResourceString("Areyousureyouwanttologout")));
 }
コード例 #4
0
 /// <summary>
 ///     Called when the view appears.
 /// </summary>
 public override void OnViewAppearing()
 {
     base.OnViewAppearing();
     if (Locations.Count < 1)
     {
         Page.DisplayAlertMessage(HACCPUtil.GetResourceString("NoLocationsFound"),
                                  HACCPUtil.GetResourceString("NolocationsfoundPleasetapSelectChangeMenuintheWirelessTasksMenu"));
     }
 }
コード例 #5
0
ファイル: UsersViewModel.cs プロジェクト: PVSPReddy/HACCP
 /// <summary>
 ///     Called when the view appears.
 /// </summary>
 public override void OnViewAppearing()
 {
     base.OnViewAppearing();
     if (Users.Count < 1)
     {
         Page.DisplayAlertMessage(HACCPUtil.GetResourceString("NoUsersFound"),
                                  HACCPUtil.GetResourceString("NousersfoundPleasetapUpdateUserListintheWirelessTasksmenu"));
     }
 }
コード例 #6
0
ファイル: QuestionViewModel.cs プロジェクト: PVSPReddy/HACCP
        /// <summary>
        ///     Initializes a new instance of the <see cref="HACCP.Core.QuestionViewModel" /> class.
        /// </summary>
        /// <param name="page">Page.</param>
        /// <param name="category"></param>
        public QuestionViewModel(IPage page, Category category) : base(page)
        {
            AutoBack           = false;
            dataStore          = new SQLiteDataStore();
            SelectedCategory   = category;
            SelectedCategoryId = category.CategoryId;
            Title    = HACCPUtil.GetResourceString("SelectQuestion");
            Subtitle = category.CategoryName;
            LoadQuestions(false);

            MessagingCenter.Subscribe <Question>(this, HaccpConstant.QuestionMessage, sender =>
            {
                var ques = sender;
                if (ques != null)
                {
                    var selectedQues = Questions.FirstOrDefault(x => x.QuestionId == ques.QuestionId);
                    if (selectedQues != null)
                    {
                        Questions.FirstOrDefault(x => x.QuestionId == ques.QuestionId).RecordStatus = 1;
                    }
                }
            });

            MessagingCenter.Subscribe <AutoAdvanceCheckListMessage>(this, HaccpConstant.AutoadvancechecklistMessage,
                                                                    sender =>
            {
                var message     = sender;
                var currentItem = Questions.FirstOrDefault(x => x.QuestionId == message.CurrentId);
                if (currentItem != null)
                {
                    var index = Questions.IndexOf(currentItem);
                    if (Questions.Count - 1 > index)
                    {
                        isBackNavigation = false;

                        var ques          = Questions [index + 1];
                        ques.CategoryName = Subtitle;
                        page.NavigateToWithSelectedObject(PageEnum.RecordAnswer, true, ques);
                    }
                    else
                    {
                        AutoBack = true;
                        if (!HaccpAppSettings.SharedInstance.IsWindows)
                        {
                            page.PopPage();
                        }
                    }
                }
            });


            MessagingCenter.Subscribe <UploadRecordRefreshMessage>(this, HaccpConstant.UploadRecordRefresh, sender =>
            {
                LoadQuestions(!isFilter);
                IsReviewAnswerVisible = false;
            });
        }
コード例 #7
0
        /// <summary>
        ///     Tests the connection.
        /// </summary>
        /// <returns>The connection.</returns>
        /// <param name="shouldShowSuccessMessage">If set to <c>true</c> should show success message.</param>
        private async Task <bool> TestConnection(bool shouldShowSuccessMessage)
        {
            var isConnected = false;

            if (serverAddress == null || serverAddress.Trim().Length < 1)
            {
                Page.DisplayAlertMessage("", HACCPUtil.GetResourceString("EnterServerIPAddressorDomainName"));
                return(false);
            }

            IHACCPService haccpService = new HACCPService(dataStore);

            if (haccpService.IsConnected())
            {
                //string webUrl = HACCPUtil.BuildServerEndpoint (serverAddress, port, serverDirectory);

                if (HaccpAppSettings.SharedInstance.IsWindows)
                {
                    isConnected = await haccpService.IsWsdlAccess(serverAddress, port, serverDirectory);
                }
                else
                {
                    isConnected = await haccpService.IsRemoteReachable(serverAddress, port);
                }
                if (isConnected == false)
                {
                    Page.DisplayAlertMessage(HACCPUtil.GetResourceString("ConnectionTimeout"),
                                             HACCPUtil.GetResourceString(
                                                 "UnabletoconnecttotheserverPleaseverifyconnectionsettingsandtryagain"));
                }
                else
                {
                    isConnected = await haccpService.IsWsdlAccess(serverAddress, port, serverDirectory);

                    if (isConnected == false)
                    {
                        Page.DisplayAlertMessage(HACCPUtil.GetResourceString("NoWebService"),
                                                 HACCPUtil.GetResourceString(
                                                     "UnabletofindthewebservicePleaseverifyconnectionsettingsandtryagain"));
                    }
                    else if (shouldShowSuccessMessage)
                    {
                        Page.DisplayAlertMessage(HACCPUtil.GetResourceString("ConnectionSuccessful"),
                                                 HACCPUtil.GetResourceString(
                                                     "Theconnectionwiththeserverandthewebservicehasbeenestablishedsuccessfully"));
                    }
                }
            }
            else
            {
                Page.DisplayAlertMessage(HACCPUtil.GetResourceString("EnableNetworkConnection"),
                                         HACCPUtil.GetResourceString(
                                             "YourequireanactiveInternetconnectiontoperformsomefunctionsWerecommendthatyouenableWiFiforthispurposeDatachargesmayapplyifWiFiisnotenabled"));
            }

            return(isConnected);
        }
コード例 #8
0
        /// <summary>
        ///     Executes the corrective action command.
        /// </summary>
        /// <returns>The corrective action command.</returns>
        protected override void ExecuteCorrectiveActionCommand()
        {
            if (IsBusy)
            {
                return;
            }
            try
            {
                IsBusy = true;
                CorrectiveActionCommand.ChangeCanExecute();
                if (string.IsNullOrEmpty(Answer) && !IsYesNo)
                {
                    Answer = string.Empty;
                    Page.DisplayAlertMessage(HACCPUtil.GetResourceString("RecordAnswer"),
                                             HACCPUtil.GetResourceString("Specifyanumericvalue"));
                }
                else
                {
                    CorrectiveActions =
                        new ObservableCollection <CorrectiveAction>(
                            dataStore.GetCorrectiveActionForQuestion(RecordResponse.QuestionId));


                    if (
                        !((IsYesNo && Answer == HACCPUtil.GetResourceString("No")) ||
                          (!IsYesNo &&
                           (HACCPUtil.ConvertToDouble(Answer) < HACCPUtil.ConvertToDouble(RecordResponse.Min) ||
                            HACCPUtil.ConvertToDouble(Answer) > HACCPUtil.ConvertToDouble(RecordResponse.Max)))))
                    {
                        CorrectiveActions.Insert(0, new CorrectiveAction {
                            CorrActionId = -1, CorrActionName = "None"
                        });
                    }

                    if (CorrectiveActions.Count < 1)
                    {
                        Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("Nocorrectiveactionsfound"));
                    }
                    else
                    {
                        IsCorrctiveOptionsVisible = true;
                    }
                }
                IsBusy = false;
                CorrectiveActionCommand.ChangeCanExecute();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Ooops! Something went wrong. Exception: {0}", ex);
            }
            finally
            {
                IsBusy = false;
                CorrectiveActionCommand.ChangeCanExecute();
            }
        }
コード例 #9
0
        /// <summary>
        ///     Saves the answer.
        /// </summary>
        private async void SaveAnswer()
        {
            var date     = DateTime.Now;
            var response = new CheckListResponse
            {
                CategoryId = RecordResponse.CategoryId,
                Question   = RecordResponse.QuestionName,
                Answer     = Answer,
                CorrAction =
                    SelectedCorrectiveAction != string.Empty
                        ? SelectedCorrectiveAction
                        : HACCPUtil.GetResourceString("None"),
                QuestionType = RecordResponse.QuestionType.ToString(),
                UserName     = HaccpAppSettings.SharedInstance.UserName,
                DeviceId     = HaccpAppSettings.SharedInstance.DeviceId,
                SiteId       = HaccpAppSettings.SharedInstance.SiteSettings.SiteId,
                IsNa         = 0,
                Hour         = date.Hour.ToString(),
                Day          = date.Day.ToString(),
                Minute       = date.Minute.ToString(),
                Month        = date.Month.ToString(),
                Sec          = date.Second.ToString(),
                Year         = date.Year.ToString(),
                Tzid         = HaccpAppSettings.SharedInstance.SiteSettings.TimeZoneId,
                Min          = RecordResponse.Min,
                Max          = RecordResponse.Max,
                QuestionId   = RecordResponse.QuestionId,
                Catname      = RecordResponse.CategoryName,
                ChecklistId  = HaccpAppSettings.SharedInstance.SiteSettings.CheckListId
            };

            Debug.WriteLine("++++++++++++++++++++++++++++++");
            Debug.WriteLine("***Category Name= {0}***", response.Catname);
            Debug.WriteLine("++++++++++++++++++++++++++++++");
            dataStore.SaveCheckListResponse(response);
            RecordResponse.RecordStatus = 1;
            dataStore.UpdateQuestionRecordStatus(RecordResponse);
            MessagingCenter.Send(RecordResponse, HaccpConstant.QuestionMessage);
            dataStore.UpdateCategoryRecordStatus(RecordResponse.CategoryId);
            MessagingCenter.Send(new CategoryStatus {
                CategoryId = RecordResponse.CategoryId
            },
                                 HaccpConstant.CategoryMessage);
            IsBusy = false;
            SaveCommand.ChangeCanExecute();
            await Page.PopPage();

            if (HaccpAppSettings.SharedInstance.DeviceSettings.AutoAdvance)
            {
                MessagingCenter.Send(new AutoAdvanceCheckListMessage {
                    CurrentId = RecordResponse.QuestionId
                },
                                     HaccpConstant.AutoadvancechecklistMessage);
            }
        }
コード例 #10
0
        /// <summary>
        ///     Executes the items filter command.
        /// </summary>
        /// <returns>The items filter command.</returns>
        private void ExecuteItemsFilterCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            ItemsFilterCommand.ChangeCanExecute();

            try
            {
                ListCompletedItems = !ListCompletedItems; //The default value of ListCompletedItems is false

                Title = ListCompletedItems
                    ? HACCPUtil.GetResourceString("ReviewItem")
                    : HACCPUtil.GetResourceString("SelectItem");

                NoItemFoundText = ListCompletedItems
                    ? HACCPUtil.GetResourceString("Noitemsfoundtoreview")
                    : HACCPUtil.GetResourceString("Noitemsfound");

                var items         = _dataStore.GetItems(LocationId, ListCompletedItems);
                var filteredItems = new List <LocationMenuItem>();
                if (ListCompletedItems && items != null)
                {
                    foreach (var item in items)
                    {
                        var record = _dataStore.GetTemperatureRecordById(item.ItemId, item.LocationId);
                        var temp   = HACCPUtil.ConvertToDouble(record.Temperature);

                        if (item.RecordStatus == 1 && record.IsNA == 0 && temp < HACCPUtil.ConvertToDouble(item.Min) ||
                            temp > HACCPUtil.ConvertToDouble(item.Max))
                        {
                            filteredItems.Add(item);
                        }
                    }
                    items = filteredItems;
                }

                Items    = new ObservableCollection <LocationMenuItem>(items);
                HasItems = Items.Any();
                OnPropertyChanged("Items");
            }
            catch
            {
                // ignored
            }
            finally
            {
                IsBusy = false;
                ItemsFilterCommand.ChangeCanExecute();
            }
        }
コード例 #11
0
        /// <summary>
        ///     Displaies the temperature reading.
        /// </summary>
        /// <param name="temperature">Temperature.</param>
        /// <param name="autoRecord"></param>
        private void DisplayTemperatureReading(double temperature, bool autoRecord)
        {
            var mintemp = HACCPUtil.ConvertToDouble(SelectedItem.Min);
            var maxtemp = HACCPUtil.ConvertToDouble(SelectedItem.Max);

            if (TemperatureUnit == TemperatureUnit.Celcius)
            {
                mintemp = HACCPUtil.ConvertFahrenheitToCelsius(mintemp);
                maxtemp = HACCPUtil.ConvertFahrenheitToCelsius(maxtemp);
            }

            if (temperature < mintemp)
            {
                OptimumTemperatureIndicator = false;
                HighTemperatureIndicator    = false;
                LowTemperatureIndicator     = true;
            }
            else if (temperature > maxtemp)
            {
                OptimumTemperatureIndicator = false;
                HighTemperatureIndicator    = true;
                LowTemperatureIndicator     = false;
            }
            else
            {
                OptimumTemperatureIndicator = true;
                HighTemperatureIndicator    = false;
                LowTemperatureIndicator     = false;
            }

            var diff = Math.Round(temperature - prevtemp, 1);

            if (diff > 2.8)
            {
                diff = 2.8;
            }
            else if (diff < -2.8)
            {
                diff = -2.8;
            }

            Rotation = HACCPUtil.GetSlope(diff);

            Blue2Temperature = temperature;
            prevtemp         = temperature;

            DisplayBlue2Temperature = string.Format("{0}{1}", Blue2Temperature.ToString("0.0"), UnitString);
            LineBreakMode           = LineBreakMode.NoWrap;
            if (autoRecord)
            {
                Device.BeginInvokeOnMainThread(() => { RecordCommand.Execute(null); });
            }
        }
コード例 #12
0
ファイル: BaseViewModel.cs プロジェクト: PVSPReddy/HACCP
        /// <summary>
        ///     Executes the log in command.
        /// </summary>
        /// <returns>The log in command.</returns>
        private async Task ExecuteLogInCommand()
        {
            var shouldShowSelectUser = false;

            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            LogInCommand.ChangeCanExecute();
            try
            {
                if (IsLoggedIn)
                {
                    var checkLogout = await ShowLogoutConfirm();

                    if (checkLogout)
                    {
                        HaccpAppSettings.SharedInstance.CurrentUserId = 0;
                    }
                }
                else
                {
                    shouldShowSelectUser = true;
                }

                if (shouldShowSelectUser)
                {
                    IDataStore dataStore   = new SQLiteDataStore();
                    var        isUserExist = dataStore.CheckUsersExist();
                    if (isUserExist)
                    {
                        await Page.NavigateTo(PageEnum.SelectUser, true);
                    }
                    else
                    {
                        await Page.ShowAlert(HACCPUtil.GetResourceString("NoUsersFound"),
                                             HACCPUtil.GetResourceString("NousersfoundPleasetapUpdateUserListintheWirelessTasksmenu"));
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Ooops! Something went wrong while login. Exception: {0}", ex);
            }
            finally
            {
                IsBusy = false;
                LogInCommand.ChangeCanExecute();
            }
        }
コード例 #13
0
        // <summary>
        /// Executes the blue2 command.
        private async void ExecuteBlue2Command()
        {
            if (IsBusy)
            {
                return;
            }


            if (HaccpAppSettings.SharedInstance.IsWindows)
            {
                WindowsBlue2Command();
                return;
            }


            if (!BLEManager.SharedInstance.Adapter.IsBluetoothEnabled)
            {
                await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("TurnONBluetoothonyourdevice"));

                return;
            }

            if (BLEManager.SharedInstance.ReadingBlue2Data)
            {
                return;
            }

            IsBusy = true;
            Blue2Command.ChangeCanExecute();

            bool gotPermission = await getLocationPermission();

            if (gotPermission)
            {
                BLEManager.SharedInstance.ResetConnection();

                if (!BLEManager.SharedInstance.ScanTimeOutElapsed)
                {
                    ConnectionStatus =
                        HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanning"), false);
                }
                else if (!BLEManager.SharedInstance.IsConnected)
                {
                    ConnectionStatus =
                        HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanBlue2"), false);
                }
            }

            IsBusy = false;
            Blue2Command.ChangeCanExecute();
        }
コード例 #14
0
ファイル: UsersViewModel.cs プロジェクト: PVSPReddy/HACCP
        /// <summary>
        ///     Checks the login.
        /// </summary>
        /// <returns>The login.</returns>
        private async Task CheckLogin()
        {
            if (IsBusy || !DisplayPasswordPopup)
            {
                return;
            }

            IsBusy = true;
            CheckLoginCommand.ChangeCanExecute();
            try
            {
                //isValidPassword = this.page.
                if (!string.IsNullOrEmpty(loginPassword))
                {
                    if (loginPassword == selectedUser.Pin)
                    {
                        Page.EndEditing();
                        HaccpAppSettings.SharedInstance.UserName      = selectedUser.Name;
                        HaccpAppSettings.SharedInstance.CurrentUserId = SelectedUserId;
                        HaccpAppSettings.SharedInstance.Permission    = selectedUser.Permision;
                        OnPropertyChanged(IsMenuCheckListActivePropertyName);
                        Settings.LastLoginUserId = SelectedUserId;
                        await Page.PopPage();
                    }
                    else
                    {
                        LoginPassword = string.Empty;
                        await
                        Page.ShowAlert(HACCPUtil.GetResourceString("Login"),
                                       HACCPUtil.GetResourceString("PasswordincorrectPleasetryagain"));

                        // this.page.DisplayAlertMessage(HACCPUtil.GetResourceString("Login"), HACCPUtil.GetResourceString("PasswordincorrectPleasetryagain"));
                        MessagingCenter.Send(new UserPasswordFocusMessage(true), HaccpConstant.UserPasswordFocusMessage);
                    }
                }
                else
                {
                    Page.DisplayAlertMessage(HACCPUtil.GetResourceString("Login"),
                                             HACCPUtil.GetResourceString("Enteryourpassword"));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error On Login. Exception: {0}", ex);
            }
            finally
            {
                IsBusy = false;
                CheckLoginCommand.ChangeCanExecute();
            }
        }
コード例 #15
0
        /// <summary>
        ///     Called when the view appears.
        /// </summary>
        public override void OnViewAppearing()
        {
            base.OnViewAppearing();
            if (Items.Count < 1)
            {
                Page.DisplayAlertMessage(string.Empty, HACCPUtil.GetResourceString("Noitemsfound"));
            }

            if (HaccpAppSettings.SharedInstance.IsWindows && HaccpAppSettings.SharedInstance.DeviceSettings.AutoAdvance &&
                AutoBack)
            {
                Page.PopPage();
            }
        }
コード例 #16
0
ファイル: QuestionViewModel.cs プロジェクト: PVSPReddy/HACCP
        /// <summary>
        ///     Loads the questions.
        /// </summary>
        public async Task LoadQuestions(bool isFilterStatus)
        {
            isFilter = isFilterStatus;

            Title = HACCPUtil.GetResourceString("SelectQuestion");
            if (isFilter)
            {
                Title = HACCPUtil.GetResourceString("ReviewChecklist");
            }

            var questionLIst = dataStore.GetQuestions(SelectedCategoryId, isFilter);
            var filteredList = new List <Question>();

            if (isFilter)
            {
                foreach (var question in questionLIst)
                {
                    var response = dataStore.GetChecklistResponseById(question.QuestionId);
                    if ((question.QuestionType == (short)QuestionType.YesOrNo &&
                         response.Answer == HACCPUtil.GetResourceString("No")) ||
                        (question.QuestionType != (short)QuestionType.YesOrNo &&
                         (HACCPUtil.ConvertToDouble(response.Answer) < HACCPUtil.ConvertToDouble(question.Min) ||
                          HACCPUtil.ConvertToDouble(response.Answer) > HACCPUtil.ConvertToDouble(question.Max))))
                    {
                        filteredList.Add(question);
                    }
                }

                questionLIst = filteredList;
            }

            isFilter  = !isFilter;
            Questions = new ObservableCollection <Question>(questionLIst);
            if (Questions.Count == 0)
            {
                if (isFilterStatus)
                {
                    //this.page.ShowAlert ("", AppResources.Noquestionsfound);
                    IsQuestionExists = true;
                    //LoadQuestions (!isFilterStatus);
                }
                else
                {
                    IsQuestionExists = false;
                    await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("Noquestionsfound"));

                    await Page.PopPage();
                }
            }
        }
コード例 #17
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="HACCP.Core.RecordItemCompleteViewModel" /> class.
 /// </summary>
 /// <param name="page">Page.</param>
 /// <param name="item">Item.</param>
 public RecordItemCompleteViewModel(IPage page, object item) : base(page)
 {
     dataStore    = new SQLiteDataStore();
     SelectedItem = item as LocationMenuItem;
     if (SelectedItem != null)
     {
         NoteText         = SelectedItem.Note;
         TemperatureUnit  = SelectedItem.TemperatureUnit;
         TemperatureValue = HACCPUtil.ConvertToDouble(SelectedItem.RecordedTemperature);
         Temperature      = TemperatureValue.ToString("0.0");
         itemTemperature  = dataStore.GetItemTemperature(SelectedItem);
     }
     LoadCorrectiveActions();
 }
コード例 #18
0
 /// <summary>
 /// OnViewAppearing
 /// </summary>
 public override void OnViewAppearing()
 {
     base.OnViewAppearing();
     if (IsNumeric)
     {
         ToggleImage     = "toggle.png";
         YesNoButtonText = string.Empty;
     }
     else
     {
         ToggleImage     = string.Empty;
         YesNoButtonText = HACCPUtil.GetResourceString("No");
     }
 }
コード例 #19
0
        /// <summary>
        ///     Executes the toggle yes no image command.
        /// </summary>
        /// <returns>The toggle yes no image command.</returns>
        protected void ExecuteToggleYesNoImageCommand()
        {
            if (IsBusy)
            {
                return;
            }

            if (IsNumeric)
            {
                MessagingCenter.Send(string.Empty, HaccpConstant.RecordAnswerFocus);
                return;
            }

            try
            {
                IsBusy = true;
                //	ToggleYesNoImageCommand.ChangeCanExecute ();


                if (YesNoButtonText == HACCPUtil.GetResourceString("No"))
                {
                    YesNoButtonText = HACCPUtil.GetResourceString("Yes");
                    Answer          = HACCPUtil.GetResourceString("No");

                    //SelectedCorrectiveAction = AppResources.None;
                }
                else
                {
                    YesNoButtonText          = HACCPUtil.GetResourceString("No");
                    Answer                   = HACCPUtil.GetResourceString("Yes");
                    SelectedCorrectiveAction = HACCPUtil.GetResourceString("None");
                    ExecuteCorrectiveActionCommand();
                }

                IsBusy = false;
                //	ToggleYesNoImageCommand.ChangeCanExecute ();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Ooops! Something went wrong. Exception: {0}", ex);
            }
            finally
            {
                IsBusy = false;
                //	ToggleYesNoImageCommand.ChangeCanExecute ();
            }
        }
コード例 #20
0
        /// <summary>
        ///     Executes the select user command.
        /// </summary>
        /// <returns>The select user command.</returns>
        private void ExecuteSelecUserCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            Page.ShowProgressIndicator();
            SelecUserCommand.ChangeCanExecute();

            try {
                Task.Run(async() => {
                    if (HaccpAppSettings.SharedInstance.IsWindows)
                    {
                        await Task.Delay(500);
                    }

                    var isUserExist = _dataStore.CheckUsersExist();

                    if (isUserExist)
                    {
                        Device.BeginInvokeOnMainThread(async() => {
                            await Page.NavigateTo(PageEnum.SelectUser, true);

                            IsBusy = false;
                            Page.DismissPopup();
                            SelecUserCommand.ChangeCanExecute();
                        });
                    }
                    else
                    {
                        Device.BeginInvokeOnMainThread(() => {
                            Page.DisplayAlertMessage(HACCPUtil.GetResourceString("NoUsersFound"),
                                                     HACCPUtil.GetResourceString("NousersfoundPleasetapUpdateUserListintheWirelessTasksmenu"));
                            IsBusy = false;
                            Page.DismissPopup();
                            SelecUserCommand.ChangeCanExecute();
                        });
                    }
                });
            } catch (Exception ex) {
                Debug.WriteLine("ExecuteSelecUserCommand Error {0}", ex.Message);
            }
        }
コード例 #21
0
        /// <summary>
        ///     Loads the menu item.
        /// </summary>
        /// <returns>The menu item.</returns>
        /// <param name="location">Location.</param>
        public async Task LoadMenuItem(MenuLocation location)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            if (_dataStore.CheckItemExists(location.LocationId))
            {
                await Page.NavigateToWithSelectedObject(PageEnum.SelectLocationItem, true, location);
            }
            else
            {
                await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("Noitemsfound"));
            }

            IsBusy = false;
        }
コード例 #22
0
        private async Task <bool> getLocationPermission()
        {
            if (Device.OS != TargetPlatform.Android)
            {
                return(true);
            }
            else
            {
                try
                {
                    PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Location);

                    if (status != PermissionStatus.Granted)
                    {
                        if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Plugin.Permissions.Abstractions.Permission.Location))
                        {
                            await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("AndroidrequiresLocationpermissionforBluetoothLEscanning"));  //Android requires \"Location\" permission for Bluetooth LE scanning.
                        }

                        var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Plugin.Permissions.Abstractions.Permission.Location });

                        status = results[Plugin.Permissions.Abstractions.Permission.Location];
                    }

                    if (status != PermissionStatus.Granted)
                    {
                        await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("CannotscanforBlue2withoutLocationpermission")); //Cannot scan for Blue2 without \"Location\" permission.

                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    await Page.ShowAlert(string.Empty, ex.ToString());

                    return(false);
                }
            }
        }
コード例 #23
0
        /// <summary>
        ///     Loads the questions.
        /// </summary>
        /// <returns>The questions.</returns>
        public async Task LoadQuestions()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            if (dataStore.CheckQuestionExists(SelectedCategory.CategoryId))
            {
                await Page.NavigateToWithSelectedObject(PageEnum.SelectQuestion, true, SelectedCategory);
            }
            else
            {
                await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("Noquestionsfound"));
            }


            IsBusy = false;
        }
コード例 #24
0
        /// <summary>
        ///     Executes the toggle command.
        /// </summary>
        public void ExecuteToggleCommand()
        {
            if (IsBusy)
            {
                return;
            }


            if (HaccpAppSettings.SharedInstance.DeviceSettings.AllowManualTemp == 1)
            {
                IsManualEntryOn = !IsManualEntryOn;
            }
            else
            {
                Page.ShowAlert(string.Empty,
                               HACCPUtil.GetResourceString(
                                   "YoudonothavepermissiontoenterthetemperaturemanuallyPleasecontacttheApplicationAdministrator"));
            }
            Settings.RecordingMode = IsManualEntryOn ? RecordingMode.Manual : RecordingMode.BlueTooth;
            OnPropertyChanged("IsWakeButtonVisible");
        }
コード例 #25
0
        /// <summary>
        ///     Searchs the blue2 devices.
        /// </summary>
        public async void LoadBlue2Settings()
        {
            if (BLEManager.SharedInstance.IsConnected)
            {
                ConnectionStatus = HACCPUtil.GetResourceString("ConnectionStatusDisconnect");
                Blue2ButtonStyle = Application.Current.Resources["Blue2ButtonActiveStyle"] as Style;
            }
            else
            {
                PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Location);

                if (status == PermissionStatus.Granted)
                {
                    ConnectionStatus = BLEManager.SharedInstance.ScanTimeOutElapsed
                    ? HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanBlue2"), false)
                    : HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanning"), false);
                }
                else
                {
                    ConnectionStatus = HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanBlue2"), false);
                    BLEManager.SharedInstance.Adapter.CancelScanning();
                    BLEManager.SharedInstance.ScanTimeOutElapsed = true;
                }

                Blue2ButtonStyle        = Application.Current.Resources["Blue2ButtonNotActiveStyle"] as Style;
                DisplayBlue2Temperature = HACCPUtil.GetResourceString("ConnectBlue2Label");
                LineBreakMode           = LineBreakMode.TailTruncation;

                if (!BLEManager.SharedInstance.Adapter.IsBluetoothEnabled && !IsManualEntryOn)
                {
                    // bluetooth in phone is disabled
                    await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("TurnONBluetoothonyourdevice"));
                }
                else if (BLEManager.SharedInstance.Adapter.IsScanning && !IsManualEntryOn)
                {
                    // connection to the blue2 device is disabled
                    await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("Blue2TurnOnMessage"));
                }
            }
        }
コード例 #26
0
        /// <summary>
        ///     Displaies the temperature reading.
        /// </summary>
        /// <param name="temperature">Temperature.</param>
        private void DisplayTemperatureReading(double temperature)
        {
            var diff = Math.Round(temperature - prevtemp, 1);

            if (diff > 2.8)
            {
                diff = 2.8;
            }
            else if (diff < -2.8)
            {
                diff = -2.8;
            }

            Rotation = HACCPUtil.GetSlope(diff);

            prevtemp = temperature;
            short tempScale;

            if (HaccpAppSettings.SharedInstance.IsWindows)
            {
                tempScale = WindowsBLEManager.SharedInstance.Settings.Scale;
            }
            else
            {
                tempScale = BLEManager.SharedInstance.Settings.Scale;
            }

            if (TemperatureUnit == TemperatureUnit.Celcius && tempScale != 0)
            {
                temperature = HACCPUtil.ConvertFahrenheitToCelsius(temperature);
            }
            else if (TemperatureUnit == TemperatureUnit.Fahrenheit && tempScale != 1)
            {
                temperature = HACCPUtil.ConvertCelsiusToFahrenheit(temperature);
            }
            CurrentTemperature = temperature;
            Blue2TempFontSize  = 32;
            LineBreakMode      = LineBreakMode.NoWrap;
        }
コード例 #27
0
        /// <summary>
        ///     Executes the select user command.
        /// </summary>
        /// <returns>The select user command.</returns>
        private void ExecuteSelectLocationCommand()
        {
            if (IsBusy || !IsLoggedIn)
            {
                return;
            }

            IsBusy = true;
            Page.ShowProgressIndicator();
            SelectLocationCommand.ChangeCanExecute();

            Task.Run(() => {
                if (HaccpAppSettings.SharedInstance.SiteSettings.MenuId > 0 && _dataStore.CheckLocationsExist())
                {
                    Device.BeginInvokeOnMainThread(async() => {
                        await Page.NavigateTo(PageEnum.SelectLocations, true);
                        if (HaccpAppSettings.SharedInstance.IsWindows)
                        {
                            await Task.Delay(500);
                        }

                        IsBusy = false;
                        Page.DismissPopup();
                        SelectLocationCommand.ChangeCanExecute();
                    });
                }
                else
                {
                    Device.BeginInvokeOnMainThread(() => {
                        Page.DisplayAlertMessage(HACCPUtil.GetResourceString("NoLocationsFound"),
                                                 HACCPUtil.GetResourceString(
                                                     "NolocationsfoundPleasetapSelectChangeMenuintheWirelessTasksMenu"));
                        IsBusy = false;
                        Page.DismissPopup();
                        SelectLocationCommand.ChangeCanExecute();
                    });
                }
            });
        }
コード例 #28
0
        /// <summary>
        ///     Checks the pending records.
        /// </summary>
        /// <returns>The pending records.</returns>
        private async Task CheckPendingRecords(bool showConfirmation)
        {
            try {
                if (HaccpAppSettings.SharedInstance.CheckPendingRecords &&
                    !HaccpAppSettings.SharedInstance.IsUploadingProgress)
                {
                    var checklists   = _dataStore.GetCheckListResponses();
                    var temperatures = _dataStore.GetItemTemperatures();

                    if ((checklists != null && checklists.Count != 0) ||
                        (temperatures != null && temperatures.Count != 0))
                    {
                        Page.DismissPopup();
                        IsBusy = false;

                        if (!_isAlertActive)
                        {
                            _isAlertActive = true;
                            var result =
                                await Page.ShowConfirmAlert(string.Empty,
                                                            HACCPUtil.GetResourceString("PendingCheckmarksMessage"));

                            await Task.Delay(500);

                            _isAlertActive = false;

                            if (result && HaccpAppSettings.SharedInstance.CheckPendingRecords)
                            {
                                await ExecuteUploadRecordCommand(showConfirmation);
                            }
                        }
                    }
                }
                HaccpAppSettings.SharedInstance.CheckPendingRecords = false;
            } catch (Exception ex) {
                Debug.WriteLine("Error on CheckPendingRecords :{0}", ex.Message);
            }
        }
コード例 #29
0
 private void BindeAllLablelProperties()
 {
     try
     {
         ServerSettingsLabel = HACCPUtil.GetResourceString("ServerSettings");
         DeviceIDLabel       = HACCPUtil.GetResourceString("DeviceID");
         ServerIPAddressorDomainNameLabel =
             HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ServerIPAddressorDomainName"), true);
         EnterPortoptionalLabel                 = HACCPUtil.GetResourceString("EnterPortoptional");
         AddDirectoryPathoptionalLabel          = HACCPUtil.GetResourceString("AddDirectoryPathoptional");
         TestServerConnectionandWebServiceLabel = HACCPUtil.GetResourceString("TestServerConnectionandWebService");
         SaveandContinueLabel   = HACCPUtil.GetResourceString("SaveandContinue");
         SelectLanguageLabel    = HACCPUtil.GetResourceString("SelectLanguage");
         LanguagesLabel         = HACCPUtil.GetResourceString("Languages");
         NotifEYEUrlLabel       = HACCPUtil.GetResourceString("NotifEyeUrl");
         NotifyEYEUsernameLabel = HACCPUtil.GetResourceString("NotifEYEUserName");
         NotifyEYEPasswordLabel = HACCPUtil.GetResourceString("NotifEyeUserPassword");
     }
     catch (Exception)
     {
         // ignored
     }
 }
コード例 #30
0
        /// <summary>
        ///     Method for loading ble settings for windows
        /// </summary>
        public void LoadWindowsBlue2Settings()
        {
            if (WindowsBLEManager.SharedInstance.HasAnyPairedDevice)
            {
                ConnectionStatus = HACCPUtil.GetResourceString("ConnectionStatusDisconnect");
                Blue2ButtonStyle = Application.Current.Resources["Blue2ButtonActiveStyle"] as Style;
                if (WindowsBLEManager.SharedInstance.Settings != null)
                {
                    Blue2Id = WindowsBLEManager.SharedInstance.Settings.SNo;
                }


                if (WindowsBLEManager.SharedInstance.Settings != null)
                {
                    var temp = WindowsBLEManager.SharedInstance.LastReading;
                    var unit = WindowsBLEManager.SharedInstance.Settings.Scale;
                    if (TemperatureUnit == TemperatureUnit.Celcius && unit != 0)
                    {
                        temp = HACCPUtil.ConvertFahrenheitToCelsius(temp);
                    }
                    else if (TemperatureUnit == TemperatureUnit.Fahrenheit && unit != 1)
                    {
                        temp = HACCPUtil.ConvertCelsiusToFahrenheit(temp);
                    }

                    DisplayTemperatureReading(temp, false);
                }
            }
            else
            {
                ConnectionStatus =
                    HACCPUtil.TruncateResourceString(HACCPUtil.GetResourceString("ConnectionStatusScanBlue2"), false);
                Blue2ButtonStyle        = Application.Current.Resources["Blue2ButtonNotActiveStyle"] as Style;
                DisplayBlue2Temperature = HACCPUtil.GetResourceString("ConnectBlue2Label");
                LineBreakMode           = LineBreakMode.TailTruncation;
            }
        }