/// <summary> /// 发消息 /// </summary> /// <param name="task"></param> public static void SendTaskNotifyStatic(TaskRequest task) { var message = new WeiXinSendMessage(); message.msgtype = "text"; message.safe = task.IsSafe ? "1" : "0"; if (!string.IsNullOrWhiteSpace(task.ListUsers)) { message.touser = task.ListUsers; } if (!string.IsNullOrWhiteSpace(task.ListPartys)) { message.toparty = task.ListPartys; } if (string.IsNullOrWhiteSpace(task.ListUsers) && string.IsNullOrWhiteSpace(task.ListPartys)) { message.toparty = "5"; } message.agentid = 0; message.text = new Text() { content = task.Content, }; var CacheTokken = GetCaCheTokken(); var sendresult = SendWeiXinMsg(message, CacheTokken); //如果失败,尝试重置token,再试一次 if (!sendresult) { if (HttpRuntime.Cache["WeiXinTokken"] != null) { HttpRuntime.Cache.Remove("WeiXinTokken"); } CacheTokken = GetCaCheTokken(); sendresult = SendWeiXinMsg(message, CacheTokken); } }
public void SendTaskNotify(TaskRequest task) { SendTaskNotifyStatic(task); }