public int GetRepliesByData(int dataId, String dataType) { OpenCommentCount objCount = OpenCommentCount.find("DataType=:dtype and DataId=" + dataId) .set("dtype", dataType) .first(); return(objCount == null ? 0 : objCount.Replies); }
public int GetRepliesByUrl(String url) { OpenCommentCount objCount = OpenCommentCount.find("TargetUrl=:url") .set("url", url) .first(); return(objCount == null ? 0 : objCount.Replies); }
private static void clearRootTargetRepliesByUrl(String url) { OpenCommentCount objCount = OpenCommentCount.find("TargetUrl=:url") .set("url", url) .first(); if (objCount == null) { return; } objCount.Replies = 0; objCount.update(); }
private static void clearRootTargetRepliesByData(int dataId, string dataType) { OpenCommentCount objCount = OpenCommentCount.find("DataType=:dtype and DataId=" + dataId) .set("dtype", dataType) .first(); if (objCount == null) { return; } objCount.Replies = 0; objCount.update(); }
private void updateRootTargetReplies(OpenComment c) { int replies; OpenCommentCount objCount; if (c.TargetDataId > 0 && strUtil.HasText(c.TargetDataType)) { replies = OpenComment.find("TargetDataType=:dtype and TargetDataId=" + c.TargetDataId) .set("dtype", c.TargetDataType) .count(); objCount = OpenCommentCount.find("DataType=:dtype and DataId=" + c.TargetDataId) .set("dtype", c.TargetDataType) .first(); } else { if (c.TargetUrl == null) { replies = 0; objCount = null; } else { replies = OpenComment.find("TargetUrl=:url") .set("url", c.TargetUrl) .count(); objCount = OpenCommentCount.find("TargetUrl=:url") .set("url", c.TargetUrl) .first(); } } if (objCount == null) { insertCommentCount(c, replies); } else { updateCommentCount(objCount, replies); } updateTargetReplies(c, replies); }