示例#1
0
    /// <summary>
    /// Gets and updates notification template text. Called when the "Get and update text" button is pressed.
    /// Expects the CreateNotificationTemplateText method to be run first.
    /// </summary>
    private bool GetAndUpdateNotificationTemplateText()
    {
        // Get the template
        NotificationTemplateInfo template = NotificationTemplateInfoProvider.GetNotificationTemplateInfo("MyNewTemplate", CMSContext.CurrentSiteID);

        //Get the gateway
        NotificationGatewayInfo gateway = NotificationGatewayInfoProvider.GetNotificationGatewayInfo("MyNewGateway");

        if ((template != null) && (gateway != null))
        {
            // Get the notification template text
            NotificationTemplateTextInfo updateText = NotificationTemplateTextInfoProvider.GetNotificationTemplateTextInfo(gateway.GatewayID, template.TemplateID);
            if (updateText != null)
            {
                // Update the property
                updateText.TemplateSubject = updateText.TemplateSubject.ToLower();

                // Update the notification template text
                NotificationTemplateTextInfoProvider.SetNotificationTemplateTextInfo(updateText);

                return(true);
            }
        }

        return(false);
    }
示例#2
0
    /// <summary>
    /// Creates notification template text. Called when the "Create text" button is pressed.
    /// </summary>
    private bool CreateNotificationTemplateText()
    {
        // Get the template
        NotificationTemplateInfo template = NotificationTemplateInfoProvider.GetNotificationTemplateInfo("MyNewTemplate", CMSContext.CurrentSiteID);

        // Get the gateway
        NotificationGatewayInfo gateway = NotificationGatewayInfoProvider.GetNotificationGatewayInfo("MyNewGateway");

        if ((template != null) && (gateway != null))
        {
            // Create new notification template text object
            NotificationTemplateTextInfo newText = new NotificationTemplateTextInfo();

            // Set the properties
            newText.TemplateSubject           = "My new text";
            newText.TemplateID                = template.TemplateID;
            newText.GatewayID                 = gateway.GatewayID;
            newText.TemplateHTMLText          = "";
            newText.TemplatePlainText         = "";
            newText.TempalateTextLastModified = DateTime.Now;

            // Create the notification template text
            NotificationTemplateTextInfoProvider.SetNotificationTemplateTextInfo(newText);

            return(true);
        }

        return(false);
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // If ID�s not specified return
        if ((TemplateID == 0) || (GatewayID == 0))
        {
            return;
        }

        // Get gateway name
        NotificationGatewayInfo ngi = NotificationGatewayInfoProvider.GetNotificationGatewayInfo(GatewayID);

        if (ngi == null)
        {
            throw new Exception("NotificationGatewayInfo with this GatewayID does not exist.");
        }

        // Setup control according to NotificationGatewayInfo
        plcSubject.Visible   = ngi.GatewaySupportsEmail;
        plcPlainText.Visible = ngi.GatewaySupportsPlainText;
        plcHTMLText.Visible  = ngi.GatewaySupportsHTMLText;

        if (plcHTMLText.Visible)
        {
            // Initialize HTML editor
            htmlText.AutoDetectLanguage           = false;
            htmlText.DefaultLanguage              = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
            htmlText.EditorAreaCSS                = CssStylesheetInfoProvider.GetHtmlEditorAreaCss(SiteContext.CurrentSiteName);
            htmlText.ToolbarSet                   = "Basic";
            htmlText.MediaDialogConfig.UseFullURL = true;
            htmlText.LinkDialogConfig.UseFullURL  = true;
            htmlText.QuickInsertConfig.UseFullURL = true;
        }

        // If gateway does not support any of text fields inform about it.
        if (!ngi.GatewaySupportsEmail && !ngi.GatewaySupportsHTMLText && !ngi.GatewaySupportsPlainText)
        {
            ShowWarning(string.Format(GetString("notifications.templatetext.notextbox"), HTMLHelper.HTMLEncode(ngi.GatewayDisplayName)));
        }

        // Get existing TemplateTextInfoObject or create new object
        NotificationTemplateTextInfo ntti = NotificationTemplateTextInfoProvider.GetNotificationTemplateTextInfo(GatewayID, TemplateID);

        if (ntti == null)
        {
            ntti = new NotificationTemplateTextInfo();
        }

        // Set edited object
        EditedObject = ntti;

        // Setup properties
        if (!URLHelper.IsPostback())
        {
            TemplateSubject   = ntti.TemplateSubject;
            TemplateHTMLText  = ntti.TemplateHTMLText;
            TemplatePlainText = ntti.TemplatePlainText;
        }
    }
示例#4
0
    /// <summary>
    /// Deletes notification template text. Called when the "Delete text" button is pressed.
    /// Expects the CreateNotificationTemplateText method to be run first.
    /// </summary>
    private bool DeleteNotificationTemplateText()
    {
        // Get the template
        NotificationTemplateInfo template = NotificationTemplateInfoProvider.GetNotificationTemplateInfo("MyNewTemplate", CMSContext.CurrentSiteID);

        //Get the gateway
        NotificationGatewayInfo gateway = NotificationGatewayInfoProvider.GetNotificationGatewayInfo("MyNewGateway");

        if ((template != null) && (gateway != null))
        {
            // Get the notification template text
            NotificationTemplateTextInfo deleteText = NotificationTemplateTextInfoProvider.GetNotificationTemplateTextInfo(gateway.GatewayID, template.TemplateID);

            // Delete the notification template text
            NotificationTemplateTextInfoProvider.DeleteNotificationTemplateTextInfo(deleteText);

            return(deleteText != null);
        }

        return(false);
    }
示例#5
0
    /// <summary>
    /// Gets and bulk updates notification template texts. Called when the "Get and bulk update texts" button is pressed.
    /// Expects the CreateNotificationTemplateText method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateNotificationTemplateTexts()
    {
        // Get the template
        NotificationTemplateInfo template = NotificationTemplateInfoProvider.GetNotificationTemplateInfo("MyNewTemplate", CMSContext.CurrentSiteID);

        //Get the gateway
        NotificationGatewayInfo gateway = NotificationGatewayInfoProvider.GetNotificationGatewayInfo("MyNewGateway");

        if ((template != null) && (gateway != null))
        {
            // Prepare the parameters
            string where = "";
            where        = SqlHelperClass.AddWhereCondition(where, "TemplateID = " + template.TemplateID, "AND");
            where        = SqlHelperClass.AddWhereCondition(where, "GatewayID = " + gateway.GatewayID, "AND");

            // Get the data
            DataSet texts = NotificationTemplateTextInfoProvider.GetNotificationTemplateTexts(where, null);
            if (!DataHelper.DataSourceIsEmpty(texts))
            {
                // Loop through the individual items
                foreach (DataRow textDr in texts.Tables[0].Rows)
                {
                    // Create object from DataRow
                    NotificationTemplateTextInfo modifyText = new NotificationTemplateTextInfo(textDr);

                    // Update the property
                    modifyText.TemplateSubject = modifyText.TemplateSubject.ToUpper();

                    // Update the notification template text
                    NotificationTemplateTextInfoProvider.SetNotificationTemplateTextInfo(modifyText);
                }

                return(true);
            }
        }

        return(false);
    }
示例#6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // If ID´s not specified return
        if ((this.TemplateID == 0) || (this.GatewayID == 0))
        {
            return;
        }

        // Get resource strings
        lblHTMLText.ResourceString  = "notification.template.html";
        lblPlainText.ResourceString = "notification.template.plain";
        lblSubject.ResourceString   = "general.subject";

        // Get gateway name
        NotificationGatewayInfo ngi = NotificationGatewayInfoProvider.GetNotificationGatewayInfo(this.GatewayID);

        if (ngi == null)
        {
            throw new Exception("NotificationGatewayInfo with this GatewayID does not exist.");
        }

        // Setup control according to NotificationGatewayInfo
        this.plcSubject.Visible   = ngi.GatewaySupportsEmail;
        this.plcPlainText.Visible = ngi.GatewaySupportsPlainText;
        this.plcHTMLText.Visible  = ngi.GatewaySupportsHTMLText;

        if (this.plcHTMLText.Visible)
        {
            // Initialize HTML editor
            htmlText.AutoDetectLanguage           = false;
            htmlText.DefaultLanguage              = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
            htmlText.EditorAreaCSS                = FormHelper.GetHtmlEditorAreaCss(CMSContext.CurrentSiteName);
            htmlText.ToolbarSet                   = "Basic";
            htmlText.MediaDialogConfig.UseFullURL = true;
            htmlText.LinkDialogConfig.UseFullURL  = true;
            htmlText.QuickInsertConfig.UseFullURL = true;
        }

        // If gateway does not support any of text fields inform about it.
        if (!ngi.GatewaySupportsEmail && !ngi.GatewaySupportsHTMLText && !ngi.GatewaySupportsPlainText)
        {
            noneStyle            = "width:100%";
            plcNoTextbox.Visible = true;
            lblNoTextbox.Text    = string.Format(GetString("notifications.templatetext.notextbox"), HTMLHelper.HTMLEncode(ngi.GatewayDisplayName));
        }

        // Get existing TemplateTextInfoObject or create new object
        NotificationTemplateTextInfo ntti = NotificationTemplateTextInfoProvider.GetNotificationTemplateTextInfo(this.GatewayID, this.TemplateID);

        if (ntti == null)
        {
            ntti = new NotificationTemplateTextInfo();
        }

        // Setup properties
        if (!URLHelper.IsPostback())
        {
            this.TemplateSubject   = ntti.TemplateSubject;
            this.TemplateHTMLText  = ntti.TemplateHTMLText;
            this.TemplatePlainText = ntti.TemplatePlainText;
        }
    }