/// <summary> /// Initializes a new instance of the <see cref="CheckInState"/> class. /// </summary> /// <param name="localDeviceConfiguration">The local device configuration.</param> public CheckInState(LocalDeviceConfiguration localDeviceConfiguration) { DeviceId = localDeviceConfiguration.CurrentKioskId ?? 0; CheckinTypeId = localDeviceConfiguration.CurrentCheckinTypeId; AllowCheckout = localDeviceConfiguration.AllowCheckout ?? this.CheckInType?.AllowCheckoutDefault ?? false; ConfiguredGroupTypes = (localDeviceConfiguration.CurrentGroupTypeIds == null) ? new List <int>() : localDeviceConfiguration.CurrentGroupTypeIds.ToList(); CheckIn = new CheckInStatus(); Messages = new List <CheckInMessage>(); }
/// <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); CheckIn.CheckinType checkinType = new Rock.CheckIn.CheckinType(localDeviceConfiguration.CurrentCheckinTypeId.Value); var configurationData = new { CheckinType = checkinType, IsMobileAndExpired = isMobileAndExpired, 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 = configurationString.XxHash(); localDeviceConfigurationStatus.ServerCurrentDateTime = RockDateTime.Now; localDeviceConfigurationStatus.CampusCurrentDateTime = campusCurrentDateTime; localDeviceConfigurationStatus.NextActiveDateTime = nextActiveDateTime; return(localDeviceConfigurationStatus); }