コード例 #1
0
ファイル: Service.asmx.cs プロジェクト: davelondon/dontstayin
		public CommentResult GetThreadComments(int threadK, int pageNumber, bool getCommentsOnly)
		{
			Thread thread = new Thread(threadK);
			GroupUsr groupUsr = null;
			if (Usr.Current != null && thread.Group != null)
			{
				groupUsr = thread.Group.GetGroupUsr(Usr.Current);
			}
			ThreadUsr threadUsr = null;
			if (Usr.Current != null && thread.CheckPermissionRead(Usr.Current))
			{
				try
				{
					threadUsr = new ThreadUsr(thread.K, Usr.Current.K);
				}
				catch (BobNotFound)
				{
				}
			}


			CommentResult result = new CommentResult();

			if (pageNumber <= 0)
			{
				pageNumber = (result.firstUnreadPage > 0) ? result.firstUnreadPage : 1;
			}

			result.comments = thread.ChildComments().Page(pageNumber, Vars.CommentsPerPage).ConvertAll(c => CreateCommentStub(c, threadUsr, groupUsr)).ToArray();
			if (result.comments.Length == 0)
			{
				throw new Exception("No comments to retrieve.");
			}

			result.firstUnreadPage = !getCommentsOnly && threadUsr != null && threadUsr.ViewCommentsInUse > 0 ?
					(threadUsr.ViewCommentsInUse / Vars.CommentsPerPage) + 1 : 0;
			result.lastPage = !getCommentsOnly ? thread.LastPage : 0;
			result.currentPage = pageNumber;
			result.initialComment = (!getCommentsOnly && pageNumber > 1) ? CreateCommentStub(thread.ChildComments()[0], threadUsr, groupUsr) : null;
			result.viewComments = !getCommentsOnly && threadUsr != null ? threadUsr.ViewCommentsInUse : 0;
			result.totalComments = !getCommentsOnly ? thread.TotalComments : 0;

			return result;
		}
コード例 #2
0
		void getThreadCommentsSuccess(CommentResult result, object userContext, string methodName)
		{
			pageNumber = result.currentPage;
			Comments = result.comments;
			if (InitialComment == null)
			{
				InitialComment = (result.initialComment != null) ? result.initialComment : result.comments[0];
			}
			if (LastPage == 0)
			{
				LastPage = result.lastPage;
			}
			if (FirstUnreadPage == 0)
			{
				FirstUnreadPage = result.firstUnreadPage;
			}
			if (TotalComments == 0)
			{
				TotalComments = result.totalComments;
			}
			if (ViewComments == 0)
			{
				ViewComments = result.viewComments;
			}

			updateLastKnownCommentK(result.comments[result.comments.Length - 1].k);

			loaded();
			Service.SetThreadUsr(this.threadK, this.pageNumber, null, null, null, -1);
		}