Пример #1
0
 public void EmailFinanceInformation(MailAddress fromaddress, Person p, List<MailAddress> list, string subject, string body)
 {
     var emailqueue = new EmailQueue
     {
         Queued = DateTime.Now,
         FromAddr = fromaddress.Address,
         FromName = fromaddress.DisplayName,
         Subject = subject,
         Body = body,
         QueuedBy = Util.UserPeopleId,
         Transactional = true,
         FinanceOnly = true
     };
     EmailQueues.InsertOnSubmit(emailqueue);
     string addmailstr = null;
     if (list != null)
         addmailstr = list.EmailAddressListToString();
     emailqueue.EmailQueueTos.Add(new EmailQueueTo
     {
         PeopleId = p.PeopleId,
         OrgId = CurrentOrgId,
         AddEmail = addmailstr,
         Guid = Guid.NewGuid(),
     });
     SubmitChanges();
     SendPersonEmail(emailqueue.Id, p.PeopleId);
 }
Пример #2
0
        public void EmailFinanceInformation(MailAddress fromaddress, Person p, List <MailAddress> list, string subject, string body)
        {
            var emailqueue = new EmailQueue
            {
                Queued        = DateTime.Now,
                FromAddr      = fromaddress.Address,
                FromName      = fromaddress.DisplayName,
                Subject       = subject,
                Body          = body,
                QueuedBy      = Util.UserPeopleId,
                Transactional = true,
                FinanceOnly   = true
            };

            EmailQueues.InsertOnSubmit(emailqueue);
            string addmailstr = null;

            if (list != null)
            {
                addmailstr = list.EmailAddressListToString();
            }
            emailqueue.EmailQueueTos.Add(new EmailQueueTo
            {
                PeopleId = p.PeopleId,
                OrgId    = CurrentOrgId,
                AddEmail = addmailstr,
                Guid     = Guid.NewGuid(),
            });
            SubmitChanges();
            SendPersonEmail(emailqueue.Id, p.PeopleId);
        }
Пример #3
0
        public EmailQueue CreateQueueForOrg(MailAddress from, string subject, string body, DateTime?schedule, int orgid, bool publicViewable, string cclist = null)
        {
            var emailqueue = new EmailQueue
            {
                Queued        = Util.Now,
                FromAddr      = from.Address,
                FromName      = from.DisplayName,
                Subject       = subject,
                Body          = body,
                SendWhen      = schedule,
                QueuedBy      = Util.UserPeopleId,
                Transactional = false,
                PublicX       = publicViewable,
                SendFromOrgId = orgid,
                CClist        = cclist
            };

            EmailQueues.InsertOnSubmit(emailqueue);
            SubmitChanges();

            if (body.Contains("http://publiclink", ignoreCase: true))
            {
                var link = ServerLink("/EmailView/" + emailqueue.Id);
                var re   = new Regex("http://publiclink", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
                emailqueue.Body = re.Replace(body, link);
            }
            SubmitChanges();
            return(emailqueue);
        }
Пример #4
0
 public void Email(MailAddress From, Person p, List<MailAddress> addmail, string subject, string body, bool redacted)
 {
     var emailqueue = new EmailQueue
     {
         Queued = DateTime.Now,
         FromAddr = From.Address,
         FromName = From.DisplayName,
         Subject = subject,
         Body = body,
         QueuedBy = Util.UserPeopleId,
         Redacted = redacted,
         Transactional = true
     };
     EmailQueues.InsertOnSubmit(emailqueue);
     string addmailstr = null;
     if (addmail != null)
         addmailstr = addmail.EmailAddressListToString();
     emailqueue.EmailQueueTos.Add(new EmailQueueTo
     {
         PeopleId = p.PeopleId,
         OrgId = CurrentOrgId,
         AddEmail = addmailstr,
         Guid = Guid.NewGuid(),
     });
     SubmitChanges();
     SendPersonEmail(emailqueue.Id, p.PeopleId);
 }
Пример #5
0
        public void Email(MailAddress fromAddress, Person p, List <MailAddress> addmail, string subject, string body, bool redacted = false)
        {
            var emailqueue = new EmailQueue
            {
                Queued        = Util.Now,
                FromAddr      = fromAddress.Address,
                FromName      = fromAddress.DisplayName,
                Subject       = subject,
                Body          = body,
                QueuedBy      = Util.UserPeopleId,
                Redacted      = redacted,
                Transactional = true
            };

            EmailQueues.InsertOnSubmit(emailqueue);
            string addmailstr = null;

            if (addmail != null)
            {
                addmailstr = addmail.EmailAddressListToString();
            }
            emailqueue.EmailQueueTos.Add(new EmailQueueTo
            {
                PeopleId = p.PeopleId,
                OrgId    = Util2.CurrentOrgId,
                AddEmail = addmailstr,
                Guid     = Guid.NewGuid(),
            });
            SubmitChanges();
            SendPersonEmail(emailqueue.Id, p.PeopleId);
        }
Пример #6
0
        public EmailQueue CreateQueue(int? queuedBy, MailAddress from, string subject, string body, DateTime? schedule, int tagId, bool publicViewable, int? goerSupporterId = null)
        {
            var tag = TagById(tagId);
            if (tag == null)
                return null;

            var emailqueue = new EmailQueue
            {
                Queued = DateTime.Now,
                FromAddr = from.Address,
                FromName = from.DisplayName,
                Subject = subject,
                Body = body,
                SendWhen = schedule,
                QueuedBy = queuedBy,
                Transactional = false,
                PublicX = publicViewable,
            };
            EmailQueues.InsertOnSubmit(emailqueue);
            SubmitChanges();

            if (body.Contains("{tracklinks}", true))
            {
                body = body.Replace("{tracklinks}", "", ignoreCase: true);
                emailqueue.Body = createClickTracking(emailqueue.Id, body);
                SubmitChanges();
            }

            if (body.Contains("http://publiclink", ignoreCase: true))
            {
                var link = Util.URLCombine(CmsHost, "/EmailView/" + emailqueue.Id);
                var re = new Regex("http://publiclink", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
                emailqueue.Body = re.Replace(body, link);
            }

            var q = tag.People(this);

            var q2 = from p in q.Distinct()
                     where p.EmailAddress != null
                     where p.EmailAddress != ""
                     where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                     where p.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr)
                     orderby p.PeopleId
                     select p.PeopleId;

            foreach (var pid in q2)
            {
                emailqueue.EmailQueueTos.Add(new EmailQueueTo
                {
                    PeopleId = pid,
                    OrgId = CurrentOrgId,
                    Guid = Guid.NewGuid(),
                    GoerSupportId = goerSupporterId,
                });
            }
            SubmitChanges();
            return emailqueue;
        }
Пример #7
0
        public EmailQueue CreateQueue(int?queuedBy, MailAddress from, string subject, string body, DateTime?schedule, int tagId, bool publicViewable)
        {
            var tag = TagById(tagId);

            if (tag == null)
            {
                return(null);
            }

            var emailqueue = new EmailQueue
            {
                Queued        = DateTime.Now,
                FromAddr      = from.Address,
                FromName      = from.DisplayName,
                Subject       = subject,
                Body          = body,
                SendWhen      = schedule,
                QueuedBy      = queuedBy,
                Transactional = false,
                PublicX       = publicViewable,
            };

            EmailQueues.InsertOnSubmit(emailqueue);

            SubmitChanges();
            if (body.Contains("http://publiclink", ignoreCase: true))
            {
                var link = Util.URLCombine(CmsHost, "/Manage/Emails/View/" + emailqueue.Id);
                var re   = new Regex("http://publiclink", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
                emailqueue.Body = re.Replace(body, link);
            }

            var q = tag.People(this);

            var q2 = from p in q.Distinct()
                     where p.EmailAddress != null
                     where p.EmailAddress != ""
                     where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                     where p.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr)
                     orderby p.PeopleId
                     select p.PeopleId;

            var i = 0;

            foreach (var pid in q2)
            {
                i++;
                emailqueue.EmailQueueTos.Add(new EmailQueueTo
                {
                    PeopleId = pid,
                    OrgId    = CurrentOrgId,
                    Guid     = Guid.NewGuid()
                });
            }
            SubmitChanges();
            return(emailqueue);
        }
Пример #8
0
        private string DoClickTracking(EmailQueue emailqueue)
        {
            var body = emailqueue.Body;

            if (body.Contains("{tracklinks}", true))
            {
                body = body.Replace("{tracklinks}", "", ignoreCase: true);
                body = CreateClickTracking(emailqueue.Id, body);
            }
            return(body);
        }
Пример #9
0
        private string DoClickTracking(EmailQueue emailqueue)
        {
            var body = emailqueue.Body;

            if (body.Contains("{tracklinks}", true))
            {
                body = body.Replace("{tracklinks}", "", ignoreCase: true);
                if (ConfigurationManager.AppSettings["UseClickTracking"].ToBool())
                {
                    body = CreateClickTracking(emailqueue.Id, body);
                }
            }
            return(body);
        }
Пример #10
0
        public EmailQueue CreateQueueForSupporters(int?queuedBy, MailAddress from, string subject, string body, DateTime?schedule, List <GoerSupporter> list, bool publicViewable)
        {
            var emailqueue = new EmailQueue
            {
                Queued        = Util.Now,
                FromAddr      = from.Address,
                FromName      = from.DisplayName,
                Subject       = subject,
                Body          = body,
                SendWhen      = schedule,
                QueuedBy      = queuedBy,
                Transactional = false,
                PublicX       = publicViewable,
            };

            EmailQueues.InsertOnSubmit(emailqueue);
            SubmitChanges();

            var q2 = from g in list
                     where g.SupporterId != null
                     where g.Supporter.EmailAddress != null
                     where g.Supporter.EmailAddress != ""
                     where (g.Supporter.SendEmailAddress1 ?? true) || (g.Supporter.SendEmailAddress2 ?? false)
                     where g.Supporter.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr)
                     orderby g.SupporterId
                     select g;

            foreach (var g in q2)
            {
                emailqueue.EmailQueueTos.Add(new EmailQueueTo
                {
                    PeopleId      = g.SupporterId ?? 0,
                    OrgId         = Util2.CurrentOrgId,
                    Guid          = Guid.NewGuid(),
                    GoerSupportId = g.Id,
                });
            }
            SubmitChanges();
            return(emailqueue);
        }
Пример #11
0
 public ActionResult ViewEmail(int emailid)
 {
     var email = DbUtil.Db.EmailQueues.SingleOrDefault(ee => ee.Id == emailid);
     if (email == null)
         return Content("no email found");
     var curruser = DbUtil.Db.LoadPersonById(Util.UserPeopleId ?? 0);
     if (curruser == null)
         return Content("no user");
     if (User.IsInRole("Admin")
         || User.IsInRole("ManageEmails")
         || email.FromAddr == curruser.EmailAddress
         || email.QueuedBy == curruser.PeopleId
         || email.EmailQueueTos.Any(et => et.PeopleId == curruser.PeopleId))
     {
         var em = new EmailQueue
         {
             Subject = email.Subject,
             Body = Regex.Replace(email.Body, "({first}|{tracklinks}|{track})", "", RegexOptions.IgnoreCase)
         };
         return View("Emails/View", em);
     }
     return Content("not authorized");
 }
Пример #12
0
        public EmailQueue CreateQueue(int?queuedBy, MailAddress from, string subject, string body, DateTime?schedule, int tagId, bool publicViewable, int?goerSupporterId = null, bool?ccParents = null, string cclist = null)
        {
            var tag = TagById(tagId);

            if (tag == null)
            {
                return(null);
            }

            var emailqueue = new EmailQueue
            {
                Queued        = Util.Now,
                FromAddr      = from.Address,
                FromName      = from.DisplayName,
                Subject       = subject,
                Body          = body,
                SendWhen      = schedule,
                QueuedBy      = queuedBy,
                Transactional = false,
                PublicX       = publicViewable,
                CCParents     = ccParents,
                CClist        = cclist,
                Testing       = Util.IsInRoleEmailTest,
                ReadyToSend   = false, // wait until all individual emailqueueto records are created.
            };

            EmailQueues.InsertOnSubmit(emailqueue);
            SubmitChanges();

            if (body.Contains("http://publiclink", ignoreCase: true))
            {
                var link = ServerLink("/EmailView/" + emailqueue.Id);
                var re   = new Regex("http://publiclink",
                                     RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
                emailqueue.Body = re.Replace(body, link);
            }

            var q = tag.People(this);

            IQueryable <int> q2 = null;

            if (emailqueue.CCParents == true)
            {
                q2 = from p in q.Distinct()
                     where (p.EmailAddress ?? "") != "" ||
                     (p.Family.HeadOfHousehold.EmailAddress ?? "") != "" ||
                     (p.Family.HeadOfHouseholdSpouse.EmailAddress ?? "") != ""
                     where (p.SendEmailAddress1 ?? true) ||
                     (p.SendEmailAddress2 ?? false) ||
                     (p.Family.HeadOfHousehold.SendEmailAddress1 ?? false) ||
                     (p.Family.HeadOfHousehold.SendEmailAddress2 ?? false) ||
                     (p.Family.HeadOfHouseholdSpouse.SendEmailAddress1 ?? false) ||
                     (p.Family.HeadOfHouseholdSpouse.SendEmailAddress2 ?? false)
                     where p.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr)
                     orderby p.PeopleId
                     select p.PeopleId;
            }
            else
            {
                q2 = from p in q.Distinct()
                     where p.EmailAddress != null
                     where p.EmailAddress != ""
                     where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                     where p.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr)
                     orderby p.PeopleId
                     select p.PeopleId;
            }

            foreach (var pid in q2)
            {
                emailqueue.EmailQueueTos.Add(new EmailQueueTo
                {
                    PeopleId      = pid,
                    OrgId         = Util2.CurrentOrgId,
                    Guid          = Guid.NewGuid(),
                    GoerSupportId = goerSupporterId,
                });
            }
            emailqueue.ReadyToSend = true;
            SubmitChanges();
            return(emailqueue);
        }
Пример #13
0
        public EmailQueue CreateQueueForOrg(MailAddress from, string subject, string body, DateTime? schedule, int orgid, bool publicViewable, string cclist = null)
        {
            var emailqueue = new EmailQueue
            {
                Queued = DateTime.Now,
                FromAddr = from.Address,
                FromName = from.DisplayName,
                Subject = subject,
                Body = body,
                SendWhen = schedule,
                QueuedBy = Util.UserPeopleId,
                Transactional = false,
                PublicX = publicViewable,
                SendFromOrgId = orgid,
                CClist = cclist
            };
            EmailQueues.InsertOnSubmit(emailqueue);
            SubmitChanges();

            if (body.Contains("http://publiclink", ignoreCase: true))
            {
                var link = ServerLink("/EmailView/" + emailqueue.Id);
                var re = new Regex("http://publiclink", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
                emailqueue.Body = re.Replace(body, link);
            }
            SubmitChanges();
            return emailqueue;
        }
Пример #14
0
        public EmailQueue CreateQueue(int? queuedBy, MailAddress from, string subject, string body, DateTime? schedule, int tagId, bool publicViewable, int? goerSupporterId = null, bool? ccParents = null, string cclist = null)
        {
            var tag = TagById(tagId);
            if (tag == null)
                return null;

            using (var tran = new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromSeconds(1200)))
            {
                var emailqueue = new EmailQueue
                {
                    Queued = DateTime.Now,
                    FromAddr = from.Address,
                    FromName = from.DisplayName,
                    Subject = subject,
                    Body = body,
                    SendWhen = schedule,
                    QueuedBy = queuedBy,
                    Transactional = false,
                    PublicX = publicViewable,
                    CCParents = ccParents,
                    CClist = cclist
                };
                EmailQueues.InsertOnSubmit(emailqueue);
                SubmitChanges();

                if (body.Contains("http://publiclink", ignoreCase: true))
                {
                    var link = ServerLink("/EmailView/" + emailqueue.Id);
                    var re = new Regex("http://publiclink",
                        RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
                    emailqueue.Body = re.Replace(body, link);
                }

                var q = tag.People(this);

                IQueryable<int> q2 = null;
                if (emailqueue.CCParents == true)
                    q2 = from p in q.Distinct()
                         where (p.EmailAddress ?? "") != ""
                               || (p.Family.HeadOfHousehold.EmailAddress ?? "") != ""
                               || (p.Family.HeadOfHouseholdSpouse.EmailAddress ?? "") != ""
                         where (p.SendEmailAddress1 ?? true)
                               || (p.SendEmailAddress2 ?? false)
                               || (p.Family.HeadOfHousehold.SendEmailAddress1 ?? false)
                               || (p.Family.HeadOfHousehold.SendEmailAddress2 ?? false)
                               || (p.Family.HeadOfHouseholdSpouse.SendEmailAddress1 ?? false)
                               || (p.Family.HeadOfHouseholdSpouse.SendEmailAddress2 ?? false)
                         where p.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr)
                         orderby p.PeopleId
                         select p.PeopleId;
                else
                    q2 = from p in q.Distinct()
                         where p.EmailAddress != null
                         where p.EmailAddress != ""
                         where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                         where p.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr)
                         orderby p.PeopleId
                         select p.PeopleId;

                foreach (var pid in q2)
                {
                    emailqueue.EmailQueueTos.Add(new EmailQueueTo
                    {
                        PeopleId = pid,
                        OrgId = CurrentOrgId,
                        Guid = Guid.NewGuid(),
                        GoerSupportId = goerSupporterId,
                    });
                }
                SubmitChanges();
                tran.Complete();
                return emailqueue;
            }
        }
Пример #15
0
		private void detach_EmailQueues(EmailQueue entity)
		{
			this.SendPropertyChanging();
			entity.Person = null;
		}
Пример #16
0
 private string DoClickTracking(EmailQueue emailqueue)
 {
     var body = emailqueue.Body;
     if (body.Contains("{tracklinks}", true))
     {
         body = body.Replace("{tracklinks}", "", ignoreCase: true);
         body = createClickTracking(emailqueue.Id, body);
     }
     return body;
 }
Пример #17
0
        public ActionResult ViewEmail(int emailid)
        {
            var q = from e in DbUtil.Db.EmailQueues
                where e.Id == emailid
                let isAdmin = User.IsInRole("Admin")
                let isPublic = (e.PublicX ?? false)
                let p = DbUtil.Db.People.Single(pp => pp.PeopleId == Util.UserPeopleId)
                let isSender = e.QueuedBy == Util.UserPeopleId
                               || (e.FromAddr == p.EmailAddress && p.EmailAddress.Length > 0)
                               || (e.FromAddr == p.EmailAddress2 && p.EmailAddress2.Length > 0)
                let isReceiver = e.EmailQueueTos.Any(ee => ee.PeopleId == Util.UserPeopleId)
                select new {e, isAdmin, isSender, isPublic };

            var i = q.SingleOrDefault();
            if (i == null)
                return Content("email document not found");

            var em = new EmailQueue
            {
                Subject = i.e.Subject,
                Body = i.e.Body.Replace("{track}", "", ignoreCase: true).Replace("{first}", "", ignoreCase: true)
            };
            return View("Emails/View", em);
        }
Пример #18
0
 public ActionResult View(string id)
 {
     var iid = id.ToInt();
     var email = DbUtil.Db.EmailQueues.SingleOrDefault(ee => ee.Id == iid);
     if (email == null)
         return Content("email document not found");
     if ((email.PublicX ?? false) == false)
         return Content("no email available");
     var em = new EmailQueue
     {
         Subject = email.Subject,
         Body = email.Body.Replace("{track}", "", ignoreCase: true).Replace("{first}", "", ignoreCase: true)
     };
     return View(em);
 }
Пример #19
0
		public new ActionResult View(string id)
		{
		    var iid = id.ToInt();
			var email = DbUtil.Db.EmailQueues.SingleOrDefault(ee => ee.Id == iid);
			if (email == null)
				return Content("email document not found");
			if ((email.PublicX ?? false) == false)
				return Content("no email available");
			var em = new EmailQueue
			{
				Subject = email.Subject,
                Body = Regex.Replace(email.Body, "({first}|{tracklinks}|{track})", "", RegexOptions.IgnoreCase)
			};
			return View(em);
		}
Пример #20
0
        public EmailQueue CreateQueueForSupporters(int? queuedBy, MailAddress from, string subject, string body, DateTime? schedule, IQueryable<GoerSupporter> list, bool publicViewable)
        {
            var emailqueue = new EmailQueue
            {
                Queued = DateTime.Now,
                FromAddr = from.Address,
                FromName = from.DisplayName,
                Subject = subject,
                Body = body,
                SendWhen = schedule,
                QueuedBy = queuedBy,
                Transactional = false,
                PublicX = publicViewable,
            };
            EmailQueues.InsertOnSubmit(emailqueue);
            SubmitChanges();

            var q2 = from g in list
                     where g.SupporterId != null
                     where g.Supporter.EmailAddress != null
                     where g.Supporter.EmailAddress != ""
                     where (g.Supporter.SendEmailAddress1 ?? true) || (g.Supporter.SendEmailAddress2 ?? false)
                     where g.Supporter.EmailOptOuts.All(oo => oo.FromEmail != emailqueue.FromAddr)
                     orderby g.SupporterId
                     select g;

            foreach (var g in q2)
            {
                emailqueue.EmailQueueTos.Add(new EmailQueueTo
                {
                    PeopleId = g.SupporterId ?? 0,
                    OrgId = CurrentOrgId,
                    Guid = Guid.NewGuid(),
                    GoerSupportId = g.Id,
                });
            }
            SubmitChanges();
            return emailqueue;
        }