Exemplo n.º 1
0
        private string getGroupField(AttendanceCacheSet cacheSet, LabelField field, string format, AttendanceGroup group)
        {
            if (group == null)
            {
                return("");
            }

            Organization org;
            Meeting      meeting;

            switch (field)
            {
            case LabelField.GROUP_NAME:
                org = cacheSet.getOrganization(group.groupID);

                return(org == null ? "" : string.Format(format, org.OrganizationName));

            case LabelField.GROUP_LOCATION:
                org = cacheSet.getOrganization(group.groupID);

                return(org == null ? "" : string.Format(format, org.Location));

            case LabelField.GROUP_SUBGROUPS:
                return(group.subgroupName);

            case LabelField.GROUP_LOCATION_AND_SUBGROUP:
                org = cacheSet.getOrganization(group.groupID);
                List <string> groupItems = new List <string>();
                if (org != null && org.Location.HasValue())
                {
                    groupItems.Add(org.Location);
                }
                if (group.subgroupName.HasValue())
                {
                    groupItems.Add(group.subgroupName);
                }
                return(string.Format(format, string.Join(" - ", groupItems)));

            case LabelField.GROUP_NAME_AND_TIME:
                org     = cacheSet.getOrganization(group.groupID);
                meeting = cacheSet.getMeeting(group.groupID, group.datetime);

                string orgName = org == null ? "" : org.OrganizationName;
                return(string.Format(format, orgName, meeting.MeetingDate));

            case LabelField.ATTENDANCE_DATE_TIME:
                meeting = cacheSet.getMeeting(group.groupID, group.datetime);

                return(string.Format(format, meeting.MeetingDate));

            case LabelField.ATTENDANCE_PAGER:
                return("");

            case LabelField.ATTENDANCE_NOTES:
                return("");

            default:
                return("");
            }
        }
Exemplo n.º 2
0
        private string getGroupField(AttendanceCacheSet cacheSet, LabelField field, string format, AttendanceGroup group)
        {
            if (group == null)
            {
                return("");
            }

            Organization org;
            Meeting      meeting;

            switch (field)
            {
            case LabelField.GROUP_NAME:
                org = cacheSet.getOrganization(group.groupID);

                return(org == null ? "" : string.Format(format, org.OrganizationName));

            case LabelField.GROUP_LOCATION:
                org = cacheSet.getOrganization(group.groupID);

                return(org == null ? "" : string.Format(format, org.Location));

            case LabelField.GROUP_SUBGROUPS:
                return(group.subgroupName);

            case LabelField.ATTENDANCE_DATE_TIME:
                meeting = cacheSet.getMeeting(group.groupID, group.datetime);

                return(string.Format(format, meeting.MeetingDate));

            case LabelField.ATTENDANCE_PAGER:
                return("");

            case LabelField.ATTENDANCE_NOTES:
                return("");

            default:
                return("");
            }
        }
Exemplo n.º 3
0
 public void populateSubgroups(SqlConnection db, AttendanceCacheSet cacheSet)
 {
     foreach (AttendanceGroup group in groups)
     {
         Organization org = cacheSet.getOrganization(group.groupID);
         if (org != null)
         {
             var subgroups = Subgroup.forGroupID(db, group.groupID, peopleID);
             if (subgroups.Count > 0)
             {
                 group.subgroupName = subgroups.First().name;
             }
         }
     }
 }
Exemplo n.º 4
0
        private bool hasAttends(AttendanceCacheSet cacheSet)
        {
            foreach (AttendanceGroup group in groups)
            {
                if (group.present)
                {
                    Organization org = cacheSet.getOrganization(group.groupID);
                    if (org != null && org.NumCheckInLabels != 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public List <Label> getLabels(AttendanceCacheSet cacheSet)
        {
            List <Label.Type> labelTypes = new List <Label.Type>();
            List <Label>      labels     = new List <Label>();

            CmsData.Person person = cacheSet.getPerson(peopleID);

            // Create label type list
            if (groups.Count > 0 && hasAttends(cacheSet))
            {
                // TODO: Client size option for age cutoff for Name Tag.  Server will override and will send it to the client and disable field
                if ((person.Age ?? 0) < cacheSet.nameTagAge)
                {
                    labelTypes.Add(Label.Type.MAIN);

                    foreach (AttendanceGroup group in groups)
                    {
                        Organization org = cacheSet.getOrganization(group.groupID);

                        if (org != null && org.NumCheckInLabels > 1 && group.present)
                        {
                            for (int iX = 0; iX < org.NumCheckInLabels - 1; iX++)
                            {
                                labelTypes.Add(Label.Type.EXTRA);
                            }
                        }
                    }

                    if (hasVisits(cacheSet))
                    {
                        if (cacheSet.guestLabels)
                        {
                            foreach (AttendanceGroup _ in getVisitGroups(cacheSet))
                            {
                                labelTypes.Add(Label.Type.GUEST);
                            }
                        }

                        if (cacheSet.locationLabels)
                        {
                            labelTypes.Add(Label.Type.LOCATION);
                        }
                    }

                    switch (cacheSet.securityLabels)
                    {
                    // case SECURITY_LABELS_NONE: 0 = No Security Labels
                    // case SECURITY_LABELS_PER_FAMILY: Security Label Per Family (Handled outside this routine)

                    case SECURITY_LABELS_PER_MEETING:
                    {
                        for (int iX = 0; iX < groups.Count; iX++)
                        {
                            labelTypes.Add(Label.Type.SECURITY);
                        }

                        break;
                    }

                    case SECURITY_LABELS_PER_CHILD:
                    {
                        labelTypes.Add(Label.Type.SECURITY);

                        break;
                    }
                    }
                }
                else
                {
                    labelTypes.Add(Label.Type.NAME_TAG);
                }
            }

            // Generate labels from type list
            foreach (Label.Type labelType in labelTypes)
            {
                if (labelType == Label.Type.GUEST)
                {
                    labels.AddRange(Label.generate(cacheSet, labelType, this, getVisitGroups(cacheSet).ToList()));
                }
                else
                {
                    labels.AddRange(Label.generate(cacheSet, labelType, this, groups));
                }
            }

            return(labels);
        }
Exemplo n.º 7
0
        public LabelEntry(AttendanceCacheSet cacheSet, LabelFormatEntry formatEntry, Attendance attendance, AttendanceGroup group = null, int index = 0)
        {
            bool conditionalRemovedEntry = false;

            typeID = formatEntry.typeID;

            if (formatEntry.orgEV.HasValue())
            {
                Organization org = cacheSet.getOrganization(group.groupID);
                if (org != null)
                {
                    var ev = org.OrganizationExtras.SingleOrDefault(e => e.Field == formatEntry.orgEV);
                    if (ev == null)
                    {
                        conditionalRemovedEntry = true;
                    }
                }
                else
                {
                    conditionalRemovedEntry = true;
                }
            }
            if (formatEntry.personFlag.HasValue() && conditionalRemovedEntry == false)
            {
                CmsData.Person person = cacheSet.getPerson(attendance.peopleID);
                if (person != null)
                {
                    var sf = cacheSet.dataContext.ViewAllStatusFlags.SingleOrDefault(f => f.Flag == formatEntry.personFlag && f.PeopleId == person.PeopleId);
                    if (sf == null)
                    {
                        conditionalRemovedEntry = true;
                    }
                }
                else
                {
                    conditionalRemovedEntry = true;
                }
            }

            switch (formatEntry.typeID)
            {
            case 1:
                try {
                    data = getField(cacheSet, (LabelField)formatEntry.fieldID, formatEntry.fieldFormat, attendance, group);
                } catch (Exception) {
                    data = "Format Exception";
                }

                break;

            case 4:
            case 5:
                data = formatEntry.fieldFormat;
                break;

            case 6:
                // populate box data so that it is printed if data is present
                // later we remove box entries if they are behind a blank field by querying this data prop
                try
                {
                    if (formatEntry.invert && formatEntry.fieldID != 0)
                    {
                        data = getField(cacheSet, (LabelField)formatEntry.fieldID, formatEntry.fieldFormat, attendance, group);
                    }
                    else
                    {
                        data = "print";
                    }
                }
                catch (Exception)
                {
                    data = "Format Exception";
                }

                break;

            default:
                data = "";
                break;
            }

            font     = formatEntry.font;
            fontSize = formatEntry.fontSize;

            start.x = formatEntry.startX;
            start.y = formatEntry.startY + (formatEntry.offset * index);

            align.x = formatEntry.alignX;
            align.y = formatEntry.alignY;

            end.x = formatEntry.endX;
            end.y = formatEntry.endY + (formatEntry.offset * index);

            size.x = formatEntry.width;
            size.y = formatEntry.height;

            invert = formatEntry.invert;
            order  = formatEntry.order;

            if (conditionalRemovedEntry)
            {
                data = "ConditionalRemovedEntry";
            }
        }