public JsonResult Add(string word, string category) { ISensitiveWordService sensitiveWordService = ServiceHelper.Create <ISensitiveWordService>(); if (sensitiveWordService.ExistSensitiveWord(word)) { Result result = new Result() { success = false, msg = "该敏感关键词已存在!" }; return(Json(result)); } SensitiveWordsInfo sensitiveWordsInfo = new SensitiveWordsInfo() { SensitiveWord = word, CategoryName = category }; sensitiveWordService.AddSensitiveWord(sensitiveWordsInfo); Result result1 = new Result() { success = true, msg = "添加成功!" }; return(Json(result1)); }
public JsonResult ImportExcel() { if (base.Request.Files.Count == 0) { Result result = new Result() { success = false, msg = "请上传文件!" }; return(Json(result)); } int num = 0; HttpPostedFileBase item = base.Request.Files[num]; if (item == null || item.ContentLength <= 0) { Result result1 = new Result() { success = false, msg = "上传文件格式不正确!" }; return(Json(result1)); } Random random = new Random(); DateTime now = DateTime.Now; string str = string.Concat(now.ToString("yyyyMMddHHmmssffffff"), num, Path.GetExtension(item.FileName)); string str1 = Server.MapPath("~/temp/"); if (!Directory.Exists(str1)) { Directory.CreateDirectory(str1); } string str2 = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "/temp/"); item.SaveAs(Path.Combine(str2, str)); DataTable data = GetData(Path.Combine(str2, str)); ISensitiveWordService sensitiveWordService = ServiceHelper.Create <ISensitiveWordService>(); foreach (DataRow row in data.Rows) { if (sensitiveWordService.ExistSensitiveWord(row[1].ToString())) { continue; } SensitiveWordsInfo sensitiveWordsInfo = new SensitiveWordsInfo() { CategoryName = row[0].ToString(), SensitiveWord = row[1].ToString() }; sensitiveWordService.AddSensitiveWord(sensitiveWordsInfo); } Result result2 = new Result() { success = true, msg = "导入成功!" }; return(Json(result2)); }
public JsonResult List(int page, string keywords, int rows, string category) { ISensitiveWordService sensitiveWordService = ServiceHelper.Create <ISensitiveWordService>(); SensitiveWordQuery sensitiveWordQuery = new SensitiveWordQuery() { SensitiveWord = keywords, CategoryName = category, PageNo = page, PageSize = rows }; PageModel <SensitiveWordsInfo> sensitiveWords = sensitiveWordService.GetSensitiveWords(sensitiveWordQuery); var list = from item in sensitiveWords.Models.ToList() select new { Id = item.Id, SensitiveWord = item.SensitiveWord, CategoryName = item.CategoryName }; return(Json(new { rows = list, total = sensitiveWords.Total })); }
public SensitiveWordController(ISensitiveWordService iSensitiveWordService) { _iSensitiveWordService = iSensitiveWordService; }
public SensitiveWordController(ISensitiveWordService iSensitiveWordService, IWebHostEnvironment environment) { _iSensitiveWordService = iSensitiveWordService; _hostingEnvironment = environment; }