Пример #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (CurrentWorkflow == null || CurrentCheckInState == null)
            {
                NavigateToHomePage();
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    try
                    {
                        lTitle.Text = GetAttributeValue(AttributeKey.Title);
                        string detailMsg = GetAttributeValue(AttributeKey.DetailMessage);

                        var printFromClient = new List <CheckInLabel>();
                        var printFromServer = new List <CheckInLabel>();

                        List <CheckinResult> checkinResultList = new List <CheckinResult>();

                        // Print the labels
                        foreach (var family in CurrentCheckInState.CheckIn.Families.Where(f => f.Selected))
                        {
                            lbAnother.Visible =
                                CurrentCheckInState.CheckInType.TypeOfCheckin == TypeOfCheckin.Individual &&
                                family.People.Count > 1;

                            foreach (var person in family.GetPeople(true))
                            {
                                foreach (var groupType in person.GetGroupTypes(true))
                                {
                                    foreach (var group in groupType.GetGroups(true))
                                    {
                                        foreach (var location in group.GetLocations(true))
                                        {
                                            foreach (var schedule in location.GetSchedules(true))
                                            {
                                                string        detailMessage = string.Format(detailMsg, person.ToString(), group.ToString(), location.Location.Name, schedule.ToString(), person.SecurityCode);
                                                CheckinResult checkinResult = new CheckinResult();
                                                checkinResult.Person        = person;
                                                checkinResult.Group         = group;
                                                checkinResult.Location      = location.Location;
                                                checkinResult.Schedule      = schedule;
                                                checkinResult.DetailMessage = detailMessage;
                                                checkinResultList.Add(checkinResult);
                                            }
                                        }
                                    }

                                    if (groupType.Labels != null && groupType.Labels.Any())
                                    {
                                        printFromClient.AddRange(groupType.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Client));
                                        printFromServer.AddRange(groupType.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Server));
                                    }
                                }
                            }
                        }

                        var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(this.RockPage, null, new Rock.Lava.CommonMergeFieldsOptions {
                            GetLegacyGlobalMergeFields = false
                        });
                        mergeFields.Add("CheckinResultList", checkinResultList);
                        mergeFields.Add("Kiosk", CurrentCheckInState.Kiosk);
                        mergeFields.Add("RegistrationModeEnabled", CurrentCheckInState.Kiosk.RegistrationModeEnabled);
                        mergeFields.Add("Messages", CurrentCheckInState.Messages);
                        if (LocalDeviceConfig.CurrentGroupTypeIds != null)
                        {
                            var checkInAreas = LocalDeviceConfig.CurrentGroupTypeIds.Select(a => Rock.Web.Cache.GroupTypeCache.Get(a));
                            mergeFields.Add("CheckinAreas", checkInAreas);
                        }

                        if (printFromClient.Any())
                        {
                            var urlRoot = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority);
#if DEBUG
                            // This is extremely useful when debugging with ngrok and an iPad on the local network.
                            // X-Original-Host will contain the name of your ngrok hostname, therefore the labels will
                            // get a LabelFile url that will actually work with that iPad.
                            if (Request.Headers["X-Forwarded-Proto"] != null && Request.Headers["X-Original-Host"] != null)
                            {
                                urlRoot = string.Format("{0}://{1}", Request.Headers.GetValues("X-Forwarded-Proto").First(), Request.Headers.GetValues("X-Original-Host").First());
                            }
#endif
                            printFromClient
                            .OrderBy(l => l.PersonId)
                            .ThenBy(l => l.Order)
                            .ToList()
                            .ForEach(l => l.LabelFile = urlRoot + l.LabelFile);

                            AddLabelScript(printFromClient.ToJson());
                        }

                        if (printFromServer.Any())
                        {
                            var messages = ZebraPrint.PrintLabels(printFromServer);
                            mergeFields.Add("ZebraPrintMessageList", messages);
                        }

                        var successLavaTemplate = CurrentCheckInState.CheckInType.SuccessLavaTemplate;
                        lCheckinResultsHtml.Text = successLavaTemplate.ResolveMergeFields(mergeFields);

                        if (LocalDeviceConfig.GenerateQRCodeForAttendanceSessions)
                        {
                            HttpCookie attendanceSessionGuidsCookie = Request.Cookies[CheckInCookieKey.AttendanceSessionGuids];
                            if (attendanceSessionGuidsCookie == null)
                            {
                                attendanceSessionGuidsCookie       = new HttpCookie(CheckInCookieKey.AttendanceSessionGuids);
                                attendanceSessionGuidsCookie.Value = string.Empty;
                            }

                            // set (or reset) the expiration to be 8 hours from the current time)
                            attendanceSessionGuidsCookie.Expires = RockDateTime.Now.AddHours(8);

                            var attendanceSessionGuids = attendanceSessionGuidsCookie.Value.Split(',').AsGuidList();
                            attendanceSessionGuids = ValidAttendanceSessionGuids(attendanceSessionGuids);

                            // Add the guid to the list of checkin session cookie guids if it's not already there.
                            if (CurrentCheckInState.CheckIn.CurrentFamily.AttendanceCheckinSessionGuid.HasValue &&
                                !attendanceSessionGuids.Contains(CurrentCheckInState.CheckIn.CurrentFamily.AttendanceCheckinSessionGuid.Value))
                            {
                                attendanceSessionGuids.Add(CurrentCheckInState.CheckIn.CurrentFamily.AttendanceCheckinSessionGuid.Value);
                            }

                            attendanceSessionGuidsCookie.Value = attendanceSessionGuids.AsDelimited(",");

                            Response.Cookies.Set(attendanceSessionGuidsCookie);

                            lCheckinQRCodeHtml.Text = string.Format("<div class='qr-code-container text-center'><img class='img-responsive qr-code' src='{0}' alt='Check-in QR Code' width='500' height='500'></div>", GetAttendanceSessionsQrCodeImageUrl(attendanceSessionGuidsCookie));
                        }
                    }
                    catch (Exception ex)
                    {
                        LogException(ex);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (CurrentWorkflow == null || CurrentCheckInState == null)
            {
                NavigateToHomePage();
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    try
                    {
                        lTitle.Text = GetAttributeValue("Title");

                        var printFromClient = new List <CheckInLabel>();
                        var printFromServer = new List <CheckInLabel>();

                        using (var rockContext = new RockContext())
                        {
                            var attendanceService = new AttendanceService(rockContext);

                            // Print the labels
                            foreach (var family in CurrentCheckInState.CheckIn.Families.Where(f => f.Selected))
                            {
                                foreach (var person in family.CheckOutPeople.Where(p => p.Selected))
                                {
                                    foreach (var attendance in attendanceService.Queryable()
                                             .Where(a => person.AttendanceIds.Contains(a.Id))
                                             .ToList())
                                    {
                                        var now = attendance.Campus != null ? attendance.Campus.CurrentDateTime : RockDateTime.Now;

                                        attendance.EndDateTime = now;

                                        if (attendance.Occurrence.Group != null &&
                                            attendance.Occurrence.Location != null &&
                                            attendance.Occurrence.Schedule != null)
                                        {
                                            var li = new HtmlGenericControl("li");
                                            li.InnerText = string.Format(GetAttributeValue("DetailMessage"),
                                                                         person.ToString(), attendance.Occurrence.Group.ToString(), attendance.Occurrence.Location.Name, attendance.Occurrence.Schedule.Name);

                                            phResults.Controls.Add(li);
                                        }
                                    }

                                    if (person.Labels != null && person.Labels.Any())
                                    {
                                        printFromClient.AddRange(person.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Client));
                                        printFromServer.AddRange(person.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Server));
                                    }
                                }
                            }

                            rockContext.SaveChanges();
                        }

                        if (printFromClient.Any())
                        {
                            var urlRoot = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority);
                            printFromClient
                            .OrderBy(l => l.PersonId)
                            .ThenBy(l => l.Order)
                            .ToList()
                            .ForEach(l => l.LabelFile = urlRoot + l.LabelFile);
                            AddLabelScript(printFromClient.ToJson());
                        }

                        if (printFromServer.Any())
                        {
                            var messages = ZebraPrint.PrintLabels(printFromServer);

                            foreach (var message in messages)
                            {
                                phResults.Controls.Add(new LiteralControl(string.Format("<br/>{0}", message)));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogException(ex);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (CurrentWorkflow == null || CurrentCheckInState == null)
            {
                NavigateToHomePage();
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    try
                    {
                        lTitle.Text = GetAttributeValue("Title");
                        string detailMsg = GetAttributeValue("DetailMessage");

                        var printFromClient = new List <CheckInLabel>();
                        var printFromServer = new List <CheckInLabel>();

                        List <CheckinResult> checkinResultList = new List <CheckinResult>();

                        // Print the labels
                        foreach (var family in CurrentCheckInState.CheckIn.Families.Where(f => f.Selected))
                        {
                            lbAnother.Visible =
                                CurrentCheckInState.CheckInType.TypeOfCheckin == TypeOfCheckin.Individual &&
                                family.People.Count > 1;

                            foreach (var person in family.GetPeople(true))
                            {
                                foreach (var groupType in person.GetGroupTypes(true))
                                {
                                    foreach (var group in groupType.GetGroups(true))
                                    {
                                        foreach (var location in group.GetLocations(true))
                                        {
                                            foreach (var schedule in location.GetSchedules(true))
                                            {
                                                string        detailMessage = string.Format(detailMsg, person.ToString(), group.ToString(), location.Location.Name, schedule.ToString(), person.SecurityCode);
                                                CheckinResult checkinResult = new CheckinResult();
                                                checkinResult.Person        = person;
                                                checkinResult.Group         = group;
                                                checkinResult.Location      = location.Location;
                                                checkinResult.Schedule      = schedule;
                                                checkinResult.DetailMessage = detailMessage;
                                                checkinResultList.Add(checkinResult);
                                            }
                                        }
                                    }

                                    if (groupType.Labels != null && groupType.Labels.Any())
                                    {
                                        printFromClient.AddRange(groupType.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Client));
                                        printFromServer.AddRange(groupType.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Server));
                                    }
                                }
                            }
                        }

                        var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(this.RockPage, null, new Rock.Lava.CommonMergeFieldsOptions {
                            GetLegacyGlobalMergeFields = false
                        });
                        mergeFields.Add("CheckinResultList", checkinResultList);
                        mergeFields.Add("Kiosk", CurrentCheckInState.Kiosk);
                        mergeFields.Add("RegistrationModeEnabled", CurrentCheckInState.Kiosk.RegistrationModeEnabled);
                        mergeFields.Add("Messages", CurrentCheckInState.Messages);
                        if (CurrentGroupTypeIds != null)
                        {
                            var checkInAreas = CurrentGroupTypeIds.Select(a => Rock.Web.Cache.GroupTypeCache.Get(a));
                            mergeFields.Add("CheckinAreas", checkInAreas);
                        }

                        if (printFromClient.Any())
                        {
                            var urlRoot = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority);
                            printFromClient
                            .OrderBy(l => l.PersonId)
                            .ThenBy(l => l.Order)
                            .ToList()
                            .ForEach(l => l.LabelFile = urlRoot + l.LabelFile);
                            AddLabelScript(printFromClient.ToJson());
                        }

                        if (printFromServer.Any())
                        {
                            var messages = ZebraPrint.PrintLabels(printFromServer);
                            mergeFields.Add("ZebraPrintMessageList", messages);
                        }

                        var successLavaTemplate = CurrentCheckInState.CheckInType.SuccessLavaTemplate;
                        lCheckinResultsHtml.Text = successLavaTemplate.ResolveMergeFields(mergeFields);
                    }
                    catch (Exception ex)
                    {
                        LogException(ex);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Shows the details.
        /// </summary>
        private void ShowDetails()
        {
            lTitle.Text = GetAttributeValue(AttributeKey.Title);

            var printFromClient = new List <CheckInLabel>();
            var printFromServer = new List <CheckInLabel>();

            List <CheckinResult> checkinResultList = new List <CheckinResult>();

            var successfullyCompletedAchievementIdsPriorToCheckin = CurrentCheckInState.CheckIn.SuccessfullyCompletedAchievementsPriorToCheckin?.Select(a => a.AchievementAttempt.Id).ToArray() ?? new int[0];
            var achievementsStateAfterCheckin  = CurrentCheckInState.CheckIn.AchievementsStateAfterCheckin;
            var successLavaTemplateDisplayMode = CurrentCheckInState.CheckInType.SuccessLavaTemplateDisplayMode;

            // Populate Checkin Results and label data
            foreach (var family in CurrentCheckInState.CheckIn.Families.Where(f => f.Selected))
            {
                lbAnother.Visible =
                    CurrentCheckInState.CheckInType.TypeOfCheckin == TypeOfCheckin.Individual &&
                    family.People.Count > 1;

                foreach (var person in family.GetPeople(true))
                {
                    foreach (var groupType in person.GetGroupTypes(true))
                    {
                        foreach (var group in groupType.GetGroups(true))
                        {
                            foreach (var location in group.GetLocations(true))
                            {
                                foreach (var schedule in location.GetSchedules(true))
                                {
                                    CheckinResult checkinResult = new CheckinResult();
                                    checkinResult.Person   = person;
                                    checkinResult.Group    = group;
                                    checkinResult.Location = location.Location;
                                    checkinResult.Schedule = schedule;
                                    checkinResult.UpdateAchievementFields(successfullyCompletedAchievementIdsPriorToCheckin, achievementsStateAfterCheckin);
                                    checkinResultList.Add(checkinResult);
                                }
                            }
                        }

                        if (groupType.Labels != null && groupType.Labels.Any())
                        {
                            printFromClient.AddRange(groupType.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Client));
                            printFromServer.AddRange(groupType.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Server));
                        }
                    }
                }
            }

            var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(this.RockPage, null, new Rock.Lava.CommonMergeFieldsOptions {
                GetLegacyGlobalMergeFields = false
            });

            mergeFields.Add(MergeFieldKey.CheckinResultList, checkinResultList);
            mergeFields.Add(MergeFieldKey.Kiosk, CurrentCheckInState.Kiosk);
            mergeFields.Add(MergeFieldKey.RegistrationModeEnabled, CurrentCheckInState.Kiosk.RegistrationModeEnabled);
            mergeFields.Add(MergeFieldKey.Messages, CurrentCheckInState.Messages);
            if (LocalDeviceConfig.CurrentGroupTypeIds != null)
            {
                var checkInAreas = LocalDeviceConfig.CurrentGroupTypeIds.Select(a => Rock.Web.Cache.GroupTypeCache.Get(a));
                mergeFields.Add(MergeFieldKey.CheckinAreas, checkInAreas);
            }

            if (printFromClient.Any())
            {
                var proxySafeUrl = Request.UrlProxySafe();
                var urlRoot      = $"{proxySafeUrl.Scheme}://{proxySafeUrl.Authority}";

                /*
                 * // This is extremely useful when debugging with ngrok and an iPad on the local network.
                 * // X-Original-Host will contain the name of your ngrok hostname, therefore the labels will
                 * // get a LabelFile url that will actually work with that iPad.
                 * if ( Request.Headers["X-Original-Host" ] != null )
                 * {
                 *  var scheme = Request.Headers["X-Forwarded-Proto"] ?? "http";
                 *  urlRoot = string.Format( "{0}://{1}", scheme, Request.Headers.GetValues( "X-Original-Host" ).First() );
                 * }
                 */

                printFromClient
                .OrderBy(l => l.PersonId)
                .ThenBy(l => l.Order)
                .ToList()
                .ForEach(l => l.LabelFile = urlRoot + l.LabelFile);

                AddLabelScript(printFromClient.ToJson());
            }

            if (printFromServer.Any())
            {
                var messages = ZebraPrint.PrintLabels(printFromServer);
                mergeFields.Add(MergeFieldKey.ZebraPrintMessageList, messages);
                if (messages.Any())
                {
                    lCheckinLabelErrorMessages.Visible = true;
                    var messageHtml = new StringBuilder();
                    foreach (var message in messages)
                    {
                        messageHtml.AppendLine($"<li>{message}</li>");
                    }

                    lCheckinLabelErrorMessages.Text = messageHtml.ToString();
                }
            }

            if (CurrentCheckInState?.Messages?.Any() == true)
            {
                lMessages.Visible = true;
                StringBuilder sbMessages = new StringBuilder();
                foreach (var message in CurrentCheckInState.Messages)
                {
                    var messageHtml = $@"<li><div class='alert alert-{ message.MessageType.ConvertToString( false ).ToLower() }'> { message.MessageText }  </div></li>";
                    sbMessages.AppendLine(messageHtml);
                }

                lMessages.Text = sbMessages.ToString();
            }

            if (lbAnother.Visible)
            {
                var bodyTag = this.Page.Master.FindControl("body") as HtmlGenericControl;
                if (bodyTag != null)
                {
                    bodyTag.AddCssClass("checkin-anotherperson");
                }
            }

            GenerateQRCodes();

            RenderCheckinResults(checkinResultList, mergeFields, successLavaTemplateDisplayMode);
        }
Пример #5
0
        public PrintSessionLabelsResponse PrintSessionLabels([FromUri] string session, [FromUri] int?kioskId = null)
        {
            List <Guid?> sessionGuids;

            //
            // The session data is a comma separated list of Guid values.
            //
            try
            {
                sessionGuids = session.SplitDelimitedValues()
                               .Select(a =>
                {
                    var guid = a.AsGuidOrNull();

                    //
                    // Check if this is a standard Guid format.
                    //
                    if (guid.HasValue)
                    {
                        return(guid.Value);
                    }

                    return(GuidHelper.FromShortStringOrNull(a));
                })
                               .ToList();
            }
            catch
            {
                sessionGuids = null;
            }

            //
            // If no session guids were found or an error occurred trying to
            // parse them, then return an error.
            //
            if (sessionGuids == null || sessionGuids.Count == 0)
            {
                return(new PrintSessionLabelsResponse
                {
                    Labels = new List <CheckInLabel>(),
                    Messages = new List <string>
                    {
                        "No check-in sessions were specified."
                    }
                });
            }

            using (var rockContext = new RockContext())
            {
                KioskDevice printer = null;

                //
                // If they specified a kiosk, attempt to load the printer for
                // that kiosk.
                //
                if (kioskId.HasValue && kioskId.Value != 0)
                {
                    var kiosk = KioskDevice.Get(kioskId.Value, null);
                    if ((kiosk?.Device?.PrinterDeviceId).HasValue)
                    {
                        //
                        // We aren't technically loading a kiosk, but this lets us
                        // load the printer IP address from cache rather than hitting
                        // the database each time.
                        //
                        printer = KioskDevice.Get(kiosk.Device.PrinterDeviceId.Value, null);
                    }
                }

                var attendanceService = new AttendanceService(rockContext);

                //
                // Retrieve all session label data from the database, then deserialize
                // it, then make one giant list of labels and finally order it.
                //
                var labels = attendanceService.Queryable()
                             .AsNoTracking()
                             .Where(a => sessionGuids.Contains(a.AttendanceCheckInSession.Guid))
                             .DistinctBy(a => a.AttendanceCheckInSessionId)
                             .Select(a => a.AttendanceData.LabelData)
                             .ToList()
                             .Select(a => a.FromJsonOrNull <List <CheckInLabel> >())
                             .Where(a => a != null)
                             .SelectMany(a => a)
                             .OrderBy(a => a.PersonId)
                             .ThenBy(a => a.Order)
                             .ToList();

                foreach (var label in labels)
                {
                    //
                    // If the label is being printed to the kiosk and client printing
                    // is enabled and the client has specified their device
                    // identifier then we need to update the label data to have the
                    // new printer information.
                    //
                    if (label.PrintTo == PrintTo.Kiosk && label.PrintFrom == PrintFrom.Client && printer != null)
                    {
                        label.PrinterDeviceId = printer.Device.Id;
                        label.PrinterAddress  = printer.Device.IPAddress;
                    }
                }

                var response = new PrintSessionLabelsResponse
                {
                    Labels = labels.Where(l => l.PrintFrom == PrintFrom.Client).ToList()
                };

                //
                // Update any labels to convert the relative URL path to an absolute URL
                // path for client printing.
                //
                if (response.Labels.Any())
                {
                    var urlRoot = Request.RequestUri.GetLeftPart(UriPartial.Authority);

                    if (Request.Headers.Contains("X-Forwarded-Proto") && Request.Headers.Contains("X-Forwarded-Host"))
                    {
                        urlRoot = $"{Request.Headers.GetValues( "X-Forwarded-Proto" ).First()}://{Request.Headers.GetValues( "X-Forwarded-Host" ).First()}";
                    }
#if DEBUG
                    // This is extremely useful when debugging with ngrok and an iPad on the local network.
                    // X-Original-Host will contain the name of your ngrok hostname, therefore the labels will
                    // get a LabelFile url that will actually work with that iPad.
                    if (Request.Headers.Contains("X-Forwarded-Proto") && Request.Headers.Contains("X-Original-Host"))
                    {
                        urlRoot = $"{Request.Headers.GetValues( "X-Forwarded-Proto" ).First()}://{Request.Headers.GetValues( "X-Original-Host" ).First()}";
                    }
#endif
                    response.Labels.ForEach(l => l.LabelFile = urlRoot + l.LabelFile);
                }

                var printFromServer = labels.Where(l => l.PrintFrom == PrintFrom.Server).ToList();

                if (printFromServer.Any())
                {
                    var messages = ZebraPrint.PrintLabels(printFromServer);
                    response.Messages = messages;
                }

                return(response);
            }
        }
Пример #6
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (CurrentWorkflow == null || CurrentCheckInState == null)
            {
                NavigateToHomePage();
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    try
                    {
                        lTitle.Text = GetAttributeValue("Title");
                        string detailMsg = GetAttributeValue("DetailMessage");

                        var printFromClient = new List <CheckInLabel>();
                        var printFromServer = new List <CheckInLabel>();

                        // Print the labels
                        foreach (var family in CurrentCheckInState.CheckIn.Families.Where(f => f.Selected))
                        {
                            lbAnother.Visible =
                                CurrentCheckInState.CheckInType.TypeOfCheckin == TypeOfCheckin.Individual &&
                                family.People.Count > 1;

                            foreach (var person in family.GetPeople(true))
                            {
                                foreach (var groupType in person.GetGroupTypes(true))
                                {
                                    foreach (var group in groupType.GetGroups(true))
                                    {
                                        foreach (var location in group.GetLocations(true))
                                        {
                                            foreach (var schedule in location.GetSchedules(true))
                                            {
                                                var li = new HtmlGenericControl("li");
                                                li.InnerText = string.Format(detailMsg, person.ToString(), group.ToString(), location.Location.Name, schedule.ToString(), person.SecurityCode);

                                                phResults.Controls.Add(li);
                                            }
                                        }
                                    }

                                    if (groupType.Labels != null && groupType.Labels.Any())
                                    {
                                        printFromClient.AddRange(groupType.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Client));
                                        printFromServer.AddRange(groupType.Labels.Where(l => l.PrintFrom == Rock.Model.PrintFrom.Server));
                                    }
                                }
                            }
                        }

                        if (printFromClient.Any())
                        {
                            var urlRoot = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority);
                            printFromClient
                            .OrderBy(l => l.PersonId)
                            .ThenBy(l => l.Order)
                            .ToList()
                            .ForEach(l => l.LabelFile = urlRoot + l.LabelFile);
                            AddLabelScript(printFromClient.ToJson());
                        }

                        if (printFromServer.Any())
                        {
                            var messages = ZebraPrint.PrintLabels(printFromServer);

                            foreach (var message in messages)
                            {
                                phResults.Controls.Add(new LiteralControl(string.Format("<br/>{0}", message)));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogException(ex);
                    }
                }
            }
        }