示例#1
0
		private void detach_FK_Supporters(GoerSupporter entity)
		{
			this.SendPropertyChanging();
			entity.Goer = null;
		}
示例#2
0
		private void attach_FK_Goers(GoerSupporter entity)
		{
			this.SendPropertyChanging();
			entity.Supporter = this;
		}
示例#3
0
        private void SendNoDbEmail(Person goer, GoerSupporter gs)
        {
            var from = new MailAddress(goer.EmailAddress ?? goer.EmailAddress2, goer.Name);

            try
            {
                var text = Body;
                //var aa = DbUtil.Db.DoReplacements(ref text, goer, null);

                text = text.Replace("{salutation}", gs.Salutation, true);
                text = text.Replace("{track}", "", true);
                var qs = "OptOut/UnSubscribe/?gid=" + Util.EncryptForUrl($"{gs.Id}");
                var url = DbUtil.Db.ServerLink(qs);
                var link = $@"<a href=""{url}"">Unsubscribe</a>";
                text = text.Replace("{unsubscribe}", link, true);
                text = text.Replace("%7Bfromemail%7D", from.Address, true);
                var supportlink = DbUtil.Db.ServerLink($"/OnlineReg/{OrgId}?gsid={gs.Id}");
                text = text.Replace("http://supportlink", supportlink, true);
                text = text.Replace("https://supportlink", supportlink, true);
                DbUtil.Db.SendEmail(from, Subject, text, Util.ToMailAddressList(gs.NoDbEmail), gs.Id);
            }
            catch (Exception ex)
            {
                DbUtil.Db.SendEmail(from, "sent emails - error", ex.ToString(),
                    Util.ToMailAddressList(from), gs.Id);
                throw;
            }
        }
示例#4
0
 public string TestSend()
 {
     var p = DbUtil.Db.LoadPersonById(Util.UserPeopleId.Value);
     try
     {
         DbUtil.Db.CopySession();
         var from = new MailAddress(p.EmailAddress ?? p.EmailAddress2, p.Name);
         DbUtil.Db.SetCurrentOrgId(OrgId);
         var gs = new GoerSupporter
         {
             Created = DateTime.Now,
             Goer = p,
             Supporter = p,
             SupporterId = p.PeopleId,
             GoerId = p.PeopleId
         };
         var plist = new List<GoerSupporter> {gs};
         DbUtil.Db.SubmitChanges();
         var emailQueue = DbUtil.Db.CreateQueueForSupporters(p.PeopleId, from, Subject, Body, null, plist, false);
         DbUtil.Db.SendPeopleEmail(emailQueue.Id);
     }
     catch (Exception ex)
     {
         return JsonConvert.SerializeObject(new {error = true, message = ex.Message});
     }
     return JsonConvert.SerializeObject(new {message = "Test Email Sent"});
 }
示例#5
0
        public int AddRecipient(int? supporterid, string email)
        {
            var q = from e in DbUtil.Db.GoerSupporters
                    where e.GoerId == PeopleId
                    where e.SupporterId == supporterid || e.NoDbEmail == email
                    select e;
            var r = q.SingleOrDefault();
            if (r == null)
            {
                r = new GoerSupporter
                {
                    GoerId = PeopleId,
                    SupporterId = supporterid,
                    NoDbEmail = email,
                    Active = true,
                    Created = DateTime.Now
                };
                var supporter = DbUtil.Db.People.SingleOrDefault(pp => pp.PeopleId == supporterid);
                var goer = DbUtil.Db.People.SingleOrDefault(pp => pp.PeopleId == PeopleId);
                if (supporter == null)
                    r.Salutation = "Dear Friend";
                else if (goer != null && goer.Age < 30 && (supporter.Age - goer.Age) > 10)
                    r.Salutation = "Dear " + supporter.TitleCode + " " + supporter.LastName;
                else
                    r.Salutation = "Hi " + supporter.PreferredName;

                DbUtil.Db.GoerSupporters.InsertOnSubmit(r);
            }
            else
                r.Active = true;
            DbUtil.Db.SubmitChanges();
            Recipients = GetRecipients();
            return r.Id;
        }
示例#6
0
        private void SendNoDbEmail(Person goer, GoerSupporter gs)
        {
            var sysFromEmail = Util.SysFromEmail;
            var from = new MailAddress(goer.EmailAddress ?? goer.EmailAddress2, goer.Name);

            try
            {
                var text = Body;
                //var aa = DbUtil.Db.DoReplacements(ref text, goer, null);

                text = text.Replace("{salutation}", gs.Salutation, ignoreCase: true);
                var qs = "OptOut/UnSubscribe/?gid=" + Util.EncryptForUrl("{0}".Fmt(gs.Id));
                var url = DbUtil.Db.ServerLink(qs);
                var link = @"<a href=""{0}"">Unsubscribe</a>".Fmt(url);
                text = text.Replace("{unsubscribe}", link, ignoreCase: true);
                text = text.Replace("%7Bfromemail%7D", from.Address, ignoreCase: true);
                text = text.Replace("http://supportlink", DbUtil.Db.ServerLink("/OnlineReg/{0}?gsid={1}".Fmt(OrgId, gs.Id)), ignoreCase: true);
                Util.SendMsg(sysFromEmail, DbUtil.Db.CmsHost, from, Subject, text, Util.ToMailAddressList(gs.NoDbEmail), gs.Id, null);
            }
            catch (Exception ex)
            {
                Util.SendMsg(sysFromEmail, DbUtil.Db.CmsHost, from, "sent emails - error", ex.ToString(),
                    Util.ToMailAddressList(from), gs.Id, null);
                throw;
            }
        }