コード例 #1
0
        // __ Impl ____________________________________________________________


        private Notification CreateNotification(IDbConnection c, IDbTransaction t, string templateKey, BaseTemplateData notificationData)
        {
            var notification = TemplateEngine.GetNotificationFromDbTemplate(c, t, mConfig.DefaultLocale, templateKey, notificationData);

            SetupNotification(notification, notificationData);

            c.Insert(notification, t);

            return(notification);
        }
コード例 #2
0
        public void NotifyPush(HttpRequest req, IDbConnection c, IDbTransaction t, string templateKey, BaseTemplateData notificationData)
        {
            var n = CreateNotification(c, t, templateKey, notificationData);

            // Queue through the push provider
        }
コード例 #3
0
 private void SetupNotification(Notification notification, BaseTemplateData data)
 {
     SetupNotification(notification, data.From, data.To);
 }
コード例 #4
0
        public void NotifyEmail(HttpRequest req, IDbConnection c, IDbTransaction t, string templateKey, BaseTemplateData notificationData)
        {
            var n = CreateNotification(c, t, templateKey, notificationData);

            // Queue through the email provider
            var result = mEmailProvider.SendEmail(req, n.RecipientData.Email, n.Text2, null, n.Text);

            if (!result)
            {
                throw new Exception("Error.SendingEmailFailed");
            }
        }
コード例 #5
0
        public static Notification GetNotificationFromDbTemplate(IDbConnection c, IDbTransaction t, string lang, string templateKey, BaseTemplateData data)
        {
            if (data == null || data.To == null || data.From == null)
            {
                throw new ArgumentNullException();
            }

            var template = c.QueryFirstOrDefault <NotificationTemplate>(
                "SELECT * FROM notificationTemplates WHERE lang = @lang AND key = @key",
                new { lang = lang, key = templateKey }, t);

            if (template == null)
            {
                throw new Exception("Error.NotFound.Template");
            }

            var result = new Notification
            {
                Text  = Process(template.ContentTemplate, data),
                Text2 = Process(template.Title, data),
            };

            return(result);
        }