public void Execute(IJobExecutionContext context) { Logger.Info("开始刷新"); var allProductComments = DalProductStatistics.GetProductStatisticsByPage(); if (allProductComments != null && allProductComments.Any()) { var groupResult = allProductComments.GroupBy(g => g.ProductID); Dictionary <string, int> commentTimes = new Dictionary <string, int>(); var productIds = groupResult.Select(x => x.Key).Split(50); try { foreach (var items in productIds) { if (items != null && items.Any()) { using (var clientComment = new ProductCommentClient()) { var productComment = clientComment.GetCommentStatisticCount(items.ToList()); if (productComment.Success && productComment.Result != null) { foreach (var kvp in productComment.Result) { if (kvp.Value != 0) { commentTimes[kvp.Key] = kvp.Value; } } } else { Logger.Error($"comment服务异常.ex:{productComment.Exception}.msg:{productComment.ErrorMessage}"); } } } } if (commentTimes != null && commentTimes.Any()) { var issuccess = DalProductStatistics.UpdateShowCommentTimes(commentTimes); Logger.Info($"结束刷新.result:{issuccess}"); } } catch (System.Exception ex) { Logger.Error(ex); } } Logger.Info("结束刷新"); }
public static CommentOrderResponse CreateProductComment(CreateProductCommentRequest request) { CommentOrderResponse result = null; try { using (var client = new ProductCommentClient()) { var getResult = client.CreateProductComment(request); getResult.ThrowIfException(true); result = getResult.Result; } } catch (Exception ex) { logger.Error(ex); } return(result); }
/// <summary> /// 分批执行 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> private static void ExecuteByPage(int pageIndex, int pageSize) { #region 批量更新 List <int> commentIDs = DalProductStatistics.SelectAdditionComment_Page(pageIndex, pageSize).ToList(); if (commentIDs == null || !commentIDs.Any()) { return; } using (var client = new ProductCommentClient()) { var result = client.RefreshCommentToESByCommentIds(commentIDs); if (result.Success && result.Result) { exeCount += commentIDs.Count; Logger.Info($"更新 追评评论 成功 pageIndex ={pageIndex} & exeCount{exeCount}"); } else { Logger.Info($"更新 追评评论 失败 pageIndex ={pageIndex} 异常 message={result.ErrorMessage} & maxid={commentIDs.Max()}&minid={commentIDs.Min()} "); } } #endregion }
private static void BatchUpdateProductCommentLabel(int pageIndex, int pageSize) { #region 批量更新 List <EsProductCommentModel> comments = DalProductStatistics.SelectCommentsByPage(pageIndex, pageSize).Result.ToList(); count += comments.Count; if (comments == null || !comments.Any()) { return; } using (var client = new ProductCommentClient()) { var result = client.RefreshCommentToESByCommentIds(comments.Select(p => p.Id).ToList()); if (result.Success && result.Result) { Logger.Info($"更新 产品评论的标签 BatchUpdateProductCommentLabel pageIndex ={pageIndex} 有效的 comment 数目 ={comments.Count()} & 总次数count{count}"); } else { Logger.Info($"更新 产品评论的标签 更新失败 BatchUpdateProductCommentLabel pageIndex ={pageIndex} 异常 message={result.ErrorMessage} & ={comments.Count()}"); } } #endregion }
public PartialViewResult ProductComments(int id) { List<Comment> commentList = new ProductCommentClient().GetCommentsByProductID(id).ToList(); return PartialView("_comments", commentList); }