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";
        }
    }
Example #2
0
 public int tblSpamRule_insert(SpamRuleDTO dt)
 {
     string sql = "INSERT INTO tblSpamRule(Keyword, Score, SameWord) " +
                  "VALUES(@Keyword, @Score, @SameWord)";
     SqlCommand cmd = new SqlCommand(sql, ConnectionData._MyConnection);
     cmd.CommandType = CommandType.Text;
     cmd.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = dt.Keyword;
     cmd.Parameters.Add("@Score", SqlDbType.Float).Value = dt.Score;
     cmd.Parameters.Add("@SameWord", SqlDbType.NVarChar).Value = dt.SameWord;
     if (ConnectionData._MyConnection.State == ConnectionState.Closed)
     {
         ConnectionData._MyConnection.Open();
     }
     int row = cmd.ExecuteNonQuery();
     cmd.Dispose();
     return row;
 }
    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;
    }
Example #4
0
 public int tblSpamRule_Update(SpamRuleDTO dt)
 {
     return SpamDao.tblSpamRule_Update(dt);
 }
Example #5
0
 public int tblSpamRule_insert(SpamRuleDTO dt)
 {
     return SpamDao.tblSpamRule_insert(dt);
 }
Example #6
0
 public int tblSpamRule_Update(SpamRuleDTO dt)
 {
     string sql = "UPDATE  tblSpamRule SET " +
                  "Score = @Score, " +
                  "SameWord = @SameWord " +
                  "WHERE  Keyword = @Keyword";
     SqlCommand cmd = new SqlCommand(sql, ConnectionData._MyConnection);
     cmd.CommandType = CommandType.Text;
     cmd.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = dt.Keyword;
     cmd.Parameters.Add("@Score", SqlDbType.Float).Value = dt.Score;
     cmd.Parameters.Add("@SameWord", SqlDbType.NVarChar).Value = dt.SameWord;
     if (ConnectionData._MyConnection.State == ConnectionState.Closed)
     {
         ConnectionData._MyConnection.Open();
     }
     int row = cmd.ExecuteNonQuery();
     cmd.Dispose();
     return row;
 }
    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;
    }