Exemple #1
0
        public void SendEventReminders(Guid id)
        {
            var org     = Db.LoadOrganizationById(Db.CurrentOrgId0);
            var setting = Db.CreateRegistrationSettings(org.OrganizationId);

            const string noSubject = "no subject";
            const string noBody    = "no body";

            var subject = Util.PickFirst(setting.ReminderSubject, noSubject);
            var message = Util.PickFirst(setting.ReminderBody, noBody);

            if (subject == noSubject || message == noBody)
            {
                throw new Exception("no subject or body");
            }

            var q = from p in Db.PeopleQuery(id)
                    join om in Db.OrganizationMembers on
                    new { p.PeopleId, org.OrganizationId }
            equals new { om.PeopleId, om.OrganizationId } into j
            from om in j
            select om;

            var notify = Db.StaffPeopleForOrg(org.OrganizationId).FirstOrDefault();

            if (notify == null)
            {
                throw new Exception("no notify person");
            }

            var needdetails = message.Contains("{details}");

            foreach (var om in q)
            {
                var details          = needdetails ? SummaryInfo.GetResults(Db, om.PeopleId, om.OrganizationId) : "";
                var organizationName = org.OrganizationName;

                subject = Util.PickFirst(setting.ReminderSubject, noSubject);
                message = Util.PickFirst(setting.ReminderBody, noBody);

                string location = org.Location;
                message = MessageReplacements(Db, om.Person, null, org.OrganizationId, organizationName, location, message);

                message = message.Replace("{phone}", org.PhoneNumber.FmtFone7());
                if (details.HasValue())
                {
                    message = message.Replace("{details}", details);
                }

                Db.Email(notify.FromEmail, om.Person, subject, message);
            }
        }
Exemple #2
0
        public void SendEventReminders(int id)
        {
            var org = Db.LoadOrganizationById(id);

            Db.SetCurrentOrgId(id);
            var setting = Db.CreateRegistrationSettings(id);

            const string noSubject = "no subject";
            const string noBody    = "no body";

            var subject = Util.PickFirst(setting.ReminderSubject, noSubject);
            var message = Util.PickFirst(setting.ReminderBody, noBody);

            if (subject == noSubject || message == noBody)
            {
                throw new Exception("no subject or body");
            }

            var currmembers = from om in org.OrganizationMembers
                              where (om.Pending ?? false) == false
                              where om.MemberTypeId != CmsData.Codes.MemberTypeCode.InActive
                              select om;
            var notify = Db.StaffPeopleForOrg(org.OrganizationId).FirstOrDefault();

            if (notify == null)
            {
                throw new Exception("no notify person");
            }

            foreach (var om in currmembers)
            {
                var si               = new SummaryInfo(Db, om.PeopleId, om.OrganizationId);
                var details          = si.ToString();
                var organizationName = org.OrganizationName;

                subject = Util.PickFirst(setting.ReminderSubject, noSubject);
                message = Util.PickFirst(setting.ReminderBody, noBody);

                string location = org.Location;
                message = MessageReplacements(Db, om.Person, null, org.OrganizationId, organizationName, location, message);

                message = message.Replace("{phone}", org.PhoneNumber.FmtFone7());
                message = message.Replace("{details}", details);

                Db.Email(notify.FromEmail, om.Person, subject, message);
            }
        }