Exemplo n.º 1
0
        public void Process()
        {
            CountstartMain = true;
            Service s = new Service();

            s.serviceID = SessionModel.bookingQ.serviceID;
            s.branchID  = SessionModel.bookingQ.branchID;
            UIReturn ChkQueue = ReserveQController.getInstance().reserveQueue(SessionModel.bookingQ);

            if (App.fristtime)
            {
                App.fristtime  = false;
                ChkTime        = SessionModel.bookingQ.estimateTime.GetHashCode() * 60;
                App.timercount = ChkTime;
                if (App.timercount < 900)
                {
                    App.Massage15 = false;
                }
            }

            if (App.RePage == false)
            {
                Device.StartTimer(new TimeSpan(0, 0, 1), () =>
                {
                    if (SessionModel.bookingQ != null)
                    {
                        if (CrossConnectivity.Current.IsConnected)
                        {
                            if (CountstartMain == true)
                            {
                                App.Recount = App.Recount + 1;
                            }

                            TimeSpan time = TimeSpan.FromSeconds(App.timercount);

                            TimesQ.Text = time.ToString(@"hh\:mm\:ss");
                            if (App.timercount == 0)
                            {
                                App.Massage15 = false;
                                App.Massage5  = false;
                            }

                            if (App.timercount <= 900 && App.Massage15 == true)
                            {
                                DependencyService.Get <IFNotification>().SendNotification(Utils.getLabel(LabelConstants.MAIN_PAGE_YOURQUEUE) + " " + SessionModel.bookingQ.queueNumber, Utils.getLabel(LabelConstants.MAIN_PAGE_NOTIFICATION1));
                                App.Massage15 = false;
                            }

                            if (App.timercount == 300 && App.Massage5 == true)
                            {
                                DependencyService.Get <IFNotification>().SendNotification(Utils.getLabel(LabelConstants.MAIN_PAGE_YOURQUEUE) + " " + SessionModel.bookingQ.queueNumber, Utils.getLabel(LabelConstants.MAIN_PAGE_NOTIFICATION2));
                                App.Massage5 = false;
                            }

                            if (App.timercount == 0 && App.Massage0 == true)
                            {
                                DependencyService.Get <IFNotification>().SendNotification(Utils.getLabel(LabelConstants.MAIN_PAGE_YOURQUEUE) + " " + SessionModel.bookingQ.queueNumber, String.Format(ChkQueue.getDescription(), SessionModel.bookingQ.queueBefore));
                                App.Massage0 = false;
                            }

                            if (!ChkQueue.isSuccess)
                            {
                                DisplayAlert(App.AppicationName, ChkQueue.getDescription(), "Close");
                                TimesQ.Text    = "00:00:00";
                                App.timercheck = false;
                            }
                            else
                            {
                                DetailQ.Text  = String.Format(ChkQueue.getDescription(), SessionModel.bookingQ.queueBefore);
                                NumberQ.Text  = SessionModel.bookingQ.queueNumber;
                                NumberQ2.Text = SessionModel.bookingQ.queueBefore.ToString();
                                if (SessionModel.loginMember != null)
                                {
                                    UserNames.Text = Utils.getLabel(LabelConstants.MAIN_PAGE_HELLO) + " " + SessionModel.loginMember.firstName + "  " + SessionModel.loginMember.lastName;
                                }

                                Main_History.Text = Utils.getLabel(LabelConstants.MAIN_PAGE_HISTORY);
                                Main_Booking.Text = Utils.getLabel(LabelConstants.MAIN_PAGE_BOOKING);
                                Main_QR.Text      = Utils.getLabel(LabelConstants.MAIN_PAGE_QR);
                                YourQ.Text        = Utils.getLabel(LabelConstants.MAIN_PAGE_YOURQUEUE);
                                AllQ.Text         = Utils.getLabel(LabelConstants.MAIN_PAGE_ALLQUEUE);
                                WaitTime.Text     = Utils.getLabel(LabelConstants.MAIN_PAGE_WATETIME);

                                if (App.Thai == true)
                                {
                                    btn_cancel.IsVisible  = false;
                                    btn_cancel2.IsVisible = true;
                                }
                                else
                                {
                                    btn_cancel.IsVisible  = true;
                                    btn_cancel2.IsVisible = false;
                                }

                                if (App.timercount == 0)
                                {
                                    TimesQ.Text = "00:00:00";
                                }
                            }

                            if (App.Recount == App.TimeReface)
                            {
                                App.Recount = 0;

                                Queue Queue = (Queue)ReserveQController.getInstance().reserveQueue(SessionModel.bookingQ).returnObject;
                                ChkTime2    = SessionModel.bookingQ.estimateTime * 60;


                                if (ChkTime2 < App.timercount)
                                {
                                    ChkTime        = SessionModel.bookingQ.estimateTime * 60;
                                    App.timercount = SessionModel.bookingQ.estimateTime * 60;
                                    NumberQ2.Text  = SessionModel.bookingQ.queueBefore.ToString();
                                }
                                else
                                {
                                    if (App.timercount == 0)
                                    {
                                        App.timercount = ChkTime2;
                                    }
                                }

                                ChkQueue = ReserveQController.getInstance().reserveQueue(SessionModel.bookingQ);
                                if (!ChkQueue.isSuccess)
                                {
                                    App.timercheck = false;
                                    DisplayAlert(App.AppicationName, ChkQueue.getDescription(), "Close");
                                    TimesQ.Text = "00:00:00";
                                }
                                else
                                {
                                    if (ChkQueue.id == 58)
                                    {
                                        DependencyService.Get <IFNotification>().SendNotification(Utils.getLabel(LabelConstants.MAIN_PAGE_YOURQUEUE) + " " + SessionModel.bookingQ.queueNumber, ChkQueue.getDescription());
                                        DetailQ.Text   = ChkQueue.getDescription();
                                        App.timercheck = false;
                                        CountstartMain = false;
                                        App.fristtime  = true;
                                        Navigation.PushAsync(new RatingPage());
                                        TimesQ.Text          = "00:00:00";
                                        b_booking1.IsVisible = true;
                                        b_booking2.IsVisible = false;
                                        b_qr1.IsVisible      = true;
                                        b_qr2.IsVisible      = false;
                                    }
                                    else if (ChkQueue.id == 63)
                                    {
                                        DependencyService.Get <IFNotification>().SendNotification(Utils.getLabel(LabelConstants.MAIN_PAGE_YOURQUEUE) + " " + SessionModel.bookingQ.queueNumber, ChkQueue.getDescription());
                                        SessionModel.clearQueue();
                                        DetailQ.Text          = ChkQueue.getDescription();
                                        NumberQ.Text          = "-";
                                        App.timercheck        = false;
                                        CountstartMain        = false;
                                        App.fristtime         = true;
                                        TimesQ.Text           = "00:00:00";
                                        b_booking1.IsVisible  = true;
                                        b_booking2.IsVisible  = false;
                                        b_qr1.IsVisible       = true;
                                        b_qr2.IsVisible       = false;
                                        btn_cancel.IsVisible  = false;
                                        btn_cancel2.IsVisible = false;
                                    }
                                    else
                                    {
                                        if (SessionModel.bookingQ != null)
                                        {
                                            DetailQ.Text = String.Format(ChkQueue.getDescription(), SessionModel.bookingQ.queueBefore);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    return(App.timercheck);
                });
            }
        }
Exemplo n.º 2
0
        public void Process()
        {
            Service s = new Service();

            s.serviceID = SessionModel.bookingQ.serviceID;
            s.branchID  = SessionModel.bookingQ.branchID;
            UIReturn ChkQueue = ReserveQController.getInstance().reserveQueue(SessionModel.bookingQ);

            if (App.fristtime)
            {
                ChkTime        = SessionModel.bookingQ.estimateTime.GetHashCode() * 60;
                App.fristtime  = false;
                App.timercount = ChkTime;
                if (App.timercount < 900)
                {
                    App.Massage15 = false;
                }
            }

            Device.StartTimer(new TimeSpan(0, 0, 1), () =>
            {
                if (SessionModel.bookingQ != null)
                {
                    if (CountstartQ == true)
                    {
                        App.Recount = App.Recount + 1;
                    }

                    TimeSpan time = TimeSpan.FromSeconds(App.timercount);

                    TimesQ.Text = time.ToString(@"hh\:mm\:ss");

                    if (App.timercount <= 900 && App.Massage15 == true)
                    {
                        DependencyService.Get <IFNotification>().SendNotification("คิวเลขที่ " + SessionModel.bookingQ.queueNumber, "อีก 15 นาทีจะถึงคิวของคุณ");
                        App.Massage15 = false;
                    }

                    if (App.timercount <= 300 && App.Massage5 == true)
                    {
                        DependencyService.Get <IFNotification>().SendNotification("คิวเลขที่ " + SessionModel.bookingQ.queueNumber, "อีก 5 นาทีจะถึงคิวของคุณ");
                        App.Massage5 = false;
                    }

                    if (App.timercount == 0 && App.Massage0 == true)
                    {
                        DependencyService.Get <IFNotification>().SendNotification("คิวเลขที่ " + SessionModel.bookingQ.queueNumber, String.Format(ChkQueue.getDescription(), SessionModel.bookingQ.queueBefore));
                        App.Massage0 = false;
                    }

                    if (!ChkQueue.isSuccess)
                    {
                        App.timercheck = false;
                        DisplayAlert("", ChkQueue.getDescription(), "Close");
                        TimesQ.Text = "00:00:00";
                    }
                    else
                    {
                        if (SessionModel.bookingQ != null)
                        {
                            DetailQ.Text = String.Format(ChkQueue.getDescription(), SessionModel.bookingQ.queueBefore);
                        }

                        if (App.timercount == 0)
                        {
                            TimesQ.Text = "00:00:00";
                        }
                    }

                    if (App.Recount == 10)
                    {
                        App.Recount = 0;

                        Queue Queue = (Queue)ReserveQController.getInstance().reserveQueue(SessionModel.bookingQ).returnObject;
                        ChkTime2    = SessionModel.bookingQ.estimateTime.GetHashCode() * 60;
                        if (ChkTime2 < App.timercount)
                        {
                            ChkTime        = SessionModel.bookingQ.estimateTime.GetHashCode() * 60;
                            App.timercount = SessionModel.bookingQ.estimateTime.GetHashCode() * 60;
                        }

                        ChkQueue = ReserveQController.getInstance().reserveQueue(SessionModel.bookingQ);
                        if (!ChkQueue.isSuccess)
                        {
                            App.timercheck = false;
                            DisplayAlert("", ChkQueue.getDescription(), "Close");
                            TimesQ.Text = "00:00:00";
                        }
                        else
                        {
                            if (ChkQueue.id == 58)
                            {
                                DependencyService.Get <IFNotification>().SendNotification("คิวเลขที่ " + SessionModel.bookingQ.queueNumber, ChkQueue.getDescription());
                                DetailQ.Text   = ChkQueue.getDescription();
                                App.timercheck = false;
                                CountstartQ    = false;
                                Navigation.PushAsync(new RatingPage());
                                TimesQ.Text = "00:00:00";
                            }
                            else if (ChkQueue.id == 63)
                            {
                                DependencyService.Get <IFNotification>().SendNotification("คิวเลขที่ " + SessionModel.bookingQ.queueNumber, ChkQueue.getDescription());
                                DetailQ.Text = ChkQueue.getDescription();
                                SessionModel.clearQueue();
                                NumberQ.Text   = "-";
                                App.timercheck = false;
                                CountstartQ    = false;
                                Navigation.PushAsync(new MainPage());
                                TimesQ.Text = "00:00:00";
                            }
                            else
                            {
                                if (SessionModel.bookingQ != null)
                                {
                                    DetailQ.Text = String.Format(ChkQueue.getDescription(), SessionModel.bookingQ.queueBefore);
                                }
                            }
                        }
                    }
                }
                return(App.timercheck);
            });
        }