tmp/test-doxy-mms/MarekMailSystem/MarekMailSystem2/EmailManager.cs

Go to the documentation of this file.
00001 using System;
00002 using System.Collections.Generic;
00003 using System.Text;
00004 
00005 namespace MarekMailSystem2
00006 {
00007 
00011     public class EmailManager : EmailSender
00012     {
00013 
00014         //TODO: tutaj beda syskie Sendy w wersji schedule z datš do schedulowania ofcourse..
00015 
00016 
00017         private IEmailTable ErrorTable;
00018         private IEmailTable TemplateTable;
00019         private IEmailSender EmailSender;
00020 
00029         public EmailManager(IEmailTable ErrorTable, IEmailTable TemplateTable, IEmailSender EmailSender)
00030             : base()
00031         {
00032             this.ErrorTable = ErrorTable;
00033             this.TemplateTable = TemplateTable;
00034             this.EmailSender = EmailSender;
00035         }
00036 
00040         public EmailManager() :this(
00041             //TODO: uncomment nhibernate versions..
00042             //new NHibernateEmailTable("ErrorTable"),
00043             //new NHibernateEmailTable("TemplateTable"),
00044             new DummyEmailTable("ErrorTable"),
00045             new TestTemplateEmailTable(),
00046             new SmtpEmailSender())
00047         {
00048 
00049         }
00050 
00051 
00059         public EmailStatus SendSavedTemplate(string TemplateName, Dictionary<string, string> context)
00060         {
00061             Email template = TemplateTable.Load(TemplateName);
00062             SendTemplate(template, context);
00063             return template.SendingStatus;
00064         }
00065 
00073         public EmailStatus SendSavedTemplate(string To, string TemplateName, Dictionary<string, string> context)
00074         {
00075             context["TO"] = To;
00076             Email template = TemplateTable.Load(TemplateName);
00077             SendTemplate(template, context);
00078             return template.SendingStatus;
00079         }
00080 
00081 
00082         //public EmailStatus SendSavedTemplate(string To, string Cc, string TemplateName, Dictionary<string, string> context)
00083         //{
00084         //    context["TO"] = To;
00085         //    context["CC"] = Cc;
00086         //    Email template = TemplateTable.Load(TemplateName);
00087         //    SendTemplate(template, context);
00088         //    return template.SendingStatus;
00089         //}
00090 
00095         public override void Send(Email email)
00096         {
00097             EmailSender.Send(email);
00098             // TODO: ponizszy kod jest.. tak mniejwiecej.. jak zrobie nhibernatowanie to przejrzec to i zrobic porzadnie..
00099             if (email.SendingStatus.Status != StatusCode.Sent)
00100                 ErrorTable.Save(email, "TODO: jaki tag?!");
00101         }
00102 
00103     }
00104 }

Generated on Thu Oct 25 11:32:52 2007 for Marek Mail System by  doxygen 1.5.3-20071008