/// <summary> /// 进行推送 /// </summary> /// <param name="sendSmall"></param> /// <returns></returns> public int PushSmall(SendSmall sendSmall) { Org org = userDal.GetOrgDetailById(sendSmall.OrgId); List <string> openIds = new List <string>() { sendSmall.OpenId }; //我自己 ozmxY0rJ3qWyq8QWzXE-6GBRXUzo string tempId = "cfoCwUwZJXU2N7Tul9UsuR5hGOcEr-iN6ewHjyqsGjA"; //推送模板 int numExec = 0; StringBuilder sb = new StringBuilder(); foreach (var item in openIds) { sb.Append("{\"touser\": \"" + item + "\"," + "\"template_id\": \"" + tempId + "\", " + "\"page\": \"" + "pages/search/details/details?orgId=" + sendSmall.OrgId + "\", " + "\"form_id\": \"" + sendSmall.FormId + "\", " + "\"data\": " + "{\"keyword1\": {\"value\": \"" + org.OrgName + "\",\"color\": \"#173177\"}," + "\"keyword2\": { \"value\": \"" + org.Content + "\",\"color\": \"#173177\"}," + "\"keyword3\": { \"value\": \"" + DateTime.Now + "\",\"color\": \"#173177\"}," + "\"keyword4\": { \"value\": \"" + org.LinkTel + "\",\"color\": \"#173177\"}," + "\"keyword5\": {\"value\": \"" + org.LInkMan + "\",\"color\": \"#173177\" }}}"); SendTempletMessge(sb.ToString(), "wxba92380dc6210082", "8938f3c2513bfc3883038284b67e0316"); numExec += 1; sb.Clear(); } return(numExec); }
/// <summary> /// 进行推送消息 /// </summary> /// <returns></returns> public string PushUserForm() { string openId = ""; string formId = ""; string data = HttpContext.Request.QueryString["data"].ToString();//机构id int orgId = 0; int.TryParse(data, out orgId); if (orgId == 0) { return(""); } try { openId = HttpContext.Request.QueryString["openId"].ToString(); formId = HttpContext.Request.QueryString["formId"].ToString(); SendSmall sendSmall = new SendSmall(); sendSmall.OpenId = openId; sendSmall.FormId = formId; sendSmall.OrgId = orgId; int num = newsBll.PushSmall(sendSmall); if (num > 0) { return("推送成功"); } else { return("推送失败"); } } catch (Exception ex) { Response.Write("openId:" + openId + "|formId:" + formId); } return("openId:" + openId + "|formId:" + formId); }