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 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(); }
/// <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(); }
/// <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 btnFlushKioskTypes_Click(object sender, EventArgs e) { KioskTypeCache.Clear(); KioskTypeCache.All(); }