protected override MacrosInfo CreateMacrosInfo(string macros)
        {
            MacrosInfo macrosInfo = base.CreateMacrosInfo(macros);

            macrosInfo.Id = GetMacrosWorkerId();
            return(macrosInfo);
        }
        private string GetUnsubscribeMacrosAlias(IEnumerable <MacrosInfo> macrosCollection)
        {
            MacrosInfo unsubMacros = macrosCollection.FirstOrDefault(
                macro => macro.Id == MailingConsts.EmailTemplateMacrosUnsubscribeUrlId);
            string unsubAlias = string.Empty;

            if (unsubMacros != null)
            {
                unsubAlias = string.Format(CESMacrosPattern, unsubMacros.Alias);
            }
            return(unsubAlias);
        }
示例#3
0
        private static string GetMacroColumnPath(MacrosInfo macro)
        {
            var columnPath = macro.ColumnPath;

            if (macro.ParentId != Guid.Empty)
            {
                return(columnPath);
            }
            columnPath = "Name";
            var dotPosition = macro.Alias.IndexOf(".", StringComparison.Ordinal);

            if (dotPosition != -1)
            {
                columnPath = macro.Alias.Substring(dotPosition + 1);
            }
            return(columnPath);
        }
        private List <MacrosInfo> GetUriEncodedMacrosCollection(List <MacrosInfo> macrosList, string src)
        {
            Dictionary <string, string> anchorElements = ParseHtmlAnchorElements(src);
            var result = new Dictionary <string, MacrosInfo>();

            foreach (MacrosInfo macros in macrosList)
            {
                bool macrosProcessed = false;
                for (int i = 0; !macrosProcessed && i < anchorElements.Count; i++)
                {
                    KeyValuePair <string, string> anchorElemet = anchorElements.ElementAt(i);
                    if (anchorElemet.Value.Contains(macros.MacrosText) && !result.Keys.Contains(macros.Alias))
                    {
                        var newMacros = new MacrosInfo(macros);
                        newMacros.Alias      = string.Format(UrlEncodedMacrosPattern, newMacros.Alias);
                        result[macros.Alias] = (newMacros);
                        macrosProcessed      = true;
                    }
                }
            }
            return(result.Values.ToList());
        }
示例#5
0
        private List <MacrosInfo> GetUriEncodedMacrosCollection(List <MacrosInfo> macrosList, string src)
        {
            var anchorElements = GetUrlElementsWithMacro(src);
            var result         = new Dictionary <string, MacrosInfo>();

            foreach (var macro in macrosList)
            {
                var macroProcessed = false;
                for (var i = 0; !macroProcessed && i < anchorElements.Count(); i++)
                {
                    var anchorElemet = anchorElements.ElementAt(i);
                    if (anchorElemet.Contains(macro.MacrosText) && !result.Keys.Contains(macro.Alias))
                    {
                        var newMacro = new MacrosInfo(macro);
                        newMacro.Alias      = string.Format(_urlEncodedMacroPattern, newMacro.Alias);
                        result[macro.Alias] = newMacro;
                        macroProcessed      = true;
                    }
                }
            }
            return(result.Values.ToList());
        }
示例#6
0
        private void ReplaceMacrosInBody()
        {
            foreach (var macros in _macrosCollection)
            {
                _body = _body.Replace(macros.MacrosText, string.Format("{0}{1}{2}", MandrillMacrosBeginPattern,
                                                                       macros.Alias, MandrillMacrosEndPattern));
            }
            MacrosInfo unsubscribeUrlMacro = _macrosCollection.FirstOrDefault(macro =>
                                                                              macro.Id == MarketingConsts.EmailTemplateMacrosUnsubscribeUrlId);

            if (unsubscribeUrlMacro != null)
            {
                string unsubscribeUrlMacroMandrillAlias = string.Format("{0}{1}{2}",
                                                                        MandrillMacrosBeginPattern, unsubscribeUrlMacro.Alias, MandrillMacrosEndPattern);
                string[] invalidUnsubscribeUrlPrefix = new string[] { "http://", "https://" };
                foreach (var prefix in invalidUnsubscribeUrlPrefix)
                {
                    string invalidUnsubscribeUrlTextMacros = string.Format("{0}{1}",
                                                                           prefix, unsubscribeUrlMacroMandrillAlias);
                    _body = ReplaceWithStringComparison(_body, invalidUnsubscribeUrlTextMacros,
                                                        unsubscribeUrlMacroMandrillAlias, StringComparison.OrdinalIgnoreCase);
                }
            }
        }
示例#7
0
        private bool IsBulkEmailMacro(MacrosInfo macro)
        {
            var rootElementMacro = macro.Alias.Split('.')[0];

            return(rootElementMacro == _globalMacroSchemaBulkEmail);
        }
示例#8
0
 private bool IsSenderMacro(MacrosInfo macro)
 {
     return(macro.ParentId == MailingConsts.EmailTemplateMacrosParentGlobalId);
 }