public void add(JabinfoContext context) { bool istemp = true; Weixin wx = new Weixin (); JavaScriptSerializer serializer = new JavaScriptSerializer (); if (!context.IsPost) { return; } int sceneId = Convert.ToInt32(context.Post ["sceneId"]); string action = context.Post ["action"]; if (action == "false") istemp = false; string resutl= wx.QRCodeTicket (istemp, sceneId); if (resutl == "0") { context.Alert ("添加失败"); return; } string seconds = istemp ? wx.GetJsonValue (resutl, "expire_seconds") : "0"; //如果用为用二维码;则二维码时间为 100000000; TicketVO tk= serializer.Deserialize<TicketVO> (resutl); context.Post ["createtime"] = Jabinfo.Help.Date.Now.ToString(); context.Post ["ticket"] = tk.ticket; context.Post ["url"] = tk.url; context.Post ["expireSeconds"] = seconds; TicketMapper.I.Insert(context.Post); context.Refresh (); }
public void remove(JabinfoContext context, String msgId) { Weixin wx = new Weixin (); string url = "https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=" + wx.GetAccessToken (); string con = "{\n \"msg_id\":" + msgId + "\n}"; string json = Jabinfo.Help.Http.PostHttps (url, con); if (wx.GetJsonValue (json, "errcode") == "0") { MsglogMapper.I.DeleteByPrimary (msgId); context.Alert ("删除成功"); } }
/// <summary> /// 图文消息推送,以分组形式进行推送 /// </summary> public void send(JabinfoContext context,string mediaId) { if (!context.IsPost) { context.Variable ["mediaId"] = mediaId; context.Variable ["categoryList"] = CategoryMapper.I.Select1 ("8"); return; } string group = context.Post ["group"]; StringBuilder str = new StringBuilder ("{ \r\n"); str.Append("\"filter\":{ \r\n"); if (string.IsNullOrEmpty (group)) str.Append ("\"is_to_all\":true \r\n"); else str.Append("\"is_to_all\":false \r\n"); str.Append ("}, \r\n"); str.Append (" \"mpnews\":{ \r\n"); str.Append (" \"media_id\":\"" + context.Post ["mediaId"] + "\" \r\n"); str.Append (" }, \r\n"); str.Append (" \"msgtype\":\"mpnews\" \r\n"); str.Append ("}"); string result=wx.Sendgroup(str.ToString ()); if (result == "0") { context.Alert ("推送成功"); return; } else { context.Alert ("推送失败"); return; } }
public void msg(JabinfoContext context,string requestId) { if (!context.IsPost) { context.Variable ["requestId"] = requestId; return; } Weixin wx = new Weixin (); StringBuilder str=new StringBuilder("{ \r\n"); StringBuilder con = new StringBuilder (); string msg = context.Post ["context"]; str.Append(" \"touser\":[ \r\n"); con.Append (string.Format ("\"{0}\",\r\n", context.Post["openId"])); string main = con.ToString (); string text = main.Substring (0, main.Length - 3); str.Append (text); str.Append(" ], \r\n"); str.Append ("\"msgtype\": \"text\", \r\n"); //您好,宾弗科技微信公众号推出两款新功能,关键字搜索文章查看,资讯推送,感谢你的关注! str.Append (" \"text\": { \"content\": \""+msg+"\"}"); str.Append("} \r\n"); string result = wx.Sendmsg (str.ToString ()); context.Post ["status"] = "1"; RequestMapper.I.UpdateByPrimary (context.Post); context.Alert ("回复成功"); }
/// <summary> /// 文章回收站恢复 /// </summary> /// <param name="logId">Log identifier.</param> public void restore(JabinfoContext context, string logId) { object result = JabinfoLoger.Restore (logId, typeof(ArticleVO)); if (result == null) context.Alert ("恢复失败"); else context.Alert ("恢复成功"); }
public void category(JabinfoContext context,string articleId) { ArticleVO article = null; if (!context.IsPost) { string[] categorys = new String[0]; article = ArticleMapper.I.Create(articleId); if (!string.IsNullOrEmpty(article.categorys)) categorys =article.categorys.Split(','); string initTag = string.Empty; for (int i = 1; i < categorys.Length-1; i++) { CategoryVO categoryVO = CategoryMapper.I.Create(categorys[i]); initTag = string.Format("{0}<li id=\"{1}\"><strong>{2}</strong> ", initTag, categoryVO.categoryId, categoryVO.title); initTag = string.Format("{0}</li>", initTag); } context.Variable["initTag"] = initTag; // context.Variable["top_id"] = Jabinfo.Help.Config.Get("core.top", "article"); context.Variable["article"] =ArticleMapper.I.Create(articleId); context.Variable["detail"] = article; context.Variable["articleId"] = articleId; return; } article =ArticleMapper.I.Create(context.Post["articleId"]); JabinfoKeyValue data = new JabinfoKeyValue(); data["articleId"] = context.Post["articleId"]; data["categorys"] = string.IsNullOrEmpty(context.Post["categorys"]) ? "" : string.Format(",{0},", context.Post["categorys"]); ArticleDetailMapper.I.UpdateByPrimary (data); if (article.iscash == "0" && !string.IsNullOrEmpty(data["categorys"])) { string[] lt = data["categorys"].Split(','); data["categoryId"] = lt[lt.Length - 2]; ArticleMapper.I.UpdateByPrimary(data); } context.Alert("保存成功"); return; }