Ejemplo n.º 1
0
        public void EnqueueUserCreatedEmail(int applicationId, string theme, string senderEmail, IStaticContentLookup staticContentLookup
                                            , string firstName, string lastName, string userEmail, int userId, string password)
        {
            ThreadPool.QueueUserWorkItem(delegate(object state)
            {
                Dictionary <string, string> placeholders = new Dictionary <string, string>()
                {
                    { "@firstname", firstName },
                    { "@lastname", lastName },
                    { "@email", userEmail },
                    { "@password", password }
                };

                string subject = staticContentLookup.GetContent(theme, "mail_AccountCreated_Subject", true, placeholders);
                string body    = staticContentLookup.GetContent(theme, "mail_AccountCreated_Body", true, placeholders);

                Email email = new Email(
                    applicationId
                    , subject
                    , body
                    , userEmail
                    , senderEmail
                    , userId
                    , EmailStatus.Unsent
                    , EmailPriority.SendImmediately
                    , EmailType.UserCreated);

                if (InstanceContainer.EmailManager.Create(email).Status == DataRepositoryActionStatus.Success)
                {
                    _Log.Info("Successfully created user created notification email for user " + userId);
                }
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Formats a specified string replacing placeholders with content
        /// </summary>
        /// <param name="theme"></param>
        /// <param name="content"></param>
        /// <param name="formatMode"></param>
        /// <param name="staticContentLookup"></param>
        /// <param name="themeFolderLookup"></param>
        /// <returns></returns>
        public static string Format(
            string theme
            , string content
            , IStaticContentLookup staticContentLookup
            , IThemeFolderLookup themeFolderLookup
            , FormatMode formatMode)
        {
            if (string.IsNullOrWhiteSpace(content))
            {
                return(content);
            }
            // TODO (Roman): implement URL.RESOLVE to be able to resolve url root folders, not only theme paths...
            string value;

            foreach (Match match in _ContentRegex.Matches(content))
            {
                value = staticContentLookup.GetContent(theme, match.Groups[1].Value);
                if ((formatMode & FormatMode.EscapeSingleQuotes) != 0)
                {
                    value = value.Replace("'", @"\'");
                }
                if ((formatMode & FormatMode.EscapeDoubleQuotes) != 0)
                {
                    value = value.Replace("\"", @"\""");
                }

                content = content.Replace(match.Value, value);
            }
            foreach (Match match in _UrlRegex.Matches(content))
            {
                value = themeFolderLookup.GetAbsoluteThemePath(theme, match.Groups[1].Value);
                if ((formatMode & FormatMode.EscapeSingleQuotes) != 0)
                {
                    value = value.Replace("'", @"\'");
                }
                if ((formatMode & FormatMode.EscapeDoubleQuotes) != 0)
                {
                    value = value.Replace("\"", @"\""");
                }

                content = content.Replace(match.Value, value);
            }

            return(content);
        }
Ejemplo n.º 3
0
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            // TODO (Roman): errorhandling, cleanup, upper/lower case stuff
            RequestContextData  requestContextData = InstanceContainer.RequestHelper.GetRequestContextData(requestContext.HttpContext.Request);
            IApplicationContext applicationContext = InstanceContainer.ApplicationContext;

            IThemeFolderLookup   themeFolderLookup   = applicationContext.GetThemeFolderLookup(requestContextData.ApplicationThemeInfo.ApplicationGroup);
            IStaticContentLookup staticContentLookup = applicationContext.GetStaticContentLookup(requestContextData.ApplicationThemeInfo.ApplicationGroup);

            string text = ContentFormatUtility.Format(
                requestContextData.Theme
                , staticContentLookup.GetContent(requestContextData.Theme, "js_globals")
                , staticContentLookup
                , themeFolderLookup
                , ContentFormatUtility.FormatMode.EscapeSingleQuotes);

            requestContext.HttpContext.Response.Clear();
            requestContext.HttpContext.Response.Write(text);
            requestContext.HttpContext.Response.End();

            return(null);
        }