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
        private void SaveHyperlink(Guid bulkEmailId, HyperlinkData hyperlink)
        {
            var url            = UtmHelper.RemoveUtmFromUri(hyperlink.Url);
            var query          = GetParams(url);
            var bpmTrackId     = GetIntParameterValue(query, _trackIdQueryParameterName);
            var bpmReplicaMask = GetIntParameterValue(query, _replicaQueryParameterName);
            var caption        = string.IsNullOrEmpty(hyperlink.Caption) ? url : hyperlink.Caption;
            var insert         = new Insert(_userConnection)
                                 .Into(_bulkEmailHyperlinkTableName)
                                 .Set("BulkEmailId", Column.Parameter(bulkEmailId))
                                 .Set("Caption", Column.Parameter(caption))
                                 .Set("Url", Column.Parameter(url))
                                 .Set("BpmReplicaMask", Column.Parameter(bpmReplicaMask))
                                 .Set("BpmTrackId", Column.Parameter(bpmTrackId));

            SetAdditionalColumns(insert, hyperlink.AdditionalColumns);
            insert.Execute();
        }