Пример #1
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;

            var list1 = ReportList(orgid, div, schedule, name);

            if (list1.Count() == 0)
            {
                Response.Write("no data found");
                return;
            }
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");

            doc = new Document(PageSize.LETTER, 36, 36, 36, 36);
            var w = PdfWriter.GetInstance(doc, Response.OutputStream);

            w.PageEvent = pageEvents;
            doc.Open();
            dc = w.DirectContent;

            foreach (var o in list1)
            {
                var t = StartPageSet(o);

                var color = BaseColor.BLACK;
                foreach (var m in RollsheetModel.FetchOrgMembers(o.OrgId, null)
                         .Where(om => om.MemberTypeId != MemberTypeCode.Member))
                {
                    if (color == BaseColor.WHITE)
                    {
                        color = new GrayColor(240);
                    }
                    else
                    {
                        color = BaseColor.WHITE;
                    }
                    AddRow(t,
                           m.PeopleId,
                           m.Name,
                           m.Email,
                           m.HomePhone,
                           m.CellPhone,
                           m.WorkPhone,
                           m.MemberType,
                           color);
                }
                doc.Add(t);
            }
            pageEvents.EndPageSet();
            doc.Close();
        }
Пример #2
0
        private void AddRow(PdfPTable t, RollsheetModel.PersonMemberInfo p, BaseColor color)
        {
            t.DefaultCell.BackgroundColor = color;

            var c = new Phrase();
            c.Add(new Chunk(p.Name, boldfont));
            c.Add(new Chunk("  ({0})\n".Fmt(p.PeopleId), smallfont));
            var sb = new StringBuilder();
            AddLine(sb, p.Address);
            AddLine(sb, p.Address2);
            AddLine(sb, p.CityStateZip);
            c.Add(new Chunk(sb.ToString(), font));
            t.AddCell(c);

            sb = new StringBuilder();
            AddPhone(sb, p.HomePhone, "h ");
            AddPhone(sb, p.CellPhone, "c ");
            AddPhone(sb, p.WorkPhone, "w ");
            AddLine(sb, p.Email);
            t.AddCell(new Phrase(sb.ToString(), font));

            t.AddCell(new Phrase(p.MemberType));
        }
Пример #3
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;

            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");

            doc = new Document(PageSize.LETTER, 36, 36, 64, 64);
            var w = PdfWriter.GetInstance(doc, Response.OutputStream);

            w.PageEvent = pageEvents;
            doc.Open();

            dc = w.DirectContent;

            if (qid.HasValue)
            {
                var o = list(org, null, null).First();
                StartPageSet(o);
                var q  = DbUtil.Db.PeopleQuery(qid.Value);
                var q2 = from p in q
                         join m in RollsheetModel.FetchOrgMembers(o.OrgId, null) on p.PeopleId equals m.PeopleId into j
                         from m in j.DefaultIfEmpty()
                         orderby p.Name2
                         select new
                {
                    p.Name,
                    MembertypeCode = (m == null ? "V" : m.MemberTypeCode),
                    p.PeopleId,
                };
                foreach (var i in q2)
                {
                    AddRow(i.MembertypeCode, i.Name, i.PeopleId, font);
                }
                if (t.Rows.Count > 1)
                {
                    doc.Add(t);
                }
                else
                {
                    doc.Add(new Phrase("no data"));
                }
            }
            else
            {
                foreach (var o in list(org, div, schedule))
                {
                    var q = from m in RollsheetModel.FetchOrgMembers(o.OrgId, null)
                            orderby m.Name2
                            select new
                    {
                        m.Name2,
                        m.MemberType,
                        m.PeopleId,
                    };
                    if (q.Count() == 0)
                    {
                        continue;
                    }
                    StartPageSet(o);
                    foreach (var i in q)
                    {
                        ;
                    }

                    if (t.Rows.Count > 1)
                    {
                        doc.Add(t);
                    }
                    else
                    {
                        doc.Add(new Phrase("no data"));
                    }
                }
            }
            if (!pagesetstarted)
            {
                w.PageEvent = null;
                doc.Add(new Phrase("no data"));
            }
            pageEvents.EndPageSet();
            doc.Close();
        }
Пример #4
0
        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;
            }

            IEnumerable <OrgInfo> list1;

            if (bygroup == true)
            {
                list1 = ReportList2(orgid, pid, div, schedule, name, sgprefix);
            }
            else
            {
                list1 = ReportList(orgid, groups, pid, div, schedule, name);
            }

            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();
            List <PdfPTable> list = null;

            foreach (var o in list1)
            {
                list = new List <PdfPTable>();
                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.Count() > 0)
                        {
                            StartPageSet(o);
                        }
                        foreach (var a in q)
                        {
                            list.Add(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.Count() > 0)
                        {
                            StartPageSet(o);
                        }
                        foreach (var a in q)
                        {
                            list.Add(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.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.Count() > 0)
                    {
                        StartPageSet(o);
                    }
                    foreach (var m in q)
                    {
                        list.Add(AddRow(m.MemberTypeCode, m.Name2, m.PeopleId, m.BirthDate, m.highlight, m.ch ? china : font));
                    }
                }

                if (bygroup == false && groups[0] == 0 && meeting == null)
                {
                    if (!pageSetStarted)
                    {
                        StartPageSet(o);
                    }
                    foreach (var m in RollsheetModel.FetchVisitors(o.OrgId, dt.Value, NoCurrentMembers: true, UseAltNames: altnames == true))
                    {
                        list.Add(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   cols     = new Rectangle[]
                {
                    new Rectangle(doc.Left, doc.Bottom, doc.Left + colwidth, doc.Top),
                    new Rectangle(doc.Right - colwidth, doc.Bottom, doc.Right, doc.Top)
                };
                var ct = new ColumnText(dc);
                ct.SetSimpleColumn(cols[0]);
                int   status = 0;
                float y;
                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)
            {
                doc.Add(new Paragraph("no members as of this meeting date and time to show on rollsheet"));
            }
            doc.Close();
        }