private void Handler(string type) { try { if (type == "inmemclans") { jsonapp = Convert.ToString(ObjectManager.GetInMemoryAlliances().Count); } else if (type == "inmemplayers") { jsonapp = Convert.ToString(ResourcesManager.GetInMemoryLevels().Count); } else if (type == "onlineplayers") { jsonapp = Convert.ToString(ResourcesManager.GetOnlinePlayers().Count); } else if (type == "totalclients") { jsonapp = Convert.ToString(ResourcesManager.GetConnectedClients().Count); } else if (type == "all") { var json = new JsonApi { UCS = new Dictionary <string, string> { { "PatchingServer", ConfigurationManager.AppSettings["patchingServer"] }, { "Maintenance", ConfigurationManager.AppSettings["maintenanceMode"] }, { "MaintenanceTimeLeft", ConfigurationManager.AppSettings["maintenanceTimeLeft"] }, { "ClientVersion", ConfigurationManager.AppSettings["clientVersion"] }, { "ServerVersion", Assembly.GetExecutingAssembly().GetName().Version.ToString() }, { "OnlinePlayers", Convert.ToString(ResourcesManager.GetOnlinePlayers().Count) }, { "InMemoryPlayers", Convert.ToString(ResourcesManager.GetInMemoryLevels().Count) }, { "InMemoryClans", Convert.ToString(ObjectManager.GetInMemoryAlliances().Count) }, { "TotalConnectedClients", Convert.ToString(ResourcesManager.GetConnectedClients().Count) } } }; jsonapp = JsonConvert.SerializeObject(json); mime = "application/json"; } else if (type == "ram") { jsonapp = Performances.GetUsedMemory(); } else { jsonapp = "OK"; } } catch (Exception ex) { jsonapp = "An exception occured in UCS : \n" + ex; } }
public static void JsonMain() { try { var ucsVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); var f = new JsonApi { Ucs = new Dictionary <string, string> { /* * Only disabled til it's implemented * * {"StartingLevel", ConfigurationManager.AppSettings["startingLevel"]}, * {"StartingExperience", ConfigurationManager.AppSettings["startingExperience"]}, */ { "StartingGems", ConfigurationManager.AppSettings["startingGems"] }, { "StartingGold", ConfigurationManager.AppSettings["startingGold"] }, { "StartingElixir", ConfigurationManager.AppSettings["startingElixir"] }, { "StartingDarkElixir", ConfigurationManager.AppSettings["startingDarkElixir"] }, { "StartingTrophies", ConfigurationManager.AppSettings["startingTrophies"] }, { "StartingShieldTime", ConfigurationManager.AppSettings["startingShieldTime"] }, { "PatchingServer", ConfigurationManager.AppSettings["patchingServer"] }, { "Maintenance", ConfigurationManager.AppSettings["maintenanceMode"] }, { "MaintenanceTimeLeft", ConfigurationManager.AppSettings["maintenanceTimeLeft"] }, //{"ServerPort", ConfigurationManager.AppSettings["serverPort"]}, { "ClientVersion", ConfigurationManager.AppSettings["clientVersion"] }, { "ServerVersion", ucsVersion }, { "LoggingLevel", ConfigurationManager.AppSettings["loggingLevel"] }, //{"OldClientVersion", ConfigurationManager.AppSettings["oldClientVersion"]}, { "DatabaseType", ConfigurationManager.AppSettings["databaseConnectionName"] }, //{"ExpertPVE", ConfigurationManager.AppSettings["expertPve"]}, //{"SaveThreadCount", ConfigurationManager.AppSettings["saveThreadCount"]}, { "OnlinePlayers", Convert.ToString(ResourcesManager.GetOnlinePlayers().Count) }, { "InMemoryPlayers", Convert.ToString(ResourcesManager.GetInMemoryLevels().Count) }, { "InMemoryClans", Convert.ToString(ObjectManager.GetInMemoryAlliances().Count) }, //{"TotalClans", Convert.ToString(ObjectManager.GetInMemoryAlliances().Count)}, { "TotalConnectedClients", Convert.ToString(ResourcesManager.GetConnectedClients().Count) } } }; jsonapp = JsonConvert.SerializeObject(f); } catch (Exception ex) { Console.WriteLine("Exception in jsonmain for A.A.S : " + ex); var e = new JsonApiE { Error = new Dictionary <string, string> { { "Issue", Convert.ToString(ex) }, } }; jsonapp = JsonConvert.SerializeObject(e); } }