public static IsSpecialLink ( string link ) : bool | ||
link | string | |
Résultat | bool |
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); }
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); }