Ejemplo n.º 1
0
        public static void SaveBulkEmailHyperlinks(Guid bulkEmailId, string templateBody, bool replace,
                                                   UserConnection userConnection)
        {
            if (replace)
            {
                ClearBulkEmailHyperlinks(bulkEmailId, userConnection);
            }
            if (string.IsNullOrEmpty(templateBody))
            {
                return;
            }

            IDictionary <string, string> hyperlinks = MailingUtilities.ParseHtmlHyperlinks(templateBody);

            foreach (KeyValuePair <string, string> hyperlink in hyperlinks)
            {
                try {
                    if (HasMacros(hyperlink.Key))
                    {
                        continue;
                    }
                    string decodeUrl = HttpUtility.UrlDecode(hyperlink.Key);
                    string url       = UtmHelper.RemoveUtmFromUri(decodeUrl);
                    string caption   = string.IsNullOrEmpty(hyperlink.Value) ? url : hyperlink.Value;
                    decodeUrl = HttpUtility.UrlDecode(url.ToLower());
                    Guid hashLink           = MailingUtilities.GetMD5HashGuid(decodeUrl);
                    var  bulkEmailHyperlink = new BulkEmailHyperlink(userConnection);
                    Dictionary <string, object> conditions = new Dictionary <string, object> {
                        { "BulkEmail", bulkEmailId },
                        { "Hash", hashLink }
                    };
                    if (!bulkEmailHyperlink.FetchFromDB(conditions))
                    {
                        bulkEmailHyperlink.SetDefColumnValues();
                        bulkEmailHyperlink.BulkEmailId = bulkEmailId;
                        bulkEmailHyperlink.Caption     = caption;
                        bulkEmailHyperlink.Url         = url;
                        bulkEmailHyperlink.Hash        = hashLink;
                        bulkEmailHyperlink.Save();
                    }
                } catch (Exception e) {
                    MailingUtilities.Log.ErrorFormat(
                        "[BulkEmailHyperlinkHelper.SaveBulkEmailHyperlinks]: Error while saving BulkEmailHyperlink" +
                        " \"{0}\" for BulkEmail with Id: {1}", e, hyperlink, bulkEmailId);
                }
            }
        }
Ejemplo n.º 2
0
 public BulkEmailHyperlink(BulkEmailHyperlink source)
     : base(source)
 {
 }