コード例 #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string err=  ValidateNull();
              if (err == "")
              {
                  spamBUS = new SpamRuleBUS();
                  SpamRuleDTO spamDTO = new SpamRuleDTO();
                  spamDTO.Keyword = txtKeyword.Text;
                  spamDTO.Score = float.Parse(txtScore.Text);
                  spamDTO.SameWord = txtSameWord.Text;
                  int i = 0;
                  if (spamBUS.tblSpamRule_GetByID(txtKeyword.Text).Rows.Count > 0)
                  {
                      spamBUS.tblSpamRule_Update(spamDTO);
                      i = 1;
                  }
                  else
                  {
                      spamBUS.tblSpamRule_insert(spamDTO);
                  }
                  if (i == 1)
                  {
                      pnError.Visible = false;
                      pnSuccess.Visible = true;
                      lblSuccess.Text = "Bạn đã cập nhật thành công ";
                  }
                  else
                  {
                      pnError.Visible = false;
                      pnSuccess.Visible = true;
                      lblSuccess.Text = "Bạn đã thêm thành công ";
                  }
                  LoadData();
                  txtKeyword.Text = "";
                  txtScore.Text = "";
                  txtSameWord.Text = "";
              }
              else
              {
                  pnError.Visible = true;
                  pnSuccess.Visible = false;
                  lblError.Text =err;
              }
        }
        catch (Exception)
        {

            pnError.Visible = true;
            pnSuccess.Visible = false;
            lblError.Text = "Lỗi trong quá trình nhập";
        }
    }
コード例 #2
0
    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;
    }
コード例 #3
0
    protected void btnDelete_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
             string Keyword = ((ImageButton)sender).CommandArgument;
            spamBUS = new SpamRuleBUS();
            spamBUS.tblSpamRule_Delete(Keyword);
            pnError.Visible = false;
            pnSuccess.Visible = true;
            lblSuccess.Text = "Bạn đã xóa thành công ";
            LoadData();
        }
        catch (Exception)
        {
            pnError.Visible = true;
            pnSuccess.Visible = false;
            lblError.Text = "Lỗi trong quá trình xóa";

        }
    }
コード例 #4
0
    protected void btnEdit_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
                  string Keyword = ((ImageButton)sender).CommandArgument;
                spamBUS = new SpamRuleBUS();
                DataTable table = spamBUS.tblSpamRule_GetByID(Keyword);
                if (table.Rows.Count > 0)
                {
                    txtKeyword.Text = Keyword;
                    txtScore.Text = table.Rows[0]["Score"].ToString();
                    txtSameWord.Text = table.Rows[0]["SameWord"].ToString();
                }

        }
        catch (Exception)
        {

            pnError.Visible = true;
            pnSuccess.Visible = false;
            lblError.Text = "Lỗi trong quá trình sửa";
        }
        LoadData();
    }
コード例 #5
0
    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;
    }
コード例 #6
0
    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 &#39;<b>Tiêu đề gửi</b>&#39; 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>" +
                    "&nbsp;</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'>&nbsp;</span><span" +
               " style='font-size: 12px; font-weight: bold;'><b>" + totalScoreTitle.ToString() + "</b></span><span class='Apple-converted-space'>&nbsp;</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 &#39;<b>Nội dung gửi</b>&#39; 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>" +
            "&nbsp;</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'>&nbsp;</span><span" +
               " style='font-size: 13px; font-weight: bold;'>" + totalScoreContent.ToString() + "</span><span class='Apple-converted-space'>&nbsp;</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;
        }
    }
コード例 #7
0
 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();
 }