Пример #1
0
        public ActionResult RollsheetForOrg(Guid queryid, NewMeetingInfo mi)
        {
            if (mi.UseWord == true)
            {
                return(new DocXRollsheetResult {
                    QueryId = queryid, NewMeetingInfo = mi
                });
            }

            return(new RollsheetResult {
                QueryId = queryid, NewMeetingInfo = mi
            });
        }
Пример #2
0
        public ActionResult Rollsheets(NewMeetingInfo mi, OrgSearchModel m)
        {
            if (mi.UseWord == true)
            {
                return(new DocXRollsheetResult {
                    OrgSearchModel = m, NewMeetingInfo = mi
                });
            }

            return(new RollsheetResult {
                OrgSearchModel = m, NewMeetingInfo = mi
            });
        }
Пример #3
0
        public ActionResult ForNewRollsheet(Guid id)
        {
            var filter = CurrentDatabase.OrgFilter(id);
            var oi     = new SettingsAttendanceModel(filter.Id, CurrentDatabase);
            var m      = new NewMeetingInfo()
            {
                MeetingDate  = oi.NextMeetingDate,
                Schedule     = new CodeInfo(0, oi.SchedulesNext()),
                AttendCredit = new CodeInfo(0, oi.AttendCreditList()),
            };

            ViewBag.Action       = "/Reports/RollsheetForOrg/" + id;
            ViewBag.Method       = "POST";
            ViewBag.ForRollsheet = true;
            return(View("MeetingInfo", m));
        }
Пример #4
0
        public ActionResult ForNewRallyRollsheet(int orgid)
        {
            var oi = new SettingsAttendanceModel {
                Id = orgid
            };
            var m = new NewMeetingInfo()
            {
                MeetingDate  = oi.NextMeetingDate,
                Schedule     = new CodeInfo(0, oi.SchedulesNext()),
                AttendCredit = new CodeInfo(0, oi.AttendCreditList()),
            };

            ViewBag.Action = "/Reports/RallyRollsheetForOrg/" + orgid;
            ViewBag.Method = "POST";
            return(View("MeetingInfo", m));
        }
Пример #5
0
        public ActionResult ForNewMeeting(int orgid)
        {
            var oi = new SettingsAttendanceModel()
            {
                Id = orgid
            };
            var m = new NewMeetingInfo()
            {
                MeetingDate  = oi.PrevMeetingDate,
                Schedule     = new CodeInfo(0, oi.SchedulesPrev()),
                AttendCredit = new CodeInfo(0, oi.AttendCreditList()),
            };

            ViewBag.Action = "/CreateNewMeeting/";
            ViewBag.Method = "POST";
            return(View("MeetingInfo", m));
        }
Пример #6
0
        public ActionResult ForNewRallyRollsheet(Guid id)
        {
            var filter = DbUtil.Db.OrgFilter(id);
            var oi     = new SettingsAttendanceModel {
                Id = filter.Id
            };
            var m = new NewMeetingInfo()
            {
                MeetingDate    = oi.NextMeetingDate,
                Schedule       = new CodeInfo(0, oi.SchedulesNext()),
                AttendCredit   = new CodeInfo(0, oi.AttendCreditList()),
                OrganizationId = filter.Id
            };

            ViewBag.Action       = "/Reports/RallyRollsheetForOrg/" + filter.Id;
            ViewBag.Method       = "POST";
            ViewBag.ForRollsheet = false;
            return(View("MeetingInfo", m));
        }
Пример #7
0
        public ActionResult CreateNewMeeting(NewMeetingInfo model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.ForRollsheet = false;
                return(View("MeetingInfo", model));
            }
            var organization = CurrentDatabase.LoadOrganizationById(model.OrganizationId);

            if (organization == null)
            {
                return(Content("error: no org"));
            }

            var mt = CurrentDatabase.Meetings.SingleOrDefault(m => m.MeetingDate == model.MeetingDate &&
                                                              m.OrganizationId == organization.OrganizationId);

            if (mt != null)
            {
                return(Redirect("/Meeting/" + mt.MeetingId));
            }

            mt = new Meeting
            {
                CreatedDate      = Util.Now,
                CreatedBy        = Util.UserId1,
                Description      = Request["DescriptionList.Value"] ?? Request["Description"],
                OrganizationId   = organization.OrganizationId,
                GroupMeetingFlag = model.ByGroup,
                Location         = organization.Location,
                MeetingDate      = model.MeetingDate,
                AttendCreditId   = model.AttendCredit.Value.ToInt(),
                NoAutoAbsents    = !CurrentDatabase.Setting("AttendanceAutoAbsents")
            };
            CurrentDatabase.Meetings.InsertOnSubmit(mt);
            CurrentDatabase.SubmitChanges();
            DbUtil.LogActivity($"Creating new meeting for {organization.OrganizationName}");
            return(Redirect("/Meeting/" + mt.MeetingId));
        }
Пример #8
0
        public ActionResult Rollsheet(string dt, int?bygroup, string sgprefix,
                                      bool?altnames, string highlight, OrgSearchModel m)
        {
            DateTime?dt2 = dt.ToDate();

            if (!dt2.HasValue)
            {
                return(Message("no date"));
            }
            var mi = new NewMeetingInfo()
            {
                ByGroup           = bygroup > 0,
                GroupFilterPrefix = sgprefix,
                UseAltNames       = altnames == true,
                HighlightGroup    = highlight,
                MeetingDate       = dt2.Value
            };

            return(new RollsheetResult
            {
                OrgSearchModel = m,
                NewMeetingInfo = mi
            });
        }
Пример #9
0
        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;
            }

            var bytes = RollsheetTemplate() ?? Resource1.DocxRollsheet;
            var ms    = new MemoryStream(bytes);

            docx         = DocX.Load(ms);
            replacements = new EmailReplacements(DbUtil.Db, docx);
            var sources = new List <Source>();

            foreach (var o in list1)
            {
                curr = docx.Copy();

                foreach (var p in curr.Headers.odd.Paragraphs)
                {
                    DoHeaderFooterParagraphReplacments(p, o);
                }
                foreach (var p in curr.Footers.odd.Paragraphs)
                {
                    DoHeaderFooterParagraphReplacments(p, o);
                }

                var tbl      = curr.Tables[0];
                var emptyrow = tbl.InsertRow();
                tbl.Rows.Add(emptyrow);
                tbl.RemoveRow(0);

                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 RollsheetPersonInfo()
                    {
                        Person         = at.Person,
                        MemberTypeCode = at.MemberType.Code,
                    };
                    foreach (var m in q)
                    {
                        AddRowWithReplacements(tbl, m, meeting.OrganizationId);
                    }
                }
                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 useAltName = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0
                                             select new RollsheetPersonInfo()
                    {
                        Person         = p,
                        MemberTypeCode = om.MemberType.Code,
                        UseAltName     = useAltName,
                        Highlight      = om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == NewMeetingInfo.HighlightGroup)
                                        ? NewMeetingInfo.HighlightGroup
                                        : ""
                    };
                    foreach (var m in q)
                    {
                        AddRowWithReplacements(tbl, m, o.OrgId);
                    }
                }
                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 useAltName = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0
                                             select new RollsheetPersonInfo()
                    {
                        Person         = p,
                        MemberTypeCode = om.MemberType.Code,
                        UseAltName     = useAltName,
                        Highlight      =
                            om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == NewMeetingInfo.HighlightGroup)
                                        ? NewMeetingInfo.HighlightGroup
                                        : ""
                    };
                    foreach (var m in q)
                    {
                        AddRowWithReplacements(tbl, m, o.OrgId);
                    }
                }
                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 useAltName = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0
                                                                       select new RollsheetPersonInfo
                    {
                        Person         = p,
                        MemberTypeCode = om == null ? "Guest" : om.MemberType.Code,
                        UseAltName     = useAltName,
                        Highlight      = om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == NewMeetingInfo.HighlightGroup)
                                    ? NewMeetingInfo.HighlightGroup
                                    : ""
                    };

                    foreach (var m in q)
                    {
                        AddRowWithReplacements(tbl, m, o.OrgId);
                    }
                }
                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))
                {
                    var q = from vp in DbUtil.Db.OrgVisitorsAsOfDate(o.OrgId, NewMeetingInfo.MeetingDate, NoCurrentMembers: true)
                            let p = DbUtil.Db.People.Single(pp => pp.PeopleId == vp.PeopleId)
                                    orderby p.LastName, p.FamilyId, p.PreferredName
                        select new RollsheetPersonInfo {
                        Person = p, MemberTypeCode = vp.VisitorType
                    };
                    foreach (var m in q)
                    {
                        AddRowWithReplacements(tbl, m, o.OrgId);
                    }
                }
                curr.Tables[0].RemoveRow(0);
                {
                    var memStream = new MemoryStream();
                    curr.SaveAs(memStream);
                    memStream.Position = 0;
                    var wmlDocument = new WmlDocument(null, memStream);
                    sources.Add(new Source(wmlDocument, keepSections: true));
                }
            }

            context.HttpContext.Response.Clear();
            context.HttpContext.Response.ContentType =
                "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
            context.HttpContext.Response.AddHeader("Content-Disposition",
                                                   $"attachment;filename=rollsheet.docx");
            var finaldoc = DocumentBuilder.BuildDocument(sources);

            context.HttpContext.Response.OutputStream.Write(finaldoc.DocumentByteArray, 0, finaldoc.DocumentByteArray.Length);
        }
Пример #10
0
 public ActionResult RallyRollsheetForOrg(int orgid, NewMeetingInfo mi)
 {
     return(new RallyRollsheetResult {
         orgid = orgid, NewMeetingInfo = mi
     });
 }
Пример #11
0
        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();
        }