From 8e5ac2966aceef3f3d3b91be3624bd355ceee928 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Mon, 5 Jul 2010 09:34:26 +0000 Subject: [PATCH] Implemented active users page --- Builder/IISMainHandler/build.txt | 2 +- Builder/IISUploadHandler/build.txt | 2 +- Common/dataobjects/User.cs | 2 +- IISMainHandler/HandlersFactory.cs | 11 ++++- IISMainHandler/IISMainHandler.csproj | 1 + IISMainHandler/PageOuter.cs | 4 ++ .../response/ActiveAccountListHandler.cs | 45 +++++++++++++++++++ .../handlers/response/UserListHandler.cs | 2 +- templates/Full/UserList.xslt | 13 ++++++ 9 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 IISMainHandler/handlers/response/ActiveAccountListHandler.cs diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 09c4039..bccc87b 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -576 \ No newline at end of file +581 \ No newline at end of file diff --git a/Builder/IISUploadHandler/build.txt b/Builder/IISUploadHandler/build.txt index 3bac779..75af06e 100644 --- a/Builder/IISUploadHandler/build.txt +++ b/Builder/IISUploadHandler/build.txt @@ -1 +1 @@ -310 \ No newline at end of file +315 \ No newline at end of file diff --git a/Common/dataobjects/User.cs b/Common/dataobjects/User.cs index a9b6e31..283ff2c 100644 --- a/Common/dataobjects/User.cs +++ b/Common/dataobjects/User.cs @@ -180,7 +180,7 @@ namespace FLocal.Common.dataobjects { return result; } - public static IEnumerable getUsers(Diapasone diapasone, UserContext context) { + public static IEnumerable getUsers(Diapasone diapasone) { return User.LoadByIds( from stringId in Config.instance.mainConnection.LoadIdsByConditions( User.TableSpec.instance, diff --git a/IISMainHandler/HandlersFactory.cs b/IISMainHandler/HandlersFactory.cs index facac65..c07f855 100644 --- a/IISMainHandler/HandlersFactory.cs +++ b/IISMainHandler/HandlersFactory.cs @@ -69,7 +69,16 @@ namespace FLocal.IISHandler { case "migrateaccount": return new handlers.response.MigrateAccountHandler(); case "users": - return new handlers.response.UserListHandler(); + if(context.requestParts.Length < 2) { + return new handlers.response.UserListHandler(); + } else { + switch(context.requestParts[1].ToLower()) { + case "active": + return new handlers.response.ActiveAccountListHandler(); + default: + return new handlers.response.UserListHandler(); + } + } case "user": if(context.requestParts.Length < 2) { return new handlers.WrongUrlHandler(); diff --git a/IISMainHandler/IISMainHandler.csproj b/IISMainHandler/IISMainHandler.csproj index 27b8a4d..da49621 100644 --- a/IISMainHandler/IISMainHandler.csproj +++ b/IISMainHandler/IISMainHandler.csproj @@ -70,6 +70,7 @@ + diff --git a/IISMainHandler/PageOuter.cs b/IISMainHandler/PageOuter.cs index 3aa8f31..a06a574 100644 --- a/IISMainHandler/PageOuter.cs +++ b/IISMainHandler/PageOuter.cs @@ -21,6 +21,10 @@ namespace FLocal.IISHandler { this.perPage = perPage; } + public static PageOuter createUnlimited(long perPage) { + return new PageOuter(perPage); + } + public static PageOuter create(long perPage, long total) { PageOuter result = new PageOuter(0, perPage, perPage); result.total = total; diff --git a/IISMainHandler/handlers/response/ActiveAccountListHandler.cs b/IISMainHandler/handlers/response/ActiveAccountListHandler.cs new file mode 100644 index 0000000..e5a949e --- /dev/null +++ b/IISMainHandler/handlers/response/ActiveAccountListHandler.cs @@ -0,0 +1,45 @@ +п»їusing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web; +using System.Xml.Linq; +using FLocal.Common; +using FLocal.Common.dataobjects; +using FLocal.Core.DB; + +namespace FLocal.IISHandler.handlers.response { + + class ActiveAccountListHandler : AbstractGetHandler { + + override protected string templateName { + get { + return "UserList.xslt"; + } + } + + override protected XElement[] getSpecificData(WebContext context) { + //PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.usersPerPage, 1); + PageOuter pageOuter = PageOuter.createUnlimited(context.userSettings.usersPerPage); + IEnumerable accounts = Account.LoadByIds( + from stringId in Config.instance.mainConnection.LoadIdsByConditions( + Account.TableSpec.instance, + new Core.DB.conditions.ComparisonCondition( + Account.TableSpec.instance.getColumnSpec(Account.TableSpec.FIELD_NEEDSMIGRATION), + Core.DB.conditions.ComparisonType.EQUAL, + "0" + ), + pageOuter + ) select int.Parse(stringId) + ); + return new XElement[] { + new XElement("users", + from account in accounts select account.user.exportToXmlForViewing(context), + pageOuter.exportToXml(2, 5, 2) + ) + }; + } + + } + +} \ No newline at end of file diff --git a/IISMainHandler/handlers/response/UserListHandler.cs b/IISMainHandler/handlers/response/UserListHandler.cs index 0e75003..d9ac2e1 100644 --- a/IISMainHandler/handlers/response/UserListHandler.cs +++ b/IISMainHandler/handlers/response/UserListHandler.cs @@ -20,7 +20,7 @@ namespace FLocal.IISHandler.handlers.response { override protected XElement[] getSpecificData(WebContext context) { PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.usersPerPage, 1); - IEnumerable users = User.getUsers(pageOuter, context); + IEnumerable users = User.getUsers(pageOuter); return new XElement[] { new XElement("users", from user in users select user.exportToXmlForViewing(context), diff --git a/templates/Full/UserList.xslt b/templates/Full/UserList.xslt index b898579..0048c8c 100644 --- a/templates/Full/UserList.xslt +++ b/templates/Full/UserList.xslt @@ -58,6 +58,19 @@ + + + + + + +
+ + Активные (смигрированные) + +
+ +