/// <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 device from the GeoLocation callback result; /// </summary> /// <param name="callbackResult">The callback result.</param> private void ProcessGeolocationCallback(string callbackResult) { hfGetGeoLocation.Value = false.ToJavaScriptValue(); var latitude = hfLatitude.Value.AsDoubleOrNull(); var longitude = hfLongitude.Value.AsDoubleOrNull(); Device device; if (callbackResult == "Success" && latitude.HasValue && longitude.HasValue) { bbtnGetGeoLocation.Visible = false; HttpCookie rockHasLocationApprovalCookie = new HttpCookie(CheckInCookieKey.RockHasLocationApproval, "true"); rockHasLocationApprovalCookie.Expires = RockDateTime.Now.AddYears(1); Response.Cookies.Set(rockHasLocationApprovalCookie); device = GetFirstMatchingKioskByGeoFencing(latitude.Value, longitude.Value); } else { lMessage.Text = GetMessageText(AttributeKey.UnableToDetermineMobileLocationTemplate); return; } if (device == null) { lMessage.Text = GetMessageText(AttributeKey.NoDevicesFoundTemplate); return; } // device found for mobile person's location LocalDeviceConfig.CurrentKioskId = device.Id; LocalDeviceConfig.AllowCheckout = false; LocalDeviceConfig.SaveToCookie(this.Page); // create new checkin state since we are starting a new checkin sessions this.CurrentCheckInState = new CheckInState(this.LocalDeviceConfig); SaveState(); CheckinConfigurationHelper.CheckinStatus checkinStatus = CheckinConfigurationHelper.CheckinStatus.Closed; if (CurrentCheckInState.Kiosk != null) { checkinStatus = CheckinConfigurationHelper.GetCheckinStatus(CurrentCheckInState); } RefreshCheckinStatusInformation(checkinStatus); }