/// <summary> /// 该方法用于删除数据库中的格式设置信息 /// </summary> /// <param name="formatname"></param> public void DeleteFormat(string formatname, string tablename) { string str_sql = $"alter table {tablename} delete where geshimingcheng='{formatname}'"; chhelper.SelectDB("default"); chhelper.DoSQL(str_sql); }
/// <summary> /// 该方法用于正文查重 /// </summary> public void ZhengwenChachong(DataGridViewRow dgvrow, ref string chachonglv) { string filename = dgvrow.Cells["wendangming"].Value.ToString(); string zhengwen = GetZhengwen(filename); string md5zhengwen = GenerateMD5(zhengwen); bool existzhengwen = IsExistZhengwen(md5zhengwen); if (existzhengwen)//如果正文存在于数据库 { //显示查重进度 dgvrow.Cells["jindu"].Value = "100.00%"; Application.DoEvents(); //显示重复率 dgvrow.Cells["chongfulv"].Value = chachonglv = "重复"; Application.DoEvents(); if (Setting._shanchu100) { File.Delete(filename); } } else//如果正文不在数据库内 { //显示查重进度 dgvrow.Cells["jindu"].Value = "100.00%"; Application.DoEvents(); //显示重复率 dgvrow.Cells["chongfulv"].Value = chachonglv = "不重复"; Application.DoEvents(); if (!existzhengwen && Setting._zhengwenruku)//如果正文入库,那么入库正文 { //Dictionary<string, object> dic = new Dictionary<string, object>() { // {"编号",md5zhengwen }, // {"来源",Path.GetFileName(filename) }, // { "正文内容",zhengwen} // }; string str_sql = $"insert into {Setting._zhengwenrukubiao} (bianhao,laiyuan,zhengwenneirong,shijian) values " + $"('{md5zhengwen}','{Path.GetFileName(filename)}','{zhengwen}','{DateTime.Now.ToString("yyyy-MM-dd")}')"; chhelper.DoSQL(str_sql); //Ruku(Setting._zhengwenrukubiao, dic); } } if (Setting._daochu) { SaveDocument(dgvrow); } }
/// <summary> /// 点击保存格式按钮时触发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Lbl_baocun_Click(object sender, EventArgs e) { string formatname = cbb_geshi.Text; //string lujing100 = Regex.Replace(tb_path1.Text, @"\\", "\\\\"); //string lujingfei100 = Regex.Replace(tb_path2.Text, @"\\", "\\\\"); string rizhilujing = Regex.Replace(tb_rizhilujing.Text, @"\\", "\\\\"); _mycontroller.DeleteFormat(formatname, "zhengwensetting"); List <string> list_db = new List <string>(); foreach (UCDatabase item in Setting.list_ucdb) { list_db.Add(item.lbl_dbname.Text); } string str_sql = $"insert into zhengwensetting (xuhao,geshimingcheng,zhengwenchachong,shanchu100,zhengwenchachongbiao," + $"zhengwenruku,zhengwenrukubiao,rizhilujing,shujukushai,riqi) values " + $"(1,'{formatname}'," + $"{(cb_leijiredu.Checked ? 1 : 0)}," + $"{(cb_shanchu100.Checked ? 1 : 0)}," + $"'{cbb_zhengwenchachongbiao.Text}'," + $"{(cb_zhengwenruku.Checked ? 1 : 0)}," + $"'{cbb_zhengwenbiao.Text}'," + $"'{rizhilujing}'," + $"'{string.Join(",", list_db)}'," + $"'{DateTime.Now.ToString("yyyy-MM-dd")}')"; //Dictionary<string, object> dic = new Dictionary<string, object>() //{ // {"格式名称", formatname}, // {"正文查重",cb_zhengwenchachong.Checked }, // {"删除100",cb_shanchu100.Checked}, // {"正文查重表", cbb_zhengwenchachongbiao.Text}, // {"正文入库",cb_zhengwenruku.Checked }, // {"正文入库表",cbb_zhengwenbiao.Text }, // { "日志路径",tb_rizhilujing.Text}, // {"数据库筛",string.Join(",",list_db )} //}; //_mycontroller.SaveFormat(dic); chhelper.DoSQL(str_sql); cbb_geshi.Items.Clear(); var format = _mycontroller.GetFormat(); cbb_geshi.Items.AddRange(format); MessageBox.Show($"格式 {formatname} 已保存成功!"); }