private bool CheckinIsActive(KioskTypeCache kioskType, out DateTime?activeAt) { activeAt = null; var currentDateTime = RockDateTime.Now; if (!kioskType.IsOpen(currentDateTime)) { activeAt = kioskType.GetNextOpen(currentDateTime); return(false); } else { var schedules = kioskType.CheckInSchedules; if (schedules.Where(s => s.WasCheckInActive(currentDateTime)).Any()) { return(true); } else if (schedules.Where(s => s.GetNextCheckInStartTime(currentDateTime).HasValue).Any()) { activeAt = schedules .Select(s => s.GetNextCheckInStartTime(currentDateTime)) .Where(a => a.HasValue ).Min(a => a.Value); return(false); } else { return(false); } } }
/// <summary> /// Refreshes the view. /// </summary> private void RefreshView() { if (KioskType == null) { LogException(new CheckInStateLost("Lost check-in state on refresh view")); NavigateToHomePage(); return; } 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.CheckInSchedules; 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); } } }