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(""); } }
private static Label getLabel(AttendanceCacheSet cacheSet, LabelFormat format, Attendance attendance, List <AttendanceGroup> groups) { Label label = new Label(); foreach (LabelFormatEntry formatEntry in format.entries) { if (formatEntry.repeat > 1) { for (int iX = 0; iX < formatEntry.repeat; iX++) { if (groups.Count <= iX) { break; } LabelEntry entry = new LabelEntry(cacheSet, formatEntry, attendance, groups[iX], iX); label.entries.Add(entry); } } else { label.entries.Add(new LabelEntry(cacheSet, formatEntry, attendance, groups[0])); } } return(label); }
private static Label getLabel(AttendanceCacheSet cacheSet, LabelFormat format, Attendance attendance, List <AttendanceGroup> groups) { Label label = new Label(); foreach (LabelFormatEntry formatEntry in format.entries) { if (formatEntry.repeat > 1) { for (int iX = 0; iX < formatEntry.repeat; iX++) { if (groups.Count <= iX) { break; } LabelEntry entry = new LabelEntry(cacheSet, formatEntry, attendance, groups[iX], iX); label.entries.Add(entry); } } else { label.entries.Add(new LabelEntry(cacheSet, formatEntry, attendance, groups[0])); } } // remove shaded box entries without data -- this means they are behind a blank field label.entries.RemoveAll(e => e.typeID == 6 && e.data == ""); return(label); }
private string getParentsField(AttendanceCacheSet cacheSet, LabelField field, string format, Attendance attendance) { CmsData.Person person = cacheSet.getPerson(attendance.peopleID); if (person == null) { return(""); } CmsData.Family family = cacheSet.getFamily(person.FamilyId); if (family == null) { return(""); } CmsData.Person head = cacheSet.getPerson(family.HeadOfHouseholdId ?? 0); CmsData.Person spouse = cacheSet.getPerson(family.HeadOfHouseholdSpouseId ?? 0); if (head == null && spouse == null) { return(""); } switch (field) { case LabelField.PARENTS_NAME: List <string> names = new List <string>(); if (head != null) { names.Add(head.FirstName); } if (spouse != null) { names.Add(spouse.FirstName); } return(string.Format(format, string.Join(", ", names))); case LabelField.PARENTS_PHONE: List <string> phones = new List <string>(); if (head != null && !head.CellPhone.IsEmpty()) { phones.Add(head.FirstName + ": " + head.CellPhone); } if (spouse != null && !spouse.CellPhone.IsEmpty()) { phones.Add(spouse.FirstName + ": " + spouse.CellPhone); } return(string.Format(format, string.Join(", ", phones))); default: return(""); } }
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); }
private string getPersonField(AttendanceCacheSet cacheSet, LabelField field, string format, Attendance attendance) { CmsData.Person person = cacheSet.getPerson(attendance.peopleID); if (person == null) { return(""); } switch (field) { case LabelField.PERSON_SECURITY_CODE: return(string.Format(format, cacheSet.securityCode)); case LabelField.PERSON_FIRST_NAME: string firstname = person.PreferredName; return(string.Format(format, firstname)); case LabelField.PERSON_LAST_NAME: return(string.Format(format, person.LastName)); case LabelField.PERSON_ALLERGIES: return(string.Format(format, person.GetRecReg().MedicalDescription)); case LabelField.PERSON_INFO: string allergies = person.GetRecReg().MedicalDescription.IsEmpty() ? "" : "A"; string custody = person.CustodyIssue.HasValue && person.CustodyIssue.Value ? "C" : ""; string transport = person.OkTransport.HasValue && person.OkTransport.Value ? "T" : ""; return(string.Format(format, allergies, custody, transport)); case LabelField.PERSON_MEMBER_GUEST: string member = person.MemberStatus.Member ? "Member" : ""; string guest = person.MemberStatus.Member ? "" : "Guest"; return(string.Format(format, member, guest)); case LabelField.PERSON_FULL_NAME: return(string.Format(format, person.PreferredName, person.LastName)); case LabelField.PERSON_DOB: return(string.Format(format, person.BirthDate)); case LabelField.PERSON_EMERGENCY_NAME: return(string.Format(format, person.GetRecReg().Emcontact)); case LabelField.PERSON_EMERGENCY_PHONE: return(string.Format(format, person.GetRecReg().Emphone.FmtFone())); case LabelField.PERSON_SCHOOL: return(string.Format(format, person.SchoolOther)); case LabelField.PERSON_GRADE: return(string.Format(format, person.Grade)); default: return(""); } }
private IEnumerable <AttendanceGroup> getVisitGroups(AttendanceCacheSet cacheSet) { OrganizationMember member; foreach (AttendanceGroup group in groups) { member = cacheSet.getOrganizationMember(group.groupID, peopleID); if (member == null) { yield return(group); } } }
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; } } } }
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); }
private bool hasVisits(AttendanceCacheSet cacheSet) { OrganizationMember member; foreach (AttendanceGroup group in groups) { member = cacheSet.getOrganizationMember(group.groupID, peopleID); if (member == null) { return(true); } } return(false); }
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); }
public string getField(AttendanceCacheSet cacheSet, LabelField field, string format, Attendance attendance, AttendanceGroup group) { switch (field.category()) { case LabelFieldAttribute.CATEGORY_UNUSED: return(""); case LabelFieldAttribute.CATEGORY_PERSON: return(getPersonField(cacheSet, field, format, attendance)); case LabelFieldAttribute.CATEGORY_PARENTS: return(getParentsField(cacheSet, field, format, attendance)); case LabelFieldAttribute.CATEGORY_GROUP: return(getGroupField(cacheSet, field, format, group)); default: return(""); } }
public static List <Label> generate(AttendanceCacheSet cacheSet, Type type, Attendance attendance, List <AttendanceGroup> groups) { List <Label> labels = new List <Label>(); LabelFormat format = cacheSet.formats[(int)type]; List <AttendanceGroup> groupsCopy = new List <AttendanceGroup>(groups); if (format.canRepeat) { do { labels.Add(getLabel(cacheSet, format, attendance, nextGroups(groupsCopy, format.maxRepeat()))); } while(groupsCopy.Any()); } else { labels.Add(getLabel(cacheSet, format, attendance, nextGroups(groupsCopy, 1))); } return(labels); }
private string getPersonField(AttendanceCacheSet cacheSet, LabelField field, string format, Attendance attendance) { CmsData.Person person = cacheSet.getPerson(attendance.peopleID); if (person == null) { return(""); } switch (field) { case LabelField.PERSON_SECURITY_CODE: return(string.Format(format, cacheSet.securityCode)); case LabelField.PERSON_FIRST_NAME: return(string.Format(format, person.FirstName)); case LabelField.PERSON_LAST_NAME: return(string.Format(format, person.LastName)); case LabelField.PERSON_ALLERGIES: return(string.Format(format, person.GetRecReg().MedicalDescription)); case LabelField.PERSON_INFO: string allergies = person.GetRecReg().MedicalDescription.IsEmpty() ? "" : "A"; string custody = person.CustodyIssue.HasValue && person.CustodyIssue.Value ? "C" : ""; string transport = person.OkTransport.HasValue && person.OkTransport.Value ? "T" : ""; return(string.Format(format, allergies, custody, transport)); case LabelField.PERSON_MEMBER_GUEST: string member = person.MemberStatus.Member ? "Member" : ""; string guest = person.MemberStatus.Member ? "" : "Guest"; return(string.Format(format, member, guest)); default: return(""); } }
public LabelEntry(AttendanceCacheSet cacheSet, LabelFormatEntry formatEntry, Attendance attendance, AttendanceGroup group = null, int index = 0) { typeID = formatEntry.typeID; 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; 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; }
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(""); } }
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); }
public List <Label> getSecurityLabel(AttendanceCacheSet cacheSet) { return(Label.generate(cacheSet, Label.Type.SECURITY, this, groups)); }
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"; } }
public LabelEntry(AttendanceCacheSet cacheSet, LabelFormatEntry formatEntry, Attendance attendance, AttendanceGroup group = null, int index = 0) { typeID = formatEntry.typeID; 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; }