/// <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, Model.WorkflowAction action, Object entity, out List <string> errorMessages) { var checkInState = GetCheckInState(entity, out errorMessages); if (checkInState != null) { var family = checkInState.CheckIn.CurrentFamily; if (family != null) { var commonMergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(null); var groupMemberService = new GroupMemberService(rockContext); var familyLabels = new List <Guid>(); var people = family.GetPeople(true); foreach (var person in people) { var personGroupTypes = person.GetGroupTypes(true); var groupTypes = new List <CheckInGroupType>(); // Get Primary area group types first personGroupTypes.Where(t => checkInState.ConfiguredGroupTypes.Contains(t.GroupType.Id)).ToList().ForEach(t => groupTypes.Add(t)); // Then get additional areas personGroupTypes.Where(t => !checkInState.ConfiguredGroupTypes.Contains(t.GroupType.Id)).ToList().ForEach(t => groupTypes.Add(t)); var personLabels = new List <Guid>(); foreach (var groupType in groupTypes) { groupType.Labels = new List <CheckInLabel>(); var groupTypeLabels = GetGroupTypeLabels(groupType.GroupType); var PrinterIPs = new Dictionary <int, string>(); foreach (var labelCache in groupTypeLabels.OrderBy(l => l.LabelType).ThenBy(l => l.Order)) { person.SetOptions(labelCache); foreach (var group in groupType.GetGroups(true)) { foreach (var location in group.GetLocations(true)) { if (labelCache.LabelType == KioskLabelType.Family) { if (familyLabels.Contains(labelCache.Guid) || personLabels.Contains(labelCache.Guid)) { break; } else { familyLabels.Add(labelCache.Guid); } } else if (labelCache.LabelType == KioskLabelType.Person) { if (personLabels.Contains(labelCache.Guid)) { break; } else { personLabels.Add(labelCache.Guid); } } var mergeObjects = new Dictionary <string, object>(); foreach (var keyValue in commonMergeFields) { mergeObjects.Add(keyValue.Key, keyValue.Value); } mergeObjects.Add("Location", location); mergeObjects.Add("Group", group); mergeObjects.Add("Person", person); mergeObjects.Add("People", people); mergeObjects.Add("GroupType", groupType); var groupMembers = groupMemberService.Queryable().AsNoTracking() .Where(m => m.PersonId == person.Person.Id && m.GroupId == group.Group.Id) .ToList(); mergeObjects.Add("GroupMembers", groupMembers); //string debugInfo = mergeObjects.lavaDebugInfo(); var label = new CheckInLabel(labelCache, mergeObjects, person.Person.Id); label.FileGuid = labelCache.Guid; label.PrintFrom = checkInState.Kiosk.Device.PrintFrom; label.PrintTo = checkInState.Kiosk.Device.PrintToOverride; if (label.PrintTo == PrintTo.Default) { label.PrintTo = groupType.GroupType.AttendancePrintTo; } if (label.PrintTo == PrintTo.Kiosk) { var device = checkInState.Kiosk.Device; if (device != null) { label.PrinterDeviceId = device.PrinterDeviceId; } } else if (label.PrintTo == PrintTo.Location) { var deviceId = location.Location.PrinterDeviceId; if (deviceId != null) { label.PrinterDeviceId = deviceId; } } if (label.PrinterDeviceId.HasValue) { if (PrinterIPs.ContainsKey(label.PrinterDeviceId.Value)) { label.PrinterAddress = PrinterIPs[label.PrinterDeviceId.Value]; } else { var printerDevice = new DeviceService(rockContext).Get(label.PrinterDeviceId.Value); if (printerDevice != null) { PrinterIPs.Add(printerDevice.Id, printerDevice.IPAddress); label.PrinterAddress = printerDevice.IPAddress; } } } groupType.Labels.Add(label); } } } } } } return(true); } return(false); }
/// <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 checkInState = GetCheckInState(entity, out errorMessages); var matrixAttributeMedicationKey = GetAttributeValue(action, "MatrixAttributeMedicationKey"); var matrixAttributeInstructionsKey = GetAttributeValue(action, "MatrixAttributeInstructionsKey"); var matrixAttributeScheduleKey = GetAttributeValue(action, "MatrixAttributeScheduleKey"); AttributeMatrixService attributeMatrixService = new AttributeMatrixService(rockContext); GroupMemberService groupMemberService = new GroupMemberService(rockContext); if (checkInState != null) { var family = checkInState.CheckIn.CurrentFamily; if (family != null) { var commonMergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(null); var people = family.GetPeople(true); foreach (var person in people.Where(p => p.Selected)) { foreach (var groupType in person.GroupTypes) { groupType.Labels = new List <CheckInLabel>(); foreach (var group in groupType.Groups) { List <string> medicationText = (( string )GetAttributeValue(action, "MedicationText")).Split(',').ToList(); List <string> instructionsText = (( string )GetAttributeValue(action, "InstructionsText")).Split(',').ToList(); List <MedInfo> medInfos = new List <MedInfo>(); if (medicationText.Count == instructionsText.Count) { for (int i = 0; i < medicationText.Count; i++) { medInfos.Add(new MedInfo { Medication = medicationText[i], Instructions = instructionsText[i] }); } } group.Group.LoadAttributes(); var groupGuid = group.Group.GetAttributeValue(GetAttributeValue(action, "GroupAttributeKey")); var registrationGroup = new GroupService(rockContext).Get(groupGuid.AsGuid()); if (registrationGroup == null) { continue; } var groupMember = groupMemberService.GetByGroupIdAndPersonId(registrationGroup.Id, person.Person.Id).FirstOrDefault(); var medicationKey = GetAttributeValue(action, "MatrixAttributeKey"); var medicationMatrix = person.Person.GetAttributeValue(medicationKey); var attributeMatrix = attributeMatrixService.Get(medicationMatrix.AsGuid()); var labelCache = KioskLabel.Get(new Guid(GetAttributeValue(action, "MedicationLabel"))); //Set up merge fields so we can use the lava from the merge fields var mergeObjects = new Dictionary <string, object>(); foreach (var keyValue in commonMergeFields) { mergeObjects.Add(keyValue.Key, keyValue.Value); } mergeObjects.Add("RegistrationGroup", registrationGroup); mergeObjects.Add("RegistrationGroupMember", groupMember); mergeObjects.Add("Group", group); mergeObjects.Add("Person", person); mergeObjects.Add("People", people); mergeObjects.Add("GroupType", groupType); if (attributeMatrix == null || attributeMatrix.AttributeMatrixItems.Count == 0) { // Add a No Medication Information label for anyone without data var checkInLabel = new CheckInLabel(labelCache, mergeObjects); var index = 0; foreach (string mergeFieldText in medicationText) { checkInLabel.MergeFields.Add(mergeFieldText, index == 0?"No Medication Information Found":""); checkInLabel.MergeFields.Add(instructionsText[index], ""); index++; } addLabel(checkInLabel, checkInState, groupType, group, rockContext); } else { var items = attributeMatrix.AttributeMatrixItems.ToList(); var index = 0; while (index < items.Count) { var checkInLabel = new CheckInLabel(labelCache, mergeObjects); foreach (var med in medInfos) { if (items.Count > index) { items[index].LoadAttributes(); string scheduleText = ""; string separator = ""; var schedule = items[index].GetAttributeValue(matrixAttributeScheduleKey).SplitDelimitedValues(); foreach (var scheduleGuid in schedule) { scheduleText += separator + DefinedValueCache.Get(scheduleGuid); separator = ", "; } checkInLabel.MergeFields.Add(med.Medication, items[index].GetAttributeValue(matrixAttributeMedicationKey) + " - " + scheduleText ); checkInLabel.MergeFields.Add(med.Instructions, items[index].GetAttributeValue(matrixAttributeInstructionsKey)); } else { checkInLabel.MergeFields.Add(med.Medication, ""); checkInLabel.MergeFields.Add(med.Instructions, ""); } index++; } addLabel(checkInLabel, checkInState, groupType, group, rockContext); } } } } } } return(true); } return(false); }
/// <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 checkInState = GetCheckInState(entity, out errorMessages); if (checkInState != null) { var family = checkInState.CheckIn.CurrentFamily; if (family != null) { var commonMergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(null); var groupMemberService = new GroupMemberService(rockContext); var familyLabels = new List <Guid>(); var people = family.GetPeople(true); foreach (var person in people) { var personGroupTypes = person.GetGroupTypes(true); var groupTypes = new List <CheckInGroupType>(); // Get Primary area group types first personGroupTypes.Where(t => checkInState.ConfiguredGroupTypes.Contains(t.GroupType.Id)).ToList().ForEach(t => groupTypes.Add(t)); // Then get additional areas personGroupTypes.Where(t => !checkInState.ConfiguredGroupTypes.Contains(t.GroupType.Id)).ToList().ForEach(t => groupTypes.Add(t)); var personLabels = new List <Guid>(); foreach (var groupType in groupTypes) { groupType.Labels = new List <CheckInLabel>(); var groupTypeLabels = GetGroupTypeLabels(groupType.GroupType); var PrinterIPs = new Dictionary <int, string>(); foreach (var labelCache in groupTypeLabels) { foreach (var group in groupType.GetGroups(true)) { foreach (var location in group.GetLocations(true)) { if (labelCache.LabelType == KioskLabelType.Family) { if (familyLabels.Contains(labelCache.Guid) || personLabels.Contains(labelCache.Guid)) { break; } else { familyLabels.Add(labelCache.Guid); } } else if (labelCache.LabelType == KioskLabelType.Person) { if (personLabels.Contains(labelCache.Guid)) { break; } else { personLabels.Add(labelCache.Guid); } } var mergeObjects = new Dictionary <string, object>(); foreach (var keyValue in commonMergeFields) { mergeObjects.Add(keyValue.Key, keyValue.Value); } group.Group.LoadAttributes(); var groupGuid = group.Group.GetAttributeValue(GetAttributeValue(action, "GroupAttributeKey")); if (!string.IsNullOrWhiteSpace(groupGuid)) { var registrationGroup = new GroupService(rockContext).Get(groupGuid.AsGuid()); if (registrationGroup != null) { mergeObjects.Add("RegistrationGroup", registrationGroup); var registrationGroupMember = registrationGroup.Members.Where(gm => gm.PersonId == person.Person.Id).FirstOrDefault(); if (registrationGroupMember != null) { mergeObjects.Add("RegistrationGroupMember", registrationGroupMember); } } } mergeObjects.Add("Location", location); mergeObjects.Add("Group", group); mergeObjects.Add("Person", person); mergeObjects.Add("People", people); mergeObjects.Add("GroupType", groupType); var groupMembers = groupMemberService.Queryable().AsNoTracking() .Where(m => m.PersonId == person.Person.Id && m.GroupId == group.Group.Id) .ToList(); mergeObjects.Add("GroupMembers", groupMembers); var label = new CheckInLabel(labelCache, mergeObjects); label.FileGuid = labelCache.Guid; label.PrintFrom = checkInState.Kiosk.Device.PrintFrom; label.PrintTo = checkInState.Kiosk.Device.PrintToOverride; if (label.PrintTo == PrintTo.Default) { label.PrintTo = groupType.GroupType.AttendancePrintTo; } if (label.PrintTo == PrintTo.Kiosk) { var device = checkInState.Kiosk.Device; if (device != null) { label.PrinterDeviceId = device.PrinterDeviceId; } } else if (label.PrintTo == PrintTo.Location) { var deviceId = location.Location.PrinterDeviceId; if (deviceId != null) { label.PrinterDeviceId = deviceId; } } if (label.PrinterDeviceId.HasValue) { if (PrinterIPs.ContainsKey(label.PrinterDeviceId.Value)) { label.PrinterAddress = PrinterIPs[label.PrinterDeviceId.Value]; } else { var printerDevice = new DeviceService(rockContext).Get(label.PrinterDeviceId.Value); if (printerDevice != null) { PrinterIPs.Add(printerDevice.Id, printerDevice.IPAddress); label.PrinterAddress = printerDevice.IPAddress; } } } groupType.Labels.Add(label); } } } } } } return(true); } errorMessages.Add($"Attempted to run {this.GetType().GetFriendlyTypeName()} in check-in, but the check-in state was null."); return(false); }
/// <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 checkInState = GetCheckInState(entity, out errorMessages); CheckInGroupType lastCheckinGroupType = null; List <string> labelCodes = new List <string>(); List <int> childGroupIds; List <CheckInLabel> checkInLabels = new List <CheckInLabel>(); var volAttributeGuid = GetAttributeValue(action, "VolunteerGroupAttribute"); string volAttributeKey = ""; if (!string.IsNullOrWhiteSpace(volAttributeGuid)) { volAttributeKey = AttributeCache.Get(volAttributeGuid.AsGuid()).Key; childGroupIds = checkInState.Kiosk.KioskGroupTypes .SelectMany(g => g.KioskGroups) .Where(g => !g.Group.GetAttributeValue(volAttributeKey).AsBoolean()) .Select(g => g.Group.Id).ToList(); } else { childGroupIds = new List <int>(); } if (checkInState != null) { var attendanceService = new AttendanceService(rockContext); var globalAttributes = Rock.Web.Cache.GlobalAttributesCache.Get(); var globalMergeValues = Rock.Lava.LavaHelper.GetCommonMergeFields(null); var groupMemberService = new GroupMemberService(rockContext); foreach (var family in checkInState.CheckIn.Families.Where(f => f.Selected)) { foreach (var person in family.People.Where(p => p.Selected)) { if (person.GroupTypes.Where(gt => gt.Selected).SelectMany(gt => gt.Groups).Where(g => g.Selected && childGroupIds.Contains(g.Group.Id)).Any()) { labelCodes.Add((person.SecurityCode) + "-" + LabelAge(person.Person)); } if (string.IsNullOrEmpty(person.SecurityCode)) { var lastAttendance = attendanceService.Queryable() .Where(a => a.PersonAlias.PersonId == person.Person.Id && a.AttendanceCode != null) .OrderByDescending(a => a.StartDateTime) .FirstOrDefault(); if (lastAttendance != null) { person.SecurityCode = lastAttendance.AttendanceCode.Code; } } var firstCheckinGroupType = person.GroupTypes.Where(g => g.Selected).FirstOrDefault(); if (firstCheckinGroupType != null) { List <Guid> labelGuids = new List <Guid>(); var mergeObjects = new Dictionary <string, object>(); foreach (var keyValue in globalMergeValues) { mergeObjects.Add(keyValue.Key, keyValue.Value); } mergeObjects.Add("Person", person); mergeObjects.Add("GroupTypes", person.GroupTypes.Where(g => g.Selected).ToList()); List <Group> mergeGroups = new List <Group>(); List <Location> mergeLocations = new List <Location>(); List <Schedule> mergeSchedules = new List <Schedule>(); var sets = attendanceService .Queryable().AsNoTracking().Where(a => a.PersonAlias.Person.Id == person.Person.Id && a.StartDateTime >= Rock.RockDateTime.Today && a.EndDateTime == null && a.Occurrence.Group != null && a.Occurrence.Schedule != null && a.Occurrence.Location != null ) .Select(a => new { Group = a.Occurrence.Group, Location = a.Occurrence.Location, Schedule = a.Occurrence.Schedule, AttendanceGuid = a.Guid } ) .ToList() .OrderBy(a => a.Schedule.StartTimeOfDay); //Load breakout group var breakoutGroups = GetBreakoutGroups(person.Person, rockContext, action); //Add in an empty object as a placeholder for our breakout group mergeObjects.Add("BreakoutGroup", ""); //Add in GUID for QR code if (sets.Any()) { mergeObjects.Add("AttendanceGuid", sets.FirstOrDefault().AttendanceGuid.ToString()); } foreach (var set in sets) { mergeGroups.Add(set.Group); mergeLocations.Add(set.Location); mergeSchedules.Add(set.Schedule); //Add the breakout group mergefield if (breakoutGroups.Any()) { var breakoutGroup = breakoutGroups.Where(g => g.ScheduleId == set.Schedule.Id).FirstOrDefault(); if (breakoutGroup != null) { var breakoutGroupEntity = new GroupService(rockContext).Get(breakoutGroup.Id); if (breakoutGroupEntity != null) { breakoutGroupEntity.LoadAttributes(); var letter = breakoutGroupEntity.GetAttributeValue("Letter"); if (!string.IsNullOrWhiteSpace(letter)) { mergeObjects["BreakoutGroup"] = letter; } } } } } mergeObjects.Add("Groups", mergeGroups); mergeObjects.Add("Locations", mergeLocations); mergeObjects.Add("Schedules", mergeSchedules); foreach (var groupType in person.GroupTypes.Where(g => g.Selected)) { lastCheckinGroupType = groupType; groupType.Labels = new List <CheckInLabel>(); GetGroupTypeLabels(groupType.GroupType, firstCheckinGroupType.Labels, mergeObjects, labelGuids); var PrinterIPs = new Dictionary <int, string>(); foreach (var label in groupType.Labels) { label.PrintFrom = checkInState.Kiosk.Device.PrintFrom; label.PrintTo = checkInState.Kiosk.Device.PrintToOverride; if (label.PrintTo == PrintTo.Default) { label.PrintTo = groupType.GroupType.AttendancePrintTo; } if (label.PrintTo == PrintTo.Kiosk) { var device = checkInState.Kiosk.Device; if (device != null) { label.PrinterDeviceId = device.PrinterDeviceId; } } else if (label.PrintTo == PrintTo.Location) { // Should only be one var group = groupType.Groups.Where(g => g.Selected).FirstOrDefault(); if (group != null) { var location = group.Locations.Where(l => l.Selected).FirstOrDefault(); if (location != null) { var device = location.Location.PrinterDevice; if (device != null) { label.PrinterDeviceId = device.PrinterDeviceId; } } } } if (label.PrinterDeviceId.HasValue) { if (PrinterIPs.ContainsKey(label.PrinterDeviceId.Value)) { label.PrinterAddress = PrinterIPs[label.PrinterDeviceId.Value]; } else { var printerDevice = new DeviceService(rockContext).Get(label.PrinterDeviceId.Value); if (printerDevice != null) { PrinterIPs.Add(printerDevice.Id, printerDevice.IPAddress); label.PrinterAddress = printerDevice.IPAddress; } } } checkInLabels.Add(label); } } } } //Add in custom labels for parents //This is the aggregate part List <CheckInLabel> customLabels = new List <CheckInLabel>(); List <string> mergeCodes = (( string )GetAttributeValue(action, "MergeText")).Split(',').ToList(); while (labelCodes.Count > 0) { var mergeDict = new Dictionary <string, string>(); foreach (var mergeCode in mergeCodes) { if (labelCodes.Count > 0) { mergeDict.Add(mergeCode, labelCodes[0]); labelCodes.RemoveAt(0); } else { mergeDict.Add(mergeCode, ""); } } mergeDict.Add("Date", Rock.RockDateTime.Today.DayOfWeek.ToString().Substring(0, 3) + " " + Rock.RockDateTime.Today.ToMonthDayString()); var labelCache = KioskLabel.Get(new Guid(GetAttributeValue(action, "AggregatedLabel"))); if (labelCache != null) { var checkInLabel = new CheckInLabel(labelCache, new Dictionary <string, object>()); checkInLabel.FileGuid = new Guid(GetAttributeValue(action, "AggregatedLabel")); foreach (var keyValue in mergeDict) { if (checkInLabel.MergeFields.ContainsKey(keyValue.Key)) { checkInLabel.MergeFields[keyValue.Key] = keyValue.Value; } else { checkInLabel.MergeFields.Add(keyValue.Key, keyValue.Value); } } checkInLabel.PrintFrom = checkInState.Kiosk.Device.PrintFrom; checkInLabel.PrintTo = checkInState.Kiosk.Device.PrintToOverride; if (checkInLabel.PrintTo == PrintTo.Default) { checkInLabel.PrintTo = lastCheckinGroupType.GroupType.AttendancePrintTo; } if (checkInLabel.PrintTo == PrintTo.Kiosk) { var device = checkInState.Kiosk.Device; if (device != null) { checkInLabel.PrinterDeviceId = device.PrinterDeviceId; } } else if (checkInLabel.PrintTo == PrintTo.Location) { // Should only be one var group = lastCheckinGroupType.Groups.Where(g => g.Selected).FirstOrDefault(); if (group != null) { var location = group.Locations.Where(l => l.Selected).FirstOrDefault(); if (location != null) { var device = location.Location.PrinterDevice; if (device != null) { checkInLabel.PrinterDeviceId = device.PrinterDeviceId; } } } } if (checkInLabel.PrinterDeviceId.HasValue) { var printerDevice = new DeviceService(rockContext).Get(checkInLabel.PrinterDeviceId.Value); checkInLabel.PrinterAddress = printerDevice.IPAddress; } if (lastCheckinGroupType != null) { lastCheckinGroupType.Labels.Add(checkInLabel); checkInLabels.Add(checkInLabel); } } } } //For mobile check-in we need to serialize this data and save it in the database. //This will mean that when it's time to finish checkin in //All we will need to do is deserialize and pass the data to the printer if (GetAttributeValue(action, "IsMobile").AsBoolean()) { MobileCheckinRecordService mobileCheckinRecordService = new MobileCheckinRecordService(rockContext); MobileCheckinRecord mobileCheckinRecord = mobileCheckinRecordService.Queryable() .Where(r => r.Status == MobileCheckinStatus.Active) .Where(r => r.CreatedDateTime > Rock.RockDateTime.Today) .Where(r => r.UserName == checkInState.CheckIn.SearchValue) .FirstOrDefault(); if (mobileCheckinRecord == null) { ExceptionLogService.LogException("Mobile Check-in failed to find mobile checkin record"); } mobileCheckinRecord.SerializedCheckInState = JsonConvert.SerializeObject(checkInLabels); rockContext.SaveChanges(); //Freshen cache (we're going to need it soon) MobileCheckinRecordCache.Update(mobileCheckinRecord.Id); } return(true); } errorMessages.Add($"Attempted to run {this.GetType().GetFriendlyTypeName()} in check-in, but the check-in state was null."); return(false); }
private static List <CheckInLabel> GenerateAggregateLabel(Guid aggregateLabelGuid, Device kioskDevice, List <Person> people) { List <CheckInLabel> labels = new List <CheckInLabel>(); List <string> labelCodes = new List <string>(); foreach (var person in people) { var applicableAttendances = AttendanceCache.All().Where(a => a.PersonId == person.Id); //only if they are checked in to somewhere that is marked as children if (applicableAttendances.Any(a => a.IsChildren)) { var newestAttendance = applicableAttendances.OrderByDescending(a => a.CreatedDateTime).FirstOrDefault(); labelCodes.Add($"{newestAttendance.Code}-{person.FormatAge()}"); } } var labelCache = KioskLabel.Get(aggregateLabelGuid); List <string> mergeCodes = labelCache.MergeFields.Keys.ToList().Where(s => Regex.IsMatch(s, "\\b[A-Z]{3}\\b")).ToList(); while (labelCodes.Count > 0 && mergeCodes.Any()) { var mergeDict = new Dictionary <string, string>(); foreach (var mergeCode in mergeCodes) { if (labelCodes.Count > 0) { mergeDict.Add(mergeCode, labelCodes[0]); labelCodes.RemoveAt(0); } else { mergeDict.Add(mergeCode, ""); } } mergeDict.Add("Date", Rock.RockDateTime.Today.DayOfWeek.ToString().Substring(0, 3) + " " + Rock.RockDateTime.Today.ToMonthDayString()); if (labelCache != null) { var checkInLabel = new CheckInLabel(labelCache, new Dictionary <string, object>()); checkInLabel.FileGuid = aggregateLabelGuid; foreach (var keyValue in mergeDict) { if (checkInLabel.MergeFields.ContainsKey(keyValue.Key)) { checkInLabel.MergeFields[keyValue.Key] = keyValue.Value; } else { checkInLabel.MergeFields.Add(keyValue.Key, keyValue.Value); } } checkInLabel.PrintFrom = kioskDevice.PrintFrom; checkInLabel.PrintTo = kioskDevice.PrintToOverride; if (checkInLabel.PrintTo == PrintTo.Kiosk) { var device = kioskDevice; if (device != null) { checkInLabel.PrinterDeviceId = device.PrinterDeviceId; } } if (checkInLabel.PrinterDeviceId.HasValue) { var printerDevice = new DeviceService(new RockContext()).Get(checkInLabel.PrinterDeviceId.Value); checkInLabel.PrinterAddress = printerDevice.IPAddress; } labels.Add(checkInLabel); } } return(labels); }