Exemplo n.º 1
0
        // *********************************************************************
        //
        //  PopulateEmailFromIDataReader
        //
        /// <summary>
        /// This private method accepts a datareader and attempts to create and
        /// populate a EmailTempalte class instance which is returned to the caller.
        /// </summary>
        //
        // ********************************************************************/
        public static EmailTemplate PopulateEmailFromIDataReader(IDataReader reader)
        {
            EmailTemplate email = new EmailTemplate();

            email.EmailID       = (Guid) reader["EmailID"];
            email.Priority      = (MailPriority) (int) reader["emailPriority"];
            email.BodyFormat    = (MailFormat) (int) reader["emailBodyFormat"];
            email.Subject       = (string) reader["emailSubject"];
            email.To            = (string) reader["emailTo"];
            email.From          = (string) reader["emailFrom"];
            email.Body          = (string) reader["emailBody"];
            email.NumberOfTries = (int) reader["numberOfTries"];

            if (reader["emailCc"] != DBNull.Value)
                email.Cc = (string) reader["emailCc"];

            if (reader["emailBcc"] != DBNull.Value)
                email.Bcc = (string) reader["emailBcc"];

            return email;
        }
Exemplo n.º 2
0
Arquivo: Emails.cs Projeto: pcstx/OA
        protected static Hashtable LoadEmailTemplates(string language)
        {
            Hashtable emailTemplates;
            FileInfo f;
            string cacheKey = "emailTemplates-" + language;
            CSContext csContext = CSContext.Current;

            emailTemplates = CSCache.Get(cacheKey) as Hashtable;
            if (emailTemplates == null) {
                emailTemplates = new Hashtable();

                try {

                    f = new FileInfo(csContext.PhysicalPath("Languages\\" + language + "\\emails\\emails.xml"));//   csContext.MapPath("~" + CSConfiguration.GetConfig().FilesPath + "\\Languages\\" + language + "\\emails\\emails.xml" ));
                } catch {

                    throw new CSException(CSExceptionType.EmailTemplateNotFound, "No email templates found for language: " + language);
                }

                // Read in the file
                //
                FileStream reader = f.OpenRead();
                XmlDocument d = new XmlDocument();
                d.Load(reader);
                reader.Close();

                // Loop through all contained emails
                //
                foreach (XmlNode node in d.GetElementsByTagName("email")) {

                    // Create a new email template
                    //
                    EmailTemplate t = new EmailTemplate(node);

                    // Add to the lookup table
                    //
                    emailTemplates.Add(t.EmailType, t);

                }

                // Terry Denham 7/26/2004
                // changing default caching duration to 2 hours, intead of forever
                // ScottW 1/24/2005 adding file dependency
                System.Web.Caching.CacheDependency dep = new CacheDependency(f.FullName);
                CSCache.Insert(cacheKey,emailTemplates,dep,2 * CSCache.HourFactor);

            }

            return emailTemplates;
        }