diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 8a32cf7..a9d8b73 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -250 \ No newline at end of file +257 \ No newline at end of file diff --git a/Builder/IISMainHandler/product.wxs b/Builder/IISMainHandler/product.wxs index eb4d903..f7cfb3d 100644 --- a/Builder/IISMainHandler/product.wxs +++ b/Builder/IISMainHandler/product.wxs @@ -61,6 +61,9 @@ + + + + + diff --git a/IISMainHandler/PageOuter.cs b/IISMainHandler/PageOuter.cs index 8bc2f17..bc79f76 100644 --- a/IISMainHandler/PageOuter.cs +++ b/IISMainHandler/PageOuter.cs @@ -41,13 +41,17 @@ namespace FLocal.IISHandler { } } - public static PageOuter createFromGet(string[] requestParts, long perPage, Dictionary> customAction) { + /*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) { + /*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", diff --git a/IISMainHandler/handlers/BoardHandler.cs b/IISMainHandler/handlers/BoardHandler.cs index 6805743..0946b2b 100644 --- a/IISMainHandler/handlers/BoardHandler.cs +++ b/IISMainHandler/handlers/BoardHandler.cs @@ -20,7 +20,7 @@ namespace FLocal.IISHandler.handlers { override protected XElement[] getSpecificData(WebContext context) { Board board = Board.LoadById(int.Parse(context.requestParts[1])); - PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.threadsPerPage); + PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.threadsPerPage, 2); IEnumerable threads = board.getThreads(pageOuter, context); return new XElement[] { new XElement("currentLocation", board.exportToXmlSimpleWithParent(context)), diff --git a/IISMainHandler/handlers/ThreadHandler.cs b/IISMainHandler/handlers/ThreadHandler.cs index 9c256de..adbecd5 100644 --- a/IISMainHandler/handlers/ThreadHandler.cs +++ b/IISMainHandler/handlers/ThreadHandler.cs @@ -48,7 +48,8 @@ namespace FLocal.IISHandler.handlers { new JoinSpec[0] ) } - } + }, + 2 ); IEnumerable posts = thread.getPosts(pageOuter, context); thread.incrementViewsCounter(); diff --git a/IISMainHandler/handlers/response/BoardAsThread.cs b/IISMainHandler/handlers/response/BoardAsThread.cs index c7fb52b..fe29cf4 100644 --- a/IISMainHandler/handlers/response/BoardAsThread.cs +++ b/IISMainHandler/handlers/response/BoardAsThread.cs @@ -20,7 +20,7 @@ namespace FLocal.IISHandler.handlers.response { override protected XElement[] getSpecificData(WebContext context) { Board board = Board.LoadById(int.Parse(context.requestParts[1])); - PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.postsPerPage); + PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.postsPerPage, 2); IEnumerable threads = board.getThreads( pageOuter, context, new SortSpec[] { diff --git a/IISMainHandler/handlers/response/UserListHandler.cs b/IISMainHandler/handlers/response/UserListHandler.cs index c4419b4..0e75003 100644 --- a/IISMainHandler/handlers/response/UserListHandler.cs +++ b/IISMainHandler/handlers/response/UserListHandler.cs @@ -19,7 +19,7 @@ namespace FLocal.IISHandler.handlers.response { } override protected XElement[] getSpecificData(WebContext context) { - PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.usersPerPage); + PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.usersPerPage, 1); IEnumerable users = User.getUsers(pageOuter, context); return new XElement[] { new XElement("users", diff --git a/ImportConsole/ImportConsole.csproj b/ImportConsole/ImportConsole.csproj index fe7ef5d..10fee14 100644 --- a/ImportConsole/ImportConsole.csproj +++ b/ImportConsole/ImportConsole.csproj @@ -31,6 +31,10 @@ 4 + + False + ..\ThirdParty\NConsoler\NConsoler.dll + diff --git a/ImportConsole/Program.cs b/ImportConsole/Program.cs index 2c299e8..e86c10d 100644 --- a/ImportConsole/Program.cs +++ b/ImportConsole/Program.cs @@ -7,10 +7,11 @@ using FLocal.Common.actions; using FLocal.Common.dataobjects; using FLocal.Core; using System.Configuration; +using NConsoler; namespace FLocal.ImportConsole { class Program { - static void Main(string[] args) { + public static void Main(string[] args) { if(!FLocal.Common.Config.isInitialized) { lock(typeof(FLocal.Common.Config)) { @@ -18,39 +19,54 @@ namespace FLocal.ImportConsole { FLocal.Common.Config.Init(ConfigurationManager.AppSettings); } } + Consolery.Run(typeof(Program), args); } + } + + [Action] + public static void ImportUsers() { for(int i=1; i<800; i++) { Console.Write("[" + i + "]"); foreach(string userName in ShallerGateway.getUserNames(i)) { - Console.Write("."); - Dictionary userData = ShallerGateway.getUserInfo(userName); - AbstractChange addUser = new InsertChange( - User.TableSpec.instance, - new Dictionary() { - { User.TableSpec.FIELD_NAME, new ScalarFieldValue(userName) }, - { User.TableSpec.FIELD_REGDATE, new ScalarFieldValue(DateTime.Parse(userData["regDate"]).ToUTCString()) }, - { User.TableSpec.FIELD_LOCATION, new ScalarFieldValue(userData["location"]) }, - { User.TableSpec.FIELD_SHOWPOSTSTOUSERS, new ScalarFieldValue("All") }, - { User.TableSpec.FIELD_SIGNATURE, new ScalarFieldValue(userData["signature"]) }, - { User.TableSpec.FIELD_TITLE, new ScalarFieldValue(userData["title"]) }, - { User.TableSpec.FIELD_TOTALPOSTS, new ScalarFieldValue("0") }, - { User.TableSpec.FIELD_USERGROUPID, new ScalarFieldValue("1") }, - { User.TableSpec.FIELD_BIOGRAPHY, new ScalarFieldValue(userData["biography"]) }, - } - ); - AbstractChange addAccount = new InsertChange( - Account.TableSpec.instance, - new Dictionary() { - { Account.TableSpec.FIELD_NAME, new ScalarFieldValue(userName.ToLower()) }, - { Account.TableSpec.FIELD_NEEDSMIGRATION, new ScalarFieldValue("1") }, - { Account.TableSpec.FIELD_PASSWORDHASH, new ScalarFieldValue("*") }, - { Account.TableSpec.FIELD_USERID, new ReferenceFieldValue(addUser) }, - } - ); - ChangeSetUtil.ApplyChanges(addUser, addAccount); + try { + User.LoadByName(userName); + Console.Write("-"); + } catch(NotFoundInDBException) { + Dictionary userData = ShallerGateway.getUserInfo(userName); + AbstractChange addUser = new InsertChange( + User.TableSpec.instance, + new Dictionary() { + { User.TableSpec.FIELD_NAME, new ScalarFieldValue(userName) }, + { User.TableSpec.FIELD_REGDATE, new ScalarFieldValue(DateTime.Parse(userData["regDate"]).ToUTCString()) }, + { User.TableSpec.FIELD_LOCATION, new ScalarFieldValue(userData["location"]) }, + { User.TableSpec.FIELD_SHOWPOSTSTOUSERS, new ScalarFieldValue("All") }, + { User.TableSpec.FIELD_SIGNATURE, new ScalarFieldValue(userData["signature"]) }, + { User.TableSpec.FIELD_TITLE, new ScalarFieldValue(userData["title"]) }, + { User.TableSpec.FIELD_TOTALPOSTS, new ScalarFieldValue("0") }, + { User.TableSpec.FIELD_USERGROUPID, new ScalarFieldValue("1") }, + { User.TableSpec.FIELD_BIOGRAPHY, new ScalarFieldValue(userData["biography"]) }, + } + ); + AbstractChange addAccount = new InsertChange( + Account.TableSpec.instance, + new Dictionary() { + { Account.TableSpec.FIELD_NAME, new ScalarFieldValue(userName.ToLower()) }, + { Account.TableSpec.FIELD_NEEDSMIGRATION, new ScalarFieldValue("1") }, + { Account.TableSpec.FIELD_PASSWORDHASH, new ScalarFieldValue("*") }, + { Account.TableSpec.FIELD_USERID, new ReferenceFieldValue(addUser) }, + } + ); + ChangeSetUtil.ApplyChanges(addUser, addAccount); + Console.Write("."); + } } } } + + [Action] + public static void ProcessUpload(string pathToUpload) { + throw new NotImplementedException(); + } } } diff --git a/ThirdParty/NConsoler/NConsoler.dll b/ThirdParty/NConsoler/NConsoler.dll new file mode 100644 index 0000000..d2c2b3d Binary files /dev/null and b/ThirdParty/NConsoler/NConsoler.dll differ diff --git a/templates/Full/UserList.xslt b/templates/Full/UserList.xslt index 1e456d6..f79d06c 100644 --- a/templates/Full/UserList.xslt +++ b/templates/Full/UserList.xslt @@ -51,7 +51,7 @@ страницы: - /UserList// + /Users/