public ActionResult SendNews(List <NewsInfoView> newsList, bool isPreview = false) { int IsSec = 0; try { var news = newsList[0]; if ("video".Equals(news.NewsCate)) { news.ImageContent = SaveBase64ImageToServer(news.ImageContent); } IsSec = news.isSecurityPost.HasValue && news.isSecurityPost.Value ? 1 : 0; var objConfig = WeChatCommonService.GetWeChatConfigByID(news.AppId); string strToken = (objConfig.IsCorp != null && !objConfig.IsCorp.Value) ? Innocellence.Weixin.MP.CommonAPIs.AccessTokenContainer.GetToken(objConfig.WeixinCorpId, objConfig.WeixinCorpSecret) : Innocellence.Weixin.QY.CommonAPIs.AccessTokenContainer.TryGetToken(objConfig.WeixinCorpId, objConfig.WeixinCorpSecret); string strUser = news.SendToPerson == null ? null : string.Join("|", news.SendToPerson); string strDept = news.SendToGroup == null ? null : string.Join("|", news.SendToGroup); string strTags = news.SendToTag == null ? null : string.Join("|", news.SendToTag); // var configs = Infrastructure.Web.Domain.Service.CommonService.lstSysConfig; using (var transactionScope = new TransactionScope(TransactionScopeOption.Suppress, new TransactionOptions { IsolationLevel = IsolationLevel.RepeatableRead })) { MassResult result = null; var lstArticles = GetArticleList(newsList, isPreview); if (!isPreview) { InsertMsgLog(string.Join(",", lstArticles.Select(a => a.Id)), newsList[0]); } if (news.PostType == (int)MessagePostTypeEnum.定时推送) { transactionScope.Complete(); } else { result = WechatCommon.SendMsgQY(news.AppId, news.NewsCate == "news" && IsSec == 1 ? "mpnews" : news.NewsCate, strUser, strDept, strTags, "", lstArticles, IsSec, isPreview); if (result.errcode == Weixin.ReturnCode_QY.请求成功) { transactionScope.Complete(); } } } //if (pp != null) //{ // _attachmentsItemService.ThumbImageAndInsertIntoDB(pp); //} } catch (Exception e) { _Logger.Error(e, "An error occurred while sending news."); return(Json(new { results = new { Data = 500 } })); } return(Json(new { results = new { Data = 200 } })); }