public static IWRespBase GoGKey(WX_ApiConfig config, ReplyType rType, string qValue, WReqBase request) { var gkey = WXKeywordServices.QueryByReplyType(config.CompanyID, rType, qValue); if (gkey == null) { return(null); } IKey iKey; switch (gkey.KeywordType) { // 文字 case KeywordType.Text: iKey = new ReplyText(); break; // 图文 case KeywordType.Article: iKey = new ReplyArticle(); break; default: return(null); } return(iKey.ReplyContent(config, gkey, request, qValue)); }
private string GetMenuTypeValue(List <WX_Menu> menus, int id) { WX_Menu menu = menus.FirstOrDefault(p => p.ID == id); var childs = menus.Where(p => p.MasterID == id); if (menu.MasterID == 0 && childs.Count() > 0) { return(string.Empty); } if (menu.MenuType == MenuType.GKeyValue && menu.KeywordId != 0) { WX_Keyword keyword = WXKeywordServices.QueryById(menu.KeywordId); if (keyword != null) { return(keyword.Keyword); } } if (menu.MenuType == MenuType.Url) { return(menu.Url); } if (menu.MenuType == MenuType.WeiXinModule && menu.KeywordId != 0) { return(((WeiXinModule)menu.KeywordId).GetDescription()); } if (menu.MenuType == MenuType.MinIprogram) { return(menu.MinIprogramPagePath); } return(string.Empty); }
private string GetKeyValue(int?keyId) { if (!keyId.HasValue) { return(string.Empty); } WX_Keyword model = WXKeywordServices.QueryById(keyId.Value); return(model == null ? string.Empty : model.Keyword); }
public JsonResult GetKeywordData(string companyId) { JsonResult json = new JsonResult(); List <WX_Keyword> models = WXKeywordServices.QueryALL(companyId); var result = from p in models select new { id = p.ID, text = p.Keyword }; json.Data = result; return(json); }
public JsonResult AddOrUpdate(WX_Keyword model) { try { if (model.KeywordType == KeywordType.Article) { if (string.IsNullOrWhiteSpace(model.ArticleGroupID)) { throw new MyException("请选择图文"); } model.Text = string.Empty; } if (model.KeywordType == KeywordType.Text) { if (string.IsNullOrWhiteSpace(model.Text)) { throw new MyException("请填写回复内容"); } model.ArticleGroupID = string.Empty; } model.ReplyType = ReplyType.AutoReplay; if (model.ID < 1) { bool result = WXKeywordServices.Create(model); if (!result) { throw new MyException("添加失败"); } } else { bool result = WXKeywordServices.Update(model); if (!result) { throw new MyException("修改失败"); } } return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "保存关键字信息失败"); return(Json(MyResult.Error("保存失败"))); } }
public JsonResult UpdateForSubscribe(string companyId, int id) { try { bool result = WXKeywordServices.UpdateForSubscribe(companyId, id); if (!result) { throw new MyException("设置关注回复失败"); } return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "设置关注回复失败"); return(Json(MyResult.Error("设置关注回复失败"))); } }
public JsonResult Delete(string companyId, int id) { try { bool result = WXKeywordServices.Delete(companyId, id); if (!result) { throw new MyException("删除关键字失败"); } return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "删除关键字失败"); return(Json(MyResult.Error("删除关键字失败"))); } }
public JsonResult GetKeywordData() { JsonResult json = new JsonResult(); try { if (string.IsNullOrWhiteSpace(Request["companyId"])) { return(json); } List <WX_Keyword> models = WXKeywordServices.QueryALL(Request["companyId"].ToString()); var result = from p in models select new { Id = p.ID, Keyword = p.Keyword, KeywordType = p.KeywordType, KeywordTypeDes = p.KeywordType.GetDescription(), MatchType = p.MatchType, MatchTypeDes = p.MatchType.GetDescription(), ReplyType = p.ReplyType, ReplyTypeDes = p.ReplyType.GetDescription(), Text = p.Text, ArticleGroupID = p.ArticleGroupID, CompanyID = p.CompanyID }; json.Data = result; } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "查询关键字信息失败"); } return(json); }