Exemple #1
0
        private async void HandleErrorDetectedMessage(ErrorDetectedMessage msg)
        {
            ErrorDialog dialog = new ErrorDialog();

            dialog.ErrorMessage = msg.Content;
            dialog.Title        = msg.Title;

            await dialog.ShowAsync();
        }
        /// <summary>
        /// The method to run when the tray is closed.
        ///
        /// This performs checks related to changes in the controllers both when the tray is opened
        /// and closed, infers the prescription administered based on what group is scheduled the
        /// nearest to current time, and fires the TrayClosedMessage back to the view.
        /// </summary>
        private async void HandleOnTrayClosed()
        {
            bool isDataSent = false;

            try
            {
                if (Mode != 2)
                {
                    string finalPresenceStatus = await TrayController.Instance.GetPresenceStatusAsync();

                    Placement placementStatus = EvaluatePresenceStatus(PatientIndex, initialPresenceStatus, finalPresenceStatus);
                    switch (placementStatus)
                    {
                    case Placement.Correct:
                        isDataSent = await UpdatePrescriptionDataAsync(Mode, SelectedPrescriptions, ContainerHasItem);

                        break;

                    case Placement.CorrectWithErrors:
                        isDataSent = await UpdatePrescriptionDataAsync(Mode, SelectedPrescriptions, ContainerHasItem);

                        ErrorDetectedMessage cweMsg = new ErrorDetectedMessage("Conflict detected", "It seems that you have also made changes to other containers. Please place the medicines at the right container.");
                        MessengerInstance.Send(cweMsg);
                        break;

                    case Placement.Incorrect:
                        ErrorDetectedMessage incMsg = new ErrorDetectedMessage("Conflict detected", "It seems that you have placed the prescriptions in the wrong container. Please place the medicines at the right container.");
                        MessengerInstance.Send(incMsg);
                        break;

                    case Placement.NoChange:
                        break;
                    }

                    await SocketService.SendToDeviceAsync(_shellVM.TcpClient, null, "refreshData", null);
                }

                Debug.WriteLine($@"Tray closed, isDataSent: {isDataSent}", "PatientViewModel");
                MessengerInstance.Send(new TrayClosedMessage());
            }
            catch (Exception)
            {
                throw;
            }
        }