public IWRespBase ReplyContent(WX_ApiConfig config, WX_Keyword gKey, WReqBase request, string qValue) { var response = request.CreateResponse <WRespText>(); response.Content = gKey.Text; return(response); }
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 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 IWRespBase ReplyContent(WX_ApiConfig config, WX_Keyword gKey, WReqBase request, string qValue) { var response = request.CreateResponse <WRespNews>(); var articles = WXArticleServices.QueryByGroupID(gKey.ArticleGroupID); foreach (var item in articles.OrderBy(o => o.Sort)) { var article = new Article { Title = item.Title, Description = item.Description, PicUrl = string.IsNullOrWhiteSpace(item.ImagePath) ? string.Empty : string.Format("{0}{1}", config.Domain, item.ImagePath) }; switch (item.ArticleType) { case ArticleType.Text: article.Url = string.Format("{0}/WxArticleDetail/Index?openId={1}&articleId={2}", config.Domain, request.FromUserName, item.ID); break; case ArticleType.Url: article.Url = item.Url; break; case ArticleType.Module: { string link = ((WeiXinModule)int.Parse(item.Url)).GetEnumDefaultValue(); if (!string.IsNullOrWhiteSpace(link)) { if (link.Contains("=")) { link = string.Format("{0}^cid={1}", link, config.CompanyID); } else { link = string.Format("{0}_cid={1}", link, config.CompanyID); } } article.Url = string.Format("{0}{1}", config.Domain, link); break; } default: continue; } response.Articles.Add(article); } return(response); }
public static bool Update(WX_Keyword model) { IWXKeyword factory = WXKeywordFactory.GetFactory(); WX_Keyword dbModel = factory.QueryByReplyType(model.CompanyID, model.ReplyType, model.Keyword); if (dbModel != null && dbModel.ID != model.ID) { throw new MyException("关键字已存在"); } bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <WX_Keyword>(model, OperateType.Update); } return(result); }
public bool Update(WX_Keyword model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update WX_Keyword set Keyword=@Keyword,KeywordType=@KeywordType,MatchType=@MatchType"); strSql.Append(",[Text]=@Text,ArticleGroupID=@ArticleGroupID where ID=@ID"); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { dbOperator.ClearParameters(); dbOperator.AddParameter("Keyword", model.Keyword); dbOperator.AddParameter("KeywordType", (int)model.KeywordType); dbOperator.AddParameter("MatchType", (int)model.MatchType); dbOperator.AddParameter("Text", model.Text); dbOperator.AddParameter("ArticleGroupID", model.ArticleGroupID); dbOperator.AddParameter("ID", model.ID); return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0); } }
public bool Create(WX_Keyword model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into WX_Keyword(Keyword,KeywordType,MatchType,ReplyType,[Text],ArticleGroupID,CompanyID,DataStatus,CreateTime)"); strSql.Append(" values(@Keyword,@KeywordType,@MatchType,@ReplyType,@Text,@ArticleGroupID,@CompanyID,@DataStatus,@CreateTime)"); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { dbOperator.ClearParameters(); dbOperator.AddParameter("Keyword", model.Keyword); dbOperator.AddParameter("KeywordType", (int)model.KeywordType); dbOperator.AddParameter("MatchType", (int)model.MatchType); dbOperator.AddParameter("ReplyType", (int)model.ReplyType); dbOperator.AddParameter("Text", model.Text); dbOperator.AddParameter("ArticleGroupID", model.ArticleGroupID); dbOperator.AddParameter("CompanyID", model.CompanyID); dbOperator.AddParameter("DataStatus", (int)model.DataStatus); dbOperator.AddParameter("CreateTime", DateTime.Now); return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0); } }