private void GetState() { if (Session["CheckInKioskId"] != null) { CurrentKioskId = (int)Session["CheckInKioskId"]; } if (Session["CheckInGroupTypeIds"] != null) { CurrentGroupTypeIds = Session["CheckInGroupTypeIds"] as List <int>; } if (Session["CheckInState"] != null) { CurrentCheckInState = Session["CheckInState"] as CheckInState; } if (Session["CheckInWorkflow"] != null) { CurrentWorkflow = Session["CheckInWorkflow"] as Rock.Model.Workflow; } if (CurrentCheckInState == null && CurrentKioskId.HasValue) { CurrentCheckInState = new CheckInState(CurrentKioskId.Value, CurrentGroupTypeIds); } }
/// <summary> /// Gets the checkin status. /// </summary> /// <param name="checkInState">State of the check in.</param> /// <returns></returns> public static CheckinStatus GetCheckinStatus(CheckInState checkInState) { KioskDevice kiosk = checkInState.Kiosk; List <int> configuredGroupTypeIds = checkInState.ConfiguredGroupTypes; bool hasGroupTypes = kiosk.FilteredGroupTypes(configuredGroupTypeIds).Any(); if (!hasGroupTypes) { return(CheckinStatus.Inactive); } if (IsTemporarilyClosed(kiosk, configuredGroupTypeIds, checkInState)) { return(CheckinStatus.TemporarilyClosed); } else if (IsClosed(kiosk, configuredGroupTypeIds, checkInState)) { return(CheckinStatus.Closed); } else { return(CheckinStatus.Active); } }
/// <summary> /// Cancels the check-in. /// </summary> protected void CancelCheckin() { CurrentWorkflow = null; CurrentCheckInState = null; SaveState(); NavigateToHomePage(); }
/// <summary> /// Gets the local device configuration status. /// </summary> /// <param name="localDeviceConfiguration">The local device configuration.</param> /// <param name="httpRequest">The HTTP request.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">LocalDeviceConfiguration with a valid KioskId and Checkin Type is required</exception> public static LocalDeviceConfigurationStatus GetLocalDeviceConfigurationStatus(LocalDeviceConfiguration localDeviceConfiguration, HttpRequest httpRequest) { if (localDeviceConfiguration?.CurrentKioskId == null || localDeviceConfiguration?.CurrentCheckinTypeId == null) { throw new ArgumentNullException("LocalDeviceConfiguration with a valid KioskId and Checkin Type is required"); } var kiosk = KioskDevice.Get(localDeviceConfiguration.CurrentKioskId.Value, localDeviceConfiguration.CurrentGroupTypeIds); DateTime nextActiveDateTime = kiosk.FilteredGroupTypes(localDeviceConfiguration.CurrentGroupTypeIds).Min(g => ( DateTime? )g.NextActiveTime) ?? DateTime.MaxValue; nextActiveDateTime = DateTime.SpecifyKind(nextActiveDateTime, DateTimeKind.Unspecified); bool isMobileAndExpired = CheckinConfigurationHelper.IsMobileAndExpiredDevice(httpRequest); CheckInState checkInState = new CheckInState(localDeviceConfiguration); CheckinConfigurationHelper.CheckinStatus checkinStatus = CheckinConfigurationHelper.GetCheckinStatus(checkInState); var rockVersion = Rock.VersionInfo.VersionInfo.GetRockProductVersionFullName(); CheckIn.CheckinType checkinType = new Rock.CheckIn.CheckinType(localDeviceConfiguration.CurrentCheckinTypeId.Value); var configurationData = new { CheckinType = checkinType, IsMobileAndExpired = isMobileAndExpired, Kiosk = kiosk, CheckinStatus = checkinStatus, NextActiveDateTime = nextActiveDateTime, RockVersion = rockVersion }; var configurationString = configurationData.ToJson(); DateTime campusCurrentDateTime = RockDateTime.Now; if (kiosk.CampusId.HasValue) { campusCurrentDateTime = CampusCache.Get(kiosk.CampusId.Value)?.CurrentDateTime ?? RockDateTime.Now; } LocalDeviceConfigurationStatus localDeviceConfigurationStatus = new LocalDeviceConfigurationStatus(); localDeviceConfigurationStatus.ConfigurationHash = Rock.Security.Encryption.GetSHA1Hash(configurationString); localDeviceConfigurationStatus.ServerCurrentDateTime = RockDateTime.Now; localDeviceConfigurationStatus.CampusCurrentDateTime = campusCurrentDateTime; localDeviceConfigurationStatus.NextActiveDateTime = nextActiveDateTime; return(localDeviceConfigurationStatus); }
/// <summary> /// Gets the state. /// </summary> private void GetState() { if ( Session["CurrentTheme"] != null ) { CurrentTheme = Session["CurrentTheme"].ToString(); } if ( Session["CheckInKioskId"] != null ) { CurrentKioskId = (int)Session["CheckInKioskId"]; } if ( Session["CheckinTypeId"] != null ) { CurrentCheckinTypeId = (int)Session["CheckinTypeId"]; } if ( Session["CheckInGroupTypeIds"] != null ) { CurrentGroupTypeIds = Session["CheckInGroupTypeIds"] as List<int>; } if ( Session["CheckInState"] != null ) { CurrentCheckInState = Session["CheckInState"] as CheckInState; } if ( Session["CheckInWorkflow"] != null ) { CurrentWorkflow = Session["CheckInWorkflow"] as Rock.Model.Workflow; } if ( CurrentCheckInState == null && CurrentKioskId.HasValue ) { CurrentCheckInState = new CheckInState( CurrentKioskId.Value, CurrentCheckinTypeId, CurrentGroupTypeIds ); } }
public static CheckinStatus GetCheckinStatus(KioskDevice kiosk, List <int> configuredGroupTypeIds, CheckinType checkInType) { var checkinState = new CheckInState(kiosk.Device?.Id ?? 0, checkInType.Id, configuredGroupTypeIds); return(GetCheckinStatus(checkinState)); }
/// <summary> /// Determines whether the specified kiosk is closed. /// </summary> /// <param name="kiosk">The kiosk.</param> /// <param name="configuredGroupTypeIds">The configured group type ids.</param> /// <param name="checkInState">State of the check in.</param> /// <returns> /// <c>true</c> if the specified kiosk is closed; otherwise, <c>false</c>. /// </returns> private static bool IsClosed(KioskDevice kiosk, List <int> configuredGroupTypeIds, CheckInState checkInState) { // Closed if there are no active locations and check-out is not allowed, or if check -out is allowed but there // are no active check-out locations. bool isClosed = (!kiosk.HasActiveLocations(configuredGroupTypeIds) && !checkInState.AllowCheckout) || (checkInState.AllowCheckout && !kiosk.HasActiveCheckOutLocations(configuredGroupTypeIds)); return(isClosed); }
/// <summary> /// Determines whether [is temporarily closed] [the specified kiosk]. /// </summary> /// <param name="kiosk">The kiosk.</param> /// <param name="configuredGroupTypeIds">The configured group type ids.</param> /// <param name="checkInState">State of the check in.</param> /// <returns> /// <c>true</c> if [is temporarily closed] [the specified kiosk]; otherwise, <c>false</c>. /// </returns> private static bool IsTemporarilyClosed(KioskDevice kiosk, List <int> configuredGroupTypeIds, CheckInState checkInState) { bool isTemporarilyClosed = (!kiosk.HasLocations(configuredGroupTypeIds) && !checkInState.AllowCheckout) || (checkInState.AllowCheckout && !kiosk.HasActiveCheckOutLocations(configuredGroupTypeIds)); return(isTemporarilyClosed); }