/// <summary>
        /// Refreshes the view.
        /// </summary>
        private void RefreshView()
        {
            hfRefreshTimerSeconds.Value = GetAttributeValue("RefreshInterval");
            pnlNotActive.Visible        = false;
            pnlNotActiveYet.Visible     = false;
            pnlClosed.Visible           = false;
            pnlActive.Visible           = false;
            ManagerLoggedIn             = false;
            lblActiveWhen.Text          = string.Empty;

            if (CurrentCheckInState == null)
            {
                LogException(new CheckInStateLost("Lost check-in state on refresh view"));
                NavigateToPreviousPage();
                return;
            }


            if (!KioskType.IsOpen())
            {
                DateTime?activeAt = KioskType.GetNextOpen();
                if (activeAt == null)
                {
                    pnlNotActive.Visible = true;
                    HideSign();
                }
                else
                {
                    lblActiveWhen.Text      = (activeAt ?? RockDateTime.Today.AddDays(1)).ToString("o");
                    pnlNotActiveYet.Visible = true;
                    HideSign();
                }
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Set Kiosk Active", "kioskActive=false;", true);
            }
            else if (CurrentCheckInState.Kiosk.FilteredGroupTypes(CurrentCheckInState.ConfiguredGroupTypes).Count == 0)
            {
                pnlNotActive.Visible = true;
                HideSign();
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Set Kiosk Active", "kioskActive=false;", true);
            }
            else if (!CurrentCheckInState.Kiosk.HasLocations(CurrentCheckInState.ConfiguredGroupTypes))
            {
                DateTime activeAt = CurrentCheckInState.Kiosk.FilteredGroupTypes(CurrentCheckInState.ConfiguredGroupTypes).Select(g => g.NextActiveTime).Min();
                lblActiveWhen.Text      = activeAt.ToString("o");
                pnlNotActiveYet.Visible = true;
                HideSign();
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Set Kiosk Active", "kioskActive=false;", true);
            }
            else
            {
                pnlActive.Visible = true;
                ShowWelcomeSign();
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Set Kiosk Active", "kioskActive=true;", true);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Refreshes the view.
        /// </summary>
        private void RefreshView()
        {
            hfRefreshTimerSeconds.Value = GetAttributeValue("RefreshInterval");
            pnlNotActive.Visible        = false;
            pnlNotActiveYet.Visible     = false;
            pnlClosed.Visible           = false;
            pnlActive.Visible           = false;
            ManagerLoggedIn             = false;
            lblActiveWhen.Text          = string.Empty;

            if (CurrentCheckInState == null)
            {
                LogException(new CheckInStateLost("Lost check-in state on refresh view"));
                NavigateToPreviousPage();
                return;
            }

            if (CurrentCheckInState.Kiosk.DebugDateTime.HasValue)
            {
                lTime.Visible = true;
                lTime.Text    = CurrentCheckInState.Kiosk.DebugDateTime.Value.ToString();
            }

            var currentDateTime = CurrentCheckInState.Kiosk.DebugDateTime.HasValue ? CurrentCheckInState.Kiosk.DebugDateTime.Value : RockDateTime.Now;

            if (!KioskType.IsOpen(currentDateTime))
            {
                DateTime?activeAt = KioskType.GetNextOpen(currentDateTime);
                if (activeAt == null)
                {
                    pnlNotActive.Visible = true;
                    HideSign();
                }
                else
                {
                    lblActiveWhen.Text      = (activeAt ?? currentDateTime.Date.AddDays(1)).ToString("o");
                    pnlNotActiveYet.Visible = true;
                    HideSign();
                }
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Set Kiosk Active", "kioskActive=false;", true);
            }
            else
            {
                var schedules = KioskType.GroupTypes
                                .SelectMany(gt => gt.Groups)
                                .SelectMany(g => g.GroupLocations)
                                .SelectMany(gl => gl.Schedules)
                                .DistinctBy(s => s.Id)
                                .ToList();

                if (schedules.Where(s => s.WasCheckInActive(currentDateTime)).Any())
                {
                    pnlActive.Visible = true;
                    ShowWelcomeSign();
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Set Kiosk Active", "kioskActive=true;", true);
                }
                else if (schedules.Where(s => s.GetNextCheckInStartTime(currentDateTime).HasValue).Any())
                {
                    DateTime activeAt = schedules
                                        .Select(s => s.GetNextCheckInStartTime(currentDateTime))
                                        .Where(a => a.HasValue
                                               ).Min(a => a.Value);
                    lblActiveWhen.Text      = activeAt.ToString("o");
                    pnlNotActiveYet.Visible = true;
                    HideSign();
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Set Kiosk Active", "kioskActive=false;", true);
                }
                else
                {
                    pnlNotActive.Visible = true;
                    HideSign();
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Set Kiosk Active", "kioskActive=false;", true);
                }
            }
        }