/// <summary> /// Generates HTML text to be used in description area. /// </summary> ///<param name="selectedValue">Selected item for which generate description</param> private string ShowInDescriptionArea(string selectedValue) { string description = String.Empty; if (!String.IsNullOrEmpty(selectedValue)) { int templateId = ValidationHelper.GetInteger(selectedValue, 0); var template = EmailTemplateInfoProvider.GetEmailTemplates() .WhereEquals("TemplateID", templateId) .Columns("TemplateDisplayName", "TemplateSubject") .TopN(1) .FirstOrDefault(); if (template != null) { description = template.TemplateSubject; } } if (!String.IsNullOrEmpty(description)) { return("<div class=\"Description\">" + HTMLHelper.HTMLEncode(description) + "</div>"); } return(String.Empty); }
private static ObjectQuery <EmailTemplateInfo> LoadAvailableEmailTemplates() { return(EmailTemplateInfoProvider.GetEmailTemplates() .Columns("TemplateID", "TemplateDisplayName", "TemplateDescription", "TemplateThumbnailGUID", "TemplateIconClass") .WhereEquals("TemplateType", EmailTemplateTypeEnum.Issue.ToStringRepresentation()) .Where(GetAssignedTemplatesWhere())); }
/// <summary> /// Generates HTML text to be used in description area. /// </summary> ///<param name="selectedValue">Selected item for which generate description</param> private string ShowInDescriptionArea(string selectedValue) { string name = String.Empty; string description = String.Empty; if (!String.IsNullOrEmpty(selectedValue)) { int templateId = ValidationHelper.GetInteger(selectedValue, 0); DataSet ds = EmailTemplateInfoProvider.GetEmailTemplates("TemplateID=" + templateId, null, 1, "TemplateDisplayName, TemplateSubject"); if (!DataHelper.DataSourceIsEmpty(ds)) { name = ResHelper.LocalizeString(ValidationHelper.GetString(ds.Tables[0].Rows[0]["TemplateDisplayName"], string.Empty)); description = ValidationHelper.GetString(ds.Tables[0].Rows[0]["TemplateSubject"], string.Empty); } } else { name = GetString("newslettertemplate.selectitem"); } string text = "<div class=\"ItemName\">" + HTMLHelper.HTMLEncode(name) + "</div>"; if (description != null) { text += "<div class=\"Description\">" + HTMLHelper.HTMLEncode(description) + "</div>"; } return(text); }
/// <summary> /// Gets and bulk updates issue templates. Called when the "Get and bulk update templates" button is pressed. /// Expects the CreateIssueTemplate method to be run first. /// </summary> private bool GetAndBulkUpdateIssueTemplates() { // Prepare the condition IWhereCondition whereCondition = new WhereCondition().Where("TemplateName", QueryOperator.Like, "MyNewIssueTemplate%"); // Get the data var templates = EmailTemplateInfoProvider.GetEmailTemplates().Where(whereCondition); if (templates.Any()) { // Loop through the individual items foreach (var template in templates) { // Update the properties template.TemplateDisplayName = template.TemplateDisplayName.ToUpper(); // Save the changes EmailTemplateInfoProvider.SetEmailTemplateInfo(template); } return(true); } return(false); }
/// <summary> /// Gets and bulk updates issue templates. Called when the "Get and bulk update templates" button is pressed. /// Expects the CreateIssueTemplate method to be run first. /// </summary> private bool GetAndBulkUpdateIssueTemplates() { // Prepare the parameters string where = "TemplateName LIKE N'MyNewIssueTemplate%'"; // Get the data DataSet templates = EmailTemplateInfoProvider.GetEmailTemplates(where, null); if (!DataHelper.DataSourceIsEmpty(templates)) { // Loop through the individual items foreach (DataRow templateDr in templates.Tables[0].Rows) { // Create object from DataRow EmailTemplateInfo modifyTemplate = new EmailTemplateInfo(templateDr); // Update the properties modifyTemplate.TemplateDisplayName = modifyTemplate.TemplateDisplayName.ToUpper(); // Save the changes EmailTemplateInfoProvider.SetEmailTemplateInfo(modifyTemplate); } return(true); } return(false); }
/// <summary> /// Fired when the step is being loaded. /// </summary> protected void InitStep(object sender, EventArgs e) { // Drop flag stepLoaded = false; StepEventArgs args = (StepEventArgs)e; switch (args.CurrentStep) { case 1: // TEMPLATE SELECTION selectElem.StopProcessing = (newsletterId <= 0); // Check if at least one additional template is available for the newsletter // ... otherwise skip the first step if (newsletterId > 0) { string where = String.Format("TemplateType='{1}' AND (NOT TemplateID IN (SELECT NewsletterTemplateID FROM Newsletter_Newsletter WHERE NewsletterID={0}))" + "AND (TemplateID IN (SELECT TemplateID FROM Newsletter_EmailTemplateNewsletter WHERE NewsletterID={0}))", newsletterId, EmailTemplateType.Issue); DataSet ds = EmailTemplateInfoProvider.GetEmailTemplates(where, null, 1, "TemplateID"); if (!DataHelper.DataSourceIsEmpty(ds)) { // Inicialize template selector selectElem.NewsletterId = newsletterId; // Register JS function for double-click template selection string javascript = "function SelectTemplate(value, skipDialog){" + Page.ClientScript.GetPostBackEventReference(btnTemplateNext, null) + "; return false;}"; ScriptHelper.RegisterStartupScript(this, typeof(string), "TemplateSelector", ScriptHelper.GetScript(javascript)); selectElem.SelectFunction = "SelectTemplate"; } else { // Skip this step args.Skip = SelectionSkipped = true; } } break; case 2: // CONTENT EDITING // Get variant issue ID if A/B testing is ON IssueId = InitVariantSlider(IssueId); editElem.StopProcessing = (newsletterId <= 0); editElem.NewsletterID = newsletterId; editElem.IssueID = IssueId; editElem.TemplateID = templateId; editElem.ReloadData(false); // Initialize action menu InitHeaderActions(); sendVariant.ForceReloadNeeded = true; // control needs to be reloaded in the next step break; case 3: // SENDING CONFIGURATION bool isIssueVariant = IssueInfoProvider.IsABTestIssue(IssueId); if (!isIssueVariant) { sendElem.StopProcessing = ((newsletterId <= 0) || (IssueId <= 0)); sendElem.NewsletterID = newsletterId; sendElem.IssueID = IssueId; } else { sendVariant.StopProcessing = (IssueId <= 0); sendVariant.IssueID = IssueId; sendVariant.ReloadData(); } sendElem.Visible = !isIssueVariant; sendVariant.Visible = isIssueVariant; break; } }