public static string getJsonList(string content) { SpamRuleBUS spamBUS = new SpamRuleBUS(); DataTable spam = spamBUS.GetAll(); List<SpamRuleDTO> listSpam = new List<SpamRuleDTO>(); for (int i = 0; i < spam.Rows.Count; i++) { SpamRuleDTO spamDto = new SpamRuleDTO(); spamDto.Keyword = spam.Rows[i]["Keyword"].ToString(); spamDto.SameWord = spam.Rows[i]["SameWord"].ToString(); spamDto.Score = float.Parse(spam.Rows[i]["Score"].ToString()); listSpam.Add(spamDto); } var json = new JavaScriptSerializer().Serialize(listSpam); return json; }
public static string getJsonSpam(string contentId) { // Lay noi dung cho xu ly spam. SendContentBUS scBUS = new SendContentBUS(); int id = int.Parse(contentId); string contentDetail = null; DataTable tblContent = scBUS.GetByID(id); if (tblContent.Rows.Count > 0) { contentDetail = tblContent.Rows[0]["Body"].ToString(); } // Tien hanh check spam SpamRuleBUS spamBUS = new SpamRuleBUS(); DataTable spam = spamBUS.GetAll(); List<SpamRuleDTO> listSpam = new List<SpamRuleDTO>(); for (int i = 0; i < spam.Rows.Count; i++) { SpamRuleDTO spamDto = new SpamRuleDTO(); spamDto.Keyword = spam.Rows[i]["Keyword"].ToString(); spamDto.SameWord = spam.Rows[i]["SameWord"].ToString(); spamDto.Score = float.Parse(spam.Rows[i]["Score"].ToString()); listSpam.Add(spamDto); } var json = new JavaScriptSerializer().Serialize(listSpam); return json; }
public static string Spam(string title, string content) { try { SpamRuleBUS spamBUS = new SpamRuleBUS(); DataTable spam = spamBUS.GetAll(); float totalScoreTitle = 0; float totalScoreContent = 0; string ruleContent = ""; float ItemScore = 0; string key = ""; string titleData = title; string contentData = HttpUtility.UrlDecode(content); #region MyRegion #region Fisrt ruleContent = "<div class='toolTipBox' style='padding: 5px; margin-top: 10px; background-color: rgb(224, 236, 255);" + "color: rgb(51, 51, 51); text-decoration: none; margin-bottom: 15px; font-family: Tahoma, Arial;" + "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" + "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" + "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" + "-webkit-text-stroke-width: 0px;'>" + "<img align='left' height='16' src='../../resource/images/infoballon.gif' width='20' />Thống" + "kê nội dung các quy tắc vi phạm của '<b>Tiêu đề gửi</b>' chi tiết như bên" + " dưới:</div>" + "<div class='Heading2' style='font-weight: bold; color: rgb(0, 0, 0); height: 16pt;" + "background-color: rgb(237, 236, 236); padding: 4px 4px 4px 10px; background-image: url(../../resource/images/table_bg.gif);" + "font-family: Tahoma, Arial; font-size: 11px; font-style: normal; font-variant: normal;" + "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" + "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" + "-webkit-text-stroke-width: 0px;'>" + "<div class='spamRuleBroken_row_rulename' style='float: left; padding: 3px 0px 3px 5px;'>" + "Quy tắc vi phạm</div>" + "<div class='spamRuleBroken_row_rulescore' style='float: right; width: 80px; text-align: right;" + "padding: 3px 15px 3px 5px;'>" + "Điểm</div>" + " </div>" + "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" + " display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" + "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" + "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" + "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" + "-webkit-text-stroke-width: 0px;'>"; #endregion Fisrt foreach (DataRow RowItem in spam.Rows) { key = " " + RowItem["Keyword"].ToString() + " "; ItemScore = float.Parse(RowItem["Score"].ToString()); if (titleData.Contains(key) == true) { //Bắt đầu vòng lặp tính điểm tiêu đề ruleContent += "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" + "display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" + "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" + "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" + "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" + "-webkit-text-stroke-width: 0px;'>"; ruleContent += "<div class='spamRuleBroken_row_rulename' style='float: left; padding: 3px 0px 3px 5px;'>" + "Chứa từ vi phạm '" + key + "'" + "</div>" + "<div class='spamRuleBroken_row_rulescore' style='float: right; width: 80px; text-align: right;" + "padding: 3px 15px 3px 5px;'>" + ItemScore + "</div> </br>"; ruleContent += "</div>"; totalScoreTitle = totalScoreTitle + ItemScore; // Kết thúc vòng lặp tính điểm tiêu đề } } #region Medium ruleContent += "" + "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" + "display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" + "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" + "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" + "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" + "-webkit-text-stroke-width: 0px;'>" + "<div class='spamRuleBroken_graph' style='border: 1px solid gray; height: 5px; background-color: rgb(238, 238, 238);'>" + "<div class='spam_notspam' style='background-color: rgb(0, 255, 0); height: 5px; width: 165.296875px;'>" + "<img height='5' src='../../resource/images/1x1.gif' width='1' /></div>" + "</div>" + "<div style='line-height: 1; margin-bottom: 5px;'>" + "<br />" + "Nội dung được đánh giá cao nhất<span class ='Apple-converted-space'> </span><span" + " style='font-size: 12px; font-weight: bold;'><b>" + totalScoreTitle.ToString() + "</b></span><span class='Apple-converted-space'> </span>trong" + " ngưỡng cho phép là 5. Điều này có nghĩa email của bạn sẽ được gửi đến đích, nhưng" + "điều này không được bảo đảm tuyệt đối nó chỉ có giá trị tham khảo.</div>" + "</div>" + "<div class='toolTipBox' style='padding: 5px; margin-top: 10px; background-color: rgb(224, 236, 255);" + "color: rgb(51, 51, 51); text-decoration: none; margin-bottom: 15px; font-family: Tahoma, Arial;" + "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" + "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" + "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" + "-webkit-text-stroke-width: 0px;'>" + "<img align='left' height='16' src='../../resource/images/infoballon.gif' width='20' />Thống" + " kê nội dung các quy tắc vi phạm của '<b>Nội dung gửi</b>' chi tiết như" + " bên dưới:" + "</div>" + "<div class='Heading2' style='font-weight: bold; color: rgb(0, 0, 0); height: 16pt;" + "background-color: rgb(237, 236, 236); padding: 4px 4px 4px 10px; background-image: url(../../resource/images/table_bg.gif);" + "font-family: Tahoma, Arial; font-size: 11px; font-style: normal; font-variant: normal;" + "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" + "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" + "-webkit-text-stroke-width: 0px;'>" + "<div class='spamRuleBroken_row_rulename' style='float: left; padding: 3px 0px 3px 5px;'>" + "Quy tắc vi phạm</div>" + "<div class='spamRuleBroken_row_rulescore' style='float: right; width: 80px; text-align: right;" + "padding: 3px 15px 3px 5px;'>" + "Điểm</div>" + " </div>"; #endregion //Đánh giá nội dung foreach (DataRow RowItem in spam.Rows) { key = " " + RowItem["Keyword"].ToString() + " "; ItemScore = float.Parse(RowItem["Score"].ToString()); if (contentData.Contains(key) == true) { //Bắt đầu vòng lặp tính điểm tiêu đề ruleContent += "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" + "display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" + "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" + "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" + "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" + "-webkit-text-stroke-width: 0px;'>"; ruleContent += "<div class='spamRuleBroken_row_rulename' style='float: left; padding: 3px 0px 3px 5px;'>" + "Chứa từ vi phạm '" + key + "'" + "</div>" + "<div class='spamRuleBroken_row_rulescore' style='float: right; width: 80px; text-align: right;" + "padding: 3px 15px 3px 5px;'>" + ItemScore + "</div></br>"; ruleContent += "</div>"; totalScoreContent = totalScoreContent + ItemScore; // Kết thúc vòng lặp tính điểm tiêu đề } } //Kết thúc đánh giá nội dung #region End ruleContent += "" + "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" + "display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" + "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" + "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" + "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" + "-webkit-text-stroke-width: 0px;'>" + "<div class='spamRuleBroken_graph' style='border: 1px solid gray; height: 5px; background-color: rgb(238, 238, 238);'>" + "<div class='spam_notspam' style='background-color: rgb(0, 255, 0); height: 5px; width: 50%;'>" + "<img height='5' src='../../resource/images/1x1.gif' width='1' /></div>" + "</div>" + "<div style='line-height: 1; margin-bottom: 5px;'>" + "<br />" + "Nội dung được đánh giá cao nhất<span class='Apple-converted-space'> </span><span" + " style='font-size: 13px; font-weight: bold;'>" + totalScoreContent.ToString() + "</span><span class='Apple-converted-space'> </span>trong" + " ngưỡng cho phép là 5. Điều này có nghĩa email của bạn sẽ được gửi đến đích, nhưng" + "điều này không được bảo đảm tuyệt đối nó chỉ có giá trị tham khảo." + "</div>" + "</div>"; #endregion #endregion return ruleContent; } catch (Exception) { return null; } }
private void LoadData() { spamBUS = new SpamRuleBUS(); dlPager.MaxPages = 1000; dlPager.PageSize = 15; dlPager.DataSource = spamBUS.GetAll().DefaultView; dlPager.BindToControl = dtlSpam; this.dtlSpam.DataSource = dlPager.DataSourcePaged; this.dtlSpam.DataBind(); }