From 47ff9101fda712c17b155b83b6a3be9a5614bbe5 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sun, 17 May 2015 01:28:44 -0700 Subject: [PATCH] Finished up changes for game task conversion. --- Plugins/BuildFiles/common.xml | 4 +- .../mineplex/chestConverter/AccountTask.java | 1 + .../chestConverter/ChestConverter.java | 110 +++- .../ChestConverterRepository.java | 4 +- .../mineplex/chestConverter/JsonWebCall.java | 12 +- .../mineplex/chestConverter/SearchConf.java | 6 +- Website/LOC.Core/SearchConf.cs | 2 +- Website/LOC.Core/Tokens/AccountTask.cs | 1 + .../Models/AccountAdministrator.cs | 24 +- .../LOC.Website.Web.Publish.xml | 480 +++++++++--------- Website/LOCWebsite.suo | Bin 474624 -> 474624 bytes 11 files changed, 349 insertions(+), 295 deletions(-) diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml index 06f154806..56ad32bcb 100644 --- a/Plugins/BuildFiles/common.xml +++ b/Plugins/BuildFiles/common.xml @@ -414,7 +414,7 @@ - + @@ -438,7 +438,7 @@ - + diff --git a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/AccountTask.java b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/AccountTask.java index f9433b184..122dbc580 100644 --- a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/AccountTask.java +++ b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/AccountTask.java @@ -2,6 +2,7 @@ package mineplex.chestConverter; public class AccountTask { + public int Id; public String Task; public String UUID; } diff --git a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java index b292eb238..ed9388f45 100644 --- a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java +++ b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java @@ -1,10 +1,14 @@ package mineplex.chestConverter; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.logging.FileHandler; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; import java.util.logging.Logger; public class ChestConverter @@ -12,45 +16,95 @@ public class ChestConverter private static ChestConverterRepository _repository = null; private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + private static Logger _logger = Logger.getLogger("Converter"); + public static void main (String args[]) { + try + { + FileHandler fileHandler = new FileHandler("converter.log", true); + fileHandler.setFormatter(new Formatter() + { + @Override + public String format(LogRecord record) + { + return record.getMessage() + "\n"; + } + }); + _logger.addHandler(fileHandler); + _logger.setUseParentHandlers(false); + } + catch (SecurityException | IOException e1) + { + e1.printStackTrace(); + } + _repository = new ChestConverterRepository(); - int count = 0; - int batchAmount = 5000; + int lastId = 11056929; + int count = 50000; + int numOfRowsProcessed = lastId; HashMap tasks = _repository.getTaskList(); - while (true) + try { - long time = System.currentTimeMillis(); - HashMap> playerMap = new HashMap>(); - - - List taskList = _repository.getTasks(count, batchAmount); - - if (taskList == null || taskList.size() == 0) - return; - - for (AccountTask task : taskList) + while (true) { - if (!playerMap.containsKey(task.UUID)) - playerMap.put(task.UUID, new ArrayList()); + long time = System.currentTimeMillis(); + HashMap> playerMap = new HashMap>(); - playerMap.get(task.UUID).add(tasks.get(task.Task)); - } - - _repository.incrementClients(playerMap); - try - { - count += batchAmount; - log("Natural sleep. " + batchAmount + " took " + (System.currentTimeMillis() - time) / 1000 + " seconds. Count = " + + count); - Thread.sleep(100); - } - catch (InterruptedException e) - { - e.printStackTrace(); + + List taskList = _repository.getTasks(lastId, count); + + if (taskList != null && taskList.size() > 0) + { + for (AccountTask task : taskList) + { + if (!playerMap.containsKey(task.UUID)) + playerMap.put(task.UUID, new ArrayList()); + + playerMap.get(task.UUID).add(tasks.get(task.Task)); + + if (task.Id > lastId) + lastId = task.Id; + } + + _repository.incrementClients(playerMap); + try + { + numOfRowsProcessed += count; + log("Natural sleep. " + count + " took " + (System.currentTimeMillis() - time) / 1000 + " seconds. Count = " + + numOfRowsProcessed); + Thread.sleep(100); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + else if (numOfRowsProcessed > 17000000) + { + System.out.println("Count : " + numOfRowsProcessed); + _logger.info("Count : " + numOfRowsProcessed); + break; + } + else + { + System.out.println("No greater than 17 mil"); + _logger.info("No greater than 17 mil"); + System.out.println("Count : " + numOfRowsProcessed); + _logger.info("Count : " + numOfRowsProcessed); + } } } + catch (Exception e) + { + _logger.info(e.getMessage()); + } + finally + { + System.out.println("Count : " + numOfRowsProcessed); + _logger.info("Count : " + numOfRowsProcessed); + } } private static void log(String message) diff --git a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverterRepository.java b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverterRepository.java index 302a6ef0e..fcb0107c6 100644 --- a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverterRepository.java +++ b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverterRepository.java @@ -95,9 +95,9 @@ public class ChestConverterRepository return tasks; } - public List getTasks(int skip, int count) + public List getTasks(int lastId, int count) throws Exception { - return new JsonWebCall("http://accounts.mineplex.com/PlayerAccount/GetTasksByCount").Execute(new com.google.gson.reflect.TypeToken>(){}.getType(), new SearchConf(skip, count)); + return new JsonWebCall("http://accounts.mineplex.com/PlayerAccount/GetTasksByCount").Execute(new com.google.gson.reflect.TypeToken>(){}.getType(), new SearchConf(lastId, count)); } public void incrementClients(HashMap> playerList) diff --git a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/JsonWebCall.java b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/JsonWebCall.java index b16829d57..2bfc6f765 100644 --- a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/JsonWebCall.java +++ b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/JsonWebCall.java @@ -154,7 +154,7 @@ public class JsonWebCall return Execute(returnClass, (Object)null); } - public T Execute(Type returnType, Object argument) + public T Execute(Type returnType, Object argument) throws Exception { HttpClient httpClient = new DefaultHttpClient(_connectionManager); InputStream in = null; @@ -185,16 +185,6 @@ public class JsonWebCall returnData = new Gson().fromJson(result, returnType); } } - catch (Exception ex) - { - System.out.println("Error executing JsonWebCall: \n" + ex.getMessage()); - System.out.println("Result: \n" + result); - - for (StackTraceElement trace : ex.getStackTrace()) - { - System.out.println(trace); - } - } finally { httpClient.getConnectionManager().shutdown(); diff --git a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/SearchConf.java b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/SearchConf.java index 36c80fa46..98fa721a5 100644 --- a/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/SearchConf.java +++ b/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/SearchConf.java @@ -2,12 +2,12 @@ package mineplex.chestConverter; public class SearchConf { - public SearchConf(int skip, int count) + public SearchConf(int idIndex, int count) { - Skip = skip; + IdIndex = idIndex; Count = count; } - public int Skip; + public int IdIndex; public int Count; } diff --git a/Website/LOC.Core/SearchConf.cs b/Website/LOC.Core/SearchConf.cs index b6489ca78..f0650fecc 100644 --- a/Website/LOC.Core/SearchConf.cs +++ b/Website/LOC.Core/SearchConf.cs @@ -7,7 +7,7 @@ namespace LOC.Core { public class SearchConf { - public int Skip { get; set; } + public int IdIndex { get; set; } public int Count { get; set; } } } diff --git a/Website/LOC.Core/Tokens/AccountTask.cs b/Website/LOC.Core/Tokens/AccountTask.cs index 85dd2914e..d245c9d08 100644 --- a/Website/LOC.Core/Tokens/AccountTask.cs +++ b/Website/LOC.Core/Tokens/AccountTask.cs @@ -7,6 +7,7 @@ namespace LOC.Core.Tokens { public class AccountTask { + public int Id { get; set; } public string Task { get; set; } public string UUID { get; set; } } diff --git a/Website/LOC.Website.Common/Models/AccountAdministrator.cs b/Website/LOC.Website.Common/Models/AccountAdministrator.cs index 2c1f298ae..e7912bfd2 100644 --- a/Website/LOC.Website.Common/Models/AccountAdministrator.cs +++ b/Website/LOC.Website.Common/Models/AccountAdministrator.cs @@ -76,19 +76,27 @@ { var tasks = new List(); - using (var repository = _repositoryFactory.CreateRepository()) + try { - var gameTasks = repository.GetAll().OrderBy(x => x.GameTaskId).Skip(searchConf.Skip).Take(searchConf.Count).Include(x => x.Account).ToList(); - - foreach (var task in gameTasks) + using (var repository = _repositoryFactory.CreateRepository()) { - AccountTask accountTask = new AccountTask(); - accountTask.Task = task.TaskName; - accountTask.UUID = task.Account.Uuid; + var gameTasks = repository.GetAll().Where(x => x.GameTaskId > searchConf.IdIndex).OrderBy(x => x.GameTaskId).Take(searchConf.Count).Include(x => x.Account).ToList(); - tasks.Add(accountTask); + foreach (var task in gameTasks) + { + AccountTask accountTask = new AccountTask(); + accountTask.Id = task.GameTaskId; + accountTask.Task = task.TaskName; + accountTask.UUID = task.Account.Uuid; + + tasks.Add(accountTask); + } } } + catch (Exception ex) + { + _logger.Log("ERROR", ex.Message + " : " + ex.StackTrace); + } return tasks; } diff --git a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml index 71278577d..a57f4f271 100644 --- a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml +++ b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml @@ -1,11 +1,13 @@  + + @@ -16,18 +18,19 @@ - + - + + - - + + @@ -41,7 +44,7 @@ - + @@ -49,16 +52,18 @@ + + + - - + @@ -69,23 +74,24 @@ - + + - + + - - - + + @@ -93,7 +99,7 @@ - + @@ -101,43 +107,42 @@ - + - - + - + + - + + + - - - + - - - + + @@ -148,53 +153,47 @@ - + + - - - - + - - - + - - - + + - + - - - + + @@ -202,9 +201,9 @@ - + - + @@ -212,61 +211,62 @@ - + - - + + - - + - + - + + - - + + - + + - - + + - + - - + + - - + + - + + - @@ -282,47 +282,47 @@ - - + - + - - + - + - + + - + + @@ -333,29 +333,30 @@ - - + + - - + + - + + @@ -363,45 +364,40 @@ - + - + - - + - + - - - - - + - - + + @@ -412,29 +408,35 @@ - + - + + + + + + - - + + + @@ -442,94 +444,92 @@ - + - + - + + - - + - + - + - - + + - + - + - - + - + - - + - - + + - + - - + + - + - - - - - + + + + + - + + - @@ -543,9 +543,9 @@ - + - + @@ -553,29 +553,30 @@ - - + - + + + + - @@ -584,8 +585,8 @@ - + @@ -596,74 +597,70 @@ - - - + + - - - + + - + - - + + - + - - + + - + - - + - + - - + @@ -674,125 +671,128 @@ - + - + + + + + + - - - - + + + - + - + + - + - + - + + - - + - + - + - - + + - - + + - + - - + - + - + - - + - - + + - + - - + + - + - - - - - + + + + + - + + - @@ -806,9 +806,9 @@ - + - + @@ -816,29 +816,30 @@ - - + - + + + + - @@ -847,8 +848,8 @@ - + @@ -859,31 +860,29 @@ - - - + + - - - + + - + @@ -891,42 +890,40 @@ - + - - + + - + - - + - + - - + @@ -937,119 +934,122 @@ - + - + + + + + + - - + - + - + + - + - + - + + - - + - + - + - - + + - - + + - + - - + - + - - + - - + + - + - - + + - + - - - - - + + + + + - + \ No newline at end of file diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index f7fc529703b0807da0c414400d7716a22e1b8ec4..933119909849f609174782de9c4efc849fdfb493 100644 GIT binary patch delta 226 zcmZqpBh&ClWay<7U5i&(Z7u`mX%pYA-D(Ww3FW=0@p0%B$$X4(FAGi$Ii zOF9z+!*oU`CXMYS*I6$V3UEJ@QREhO4Cp=bcIT~|?`}>vv}P2U9&n6_Z?c~b*YpNY zwqjoQnamx9E9V@U82a@4@#zhdS(Uacd9kUnup}W2^J5EOPd?0I*#2cRBM>tIF*6XeZ2z*EHAI;u zg^7V-I-?Vl#`coytQQIe>vY!su^afA1 zV%}4(hyDL-m-qj|^KHA{^oGf-O52sZ*wk29(h-LFu>~-4BmwzK3@{76__O)5b24NC z1+!rar