private bool CheckParam() { if (CommentId > 0) { comment = db.TpxinCommentHisSet.FirstOrDefault(c => c.Hisid == CommentId); } else { CommentId = comment.Hisid; } if (comment == null) { log.Info($"{nameof(CommentId)}={CommentId}:评论不存在"); return(false); } return(true); }
/// <summary> /// /// </summary> public void Execute() { string guidStr = Guid.NewGuid().ToString(); log.Info($"开始执行评论分发{guidStr}"); if (!Try(CheckParam)) { return; } db.Configuration.AutoDetectChangesEnabled = false; if (Try(ExecuteCore)) { log.Info($"执行评论分发成功-结束{guidStr}"); } else { log.Info($"执行评论分发失败-结束{guidStr}"); } db.Configuration.AutoDetectChangesEnabled = true; CommentId = 0; comment = null; }
/// <summary> /// /// </summary> /// <param name="comment"></param> public void Execute(TpxinCommentHis comment) { this.comment = comment; Execute(); }
/// <summary> /// /// </summary> /// <param name="comment"></param> public CommentDispatchService(TpxinCommentHis comment) { this.comment = comment; }
/// <summary> /// 评论 /// </summary> /// <param name="req"></param> /// <returns></returns> public bool CreateComment(ReqCreateComment req) { if (req.Content.Length > 100) { Alert("评论不能超过100字哦"); return(false); } TnetReginfo regInfo = PxinCache.GetRegInfo(req.Nodeid); TpxinMessage tpxinMessage = db.TpxinMessageSet.FirstOrDefault(a => a.Infoid == req.Infoid && a.Status == 1); if (tpxinMessage == null) { Alert("信友圈信息不存在"); return(false); } //发布文章的用户不只是自己的要支付V点 if (tpxinMessage.Price > 0 && tpxinMessage.Nodeid != regInfo.Nodeid) { TpxinPayhis tpxinPayhis = db.TpxinPayhisSet.FirstOrDefault(a => a.Infoid == tpxinMessage.Infoid && a.Nodeid == req.Nodeid && a.Typeid == 3); if (tpxinPayhis == null) { Alert("请支付V点查看后评论"); return(false); } } int Pnodeid = 0; if (req.Phisid > 0) { TpxinCommentHis His = db.TpxinCommentHisSet.FirstOrDefault(a => a.Hisid == req.Phisid && a.Status == 1 && a.Infoid == req.Infoid); if (His == null) { Alert("回复的评论不存在,或已删除"); return(false); } Pnodeid = His.Nodeid; if (Pnodeid == req.Nodeid) { Alert("自己不能回复自己的评论"); return(false); } } //添加评论历史表 TpxinCommentHis commentHis = new TpxinCommentHis { Nodeid = req.Nodeid, Content = req.Content, Createtime = DateTime.Now, Infoid = req.Infoid, Remarks = "", Status = 1, Phisid = req.Phisid, Pnodeid = Pnodeid }; db.TpxinCommentHisSet.Add(commentHis); //添加文章评论次数 tpxinMessage.Commentnum += 1; if (db.SaveChanges() <= 0) { Alert("评论失败"); return(false); } PxinSerivce.EnqueueComment(commentHis.Hisid); Alert("评论成功", 1); CommentHisId = commentHis.Hisid; return(true); }