/// <summary> /// 微信消息模板推送 /// </summary> /// <param name="userids"></param> /// <param name="batchid"></param> /// <param name="log"></param> /// <returns></returns> public static async Task <bool> PushByUserIDAndBatchIDAsync(IEnumerable <string> userids, int batchid, PushTemplateLog log) { try { using (var client = new TemplatePushClient()) { var pushResult = await client.PushByUserIDAndBatchIDAsync(userids, batchid, log); if (pushResult.Success && pushResult.Result) { return(true); } else { Logger.Warn($"PushByUserIDAndBatchIDAsync 推送失败{pushResult.ErrorCode + pushResult.ErrorMessage}"); } } } catch (Exception ex) { Logger.Error($"PushByUserIDAndBatchIDAsync 异常,{ex.Message + ex.StackTrace}", ex); } return(false); }
/// <summary> /// 消息推送 /// </summary> /// <param name="userids"></param> /// <param name="batchid"></param> /// <param name="log"></param> /// <returns></returns> public async static Task <OperationResult <bool> > PushByUserIDAndBatchIDAsync(IEnumerable <string> userids, int batchid, PushTemplateLog log) { if (userids != null && userids.Any()) { using (var client = new TemplatePushClient()) { var result = await client.PushByUserIDAndBatchIDAsync(userids, batchid, log); if (!result.Success) { Logger.Error($" PushByUserIDAndBatchIDAsync fail => ErrorCode ={result.ErrorCode} & ErrorMessage ={result.ErrorMessage} "); } return(result); } } else { return(OperationResult.FromResult(true)); } }