Esempio n. 1
0
        private string CreateClickTracking(int emailId, string input)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(input);
            int linkIndex = 0;

            using (var md5Hash = MD5.Create())
            {
                var linkList = doc.DocumentNode.SelectNodes("//a[@href]");
                if (linkList == null)
                {
                    return(doc.DocumentNode.OuterHtml);
                }

                foreach (HtmlNode link in linkList)
                {
                    var att = link.Attributes["href"];
                    var url = att.Value;
                    if (EmailReplacements.IsSpecialLink(url))
                    {
                        continue;
                    }
                    if (url.StartsWith("mailto:"))
                    {
                        continue;
                    }

                    if (EmailReplacements.SettingUrlRe.IsMatch(url))
                    {
                        url = EmailReplacements.SettingUrlReplacement(this, url);
                    }
                    var hash = HashMd5Base64(md5Hash, url + DateTime.Now.ToString("o") + linkIndex);

                    var emailLink = new EmailLink
                    {
                        Created = DateTime.Now,
                        EmailID = emailId,
                        Hash    = hash,
                        Link    = url
                    };
                    EmailLinks.InsertOnSubmit(emailLink);
                    SubmitChanges();

                    att.Value = ServerLink($"/ExternalServices/ct?l={HttpUtility.UrlEncode(hash)}");

                    linkIndex++;
                }
            }

            return(doc.DocumentNode.OuterHtml);
        }
Esempio n. 2
0
        private string CreateClickTracking(int emailId, string input)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(input);
            int linkIndex = 0;

            using (var md5Hash = MD5.Create())
            {
                var linkList = doc.DocumentNode.SelectNodes("//a[@href]");
                if (linkList == null)
                {
                    return(doc.DocumentNode.OuterHtml);
                }

                foreach (HtmlNode link in linkList)
                {
                    var att = link.Attributes["href"];
                    if (EmailReplacements.IsSpecialLink(att.Value))
                    {
                        continue;
                    }

                    var hash = HashMd5Base64(md5Hash, att.Value + DateTime.Now.ToString("o") + linkIndex);

                    var emailLink = new EmailLink
                    {
                        Created = DateTime.Now,
                        EmailID = emailId,
                        Hash    = hash,
                        Link    = att.Value
                    };
                    EmailLinks.InsertOnSubmit(emailLink);
                    SubmitChanges();

                    att.Value = ServerLink($"/ExternalServices/ct?l={HttpUtility.UrlEncode(hash)}");

                    linkIndex++;

                    //System.Diagnostics.Debug.WriteLine(att.Value);
                    //System.Diagnostics.Debug.WriteLine("Unhashed: " + att.Value + DateTime.Now.ToString("o"));
                    //System.Diagnostics.Debug.WriteLine("Hashed: " + hashMD5Base64( md5Hash, att.Value + DateTime.Now.ToString("o") ) );
                }
            }

            return(doc.DocumentNode.OuterHtml);
        }
Esempio n. 3
0
		private void detach_EmailLinks(EmailLink entity)
		{
			this.SendPropertyChanging();
			entity.EmailQueue = null;
		}
Esempio n. 4
0
        private static string createClickTracking(int emailID, string input)
        {
            var doc = new HtmlDocument();
            doc.LoadHtml(input);
            int linkIndex = 0;

            using (var md5Hash = MD5.Create())
            {
                var linkList = doc.DocumentNode.SelectNodes("//a[@href]");
                if (linkList == null) return doc.DocumentNode.OuterHtml;

                foreach (HtmlNode link in linkList)
                {
                    var att = link.Attributes["href"];
                    if (EmailReplacements.IsSpecialLink(att.Value)) continue;

                    var hash = hashMD5Base64(md5Hash, att.Value + DateTime.Now.ToString("o") + linkIndex);

                    var emailLink = new EmailLink
                        {
                            Created = DateTime.Now,
                            EmailID = emailID,
                            Hash = hash,
                            Link = att.Value
                        };
                    DbUtil.Db.EmailLinks.InsertOnSubmit(emailLink);
                    DbUtil.Db.SubmitChanges();

                    att.Value = CLICK_TRACK.Fmt(Util.Host, HttpUtility.UrlEncode(hash));

                    linkIndex++;

                    //System.Diagnostics.Debug.WriteLine(att.Value);
                    //System.Diagnostics.Debug.WriteLine("Unhashed: " + att.Value + DateTime.Now.ToString("o"));
                    //System.Diagnostics.Debug.WriteLine("Hashed: " + hashMD5Base64( md5Hash, att.Value + DateTime.Now.ToString("o") ) );
                }
            }

            return doc.DocumentNode.OuterHtml;
        }
Esempio n. 5
0
 private void detach_EmailLinks(EmailLink entity)
 {
     this.SendPropertyChanging();
     entity.EmailQueue = null;
 }