Ejemplo n.º 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();
        }
Ejemplo n.º 2
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();
        }