public override void ExecuteResult(ControllerContext context) { var Response = context.HttpContext.Response; if (MeetingId.HasValue) { meeting = DbUtil.Db.Meetings.Single(mt => mt.MeetingId == MeetingId); Debug.Assert(meeting.MeetingDate != null, "meeting.MeetingDate != null"); NewMeetingInfo = new NewMeetingInfo { MeetingDate = meeting.MeetingDate.Value }; } var list1 = NewMeetingInfo.ByGroup ? ReportList2().ToList() : ReportList().ToList(); if (!list1.Any()) { Response.Write("no data found"); return; } Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "filename=foo.pdf"); doc = new Document(PageSize.LETTER.Rotate(), 36, 36, 64, 64); var w = PdfWriter.GetInstance(doc, Response.OutputStream); w.PageEvent = pageEvents; doc.Open(); dc = w.DirectContent; box = new PdfPCell(); box.Border = Rectangle.NO_BORDER; box.CellEvent = new CellEvent(); OrgInfo lasto = null; foreach (var o in list1) { lasto = o; var table = new PdfPTable(1); table.DefaultCell.Border = Rectangle.NO_BORDER; table.DefaultCell.Padding = 0; table.WidthPercentage = 100; if (meeting != null) { var q = from at in meeting.Attends where at.AttendanceFlag || AttendCommitmentCode.committed.Contains(at.Commitment ?? 0) orderby at.Person.LastName, at.Person.FamilyId, at.Person.Name2 select new { at.MemberType.Code, Name2 = NewMeetingInfo.UseAltNames && at.Person.AltName.HasValue() ? at.Person.AltName : at.Person.Name2, at.PeopleId, at.Person.DOB }; if (q.Any()) { StartPageSet(o); } foreach (var a in q) { table.AddCell(AddRow(a.Code, a.Name2, a.PeopleId, a.DOB, "", font)); } } else if (OrgSearchModel != null) { var q = from om in DbUtil.Db.OrganizationMembers where om.OrganizationId == o.OrgId join m in DbUtil.Db.OrgPeople(o.OrgId, o.Groups) on om.PeopleId equals m.PeopleId where om.EnrollmentDate <= Util.Now orderby om.Person.LastName, om.Person.FamilyId, om.Person.Name2 let p = om.Person let ch = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0 select new { p.PeopleId, Name2 = ch ? p.AltName : p.Name2, BirthDate = Person.FormatBirthday( p.BirthYr, p.BirthMonth, p.BirthDay, p.PeopleId), MemberTypeCode = om.MemberType.Code, ch, highlight = om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == NewMeetingInfo.HighlightGroup) ? NewMeetingInfo.HighlightGroup : "" }; if (q.Any()) { StartPageSet(o); } foreach (var m in q) { table.AddCell(AddRow(m.MemberTypeCode, m.Name2, m.PeopleId, m.BirthDate, m.highlight, m.ch ? china ?? font : font)); } } else if (Filter?.GroupSelect == GroupSelectCode.Member) { var q = from om in DbUtil.Db.OrganizationMembers where om.OrganizationId == Filter.Id join m in DbUtil.Db.OrgFilterPeople(QueryId, null) on om.PeopleId equals m.PeopleId where om.EnrollmentDate <= Util.Now where NewMeetingInfo.ByGroup == false || m.Groups.Contains((char)10 + o.Groups + (char)10) orderby om.Person.LastName, om.Person.FamilyId, om.Person.Name2 let p = om.Person let ch = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0 select new { p.PeopleId, Name2 = ch ? p.AltName : p.Name2, BirthDate = Person.FormatBirthday( p.BirthYr, p.BirthMonth, p.BirthDay, p.PeopleId), MemberTypeCode = om.MemberType.Code, ch, highlight = om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == NewMeetingInfo.HighlightGroup) ? NewMeetingInfo.HighlightGroup : "" }; if (q.Any()) { StartPageSet(o); } foreach (var m in q) { table.AddCell(AddRow(m.MemberTypeCode, m.Name2, m.PeopleId, m.BirthDate, m.highlight, m.ch ? china ?? font : font)); } } else { var q = from m in DbUtil.Db.OrgFilterPeople(QueryId, null) orderby m.Name2 let p = DbUtil.Db.People.Single(pp => pp.PeopleId == m.PeopleId) let om = p.OrganizationMembers.SingleOrDefault(mm => mm.OrganizationId == Filter.Id) let ch = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0 select new { p.PeopleId, Name2 = ch ? p.AltName : p.Name2, BirthDate = Person.FormatBirthday( p.BirthYr, p.BirthMonth, p.BirthDay, p.PeopleId), MemberTypeCode = om == null ? "Guest" : om.MemberType.Code, ch, highlight = om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == NewMeetingInfo.HighlightGroup) ? NewMeetingInfo.HighlightGroup : "" }; if (q.Any()) { StartPageSet(o); } foreach (var m in q) { table.AddCell(AddRow(m.MemberTypeCode, m.Name2, m.PeopleId, m.BirthDate, m.highlight, m.ch ? china ?? font : font)); } } if ((OrgSearchModel != null && NewMeetingInfo.ByGroup == false) || (Filter != null && Filter.GroupSelect == GroupSelectCode.Member && meeting == null && !Filter.SgFilter.HasValue() && !Filter.NameFilter.HasValue() && !Filter.FilterIndividuals == true && !Filter.FilterTag == true && NewMeetingInfo.ByGroup == false)) { foreach (var m in RollsheetModel.FetchVisitors(o.OrgId, NewMeetingInfo.MeetingDate, true, NewMeetingInfo.UseAltNames)) { if (table.Rows.Count == 0) { StartPageSet(o); } table.AddCell(AddRow(m.VisitorType, m.Name2, m.PeopleId, m.BirthDate, "", boldfont)); } } if (!pageSetStarted) { continue; } var col = 0; var gutter = 20f; var colwidth = (doc.Right - doc.Left - gutter) / 2; var ct = new ColumnText(w.DirectContent); ct.AddElement(table); var status = 0; while (ColumnText.HasMoreText(status)) { if (col == 0) { ct.SetSimpleColumn(doc.Left, doc.Bottom, doc.Left + colwidth, doc.Top); } else { ct.SetSimpleColumn(doc.Right - colwidth, doc.Bottom, doc.Right, doc.Top); } status = ct.Go(); ++col; if (col > 1) { col = 0; doc.NewPage(); } } } if (!hasRows) { if (!pageSetStarted) { StartPageSet(lasto); } doc.Add(new Paragraph("no members as of this meeting date and time to show on rollsheet")); } doc.Close(); }
public override void ExecuteResult(ControllerContext context) { var Response = context.HttpContext.Response; CmsData.Meeting meeting = null; if (meetingid.HasValue) { meeting = DbUtil.Db.Meetings.Single(mt => mt.MeetingId == meetingid); dt = meeting.MeetingDate; orgid = meeting.OrganizationId; } var list1 = bygroup == true?ReportList2().ToList() : ReportList().ToList(); if (!list1.Any()) { Response.Write("no data found"); return; } if (!dt.HasValue) { Response.Write("bad date"); return; } Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "filename=foo.pdf"); doc = new Document(PageSize.LETTER.Rotate(), 36, 36, 64, 64); var w = PdfWriter.GetInstance(doc, Response.OutputStream); w.PageEvent = pageEvents; doc.Open(); dc = w.DirectContent; box = new PdfPCell(); box.Border = PdfPCell.NO_BORDER; box.CellEvent = new CellEvent(); PdfPTable table = null; OrgInfo lasto = null; foreach (var o in list1) { lasto = o; table = new PdfPTable(1); table.DefaultCell.Border = PdfPCell.NO_BORDER; table.DefaultCell.Padding = 0; table.WidthPercentage = 100; if (meeting != null) { var Groups = o.Groups; if (Groups[0] == 0) { var q = from at in meeting.Attends where at.AttendanceFlag == true || at.Commitment == AttendCommitmentCode.Attending || at.Commitment == AttendCommitmentCode.Substitute orderby at.Person.LastName, at.Person.FamilyId, at.Person.Name2 select new { at.MemberType.Code, Name2 = (altnames == true && at.Person.AltName != null && at.Person.AltName.Length > 0) ? at.Person.AltName : at.Person.Name2, at.PeopleId, at.Person.DOB, }; if (q.Any()) { StartPageSet(o); } foreach (var a in q) { table.AddCell(AddRow(a.Code, a.Name2, a.PeopleId, a.DOB, "", font)); } } else { var q = from at in meeting.Attends let om = at.Organization.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == at.PeopleId) let gc = om.OrgMemMemTags.Count(mt => Groups.Contains(mt.MemberTagId)) where gc == Groups.Length || Groups[0] <= 0 where gc > 0 where !Groups.Contains(-1) || (Groups.Contains(-1) && om.OrgMemMemTags.Count() == 0) where at.AttendanceFlag == true || at.Commitment == AttendCommitmentCode.Attending || at.Commitment == AttendCommitmentCode.Substitute orderby at.Person.LastName, at.Person.FamilyId, at.Person.Name2 select new { at.MemberType.Code, Name2 = (altnames == true && at.Person.AltName != null && at.Person.AltName.Length > 0) ? at.Person.AltName : at.Person.Name2, at.PeopleId, at.Person.DOB, }; if (q.Any()) { StartPageSet(o); } foreach (var a in q) { table.AddCell(AddRow(a.Code, a.Name2, a.PeopleId, a.DOB, "", font)); } } } else { var Groups = o.Groups; if (Groups == null) { Groups = new int[] { 0 } } ; var q = from om in DbUtil.Db.OrganizationMembers where om.OrganizationId == o.OrgId let gc = om.OrgMemMemTags.Count(mt => Groups.Contains(mt.MemberTagId)) where gc == Groups.Length || Groups[0] <= 0 where !Groups.Contains(-1) || (Groups.Contains(-1) && om.OrgMemMemTags.Count() == 0) where (om.Pending ?? false) == false where om.MemberTypeId != MemberTypeCode.InActive where om.MemberTypeId != MemberTypeCode.Prospect where om.EnrollmentDate <= Util.Now orderby om.Person.LastName, om.Person.FamilyId, om.Person.Name2 let p = om.Person let ch = altnames == true && p.AltName != null && p.AltName.Length > 0 select new { PeopleId = p.PeopleId, Name2 = ch ? p.AltName : p.Name2, BirthDate = Util.FormatBirthday( p.BirthYear, p.BirthMonth, p.BirthDay), MemberTypeCode = om.MemberType.Code, ch, highlight = om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == highlightsg) ? highlightsg : "" }; if (q.Any()) { StartPageSet(o); } foreach (var m in q) { table.AddCell(AddRow(m.MemberTypeCode, m.Name2, m.PeopleId, m.BirthDate, m.highlight, m.ch ? china : font)); } } if (bygroup == false && groups[0] == 0 && meeting == null) { foreach (var m in RollsheetModel.FetchVisitors(o.OrgId, dt.Value, NoCurrentMembers: true, UseAltNames: altnames == true)) { if (table.Rows.Count == 0) { StartPageSet(o); } table.AddCell(AddRow(m.VisitorType, m.Name2, m.PeopleId, m.BirthDate, "", boldfont)); } } if (!pageSetStarted) { continue; } var col = 0; float gutter = 20f; float colwidth = (doc.Right - doc.Left - gutter) / 2; var ct = new ColumnText(w.DirectContent); ct.AddElement(table); int status = 0; while (ColumnText.HasMoreText(status)) { if (col == 0) { ct.SetSimpleColumn(doc.Left, doc.Bottom, doc.Left + colwidth, doc.Top); } else { ct.SetSimpleColumn(doc.Right - colwidth, doc.Bottom, doc.Right, doc.Top); } status = ct.Go(); ++col; if (col > 1) { col = 0; doc.NewPage(); } } // foreach (var li in list) // { // y = ct.YLine; // ct.AddElement(li); // status = ct.Go(true); // if (ColumnText.HasMoreText(status)) // { // ++col; // if (col > 1) // { // col = 0; // doc.NewPage(); // } // ct.SetSimpleColumn(cols[col]); // y = doc.Top; // } // ct.YLine = y; // ct.SetText(null); // ct.AddElement(li); // status = ct.Go(); // } } if (!hasRows) { if (!pageSetStarted) { StartPageSet(lasto); } doc.Add(new Paragraph("no members as of this meeting date and time to show on rollsheet")); } doc.Close(); }