using Core.Web.App_Start; using Core.Web.WebHelper; using CRM.Core.BLL.Base; using CRM.Core.BLL.EventBus.Events; using CRM.Core.Common.EventBus; using CRM.Core.DTO; using CRM.Core.Model.Entity; using CRM.Core.Model.Enum; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using WX.CRM.Common; namespace Core.Web.Controllers { public class HGKeyWordController : BaseController { private BAS_PARAMETER_BL paramter_bl = new BAS_PARAMETER_BL(); public ValidationErrors errors = new ValidationErrors(); [AuthorizeRedirect(RightsConfig.CONST_合规关键词, ToolBarConfig.CONST_NotButton, true)] // GET: HGKeyWord public ActionResult Index() { BAS_PARAMETER model = paramter_bl.GetModel(Parameter.WeiXin_IllegalKewords.ToString()); if (model == null) model = new BAS_PARAMETER(); return View(model); } [HttpPost] [AuthorizeRedirect(RightsConfig.CONST_合规关键词, ToolBarConfig.CONST_NotButton, false)] public JsonResult SaveKey(BAS_PARAMETER model) { if (string.IsNullOrEmpty(model.PARAKEY)) { model.PARAKEY = Parameter.WeiXin_IllegalKewords.ToString(); model.PARANAME = "合规关键词"; model.GROUPID = "SystemConfig"; model.PARATYPE = "字符"; model.REMARK = "合规关键词匹配的所有关键词"; model.CREATEUSER = 600000207; } if (!string.IsNullOrEmpty(model.PARAVALUE)) { string keywords = model.PARAVALUE.Replace(";", ";").Replace("\n\r", "").Replace("\r", "").Replace("\n", ""); List keylist2 = keywords.Split(';').ToList(); List keylist = new List(); foreach (var item in keylist2) { if (!string.IsNullOrEmpty(item)) keylist.Add(item); } string newkeyword = string.Join(";", keylist.ToArray()); model.PARAVALUE = keywords; } bool result = paramter_bl.SetValue_Parameter(model, ref errors); if (result) { BAS_PARAMETER pm = paramter_bl.GetModel(Parameter.WeiXin_IllegalKewordsDeptConfig.ToString()); string[] dep = pm.PARAVALUE.Split(';'); foreach (var item in dep) { if (string.IsNullOrEmpty(item)) continue; EventBus.Instance.Publish(new HGKeyWordEvent(model.PARAVALUE, item));//推送到各个点 } return Json(new retMsg { result = true, retmsg = "保存成功!" }, JsonRequestBehavior.AllowGet); } else return Json(new retMsg { result = result, retmsg = errors.Error }, JsonRequestBehavior.AllowGet); } } }