protected void gOccurrences_RowSelected(object sender, RowEventArgs e) { var accessKey = ( string )e.RowKeyValue; var occurrence = OccurrenceCache.Get(accessKey); ShowAttendances(occurrence.Attendances.Select(a => a.Id).ToList()); }
private void ShowCheckinCompletion() { pnlQr.Visible = false; pnlPostCheckin.Visible = true; ltPostCheckin.Text = GetAttributeValue(AttributeKeys.PostCheckinInstructions); //This is all an elaborate effort to get the family's checkin data in an organized fashion without touching the db //The thought is I can add more webservers I can't add more database servers right now. var personIds = CurrentPerson.PrimaryFamily.Members.Select(m => m.Person) .OrderBy(p => p.AgeClassification) .ThenBy(p => p.BirthDate) .Select(p => p.Id) .ToList(); var attendances = AttendanceCache.All() .Where(a => personIds.Contains(a.PersonId) && a.AttendanceState != AttendanceState.CheckedOut) .ToList(); var scheduleIds = attendances.Select(a => a.ScheduleId).Distinct().ToList(); var tokenOccurrences = OccurrenceCache.All() //Just need the schedule data so we can order stuff. .Where(o => scheduleIds.Contains(o.ScheduleId)) .DistinctBy(o => o.ScheduleId) .OrderBy(o => o.ScheduleStartTime) .ToList(); var attendanceData = new StringBuilder(); foreach (var tokenOccurrence in tokenOccurrences) { if (attendances.Where(a => a.ScheduleId == tokenOccurrence.ScheduleId).Any()) { attendanceData.Append("<b>" + tokenOccurrence.ScheduleName + "</b><ul>"); foreach (var personId in personIds) { var attendance = attendances.FirstOrDefault(a => a.PersonId == personId && a.ScheduleId == tokenOccurrence.ScheduleId); if (attendance == null) { continue; } OccurrenceCache occurrence = OccurrenceCache.Get(attendance.OccurrenceAccessKey); if (occurrence == null) { continue; } attendanceData.Append(string.Format("<li>{0}: {1} in {2}</li>", attendance.PersonName, occurrence.GroupName, occurrence.LocationName)); } attendanceData.Append("</ul>"); } } ltAttendance.Text = attendanceData.ToString(); }
/// <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, WorkflowAction action, object entity, out List <string> errorMessages) { var filterAttendanceSchedules = GetActionAttributeValue(action, "FilterAttendanceSchedules").AsBoolean(); var checkInState = GetCheckInState(entity, out errorMessages); if (checkInState != null) { var family = checkInState.CheckIn.Families.Where(f => f.Selected).FirstOrDefault(); if (family != null) { foreach (var person in family.People) { var inScheduleIds = AttendanceCache.All() .Where(a => a.PersonId == person.Person.Id && a.AttendanceState != AttendanceState.CheckedOut) .Select(a => a.ScheduleId) .ToList(); foreach (var groupType in person.GroupTypes) { foreach (var group in groupType.Groups) { foreach (var location in group.Locations) { foreach (var schedule in location.Schedules.ToList()) { if (filterAttendanceSchedules && inScheduleIds.Contains(schedule.Schedule.Id)) { location.Schedules.Remove(schedule); continue; } var occurrence = OccurrenceCache.Get(group.Group.Id, location.Location.Id, schedule.Schedule.Id); if (occurrence == null || occurrence.IsFull) { location.Schedules.Remove(schedule); continue; } } } } } } return(true); } else { errorMessages.Add("There is not a family that is selected"); } return(false); } errorMessages.Add($"Attempted to run {this.GetType().GetFriendlyTypeName()} in check-in, but the check-in state was null."); return(false); }