public static bool SendMsgByRemarkName(IWxFriendsRepository wxFriendsRepository, IWxUsersRepository wxUsersRepository, IRedisHelper redisHelper, IOptions <AppConfig> appConfig, WebHookParam webHook) { AuthCore authCore = new AuthCore(redisHelper); var username = authCore.GetUserName(appConfig.Value.UserUin); //当前登录用户名称 var userHosts = authCore.GetUserHosts(appConfig.Value.UserUin); //当前登录用户操作域名 var userCookies = authCore.GetUserCookie(appConfig.Value.UserUin); //当前登录用户Cookies var userKeys = authCore.GetUserKeys(appConfig.Value.UserUin); //当前登录用户秘钥 var dbWxUser = wxUsersRepository.GetWxUsers(appConfig.Value.UserUin);//当前登录用户 if (dbWxUser == null) { throw new CustomerException("未找到登录信息", -2); } var dbFriends = wxFriendsRepository.GetFriendByName(webHook.actor, dbWxUser.Uin); if (dbFriends == null) { throw new CustomerException("未找到好友信息", -1); //好友信息 } return(WeiXinHelper.SendMsg(userHosts, webHook.text, dbFriends.UserName, dbWxUser.UserName, userKeys, userCookies)); }
public JsonResult SendMsg(WebHookParam webHookParam) { var result = WxCore.SendMsgByRemarkName(_wxFriendsRepository, _wxUsersRepository, _redisHelper, _appconfig, webHookParam); return(Json(result == true)); }