public void UpdateCannedEmail() { CannedEmail email = new CannedEmail { Active = true, Body = RandomString.GetRandomString(10), BodyType = EmailBodyType.Text, Description = RandomString.GetRandomString(10), Guid = Guid.NewGuid(), Name = RandomString.GetRandomString(10), Subject = RandomString.GetRandomString(10), To = "*****@*****.**", From = "*****@*****.**", ReplyTo = "*****@*****.**" }; mcm.Persist(email); CannedEmail email2 = mcm.GetCannedEmail(email.Guid); Assert.IsNotNull(email2); email2.Body = RandomString.GetRandomString(10); mcm.Persist(email2); CannedEmail email3 = mcm.GetCannedEmail(email.Guid); Assert.IsNotNull(email3); Assert.AreEqual(email2.Body, email3.Body); }
public void SerializationTest() { CannedEmail email = new CannedEmail { Active = true, Body = RandomString.GetRandomString(10), BodyType = EmailBodyType.Text, Description = RandomString.GetRandomString(10), Guid = Guid.NewGuid(), Name = RandomString.GetRandomString(10), Subject = RandomString.GetRandomString(10), To = "*****@*****.**", From = "*****@*****.**", ReplyTo = "*****@*****.**" }; TGSerializedObject tgs = email.GetTGSerializedObject(); CannedEmail email2 = new CannedEmail(); email2.LoadFromTGSerializedObject(tgs); Assert.AreEqual(email.Active, email2.Active); Assert.AreEqual(email.Body, email2.Body); Assert.AreEqual(email.BodyType, email2.BodyType); Assert.AreEqual(email.Description, email2.Description); Assert.AreEqual(email.Guid, email2.Guid); Assert.AreEqual(email.Name, email2.Name); Assert.AreEqual(email.Subject, email2.Subject); Assert.AreEqual(email.To, email2.To); Assert.AreEqual(email.From, email2.From); Assert.AreEqual(email.ReplyTo, email2.ReplyTo); }
public void GetActiveCannedEmails() { CannedEmail email = new CannedEmail { Active = true, Body = RandomString.GetRandomString(10), BodyType = EmailBodyType.Text, Description = RandomString.GetRandomString(10), Guid = Guid.NewGuid(), Name = RandomString.GetRandomString(10), Subject = RandomString.GetRandomString(10), To = "*****@*****.**", From = "*****@*****.**", ReplyTo = "*****@*****.**" }; mcm.Persist(email); CannedEmail email2 = new CannedEmail { Active = false, Body = RandomString.GetRandomString(10), BodyType = EmailBodyType.Text, Description = RandomString.GetRandomString(10), Guid = Guid.NewGuid(), Name = RandomString.GetRandomString(10), Subject = RandomString.GetRandomString(10), To = "*****@*****.**", From = "*****@*****.**", ReplyTo = "*****@*****.**" }; mcm.Persist(email2); List <CannedEmail> emails = mcm.GetActiveCannedEmails(); bool has1 = false; bool has2 = false; foreach (var ce in emails) { if (ce.Guid == email.Guid) { has1 = true; } if (ce.Guid == email2.Guid) { has2 = true; } } Assert.IsTrue(has1); Assert.IsFalse(has2); }
public static void PopulateEmail(CannedEmail _cannedEmail, TGEmail _email, TGSerializedObject _source) { if (_cannedEmail != null) { _email.From = ProcessString(_cannedEmail.From, _source); _email.To = ProcessString(_cannedEmail.To, _source); _email.ReplyTo = ProcessString(_cannedEmail.ReplyTo, _source); _email.Subject = ProcessString(_cannedEmail.Subject, _source); _email.BodyType = _cannedEmail.BodyType; _email.Body = ProcessString(_cannedEmail.Body, _source); } }
public void AddCannedEmail() { CannedEmail email = new CannedEmail { Active = true, Body = RandomString.GetRandomString(10), BodyType = EmailBodyType.Text, Description = RandomString.GetRandomString(10), Guid = Guid.NewGuid(), Name = RandomString.GetRandomString(10), Subject = RandomString.GetRandomString(10), To = "*****@*****.**", From = "*****@*****.**", ReplyTo = "*****@*****.**" }; mcm.Persist(email); }
public static TGEmail GetEmail(CannedEmail _cannedEmail, TGSerializedObject _source) { if (_cannedEmail != null) { TGEmail email = new TGEmail { From = ProcessString(_cannedEmail.From, _source), To = ProcessString(_cannedEmail.To, _source), ReplyTo = ProcessString(_cannedEmail.ReplyTo, _source), Subject = ProcessString(_cannedEmail.Subject, _source), BodyType = _cannedEmail.BodyType, Body = ProcessString(_cannedEmail.Body, _source) }; return(email); } return(null); }
public bool SendCannedEmail(TGUser _tgUser, string _cannedEmailName, NameValueCollection _additionParameters) { try { CannedEmail cannedEmail = GetCannedEmail(_cannedEmailName); if (cannedEmail != null) { SystemEmail email = new SystemEmail(cannedEmail.Guid); TGSerializedObject tgso = _tgUser.GetTGSerializedObject(); foreach (string key in _additionParameters.Keys) { string value = _additionParameters.Get(key); tgso.Add(key, value); } CannedEmailHelper.PopulateEmail(cannedEmail, email, tgso); SESHelper.SendMessage(email); Persist(email); return(true); } TraceFileHelper.Warning("Canned email not found"); } catch (Exception ex) { TraceFileHelper.Exception(ex); } return(false); }
public void Persist(CannedEmail _cannedEmail) { CannedEmailDAO dao = new CannedEmailDAO(MongoDB); dao.Persist(_cannedEmail); }