private static void updateParentReplies(OpenComment c) { if (c.ParentId == 0) { return; } OpenComment p = OpenComment.findById(c.ParentId); if (p == null) { c.ParentId = 0; c.update(); return; } //------------------------------------------------ p.Replies = OpenComment.count("ParentId=" + p.Id); //------------------------------------------------- List <OpenComment> subFirst = OpenComment.find("ParentId=" + p.Id + " order by Id asc").list(OpenComment.subCacheSize); List <OpenComment> subLast = OpenComment.find("ParentId=" + p.Id + " order by Id desc").list(OpenComment.subCacheSize); p.FirstReplyIds = strUtil.GetIds(subFirst); p.LastReplyIds = strUtil.GetIds(subLast); p.update(); }
private static void updateTargetReplies(OpenComment c, int replies) { Type targetType = Entity.GetType(c.TargetDataType); ICommentTarget target = ndb.findById(targetType, c.TargetDataId) as ICommentTarget; if (target == null) { return; } target.Replies = replies; db.update(target); if (c.AppId <= 0) { return; } Type appType = target.GetAppType(); if (appType == null) { return; } ICommentApp app = ndb.findById(appType, c.AppId) as ICommentApp; if (app == null) { return; } int appCount = OpenComment.count("AppId=" + c.AppId + " and TargetDataType='" + c.TargetDataType + "'"); app.CommentCount = appCount; db.update(app); }
private void updateTargetReplies(OpenComment c, int replies) { ICommentTarget target = GetTarget(c) as ICommentTarget; if (target != null) { target.Replies = replies; db.update(target); } // feed replies Microblog mblog = getFeed(c); if (mblog != null) { mblog.Replies = replies; mblog.update(); } if (c.AppId > 0 && target != null) { Type appType = target.GetAppType(); if (appType != null) { ICommentApp app = ndb.findById(appType, c.AppId) as ICommentApp; if (app != null) { int appCount = OpenComment.count("AppId=" + c.AppId + " and TargetDataType='" + c.TargetDataType + "'"); app.CommentCount = appCount; db.update(app); } } } }