From 264e809af9f5e1e32b226d7a98bfbdf1d9908b43 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Wed, 7 Jul 2010 22:16:10 +0000 Subject: [PATCH] 'Who is online' implemented --- Builder/IISMainHandler/build.txt | 2 +- Builder/IISUploadHandler/build.txt | 2 +- Common/dataobjects/Account.cs | 2 +- IISMainHandler/HandlersFactory.cs | 2 + IISMainHandler/IISMainHandler.csproj | 1 + .../handlers/response/WhoIsOnlineHandler.cs | 45 +++++++++++++++++++ templates/Full/elems/Header.xslt | 5 ++- 7 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 IISMainHandler/handlers/response/WhoIsOnlineHandler.cs diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 0da6a13..a869e99 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -630 \ No newline at end of file +638 \ No newline at end of file diff --git a/Builder/IISUploadHandler/build.txt b/Builder/IISUploadHandler/build.txt index e8930b6..3456e74 100644 --- a/Builder/IISUploadHandler/build.txt +++ b/Builder/IISUploadHandler/build.txt @@ -1 +1 @@ -364 \ No newline at end of file +372 \ No newline at end of file diff --git a/Common/dataobjects/Account.cs b/Common/dataobjects/Account.cs index 69962d4..93fc049 100644 --- a/Common/dataobjects/Account.cs +++ b/Common/dataobjects/Account.cs @@ -177,7 +177,7 @@ namespace FLocal.Common.dataobjects { public static Account tryAuthorize(string name, string password) { Account account = LoadByName(name); - if(account.passwordHash != account.hashPassword(password)) throw new FLocalException("Wrong password"); + if(account.passwordHash != account.hashPassword(password)) throw new FLocalException("Wrong password (" + account.hashPassword(password) + ")"); return account; } diff --git a/IISMainHandler/HandlersFactory.cs b/IISMainHandler/HandlersFactory.cs index 3e6a12c..75a43d9 100644 --- a/IISMainHandler/HandlersFactory.cs +++ b/IISMainHandler/HandlersFactory.cs @@ -77,6 +77,8 @@ namespace FLocal.IISHandler { switch(context.requestParts[1].ToLower()) { case "active": return new handlers.response.ActiveAccountListHandler(); + case "online": + return new handlers.response.WhoIsOnlineHandler(); default: return new handlers.response.UserListHandler(); } diff --git a/IISMainHandler/IISMainHandler.csproj b/IISMainHandler/IISMainHandler.csproj index 402d90f..a75803d 100644 --- a/IISMainHandler/IISMainHandler.csproj +++ b/IISMainHandler/IISMainHandler.csproj @@ -93,6 +93,7 @@ + diff --git a/IISMainHandler/handlers/response/WhoIsOnlineHandler.cs b/IISMainHandler/handlers/response/WhoIsOnlineHandler.cs new file mode 100644 index 0000000..d6bc6f6 --- /dev/null +++ b/IISMainHandler/handlers/response/WhoIsOnlineHandler.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; +using FLocal.Core.DB; +using FLocal.Core.DB.conditions; + +namespace FLocal.IISHandler.handlers.response { + + class WhoIsOnlineHandler : AbstractGetHandler { + + override protected string templateName { + get { + return "UserList.xslt"; + } + } + + override protected XElement[] getSpecificData(WebContext context) { + PageOuter pageOuter = PageOuter.createUnlimited(context.userSettings.usersPerPage); + IEnumerable sessions = + from stringId in Config.instance.mainConnection.LoadIdsByConditions( + Session.TableSpec.instance, + new Core.DB.conditions.ComparisonCondition( + Session.TableSpec.instance.getColumnSpec(Session.TableSpec.FIELD_LASTACTIVITY), + Core.DB.conditions.ComparisonType.GREATEROREQUAL, + DateTime.Now.Subtract(Config.instance.ActivityThreshold).ToUTCString() + ), + pageOuter + ) select Session.LoadById(Session.SessionKey.Parse(stringId)); + return new XElement[] { + new XElement("users", + from session in sessions select session.account.user.exportToXmlForViewing(context), + pageOuter.exportToXml(2, 5, 2) + ) + }; + } + + } + +} \ No newline at end of file diff --git a/templates/Full/elems/Header.xslt b/templates/Full/elems/Header.xslt index 918f779..4d5959b 100644 --- a/templates/Full/elems/Header.xslt +++ b/templates/Full/elems/Header.xslt @@ -73,7 +73,10 @@ Âõîä | - Êòî â îíëàéíå + + /Users/Online/ + Êòî â îíëàéíå + | /q/faq