private void BindUserGorupMaxspacephotosize() { #region 绑定用户组照片空间大小 DataTable dt = DatabaseProvider.GetInstance().GetUserGroupMaxspacephotosize(); int i = 1; HtmlTableRow tr = new HtmlTableRow(); foreach (DataRow dr in dt.Rows) { if (i % 2 == 1) { tr = new HtmlTableRow(); } HtmlTableCell td = new HtmlTableCell("td"); td.Controls.Add(new LiteralControl(dr["grouptitle"].ToString())); tr.Cells.Add(td); td = new HtmlTableCell("td"); Discuz.Control.TextBox tb = new Discuz.Control.TextBox(); tb.ID = "maxspacephotosize" + dr["groupid"].ToString(); tb.Size = 10; tb.MaxLength = 9; tb.Text = dr["maxspacephotosize"].ToString(); tb.RequiredFieldType = "数据校验"; td.Controls.Add(tb); tr.Cells.Add(td); tr.Cells.Add(GetTD("maxspacephotosize" + dr["groupid"].ToString())); groupphotosize.Rows.Add(tr); i++; } #endregion }
private void BindUserGorupMaxspaceattachsize() { DataTable dt = DatabaseProvider.GetInstance().GetUserGroupMaxspaceattachsize(); int i = 1; HtmlTableRow tr = new HtmlTableRow(); foreach (DataRow dr in dt.Rows) { if (i % 2 == 1) { tr = new HtmlTableRow(); } HtmlTableCell td = new HtmlTableCell("td"); td.Controls.Add(new LiteralControl(dr["grouptitle"].ToString())); tr.Cells.Add(td); td = new HtmlTableCell("td"); Discuz.Control.TextBox tb = new Discuz.Control.TextBox(); tb.ID = "maxspaceattachsize" + dr["groupid"].ToString(); tb.Size = 10; tb.MaxLength = 9; tb.Text = dr["maxspaceattachsize"].ToString(); tb.RequiredFieldType = "数据校验"; td.Controls.Add(tb); tr.Cells.Add(td); tr.Cells.Add(GetTD("maxspaceattachsize" + dr["groupid"].ToString())); groupattachsize.Rows.Add(tr); i++; } }
private static bool GetReplacement(String[] badwords, String[] filterwords, ref string find, ref string replacement) { if (find == "") { return(false); } if (filterwords.Length == 2) { for (int m = 0; m < badwords.Length; m++) { if (filterwords[1].ToString() != "") { replacement = filterwords[1].ToString(); } } } else if (filterwords.Length < 2) { for (int m = 0; m < badwords.Length; m++) { replacement = "**"; } } else { replacement = filterwords[filterwords.Length - 1]; filterwords.SetValue("", filterwords.Length - 1); find = string.Join("=", filterwords); find = find.Remove(find.Length - 2); } if (replacement == string.Empty) { replacement = "**"; } return(true); }
private void addbadwords_Click(object sender, EventArgs e) { if (this.badwords.Text == "") { BindData(); return; } String[] badwords = getwords(); String[] filterwords; #region 根据radiobuttonlist选择条件 if (radfilter.SelectedValue == "0") { //清空当前词语表,再插入 string find = ""; string replacement = ""; DatabaseProvider.GetInstance().DeleteBadWords(); for (int i = 0; i < badwords.Length; i++) { filterwords = badwords[i].Split('='); find = filterwords[0].ToString().Replace("\r", "").Trim(); if (!GetReplacement(badwords, filterwords, ref find, ref replacement)) { continue; } DatabaseProvider.GetInstance().InsertBadWords(username, find, replacement); } } if (radfilter.SelectedValue == "1") { //使用新的设置覆盖已经存在的词语 string find = ""; string replacement = ""; DataTable dt = DatabaseProvider.GetInstance().GetBadWords(); for (int i = 0; i < badwords.Length; i++) { #region 注释掉 //filterwords = badwords[i].Split('='); //find = filterwords[0].ToString(); //if (find == "") //{ // break; //} //if (filterwords.Length == 2 && filterwords[1].ToString() != "") //{ // replacement = filterwords[1].ToString().Replace("\r","").Replace("\"","").Trim(); //} //else if (filterwords.Length < 2) //{ // replacement = "**"; //} //else//filterwords.Length > 2 的情况 //{ // replacement = filterwords[filterwords.Length - 1]; // filterwords.SetValue("", filterwords.Length - 1); // find = string.Join("=", filterwords); // find = find.Remove(find.Length - 2); //} #endregion filterwords = badwords[i].Split('='); find = filterwords[0].ToString().Replace("\r", "").Trim(); if (!GetReplacement(badwords, filterwords, ref find, ref replacement)) { continue; } DatabaseProvider.GetInstance().UpdateBadWords(find, replacement); } } if (radfilter.SelectedValue == "2") { //不导入已经存在的词语 string find = ""; string replacement = ""; DataTable dt = DatabaseProvider.GetInstance().GetBadWords(); for (int i = 0; i < badwords.Length; i++) { #region //filterwords = badwords[i].Split('='); //find = filterwords[0].ToString().Replace("\r", "").Trim(); //#region //if (find == "") //{ // continue; //} //if (filterwords.Length == 2 && filterwords[1].ToString() != "") //{ // replacement = filterwords[1].ToString(); //} //else if (filterwords.Length < 2) //{ // replacement = "**"; //} //else//filterwords.Length > 2 的情况 //{ // replacement = filterwords[filterwords.Length - 1]; // filterwords.SetValue("", filterwords.Length - 1); // find = string.Join("=", filterwords); // find = find.Remove(find.Length - 2); //} //#endregion #endregion filterwords = badwords[i].Split('='); find = filterwords[0].ToString().Replace("\r", "").Trim(); if (!GetReplacement(badwords, filterwords, ref find, ref replacement)) { continue; } DataRow[] arrRow = dt.Select("find='" + find + "'"); if (arrRow.Length == 0) { DatabaseProvider.GetInstance().InsertBadWords(username, find, replacement); } } } #endregion BindData(); this.badwords.Text = ""; }
private static bool GetReplacement(String[] badwords, String[] filterwords, ref string find, ref string replacement) { if (find == "") { return false; } if (filterwords.Length == 2) { for (int m = 0; m < badwords.Length; m++) { if (filterwords[1].ToString() != "") { replacement = filterwords[1].ToString(); } } } else if (filterwords.Length < 2) { for (int m = 0; m < badwords.Length; m++) { replacement = "**"; } } else { replacement = filterwords[filterwords.Length - 1]; filterwords.SetValue("", filterwords.Length - 1); find = string.Join("=", filterwords); find = find.Remove(find.Length - 2); } if (replacement == string.Empty) { replacement = "**"; } return true; }