예제 #1
0
        public static void CreateDefaultLetterTemplates(Guid siteGuid)
        {
            if (HttpContext.Current == null) return;

            string pathToTemplates = HttpContext.Current.Server.MapPath("~/Data/emailtemplates");

            if (!Directory.Exists(pathToTemplates)) return;

            DirectoryInfo dir = new DirectoryInfo(pathToTemplates);
            FileInfo[] templates = dir.GetFiles("*.config");
            foreach (FileInfo template in templates)
            {
                LetterHtmlTemplate emailTemplate = new LetterHtmlTemplate();
                emailTemplate.SiteGuid = siteGuid;
                emailTemplate.Title = template.Name.Replace(".config", string.Empty);
                StreamReader contentStream = template.OpenText();
                emailTemplate.Html = contentStream.ReadToEnd();
                contentStream.Close();
                emailTemplate.Save();

            }
        }
예제 #2
0
        void btnSaveAsTemplate_Click(object sender, EventArgs e)
        {
            Page.Validate("newtemplate");
            if (!Page.IsValid) { return; }

            SaveLetter();

            LetterHtmlTemplate template = new LetterHtmlTemplate();
            template.SiteGuid = siteSettings.SiteGuid;
            template.Title = txtNewTemplateName.Text;
            template.Html = edContent.Text;
            template.Save();

            string redirectUrl = SiteRoot + "/eletter/LetterEdit.aspx?l=" + letterInfoGuid.ToString()
                     + "&letter=" + letter.LetterGuid.ToString();

            WebUtils.SetupRedirect(this, redirectUrl);
        }