public HttpResponseMessage KioskStatus(int param) { CheckInState currentCheckInState; var kioskType = KioskTypeCache.Get(param); var Session = HttpContext.Current.Session; if (Session["CheckInState"] != null) { currentCheckInState = Session["CheckInState"] as CheckInState; } else { return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new Dictionary <string, bool> { { "active", false } })); } if (kioskType == null || currentCheckInState == null || !kioskType.IsOpen() || currentCheckInState.Kiosk.FilteredGroupTypes(currentCheckInState.ConfiguredGroupTypes).Count == 0 || !currentCheckInState.Kiosk.HasLocations(currentCheckInState.ConfiguredGroupTypes)) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new Dictionary <string, bool> { { "active", false } })); } return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new Dictionary <string, bool> { { "active", true } })); }
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); } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); Session["BlockGuid"] = BlockCache.Guid; if (CurrentCheckInState == null) { LogException(new CheckInStateLost("Lost check-in state on init")); NavigateToPreviousPage(); return; } var kioskTypeCookie = this.Page.Request.Cookies["KioskTypeId"]; if (kioskTypeCookie != null) { KioskType = KioskTypeCache.Get(kioskTypeCookie.Value.AsInteger()); } if (KioskType == null) { NavigateToHomePage(); } RockPage.AddScriptLink("~/scripts/jquery.plugin.min.js"); RockPage.AddScriptLink("~/scripts/jquery.countdown.min.js"); RockPage.AddScriptLink("~/Scripts/CheckinClient/ZebraPrint.js"); RegisterScript(); }
protected void gKioskTypes_RowSelected(object sender, RowEventArgs e) { var id = e.RowKeyValue.ToString().AsInteger(); var item = KioskTypeCache.Get(id); KioskTypeCache.ClearForTemplateId(item.CheckinTemplateId ?? 0); }
private void UpdateKioskText() { if (ddlCampus.SelectedValue.IsNotNullOrWhiteSpace()) { var kioskTypeId = ddlCampus.SelectedValue.AsInteger(); var kioskType = KioskTypeCache.Get(kioskTypeId); lCampusLava.Text = kioskType.Message; DateTime?activeAt = null; bool isOpen = CheckinIsActive(kioskType, out activeAt); if (isOpen) { btnSelectCampus.Enabled = true; btnSelectCampus.OnClientClick = ""; btnSelectCampus.Text = "Begin Check-in"; } else if (activeAt.HasValue) { btnSelectCampus.Enabled = false; btnSelectCampus.OnClientClick = "javascript:return false;"; lblActiveWhen.Text = activeAt.Value.AddSeconds(30).ToString("o"); RegisterCountdownScript(); } else { btnSelectCampus.Enabled = false; btnSelectCampus.OnClientClick = "javascript:return false;"; btnSelectCampus.Text = "No More Check-ins Today"; } } }
protected void gKioskType_Delete(object sender, RowEventArgs e) { var checkinContext = new RockContext(); KioskTypeService KioskTypeService = new KioskTypeService(checkinContext); KioskType KioskType = KioskTypeService.Get(e.RowKeyId); if (KioskType != null) { int kosktypeId = KioskType.Id; string errorMessage; if (!KioskTypeService.CanDelete(KioskType, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } KioskTypeService.Delete(KioskType); checkinContext.SaveChanges(); KioskTypeCache.Clear(); KioskDeviceHelpers.Clear(); } BindGrid(); }
private void BindDropDown() { var kioskTypes = KioskTypeCache.All() .Where(kt => kt.IsMobile && kt.Campus != null) .OrderBy(kt => kt.Campus.Name) .Select(kt => new { Text = kt.Campus.Name, Value = kt.Id.ToString() }) .ToList(); ddlCampus.DataSource = kioskTypes; ddlCampus.DataBind(); }
protected void btnSelectCampus_Click(object sender, EventArgs e) { var kiosk = ConfigureKiosk(); var kioskType = KioskTypeCache.Get(kiosk.KioskTypeId ?? 0); PersonService.SaveUserPreference(currentPerson, UserPreferenceKeys.PreferredCampusId, kioskType.CampusId.ToString()); DateTime?activeAt = null; if (CheckinIsActive(kioskType, out activeAt)) { ActivateCheckIn(); } }
/// <summary> /// Executes the specified context. /// </summary> /// <param name="context">The context.</param> public void Execute(IJobExecutionContext context) { JobDataMap dataMap = context.JobDetail.JobDataMap; var rockContext = new RockContext(); var definedTypeService = new DefinedTypeService(rockContext); var definedValueService = new DefinedValueService(rockContext); var dtDeactivated = definedTypeService.Get(Constants.DEFINED_TYPE_DISABLED_GROUPLOCATIONSCHEDULES.AsGuid()); var dvDeactivated = dtDeactivated.DefinedValues.ToList(); var scheduleService = new ScheduleService(rockContext); var groupLocationService = new GroupLocationService(rockContext); var deactivatedGroupLocationSchedules = dvDeactivated.Select(dv => dv.Value.Split('|')) .Select(s => new { GroupLocation = groupLocationService.Get(s[0].AsInteger()), Schedule = scheduleService.Get(s[1].AsInteger()), }).ToList(); //add schedules back foreach (var groupLocationSchedule in deactivatedGroupLocationSchedules) { if (!groupLocationSchedule.GroupLocation.Schedules.Contains(groupLocationSchedule.Schedule)) { groupLocationSchedule.GroupLocation.Schedules.Add(groupLocationSchedule.Schedule); } } //Remove defined values foreach (var value in dvDeactivated) { definedValueService.Delete(value); Rock.Web.Cache.DefinedValueCache.Remove(value.Id); } //clear defined type cache Rock.Web.Cache.DefinedTypeCache.Remove(dtDeactivated.Id); rockContext.SaveChanges(); //clear caches KioskTypeCache.Clear(); Rock.CheckIn.KioskDevice.Clear(); OccurrenceCache.Clear(); AttendanceCache.Clear(); context.Result = string.Format("Finished at {0}. Reset {1} GroupScheduleLocations.", Rock.RockDateTime.Now, deactivatedGroupLocationSchedules.Count); }
protected override void OnInit(EventArgs e) { base.OnInit(e); RockPage.AddScriptLink("~/Scripts/CheckinClient/ZebraPrint.js"); var kioskTypeCookie = this.Page.Request.Cookies["KioskTypeId"]; if (kioskTypeCookie != null) { KioskType = KioskTypeCache.Get(kioskTypeCookie.Value.AsInteger()); } if (KioskType == null) { NavigateToPreviousPage(); } }
protected void btnKioskTypes_Click(object sender, EventArgs e) { btnOccurrences.CssClass = defaultCss; btnAttendances.CssClass = defaultCss; btnMobileRecords.CssClass = defaultCss; btnKioskTypes.CssClass = activeCss; pnlOccurrences.Visible = false; pnlAttendances.Visible = false; pnlMobileRecords.Visible = false; pnlKioskTypes.Visible = true; pnlVerify.Visible = false; var kioskTypes = KioskTypeCache.All().Select(k => new CacheContainer(k, k.Id)).ToList(); gKioskTypes.DataSource = kioskTypes; gKioskTypes.DataBind(); }
private void VerifyCache() { List <string> errors = new List <string>(); KioskTypeCache.Verify(ref errors); AttendanceCache.Verify(ref errors); MobileCheckinRecordCache.Verify(ref errors); if (errors.Any()) { ltVerify.Text = string.Join("<br>", errors); } else { ltVerify.Text = "<b>No Errors</b>"; } }
/// <summary> /// Sets up the kiosk for display. /// </summary> /// <param name="kioskName">Name of the kiosk.</param> private void ConfigureForUser(string kioskName) { lIntroduction.Text = GetAttributeValue(AttributeKeys.IntroductionText); var rockContext = new RockContext(); KioskTypeCache kioskType = null; //First try page parameter var campusParameter = PageParameter(PageParameterKeys.CampusId); if (campusParameter.IsNotNullOrWhiteSpace()) { kioskType = KioskTypeCache.All().Where(k => k.IsMobile && k.CampusId == campusParameter.AsIntegerOrNull()).FirstOrDefault(); } //Next try personal preference if (kioskType == null) { var campusId = PersonService.GetUserPreference(currentPerson, UserPreferenceKeys.PreferredCampusId).AsIntegerOrNull(); kioskType = KioskTypeCache.All().Where(k => k.IsMobile && k.CampusId == campusId).FirstOrDefault(); } //Finally set to primary campus Id if (kioskType == null) { var campusId = currentPerson.PrimaryCampusId; kioskType = KioskTypeCache.All().Where(k => k.IsMobile && k.CampusId == campusId).FirstOrDefault(); } if (kioskType != null) { ddlCampus.SetValue(kioskType.Id.ToString()); } //Default is first in list UpdateKioskText(); }
private void ActivateKiosk(Kiosk kiosk, bool logout) { RockContext rockContext = new RockContext(); DeviceService deviceService = new DeviceService(rockContext); KioskService kioskService = new KioskService(rockContext); //The kiosk can come in a variety of states. //Get a fresh version with our context to avoid context errors. kiosk = kioskService.Get(kiosk.Id); //Load matching device and update or create information var device = deviceService.Queryable().Where(d => d.Name == kiosk.Name).FirstOrDefault(); //create new device to match our kiosk if (device == null) { device = new Device(); device.DeviceTypeValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_CHECKIN_KIOSK).Id; device.Name = kiosk.Name; deviceService.Add(device); } device.LoadAttributes(); device.IPAddress = kiosk.IPAddress; device.Locations.Clear(); foreach (var loc in kiosk.KioskType.Locations.ToList()) { device.Locations.Add(loc); } device.PrintFrom = kiosk.PrintFrom; device.PrintToOverride = kiosk.PrintToOverride; device.PrinterDeviceId = kiosk.PrinterDeviceId; rockContext.SaveChanges(); if (PageParameter("DateTime").AsDateTime().HasValue) { device.SetAttributeValue("core_device_DebugDateTime", PageParameter("datetime")); } else { device.SetAttributeValue("core_device_DebugDateTime", ""); } device.SaveAttributeValues(rockContext); LocalDeviceConfig.CurrentKioskId = device.Id; LocalDeviceConfig.CurrentGroupTypeIds = kiosk.KioskType.GroupTypes.Select(gt => gt.Id).ToList(); LocalDeviceConfig.CurrentCheckinTypeId = kiosk.KioskType.CheckinTemplateId; CurrentCheckInState = null; CurrentWorkflow = null; var kioskTypeCookie = this.Page.Request.Cookies["KioskTypeId"]; if (kioskTypeCookie == null) { kioskTypeCookie = new System.Web.HttpCookie("KioskTypeId"); } kioskTypeCookie.Expires = RockDateTime.Now.AddYears(1); kioskTypeCookie.Value = kiosk.KioskType.Id.ToString(); this.Page.Response.Cookies.Set(kioskTypeCookie); Session["KioskTypeId"] = kiosk.KioskType.Id; Session["KioskMessage"] = kiosk.KioskType.Message; //Clean things up so we have the freshest possible version. KioskTypeCache.Remove(kiosk.KioskTypeId ?? 0); KioskDevice.Remove(device.Id); Dictionary <string, string> pageParameters = new Dictionary <string, string>(); if (kiosk.KioskType.Theme.IsNotNullOrWhiteSpace() && !GetAttributeValue("Manual").AsBoolean()) { LocalDeviceConfig.CurrentTheme = kiosk.KioskType.Theme; pageParameters.Add("theme", LocalDeviceConfig.CurrentTheme); } if (logout) { pageParameters.Add("logout", "true"); } SaveState(); NavigateToNextPage(pageParameters); }
/// <summary> /// Executes the specified workflow. /// </summary> /// <param name="rockContext">The rock context.</param> /// <param name="action">The workflow action.</param> /// <param name="entity">The entity.</param> /// <param name="errorMessages">The error messages.</param> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public override bool Execute(RockContext rockContext, Rock.Model.WorkflowAction action, Object entity, out List <string> errorMessages) { var isMobile = GetAttributeValue(action, "IsMobile").AsBoolean(); var mobileDidAttendId = DefinedValueCache.Get(Constants.DEFINED_VALUE_MOBILE_DID_ATTEND).Id; var mobileNotAttendId = DefinedValueCache.Get(Constants.DEFINED_VALUE_MOBILE_NOT_ATTEND).Id; var checkInState = GetCheckInState(entity, out errorMessages); if (checkInState != null) { KioskService kioskService = new KioskService(rockContext); var kioskTypeId = kioskService.GetByClientName(checkInState.Kiosk.Device.Name).KioskTypeId; var kioskType = KioskTypeCache.Get(kioskTypeId.Value); var campusId = kioskType.CampusId; if (campusId == null) { var compatableKioskType = KioskTypeCache.All().Where(kt => kt.CampusId.HasValue && kt.CheckinTemplateId == kioskType.CheckinTemplateId).FirstOrDefault(); if (compatableKioskType != null) { campusId = compatableKioskType.CampusId; } else { campusId = 0; } } campusId = GetCampusOrFamilyCampusId(campusId, checkInState.CheckIn.CurrentFamily.Group.CampusId); AttendanceCode attendanceCode = null; DateTime startDateTime = Rock.RockDateTime.Now; DateTime today = startDateTime.Date; DateTime tomorrow = startDateTime.AddDays(1); bool reuseCodeForFamily = checkInState.CheckInType != null && checkInState.CheckInType.ReuseSameCode; int securityCodeLength = checkInState.CheckInType != null ? checkInState.CheckInType.SecurityCodeAlphaNumericLength : 3; var attendanceCodeService = new AttendanceCodeService(rockContext); var attendanceService = new AttendanceService(rockContext); var groupMemberService = new GroupMemberService(rockContext); var personAliasService = new PersonAliasService(rockContext); //This list is just for mobile check-in List <Attendance> attendances = new List <Attendance>(); var family = checkInState.CheckIn.CurrentFamily; if (family != null) { foreach (var person in family.GetPeople(true)) { if (reuseCodeForFamily && attendanceCode != null) { person.SecurityCode = attendanceCode.Code; } else { attendanceCode = AttendanceCodeService.GetNew(securityCodeLength); person.SecurityCode = attendanceCode.Code; } foreach (var groupType in person.GetGroupTypes(true)) { foreach (var group in groupType.GetGroups(true)) { if (groupType.GroupType.AttendanceRule == AttendanceRule.AddOnCheckIn && groupType.GroupType.DefaultGroupRoleId.HasValue && !groupMemberService.GetByGroupIdAndPersonId(group.Group.Id, person.Person.Id, true).Any()) { var groupMember = new GroupMember(); groupMember.GroupId = group.Group.Id; groupMember.PersonId = person.Person.Id; groupMember.GroupRoleId = groupType.GroupType.DefaultGroupRoleId.Value; groupMemberService.Add(groupMember); } foreach (var location in group.GetLocations(true)) { foreach (var schedule in location.GetSchedules(true)) { var primaryAlias = personAliasService.GetPrimaryAlias(person.Person.Id); if (primaryAlias != null) { int groupId = ActualGroupId(group.Group); // If a like attendance service exists close it before creating another one. var oldAttendance = attendanceService.Queryable() .Where(a => a.StartDateTime >= today && a.StartDateTime < tomorrow && a.Occurrence.LocationId == location.Location.Id && a.Occurrence.ScheduleId == schedule.Schedule.Id && a.Occurrence.GroupId == groupId && a.PersonAlias.PersonId == person.Person.Id) .FirstOrDefault(); if (oldAttendance != null) { oldAttendance.EndDateTime = Rock.RockDateTime.Now; oldAttendance.DidAttend = false; } var attendance = attendanceService.AddOrUpdate(primaryAlias.Id, startDateTime.Date, groupId, location.Location.Id, schedule.Schedule.Id, campusId ?? location.CampusId, checkInState.Kiosk.Device.Id, checkInState.CheckIn.SearchType.Id, checkInState.CheckIn.SearchValue, family.Group.Id, attendanceCode.Id); attendance.DeviceId = checkInState.Kiosk.Device.Id; attendance.SearchTypeValueId = checkInState.CheckIn.SearchType.Id; attendance.SearchValue = checkInState.CheckIn.SearchValue; attendance.CheckedInByPersonAliasId = checkInState.CheckIn.CheckedInByPersonAliasId; attendance.SearchResultGroupId = family.Group.Id; attendance.AttendanceCodeId = attendanceCode.Id; attendance.CreatedDateTime = startDateTime; attendance.StartDateTime = startDateTime; attendance.EndDateTime = null; attendance.Note = group.Notes; attendance.DidAttend = isMobile ? false : groupType.GroupType.GetAttributeValue("SetDidAttend").AsBoolean(); if (isMobile) { if (groupType.GroupType.GetAttributeValue("SetDidAttend").AsBoolean()) { attendance.QualifierValueId = mobileDidAttendId; } else { attendance.QualifierValueId = mobileNotAttendId; } } ; attendanceService.Add(attendance); attendances.Add(attendance); } } } } } } } if (isMobile) { var alreadyExistingMobileCheckin = MobileCheckinRecordCache.GetActiveByFamilyGroupId(checkInState.CheckIn.CurrentFamily.Group.Id); if (alreadyExistingMobileCheckin != null) { //This should never run, it's just in case. Each family should only have 1 mobile check-in reservation. MobileCheckinRecordCache.CancelReservation(alreadyExistingMobileCheckin, true); } campusId = RollUpToParentCampus(campusId); MobileCheckinRecordService mobileCheckinRecordService = new MobileCheckinRecordService(rockContext); var mobileCheckinRecord = new MobileCheckinRecord { AccessKey = "MCR" + Guid.NewGuid().ToString("N").Substring(0, 12), ReservedUntilDateTime = Rock.RockDateTime.Now.AddMinutes(kioskType.MinutesValid ?? 10), ExpirationDateTime = Rock.RockDateTime.Now.AddMinutes((kioskType.MinutesValid ?? 10) + (kioskType.GraceMinutes ?? 60)), UserName = checkInState.CheckIn.SearchValue, FamilyGroupId = checkInState.CheckIn.CurrentFamily.Group.Id, CampusId = campusId.Value }; foreach (var attendance in attendances) { mobileCheckinRecord.Attendances.Add(attendance); } mobileCheckinRecordService.Add(mobileCheckinRecord); } rockContext.SaveChanges(); foreach (var attendance in attendances) { AttendanceCache.AddOrUpdate(attendance); } return(true); } errorMessages.Add($"Attempted to run {this.GetType().GetFriendlyTypeName()} in check-in, but the check-in state was null."); return(false); }
protected void btnSave_Click(object sender, EventArgs e) { KioskType kioskType = null; var rockContext = new RockContext(); var kioskTypeService = new KioskTypeService(rockContext); var attributeService = new AttributeService(rockContext); var locationService = new LocationService(rockContext); var scheduleService = new ScheduleService(rockContext); var groupTypeService = new GroupTypeService(rockContext); int kioskTypeId = int.Parse(hfKioskTypeId.Value); if (kioskTypeId != 0) { kioskType = kioskTypeService.Get(kioskTypeId); } if (kioskType == null) { kioskType = new KioskType(); kioskTypeService.Add(kioskType); } if (kioskType != null) { kioskType.Name = tbName.Text; kioskType.Description = tbDescription.Text; kioskType.Message = tbMessage.Text; kioskType.IsMobile = cbIsMobile.Checked; kioskType.MinutesValid = tbMinutesValid.Text.AsIntegerOrNull(); kioskType.GraceMinutes = tbGraceMinutes.Text.AsIntegerOrNull(); if (!kioskType.IsValid || !Page.IsValid) { // Controls will render the error messages return; } // Remove any deleted locations foreach (var location in kioskType.Locations .Where(l => !Locations.Keys.Contains(l.Id)) .ToList()) { kioskType.Locations.Remove(location); } // Remove any deleted schedules foreach (var schedule in kioskType.Schedules .Where(s => !Schedules.Keys.Contains(s.Id)) .ToList()) { kioskType.Schedules.Remove(schedule); } // Add any new locations var existingLocationIDs = kioskType.Locations.Select(l => l.Id).ToList(); foreach (var location in locationService.Queryable() .Where(l => Locations.Keys.Contains(l.Id) && !existingLocationIDs.Contains(l.Id))) { kioskType.Locations.Add(location); } // Add any new schedules var existingScheduleIDs = kioskType.Schedules.Select(s => s.Id).ToList(); foreach (var schedule in scheduleService.Queryable() .Where(s => Schedules.Keys.Contains(s.Id) && !existingScheduleIDs.Contains(s.Id))) { kioskType.Schedules.Add(schedule); } //Save checkin template kioskType.CheckinTemplateId = ddlTemplates.SelectedValue.AsInteger(); var GroupTypes = kioskType.GroupTypes; GroupTypes.Clear(); foreach (ListItem item in cblPrimaryGroupTypes.Items) { if (item.Selected) { GroupTypes.Add(groupTypeService.Get(item.Value.AsInteger())); } } kioskType.CampusId = ddlCampus.SelectedCampusId; rockContext.SaveChanges(); KioskTypeCache.Remove(kioskType.Id); KioskTypeCache.Get(kioskType.Id); Rock.CheckIn.KioskDevice.Clear(); NavigateToParentPage(); } }
protected void btnFlushKioskTypes_Click(object sender, EventArgs e) { KioskTypeCache.Clear(); KioskTypeCache.All(); }
private Kiosk ConfigureKiosk() { var rockContext = new RockContext(); var kioskTypeId = ddlCampus.SelectedValue.AsInteger(); var kioskType = KioskTypeCache.Get(kioskTypeId); var kioskName = "Mobile:" + kioskType.Name.RemoveAllNonAlphaNumericCharacters(); var mobileUserCategory = CategoryCache.Get(org.secc.FamilyCheckin.Utilities.Constants.KIOSK_CATEGORY_MOBILEUSER); var kioskService = new KioskService(rockContext); var kiosk = kioskService.Queryable("KioskType") .Where(k => k.Name == kioskName) .FirstOrDefault(); if (kiosk == null) { kiosk = new Kiosk { Name = kioskName, CategoryId = mobileUserCategory.Id, Description = "Automatically created mobile Kiosk" }; kioskService.Add(kiosk); } kiosk.KioskTypeId = kioskType.Id; rockContext.SaveChanges(); DeviceService deviceService = new DeviceService(rockContext); //Load matching device and update or create information var device = deviceService.Queryable("Location").Where(d => d.Name == kioskName).FirstOrDefault(); var dirty = false; //create new device to match our kiosk if (device == null) { device = new Device(); device.DeviceTypeValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_CHECKIN_KIOSK).Id; device.Name = kioskName; deviceService.Add(device); device.PrintFrom = PrintFrom.Client; device.PrintToOverride = PrintTo.Default; dirty = true; } var deviceLocationIds = device.Locations.Select(l => l.Id); var ktLocationIds = kioskType.Locations.Select(l => l.Id); var unmatchedDeviceLocations = deviceLocationIds.Except(ktLocationIds).Any(); var unmatchedKtLocations = ktLocationIds.Except(deviceLocationIds).Any(); if (unmatchedDeviceLocations || unmatchedKtLocations) { LocationService locationService = new LocationService(rockContext); device.Locations.Clear(); foreach (var loc in kioskType.Locations.ToList()) { var location = locationService.Get(loc.Id); device.Locations.Add(location); } dirty = true; } if (this.IsUserAuthorized(Rock.Security.Authorization.ADMINISTRATE)) { device.LoadAttributes(); if (PageParameter("datetime").IsNotNullOrWhiteSpace()) { device.SetAttributeValue("core_device_DebugDateTime", PageParameter("datetime")); } else { device.SetAttributeValue("core_device_DebugDateTime", ""); } } if (dirty) { rockContext.SaveChanges(); device.SaveAttributeValues(rockContext); KioskDevice.Remove(device.Id); } LocalDeviceConfig.CurrentKioskId = device.Id; LocalDeviceConfig.CurrentGroupTypeIds = kiosk.KioskType.GroupTypes.Select(gt => gt.Id).ToList(); LocalDeviceConfig.CurrentCheckinTypeId = kiosk.KioskType.CheckinTemplateId; CurrentCheckInState = null; CurrentWorkflow = null; var kioskTypeCookie = this.Page.Request.Cookies["KioskTypeId"]; if (kioskTypeCookie == null) { kioskTypeCookie = new System.Web.HttpCookie("KioskTypeId"); } kioskTypeCookie.Expires = RockDateTime.Now.AddYears(1); kioskTypeCookie.Value = kiosk.KioskType.Id.ToString(); this.Page.Response.Cookies.Set(kioskTypeCookie); Session["KioskTypeId"] = kioskType.Id; SaveState(); return(kiosk); }
/// <summary> /// Attempts to match a known kiosk based on the IP address of the client. /// </summary> private void GetKioskType(Kiosk kiosk, RockContext rockContext) { if (kiosk.KioskType != null) { DeviceService deviceService = new DeviceService(rockContext); //Load matching device and update or create information var device = deviceService.Queryable().Where(d => d.Name == kiosk.Name).FirstOrDefault(); //create new device to match our kiosk if (device == null) { device = new Device(); device.DeviceTypeValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_CHECKIN_KIOSK).Id; device.Name = kiosk.Name; deviceService.Add(device); } device.LoadAttributes(); device.IPAddress = kiosk.IPAddress; device.Locations.Clear(); foreach (var loc in kiosk.KioskType.Locations.ToList()) { device.Locations.Add(loc); } device.PrintFrom = kiosk.PrintFrom; device.PrintToOverride = kiosk.PrintToOverride; device.PrinterDeviceId = kiosk.PrinterDeviceId; rockContext.SaveChanges(); if (PageParameter("DateTime").AsDateTime().HasValue) { device.SetAttributeValue("core_device_DebugDateTime", PageParameter("datetime")); } else { device.SetAttributeValue("core_device_DebugDateTime", ""); } device.SaveAttributeValues(rockContext); LocalDeviceConfig.CurrentKioskId = device.Id; LocalDeviceConfig.CurrentGroupTypeIds = kiosk.KioskType.GroupTypes.Select(gt => gt.Id).ToList(); LocalDeviceConfig.CurrentCheckinTypeId = kiosk.KioskType.CheckinTemplateId; CurrentCheckInState = null; CurrentWorkflow = null; var kioskTypeCookie = this.Page.Request.Cookies["KioskTypeId"]; if (kioskTypeCookie == null) { kioskTypeCookie = new System.Web.HttpCookie("KioskTypeId"); } kioskTypeCookie.Expires = RockDateTime.Now.AddYears(1); kioskTypeCookie.Value = kiosk.KioskType.Id.ToString(); this.Page.Response.Cookies.Set(kioskTypeCookie); Session["KioskTypeId"] = kiosk.KioskType.Id; Session["KioskMessage"] = kiosk.KioskType.Message; //Clean things up so we have the freshest possible version. KioskTypeCache.Remove(kiosk.KioskTypeId ?? 0); KioskDevice.Remove(device.Id); SaveState(); NavigateToNextPage(); } else { ltDNS.Text = kiosk.Name; pnlMain.Visible = true; } }