Пример #1
0
 private static string RecentVisitsEmail(OrgSearchController c, IEnumerable<OrgVisitorsAsOfDate> list)
 {
     var q = from p in list
             orderby p.LastAttended, p.LastName, p.PreferredName
             select p;
     return ViewExtensions2.RenderPartialViewToString(c, "RecentVisitsEmail", q);
 }
Пример #2
0
 public void SendNotices(OrgSearchController c)
 {
     var leaders = NoticesToSend(c);
     foreach (var leader in leaders)
     {
         DbUtil.Db.Email(DbUtil.Db.CurrentUser.Person.FromEmail, leader.Key, null,
             DbUtil.Db.Setting("SubjectAttendanceNotices", "Attendance reports are ready for viewing"), leader.Value, false);
     }
     DbUtil.Db.Email(DbUtil.Db.CurrentUser.Person.FromEmail, DbUtil.Db.CurrentUser.Person, null,
         "Attendance emails sent", noticelist, false);
 }
Пример #3
0
 private static string RecentAbsentsEmail(OrgSearchController c, IEnumerable<RecentAbsent> list)
 {
     var q = from p in list
             orderby p.Consecutive, p.Name2
             select p;
     return ViewExtensions2.RenderPartialViewToString(c, "RecentAbsentsEmail", q);
 }
Пример #4
0
        public Dictionary<Person, string> NoticesToSend(OrgSearchController c)
        {
            var leaderNotices = new Dictionary<Person, string>();

            const int days = 36;

            var olist = FetchOrgs().Select(oo => oo.OrganizationId).ToList();

            var alist = (from p in DbUtil.Db.RecentAbsents(null, null, days)
                         where olist.Contains(p.OrganizationId)
                         select p).ToList();

            var mlist = (from r in DbUtil.Db.LastMeetings(null, null, days)
                         where olist.Contains(r.OrganizationId)
                         select r).ToList();

            var plist = (from om in DbUtil.Db.ViewOrganizationLeaders
                         where olist.Contains(om.OrganizationId)
                         group om.OrganizationId by om.PeopleId
                         into leaderlist
                         select leaderlist).ToList();

            var sb2 = new StringBuilder("Notices sent to:</br>\n<table>\n");
            foreach (var p in plist)
            {
                var sb = new StringBuilder("The following meetings are ready to be viewed:<br/>\n");
                var orgids = p.ToList();
                var meetings = mlist.Where(m => orgids.Contains(m.OrganizationId)).ToList();
                var leader = DbUtil.Db.LoadPersonById(p.Key);
                foreach (var m in meetings)
                {
                    var orgname = Organization.FormatOrgName(m.OrganizationName, m.LeaderName, m.Location);
                    sb.AppendFormat("<a href='{0}'>{1} - {2}</a><br/>\n",
                        DbUtil.Db.ServerLink("/Meeting/" + m.MeetingId),
                        orgname, m.Lastmeeting.FormatDateTm());
                    sb2.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2:g}</td></tr>\n",
                        leader.Name, orgname, m.Lastmeeting.FormatDateTm());
                }
                foreach (var m in meetings)
                {
                    var absents = alist.Where(a => a.OrganizationId == m.OrganizationId);
                    var vlist = DbUtil.Db.OrgVisitorsAsOfDate(m.OrganizationId, m.Lastmeeting, true).ToList();
                    sb.Append(RecentAbsentsEmail(c, absents));
                    sb.Append(RecentVisitsEmail(c, vlist));
                }
                leaderNotices.Add(leader, sb.ToString());
            }
            sb2.Append("</table>\n");
            noticelist = sb2.ToString();
            return leaderNotices;
        }