private void SendSingleMessage(string user, string message) { SendTextRequest str = new SendTextRequest(); str.agentid = Agentid; str.safe = "0"; str.touser = user; SendTextRequest.Text text = new SendTextRequest.Text(); str.msgtype = "text"; text.content = message; str.text = text; messageBiz.Send <SendTextRequest>(str); }
public Result Delete(Model.DB.User model) { UserRA.Delete(model.id.ToString()); MessageBiz.Send(model.id.ToString(), MessageTypeEnum.User_Forbidden); model.created_by = user_id; return(Result(UserDA.Delete(model))); }
public Result UpdateStatusOrder(StatusOrder model) { string status_order = ((int)model.status).ToString(); if (UserRA.Exists(model.id.ToString())) { UserRA.Set(model.id.ToString(), "status_order", status_order); } MessageBiz.Send(model.id.ToString(), MessageTypeEnum.User_Order_Status, status_order); return(Result(UserDA.UpdateStatusOrder(model))); }
public static void Start(string monthkey, string user) { MessageBiz messageBiz = new MessageBiz(); SendMPNewsRequest sendNewsRequest = new SendMPNewsRequest(); string strConn = @"Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" + filePath + "Report Mapping.xlsx;Extended Properties='Excel 12.0;HDR=Yes;IMEX=1'"; DataTable ExcelTable = GetDTFromExcel(strConn); if (!string.IsNullOrEmpty(user)) { sendNewsRequest = GetSendMPNewsRequest(monthkey, user, ExcelTable); messageBiz.Send <SendMPNewsRequest>(sendNewsRequest); } else { DataView dataView = ExcelTable.DefaultView; DataTable dataTableDistinct = dataView.ToTable(true, "Name"); for (int i = 0; i < dataTableDistinct.Rows.Count; i++) { string account = Convert.ToString(dataTableDistinct.Rows[i][0]); sendNewsRequest = GetSendMPNewsRequest(monthkey, account, ExcelTable); messageBiz.Send <SendMPNewsRequest>(sendNewsRequest); } } }
public Result UpdateStatus(StatusUser model) { if (model.status != StatusUserEnum.Allowed) { UserRA.Delete(model.id.ToString()); } if (model.status != StatusUserEnum.Forbidden) { MessageBiz.Send(model.id.ToString(), MessageTypeEnum.User_Forbidden); } else if (model.status == StatusUserEnum.ForcedOffline) { MessageBiz.Send(model.id.ToString(), MessageTypeEnum.User_ForcedOffline); } return(Result(UserDA.UpdateStatus(model))); }
public Result ResetPassword(UserPassword model) { MessageBiz.Send(model.id.ToString(), MessageTypeEnum.Password_Changed); return(Result(UserDA.ResetPassword(model))); }
public Result Authority(Model.DB.User model) { MessageBiz.Send(model.id.ToString(), MessageTypeEnum.Authorization_Changed); return(Result(UserDA.Authority(model))); }
public string SendMessage(string inputMessage, string user) { string xmlFilePath = xmlPath; XmlDocument doc = new XmlDocument(); doc.Load(xmlFilePath); var rp = GetLusiResult(inputMessage); if (rp != null) { var res = rp.intents.OrderByDescending(x => x.score).First(); if (res.intent.ToLower() == "none" && rp.entities.Count == 0)//没有查到结果返回默认结果 { XmlNodeList NoResultNodeList = doc.SelectNodes("Results/NoResult"); if (NoResultNodeList != null) { foreach (XmlNode noResultNode in NoResultNodeList) { SendSingleMessage(user, noResultNode); } } } //else if (res.intent.ToLower() != "none" && rp.entities.Count == 0)//有搜到,但不能精确定位 //{ // SendTextRequest str = new SendTextRequest(); // str.agentid = Agentid; // str.safe = "0"; // str.touser = user; // SendTextRequest.Text text = new SendTextRequest.Text(); // str.msgtype = "text"; // text.content = "您是要搜索" + res.intent + "么?请再提供更多关键字来精确定位吧。"; // str.text = text; // messageBiz.Send<SendTextRequest>(str); //} else { bool HasFind = false; XmlNodeList ResultNodeList = doc.SelectNodes("Results/Result"); if (ResultNodeList != null) { foreach (XmlNode ResultNode in ResultNodeList) { if (rp.entities.Any() && ResultNode.Attributes["name"].Value != "" && res.intent.ToLower() == ResultNode.Attributes["name"].Value.ToLower())//查询贺卡/邀请卡 { foreach (XmlNode SubResultNode in ResultNode) { if (rp.entities.First().type == SubResultNode.Attributes["name"].Value)//贺卡/邀请卡::StarProducts" { foreach (XmlNode TSubResultNode in SubResultNode) { if (rp.entities.First().entity.ToLower() == TSubResultNode.Attributes["name"].Value) { if (TSubResultNode.SelectSingleNode("msgtype").InnerText == "text") { HasFind = true; SendSingleMessage(user, TSubResultNode); } else if (TSubResultNode.SelectSingleNode("msgtype").InnerText == "mpnews") { HasFind = true; SendMpMessage(user, TSubResultNode); } else if (TSubResultNode.SelectSingleNode("msgtype").InnerText == "image") { HasFind = true; SendImageMessage(user, TSubResultNode); } else if (TSubResultNode.SelectSingleNode("msgtype").InnerText == "news") { HasFind = true; SendNewsMessage(user, TSubResultNode); } } } } } } } if (!HasFind) { foreach (XmlNode ResultNode in ResultNodeList) { if (ResultNode.Attributes["name"].Value != "" && res.intent.ToLower() == ResultNode.Attributes["name"].Value.ToLower())//查询贺卡/邀请卡 { foreach (XmlNode SubResultNode in ResultNode) { if (SubResultNode.Attributes["name"].Value.ToLower() == "default")//查询贺卡/邀请卡 { if (SubResultNode.SelectSingleNode("msgtype").InnerText == "text") { HasFind = true; SendSingleMessage(user, SubResultNode); } else if (SubResultNode.SelectSingleNode("msgtype").InnerText == "mpnews") { HasFind = true; SendMpMessage(user, SubResultNode); } else if (SubResultNode.SelectSingleNode("msgtype").InnerText == "image") { HasFind = true; SendImageMessage(user, SubResultNode); } else if (SubResultNode.SelectSingleNode("msgtype").InnerText == "news") { HasFind = true; SendNewsMessage(user, SubResultNode); } } } } } } if (!HasFind) { SendTextRequest str = new SendTextRequest(); str.agentid = Agentid; str.safe = "0"; str.touser = user; SendTextRequest.Text text = new SendTextRequest.Text(); str.msgtype = "text"; text.content = "您是要搜索" + res.intent + "么?请再提供更多关键字来精确定位吧。"; str.text = text; messageBiz.Send <SendTextRequest>(str); } } } } return(""); }