Esempio n. 1
0
        public List <Label> createLabelData(CMSDataContext dataContext)
        {
            List <Label> labels = new List <Label>();

            using (var db = new SqlConnection(Util.ConnectionString)) {
                AttendanceCacheSet cacheSet = new AttendanceCacheSet {
                    dataContext    = dataContext,
                    formats        = LabelFormat.forSize(db, labelSize),
                    securityLabels = securityLabels,
                    securityCode   = dataContext.NextSecurityCode().Select(c => c.Code).Single().Trim(),
                    guestLabels    = guestLabels,
                    locationLabels = locationLabels,
                    nameTagAge     = nameTagAge
                };

                foreach (Attendance attendance in attendances)
                {
                    labels.AddRange(attendance.getLabels(cacheSet));
                }

                if (labels.Count > 0 && attendances.Count > 0 && securityLabels == Attendance.SECURITY_LABELS_PER_FAMILY)
                {
                    labels.AddRange(attendances[0].getSecurityLabel(cacheSet));
                }
            }

            return(labels);
        }
Esempio n. 2
0
        public List <Label> createLabelData(CMSDataContext dataContext)
        {
            List <Label> labels = new List <Label>();
            bool         printingForChildren = false;
            bool         needsSecurityLabel  = false;

            using (var db = new SqlConnection(Util.ConnectionString)) {
                AttendanceCacheSet cacheSet = new AttendanceCacheSet {
                    dataContext    = dataContext,
                    formats        = LabelFormat.forSize(db, labelSize),
                    securityLabels = securityLabels,
                    securityCode   = dataContext.NextSecurityCode().Select(c => c.Code).Single().Trim(),
                    guestLabels    = guestLabels,
                    locationLabels = locationLabels,
                    nameTagAge     = nameTagAge
                };

                foreach (Attendance attendance in attendances)
                {
                    attendance.populateSubgroups(db, cacheSet);
                    labels.AddRange(attendance.getLabels(cacheSet));
                    CmsData.Person person = cacheSet.getPerson(attendance.peopleID);
                    if (securityLabels == Attendance.SECURITY_LABELS_PER_FAMILY)
                    {
                        // we only add a security label if we are printing for children in orgs with a security label needed; do those checks now
                        if ((person.Age ?? 0) < cacheSet.nameTagAge)
                        {
                            printingForChildren = true;
                        }
                        foreach (AttendanceGroup group in attendance.groups)
                        {
                            Organization org = cacheSet.getOrganization(group.groupID);
                            if (org != null && org.NoSecurityLabel != true && org.NumCheckInLabels > 0 && group.present)
                            {
                                needsSecurityLabel = true;
                            }
                        }
                    }
                }
                if (printingForChildren && needsSecurityLabel && labels.Count > 0)
                {
                    labels.AddRange(attendances[0].getSecurityLabel(cacheSet));
                }
            }

            return(labels);
        }