diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 28a0b01..eb0b3e7 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -1356 \ No newline at end of file +1358 \ No newline at end of file diff --git a/Common/dataobjects/Board.cs b/Common/dataobjects/Board.cs index 18c8b87..0374aaf 100644 --- a/Common/dataobjects/Board.cs +++ b/Common/dataobjects/Board.cs @@ -332,7 +332,7 @@ namespace FLocal.Common.dataobjects { ); } - public IEnumerable getThreads(Diapasone diapasone) { + public IEnumerable getThreads(Diapasone diapasone, bool isAscending) { return this.getThreads( diapasone, new SortSpec[] { @@ -342,7 +342,7 @@ namespace FLocal.Common.dataobjects { ), new SortSpec( Thread.TableSpec.instance.getColumnSpec(Thread.TableSpec.FIELD_LASTPOSTID), - false + isAscending ), } ); diff --git a/Common/dataobjects/PMConversation.cs b/Common/dataobjects/PMConversation.cs index b0484a8..6c58df9 100644 --- a/Common/dataobjects/PMConversation.cs +++ b/Common/dataobjects/PMConversation.cs @@ -155,7 +155,7 @@ namespace FLocal.Common.dataobjects { return result; } - public IEnumerable getMessages(Diapasone diapasone, UserContext context) { + public IEnumerable getMessages(Diapasone diapasone, UserContext context, bool isAscending) { return PMMessage.LoadByIds( from stringId in Config.instance.mainConnection.LoadIdsByConditions( PMMessage.TableSpec.instance, @@ -177,7 +177,7 @@ namespace FLocal.Common.dataobjects { new SortSpec[] { new SortSpec( PMMessage.TableSpec.instance.getIdSpec(), - true + isAscending ), } ) select int.Parse(stringId) @@ -240,7 +240,7 @@ namespace FLocal.Common.dataobjects { }); } - public static IEnumerable getConversations(Account owner, Diapasone diapasone) { + public static IEnumerable getConversations(Account owner, Diapasone diapasone, bool isAscending) { return LoadByIds( from stringId in Config.instance.mainConnection.LoadIdsByConditions( TableSpec.instance, @@ -254,7 +254,7 @@ namespace FLocal.Common.dataobjects { new SortSpec[] { new SortSpec( TableSpec.instance.getColumnSpec(TableSpec.FIELD_LASTMESSAGEID), - false + isAscending ) } ) select int.Parse(stringId) diff --git a/Common/dataobjects/Thread.cs b/Common/dataobjects/Thread.cs index 9654521..ef07181 100644 --- a/Common/dataobjects/Thread.cs +++ b/Common/dataobjects/Thread.cs @@ -230,7 +230,7 @@ namespace FLocal.Common.dataobjects { return result; } - public IEnumerable getPosts(Diapasone diapasone) { + public IEnumerable getPosts(Diapasone diapasone, bool isAscending) { return Post.LoadByIds( from stringId in Config.instance.mainConnection.LoadIdsByConditions( Post.TableSpec.instance, @@ -244,7 +244,7 @@ namespace FLocal.Common.dataobjects { new SortSpec[] { new SortSpec( Post.TableSpec.instance.getIdSpec(), - true + isAscending ), } ) select int.Parse(stringId) diff --git a/Common/dataobjects/User.cs b/Common/dataobjects/User.cs index 8c44aaa..3ff92bf 100644 --- a/Common/dataobjects/User.cs +++ b/Common/dataobjects/User.cs @@ -208,7 +208,7 @@ namespace FLocal.Common.dataobjects { return result; } - public static IEnumerable getUsers(Diapasone diapasone) { + public static IEnumerable getUsers(Diapasone diapasone, bool isAscending) { return User.LoadByIds( from stringId in Config.instance.mainConnection.LoadIdsByConditions( User.TableSpec.instance, @@ -218,7 +218,7 @@ namespace FLocal.Common.dataobjects { new SortSpec[] { new SortSpec( User.TableSpec.instance.getIdSpec(), - true + isAscending ), } ) select int.Parse(stringId) @@ -231,7 +231,7 @@ namespace FLocal.Common.dataobjects { return desiredLayer; } - public IEnumerable getPosts(Diapasone diapasone) { + public IEnumerable getPosts(Diapasone diapasone, bool isAscending) { return Post.LoadByIds( from stringId in Config.instance.mainConnection.LoadIdsByConditions( Post.TableSpec.instance, @@ -245,14 +245,14 @@ namespace FLocal.Common.dataobjects { new SortSpec[] { new SortSpec( Post.TableSpec.instance.getIdSpec(), - false + isAscending ), } ) select int.Parse(stringId) ); } - public IEnumerable getReplies(Diapasone diapasone) { + public IEnumerable getReplies(Diapasone diapasone, bool isAscending) { JoinSpec parent = new JoinSpec( Post.TableSpec.instance.getColumnSpec(Post.TableSpec.FIELD_PARENTPOSTID), Post.TableSpec.instance, @@ -281,14 +281,14 @@ namespace FLocal.Common.dataobjects { new SortSpec[] { new SortSpec( Post.TableSpec.instance.getIdSpec(), - false + isAscending ), } ) select int.Parse(stringId) ); } - public IEnumerable getThreads(Diapasone diapasone) { + public IEnumerable getThreads(Diapasone diapasone, bool isAscending) { return Thread.LoadByIds( from stringId in Config.instance.mainConnection.LoadIdsByConditions( Thread.TableSpec.instance, @@ -302,7 +302,7 @@ namespace FLocal.Common.dataobjects { new SortSpec[] { new SortSpec( Thread.TableSpec.instance.getColumnSpec(Thread.TableSpec.FIELD_LASTPOSTID), - false + isAscending ), } ) select int.Parse(stringId) diff --git a/IISMainHandler/PageOuter.cs b/IISMainHandler/PageOuter.cs index 8bffdfa..60efa96 100644 --- a/IISMainHandler/PageOuter.cs +++ b/IISMainHandler/PageOuter.cs @@ -11,54 +11,64 @@ namespace FLocal.IISHandler { public readonly long perPage; - private PageOuter(long start, long count, long perPage) + public readonly bool reversed; + + public bool ascendingDirection { + get { + return !this.reversed; + } + } + + public bool descendingDirection { + get { + return this.reversed; + } + } + + private PageOuter(long start, long count, long perPage, bool reversed) : base(start, count) { this.perPage = perPage; + this.reversed = reversed; } - private PageOuter(long perPage) + private PageOuter(long perPage, bool reversed) : base(0, -1) { this.perPage = perPage; + this.reversed = reversed; } public static PageOuter createUnlimited(long perPage) { - return new PageOuter(perPage); + return new PageOuter(perPage, false); } public static PageOuter create(long perPage, long total) { - PageOuter result = new PageOuter(0, perPage, perPage); + PageOuter result = new PageOuter(0, perPage, perPage, false); result.total = total; return result; } public static PageOuter createFromGet(string[] requestParts, long perPage, Dictionary> customAction, int offset) { + bool reversed = (requestParts.Length > (offset+1)) && (requestParts[offset+1].ToLower() == "reversed"); if(requestParts.Length > offset) { if(requestParts[offset].ToLower() == "all") { - return new PageOuter(perPage); + return new PageOuter(perPage, reversed); } else if(Char.IsDigit(requestParts[offset][0])) { - return new PageOuter(long.Parse(requestParts[offset]), perPage, perPage); + return new PageOuter(long.Parse(requestParts[offset]), perPage, perPage, reversed); } else { - return new PageOuter(customAction[requestParts[offset][0]](), perPage, perPage); + return new PageOuter(customAction[requestParts[offset][0]](), perPage, perPage, reversed); } } else { - return new PageOuter(0, perPage, perPage); + return new PageOuter(0, perPage, perPage, reversed); } } - /*public static PageOuter createFromGet(string[] requestParts, long perPage, Dictionary> customAction) { - return createFromGet(requestParts, perPage, customAction, 2); - }*/ - public static PageOuter createFromGet(string[] requestParts, long perPage, int offset) { return createFromGet(requestParts, perPage, new Dictionary>(), offset); } - /*public static PageOuter createFromGet(string[] requestParts, long perPage) { - return createFromGet(requestParts, perPage, new Dictionary>()); - }*/ - public XElement exportToXml(int left, int current, int right) { XElement result = new XElement("pageOuter", + new XElement("isReversed", this.reversed), new XElement("unlimited", (this.count < 1).ToPlainString()), new XElement("start", this.start), new XElement("count", this.count), diff --git a/IISMainHandler/handlers/BoardHandler.cs b/IISMainHandler/handlers/BoardHandler.cs index ecb8bd8..132f15b 100644 --- a/IISMainHandler/handlers/BoardHandler.cs +++ b/IISMainHandler/handlers/BoardHandler.cs @@ -22,7 +22,7 @@ namespace FLocal.IISHandler.handlers { override protected IEnumerable getSpecificData(WebContext context) { Board board = Board.LoadById(int.Parse(context.requestParts[1])); PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.threadsPerPage, 2); - IEnumerable threads = board.getThreads(pageOuter); + IEnumerable threads = board.getThreads(pageOuter, pageOuter.descendingDirection); XElement[] result = new XElement[] { new XElement("currentLocation", board.exportToXmlSimpleWithParent(context)), new XElement("boards", from subBoard in board.subBoards select subBoard.exportToXml(context, Board.SubboardsOptions.FirstLevel)), diff --git a/IISMainHandler/handlers/ThreadHandler.cs b/IISMainHandler/handlers/ThreadHandler.cs index 5656424..4517da9 100644 --- a/IISMainHandler/handlers/ThreadHandler.cs +++ b/IISMainHandler/handlers/ThreadHandler.cs @@ -48,7 +48,7 @@ namespace FLocal.IISHandler.handlers { }, 2 ); - IEnumerable posts = thread.getPosts(pageOuter); + IEnumerable posts = thread.getPosts(pageOuter, pageOuter.ascendingDirection); int lastReadId = 0; if(context.session != null) { diff --git a/IISMainHandler/handlers/response/AllPostsHandler.cs b/IISMainHandler/handlers/response/AllPostsHandler.cs index 3937ab7..17d28a5 100644 --- a/IISMainHandler/handlers/response/AllPostsHandler.cs +++ b/IISMainHandler/handlers/response/AllPostsHandler.cs @@ -40,7 +40,7 @@ namespace FLocal.IISHandler.handlers.response { new SortSpec[] { new SortSpec( Post.TableSpec.instance.getIdSpec(), - false + pageOuter.descendingDirection ) } ) diff --git a/IISMainHandler/handlers/response/AllThreadsHandler.cs b/IISMainHandler/handlers/response/AllThreadsHandler.cs index 67e4241..ded85e3 100644 --- a/IISMainHandler/handlers/response/AllThreadsHandler.cs +++ b/IISMainHandler/handlers/response/AllThreadsHandler.cs @@ -40,7 +40,7 @@ namespace FLocal.IISHandler.handlers.response { new SortSpec[] { new SortSpec( Thread.TableSpec.instance.getColumnSpec(Thread.TableSpec.FIELD_LASTPOSTID), - false + pageOuter.descendingDirection ) } ) diff --git a/IISMainHandler/handlers/response/BoardAsThread.cs b/IISMainHandler/handlers/response/BoardAsThread.cs index e82a85b..34fdfd1 100644 --- a/IISMainHandler/handlers/response/BoardAsThread.cs +++ b/IISMainHandler/handlers/response/BoardAsThread.cs @@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response { new SortSpec[] { new SortSpec( Thread.TableSpec.instance.getColumnSpec(Thread.TableSpec.FIELD_ID), - true + pageOuter.ascendingDirection ), } ); diff --git a/IISMainHandler/handlers/response/ConversationHandler.cs b/IISMainHandler/handlers/response/ConversationHandler.cs index ba824d9..7d20a2d 100644 --- a/IISMainHandler/handlers/response/ConversationHandler.cs +++ b/IISMainHandler/handlers/response/ConversationHandler.cs @@ -54,7 +54,7 @@ namespace FLocal.IISHandler.handlers.response { }, 4 ); - IEnumerable messages = conversation.getMessages(pageOuter, context); + IEnumerable messages = conversation.getMessages(pageOuter, context, pageOuter.ascendingDirection); XElement[] result = new XElement[] { conversation.exportToXml(context, false), diff --git a/IISMainHandler/handlers/response/ConversationsHandler.cs b/IISMainHandler/handlers/response/ConversationsHandler.cs index 6744c68..09863fa 100644 --- a/IISMainHandler/handlers/response/ConversationsHandler.cs +++ b/IISMainHandler/handlers/response/ConversationsHandler.cs @@ -21,7 +21,7 @@ namespace FLocal.IISHandler.handlers.response { override protected IEnumerable getSpecificData(WebContext context) { PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.threadsPerPage, 2); - IEnumerable conversations = PMConversation.getConversations(context.session.account, pageOuter); + IEnumerable conversations = PMConversation.getConversations(context.session.account, pageOuter, pageOuter.descendingDirection); XElement[] result = new XElement[] { new XElement("conversations", from conversation in conversations select conversation.exportToXml(context, false), diff --git a/IISMainHandler/handlers/response/UploadListHandler.cs b/IISMainHandler/handlers/response/UploadListHandler.cs index 1b89821..e15b192 100644 --- a/IISMainHandler/handlers/response/UploadListHandler.cs +++ b/IISMainHandler/handlers/response/UploadListHandler.cs @@ -30,11 +30,11 @@ namespace FLocal.IISHandler.handlers.response { new SortSpec[] { new SortSpec( Upload.TableSpec.instance.getColumnSpec(Upload.TableSpec.FIELD_UPLOADDATE), - true + pageOuter.ascendingDirection ), new SortSpec( Upload.TableSpec.instance.getIdSpec(), - true + pageOuter.ascendingDirection ), } ) select int.Parse(stringId) diff --git a/IISMainHandler/handlers/response/UserListHandler.cs b/IISMainHandler/handlers/response/UserListHandler.cs index fd33133..a745e29 100644 --- a/IISMainHandler/handlers/response/UserListHandler.cs +++ b/IISMainHandler/handlers/response/UserListHandler.cs @@ -20,7 +20,7 @@ namespace FLocal.IISHandler.handlers.response { override protected IEnumerable getSpecificData(WebContext context) { PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.usersPerPage, 2); - IEnumerable users = User.getUsers(pageOuter); + IEnumerable users = User.getUsers(pageOuter, pageOuter.ascendingDirection); return new XElement[] { new XElement("users", from user in users select user.exportToXmlForViewing(context), diff --git a/IISMainHandler/handlers/response/UserPollsParticipatedHandler.cs b/IISMainHandler/handlers/response/UserPollsParticipatedHandler.cs index 9b7eb92..e9d6cc5 100644 --- a/IISMainHandler/handlers/response/UserPollsParticipatedHandler.cs +++ b/IISMainHandler/handlers/response/UserPollsParticipatedHandler.cs @@ -39,7 +39,7 @@ namespace FLocal.IISHandler.handlers.response { new SortSpec[] { new SortSpec( Poll.Vote.TableSpec.instance.getIdSpec(), - false + pageOuter.descendingDirection ) } ) select int.Parse(stringId) diff --git a/IISMainHandler/handlers/response/UserPostsHandler.cs b/IISMainHandler/handlers/response/UserPostsHandler.cs index be01a75..9b994ba 100644 --- a/IISMainHandler/handlers/response/UserPostsHandler.cs +++ b/IISMainHandler/handlers/response/UserPostsHandler.cs @@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response { context.userSettings.postsPerPage, 4 ); - IEnumerable posts = user.getPosts(pageOuter); + IEnumerable posts = user.getPosts(pageOuter, pageOuter.descendingDirection); return new XElement[] { new XElement("posts", diff --git a/IISMainHandler/handlers/response/UserRepliesHandler.cs b/IISMainHandler/handlers/response/UserRepliesHandler.cs index d87ffc0..cf87ccb 100644 --- a/IISMainHandler/handlers/response/UserRepliesHandler.cs +++ b/IISMainHandler/handlers/response/UserRepliesHandler.cs @@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response { context.userSettings.postsPerPage, 4 ); - IEnumerable posts = user.getReplies(pageOuter); + IEnumerable posts = user.getReplies(pageOuter, pageOuter.descendingDirection); return new XElement[] { user.exportToXmlForViewing(context), diff --git a/IISMainHandler/handlers/response/UserThreadsHandler.cs b/IISMainHandler/handlers/response/UserThreadsHandler.cs index b915f55..7ff8921 100644 --- a/IISMainHandler/handlers/response/UserThreadsHandler.cs +++ b/IISMainHandler/handlers/response/UserThreadsHandler.cs @@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response { context.userSettings.postsPerPage, 4 ); - IEnumerable threads = user.getThreads(pageOuter); + IEnumerable threads = user.getThreads(pageOuter, pageOuter.descendingDirection); return new XElement[] { new XElement("threads",