From ea918f5cc172ee25d5fb7e58da4184257894622f Mon Sep 17 00:00:00 2001 From: Kevin Boon Date: Wed, 28 Jun 2023 15:10:16 -0400 Subject: [PATCH 1/2] Removed Newtonsoft.Json dependency Removed Newtonsoft.Json dependency --- src/OWSShared/InternalAPICalls/InternalAPICallsService.cs | 6 +++--- src/OWSShared/Objects/ServerLauncherHealthMonitoring.cs | 7 ++++--- src/OWSShared/Objects/ServerLauncherMQListener.cs | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/OWSShared/InternalAPICalls/InternalAPICallsService.cs b/src/OWSShared/InternalAPICalls/InternalAPICallsService.cs index 5891fc2c6..0311e5b72 100644 --- a/src/OWSShared/InternalAPICalls/InternalAPICallsService.cs +++ b/src/OWSShared/InternalAPICalls/InternalAPICallsService.cs @@ -1,9 +1,9 @@ -using Newtonsoft.Json; -using OWSShared.RequestPayloads; +using OWSShared.RequestPayloads; using System; using System.Collections.Generic; using System.Net.Http; using System.Text; +using System.Text.Json; using System.Threading.Tasks; namespace OWSShared.InternalAPICalls @@ -32,7 +32,7 @@ public async Task RequestServerSpinUp(Guid customerGUID, int worldServerID Port = port }; - var serverSpinUpPayload = new StringContent(JsonConvert.SerializeObject(spinUpServerInstanceRequestPayload), Encoding.UTF8, "application/json"); + var serverSpinUpPayload = new StringContent(JsonSerializer.Serialize(spinUpServerInstanceRequestPayload), Encoding.UTF8, "application/json"); var responseMessage = await instanceManagementHttpClient.PostAsync("api/Instance/SpinUpServerInstance", serverSpinUpPayload); diff --git a/src/OWSShared/Objects/ServerLauncherHealthMonitoring.cs b/src/OWSShared/Objects/ServerLauncherHealthMonitoring.cs index 199f6c515..37eb1d54b 100644 --- a/src/OWSShared/Objects/ServerLauncherHealthMonitoring.cs +++ b/src/OWSShared/Objects/ServerLauncherHealthMonitoring.cs @@ -1,6 +1,5 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; -using Newtonsoft.Json; using OWSData.Models; using OWSData.Models.StoredProcs; using OWSData.Repositories.Interfaces; @@ -11,10 +10,12 @@ using System.Collections.Generic; using System.Net.Http; using System.Text; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Serilog; using MongoDB.Driver.Linq; +using MongoDB.Bson; namespace OWSShared.Objects { @@ -80,7 +81,7 @@ private List GetZoneInstancesForWorldServer(int } }; - var shutDownInstanceLauncherRequest = new StringContent(JsonConvert.SerializeObject(worldServerIDRequestPayload), Encoding.UTF8, "application/json"); + var shutDownInstanceLauncherRequest = new StringContent(JsonSerializer.Serialize(worldServerIDRequestPayload), Encoding.UTF8, "application/json"); var responseMessageTask = instanceManagementHttpClient.PostAsync("api/Instance/GetZoneInstancesForWorldServer", shutDownInstanceLauncherRequest); var responseMessage = responseMessageTask.Result; @@ -89,7 +90,7 @@ private List GetZoneInstancesForWorldServer(int { var responseContentAsync = responseMessage.Content.ReadAsStringAsync(); string responseContentString = responseContentAsync.Result; - output = JsonConvert.DeserializeObject>(responseContentString); + output = JsonSerializer.Deserialize>(responseContentString); } else { diff --git a/src/OWSShared/Objects/ServerLauncherMQListener.cs b/src/OWSShared/Objects/ServerLauncherMQListener.cs index ef54969e6..ddbe95e62 100644 --- a/src/OWSShared/Objects/ServerLauncherMQListener.cs +++ b/src/OWSShared/Objects/ServerLauncherMQListener.cs @@ -1,6 +1,5 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; -using Newtonsoft.Json; using OWSData.Models; using OWSData.Repositories.Interfaces; using OWSShared.Interfaces; @@ -14,6 +13,7 @@ using System.IO; using System.Net.Http; using System.Text; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Serilog; @@ -350,7 +350,7 @@ private int RegisterInstanceLauncherRequest() } }; - var RegisterLauncherPayloadRequest = new StringContent(JsonConvert.SerializeObject(RegisterLauncherPayload), Encoding.UTF8, "application/json"); + var RegisterLauncherPayloadRequest = new StringContent(JsonSerializer.Serialize(RegisterLauncherPayload), Encoding.UTF8, "application/json"); var responseMessageAsync = instanceManagementHttpClient.PostAsync("api/Instance/RegisterLauncher", RegisterLauncherPayloadRequest); var responseMessage = responseMessageAsync.Result; @@ -431,7 +431,7 @@ private async Task ShutDownInstanceLauncherRequest(int worldServerId) } }; - var shutDownInstanceLauncherRequest = new StringContent(JsonConvert.SerializeObject(worldServerIDRequestPayload), Encoding.UTF8, "application/json"); + var shutDownInstanceLauncherRequest = new StringContent(JsonSerializer.Serialize(worldServerIDRequestPayload), Encoding.UTF8, "application/json"); var request = new HttpRequestMessage() { @@ -459,7 +459,7 @@ private async Task UpdateZoneServerStatusReady(int zoneInstanceID) } }; - var setZoneInstanceStatusRequest = new StringContent(JsonConvert.SerializeObject(setZoneInstanceStatusRequestPayload), Encoding.UTF8, "application/json"); + var setZoneInstanceStatusRequest = new StringContent(JsonSerializer.Serialize(setZoneInstanceStatusRequestPayload), Encoding.UTF8, "application/json"); var responseMessage = await instanceManagementHttpClient.PostAsync("api/Instance/SetZoneInstanceStatus", setZoneInstanceStatusRequest); From 0a9fabb68230d8550954525cafd895411e289ba6 Mon Sep 17 00:00:00 2001 From: Kevin Boon Date: Thu, 29 Jun 2023 12:55:40 -0400 Subject: [PATCH 2/2] Removed Dependency Loop between OWSData and OWSShared --- .../OWSCharacterPersistence.csproj | 1 + src/OWSCharacterPersistence/Startup.cs | 2 +- src/OWSData/OWSData.csproj | 4 ++++ .../InMemory/ZoneServerProcessesRepository.cs | 1 + .../MSSQL/CharactersRepository.cs | 1 + .../MSSQL/GlobalDataRepository.cs | 1 + .../MSSQL/InstanceManagementRepository.cs | 1 + .../Implementations/MSSQL/UsersRepository.cs | 1 + .../MongoDB/CharactersRepository.cs | 1 + .../MySQL/CharactersRepository.cs | 1 + .../MySQL/GlobalDataRepository.cs | 1 + .../MySQL/InstanceManagementRepository.cs | 1 + .../Implementations/MySQL/UsersRepository.cs | 1 + .../Postgres/CharactersRepository.cs | 1 + .../Postgres/GlobalDataRespository.cs | 1 + .../Postgres/InstanceManagementRepository.cs | 1 + .../Postgres/UsersRepository.cs | 1 + .../IZoneServerProcessesRepository.cs | 1 + src/OWSGlobalData/OWSGlobalData.csproj | 1 + src/OWSGlobalData/Startup.cs | 2 +- src/OWSInstanceLauncher/Program.cs | 1 - .../ServerLauncherHealthMonitoring.cs | 14 +++++--------- .../Services}/ServerLauncherMQListener.cs | 18 ++++++++---------- .../Services/ServerLauncherShutDown.cs | 7 +++++++ .../Services}/TimedHostedService.cs | 13 ++++--------- src/OWSInstanceLauncher/Startup.cs | 10 +++++----- src/OWSInstanceManagement/Startup.cs | 2 +- src/OWSManagement/OWSManagement.csproj | 1 + src/OWSManagement/Startup.cs | 2 +- src/OWSPublicAPI/Startup.cs | 2 +- ...WorldMMOPublicAPICharacterDataValidation.cs | 1 - src/OWSShared/OWSShared.csproj | 4 ---- .../Objects/ServerLauncherShutDown.cs | 11 ----------- .../Options}/OWSInstanceLauncherOptions.cs | 6 +----- .../Options}/StorageOptions.cs | 6 +----- .../Options}/ZoneServerProcess.cs | 6 +----- 36 files changed, 59 insertions(+), 70 deletions(-) rename src/{OWSShared/Objects => OWSInstanceLauncher/Services}/ServerLauncherHealthMonitoring.cs (94%) rename src/{OWSShared/Objects => OWSInstanceLauncher/Services}/ServerLauncherMQListener.cs (98%) create mode 100644 src/OWSInstanceLauncher/Services/ServerLauncherShutDown.cs rename src/{OWSShared/Objects => OWSInstanceLauncher/Services}/TimedHostedService.cs (93%) delete mode 100644 src/OWSShared/Objects/ServerLauncherShutDown.cs rename src/{OWSData/Models => OWSShared/Options}/OWSInstanceLauncherOptions.cs (89%) rename src/{OWSData/Models => OWSShared/Options}/StorageOptions.cs (69%) rename src/{OWSData/Models => OWSShared/Options}/ZoneServerProcess.cs (73%) diff --git a/src/OWSCharacterPersistence/OWSCharacterPersistence.csproj b/src/OWSCharacterPersistence/OWSCharacterPersistence.csproj index aac65b9ee..11159d7fc 100644 --- a/src/OWSCharacterPersistence/OWSCharacterPersistence.csproj +++ b/src/OWSCharacterPersistence/OWSCharacterPersistence.csproj @@ -39,6 +39,7 @@ + diff --git a/src/OWSCharacterPersistence/Startup.cs b/src/OWSCharacterPersistence/Startup.cs index 8a31fe140..b87f589cf 100644 --- a/src/OWSCharacterPersistence/Startup.cs +++ b/src/OWSCharacterPersistence/Startup.cs @@ -80,7 +80,7 @@ public void ConfigureServices(IServiceCollection services) c.IncludeXmlComments(filePath); }); - services.Configure(Configuration.GetSection(OWSData.Models.StorageOptions.SectionName)); + services.Configure(Configuration.GetSection(OWSShared.Options.StorageOptions.SectionName)); services.Configure(Configuration.GetSection(OWSShared.Options.APIPathOptions.SectionName)); services.Configure(Configuration.GetSection(OWSShared.Options.RabbitMQOptions.SectionName)); diff --git a/src/OWSData/OWSData.csproj b/src/OWSData/OWSData.csproj index 3f131646d..122439b9f 100644 --- a/src/OWSData/OWSData.csproj +++ b/src/OWSData/OWSData.csproj @@ -17,4 +17,8 @@ + + + + diff --git a/src/OWSData/Repositories/Implementations/InMemory/ZoneServerProcessesRepository.cs b/src/OWSData/Repositories/Implementations/InMemory/ZoneServerProcessesRepository.cs index 002279b71..b67dcbece 100644 --- a/src/OWSData/Repositories/Implementations/InMemory/ZoneServerProcessesRepository.cs +++ b/src/OWSData/Repositories/Implementations/InMemory/ZoneServerProcessesRepository.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Text; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.InMemory { diff --git a/src/OWSData/Repositories/Implementations/MSSQL/CharactersRepository.cs b/src/OWSData/Repositories/Implementations/MSSQL/CharactersRepository.cs index 3ef7ec647..8ff043439 100644 --- a/src/OWSData/Repositories/Implementations/MSSQL/CharactersRepository.cs +++ b/src/OWSData/Repositories/Implementations/MSSQL/CharactersRepository.cs @@ -14,6 +14,7 @@ using OWSData.Models.Composites; using OWSData.Models.Tables; using OWSData.SQL; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.MSSQL { diff --git a/src/OWSData/Repositories/Implementations/MSSQL/GlobalDataRepository.cs b/src/OWSData/Repositories/Implementations/MSSQL/GlobalDataRepository.cs index fb1fb07d8..f51230317 100644 --- a/src/OWSData/Repositories/Implementations/MSSQL/GlobalDataRepository.cs +++ b/src/OWSData/Repositories/Implementations/MSSQL/GlobalDataRepository.cs @@ -8,6 +8,7 @@ using System.Data; using System.Data.SqlClient; using System.Threading.Tasks; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.MSSQL { diff --git a/src/OWSData/Repositories/Implementations/MSSQL/InstanceManagementRepository.cs b/src/OWSData/Repositories/Implementations/MSSQL/InstanceManagementRepository.cs index e3de8b213..90a0a953f 100644 --- a/src/OWSData/Repositories/Implementations/MSSQL/InstanceManagementRepository.cs +++ b/src/OWSData/Repositories/Implementations/MSSQL/InstanceManagementRepository.cs @@ -12,6 +12,7 @@ using System.Data.SqlClient; using System.Text; using System.Threading.Tasks; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.MSSQL { diff --git a/src/OWSData/Repositories/Implementations/MSSQL/UsersRepository.cs b/src/OWSData/Repositories/Implementations/MSSQL/UsersRepository.cs index 4ef2b3481..f1b5c17e8 100644 --- a/src/OWSData/Repositories/Implementations/MSSQL/UsersRepository.cs +++ b/src/OWSData/Repositories/Implementations/MSSQL/UsersRepository.cs @@ -13,6 +13,7 @@ using OWSData.Models.Tables; using OWSData.Repositories.Interfaces; using OWSData.SQL; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.MSSQL { diff --git a/src/OWSData/Repositories/Implementations/MongoDB/CharactersRepository.cs b/src/OWSData/Repositories/Implementations/MongoDB/CharactersRepository.cs index e2ab4c8bf..c24e029a9 100644 --- a/src/OWSData/Repositories/Implementations/MongoDB/CharactersRepository.cs +++ b/src/OWSData/Repositories/Implementations/MongoDB/CharactersRepository.cs @@ -10,6 +10,7 @@ using OWSData.Repositories.Implementations.MongoDB.Models; using Microsoft.Extensions.Configuration; using System.Threading.Tasks; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.MongoDB { diff --git a/src/OWSData/Repositories/Implementations/MySQL/CharactersRepository.cs b/src/OWSData/Repositories/Implementations/MySQL/CharactersRepository.cs index b1d56cc91..2e194df19 100644 --- a/src/OWSData/Repositories/Implementations/MySQL/CharactersRepository.cs +++ b/src/OWSData/Repositories/Implementations/MySQL/CharactersRepository.cs @@ -13,6 +13,7 @@ using OWSData.Repositories.Interfaces; using OWSData.Models.Tables; using OWSData.SQL; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.MySQL { diff --git a/src/OWSData/Repositories/Implementations/MySQL/GlobalDataRepository.cs b/src/OWSData/Repositories/Implementations/MySQL/GlobalDataRepository.cs index b818094bb..cdede79de 100644 --- a/src/OWSData/Repositories/Implementations/MySQL/GlobalDataRepository.cs +++ b/src/OWSData/Repositories/Implementations/MySQL/GlobalDataRepository.cs @@ -13,6 +13,7 @@ using OWSData.Repositories.Interfaces; using OWSData.Models.Tables; using OWSData.SQL; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.MySQL { diff --git a/src/OWSData/Repositories/Implementations/MySQL/InstanceManagementRepository.cs b/src/OWSData/Repositories/Implementations/MySQL/InstanceManagementRepository.cs index 80e790362..e017dad92 100644 --- a/src/OWSData/Repositories/Implementations/MySQL/InstanceManagementRepository.cs +++ b/src/OWSData/Repositories/Implementations/MySQL/InstanceManagementRepository.cs @@ -10,6 +10,7 @@ using OWSData.Models.StoredProcs; using OWSData.Repositories.Interfaces; using OWSData.SQL; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.MySQL { diff --git a/src/OWSData/Repositories/Implementations/MySQL/UsersRepository.cs b/src/OWSData/Repositories/Implementations/MySQL/UsersRepository.cs index 7f935b8be..da9f0e785 100644 --- a/src/OWSData/Repositories/Implementations/MySQL/UsersRepository.cs +++ b/src/OWSData/Repositories/Implementations/MySQL/UsersRepository.cs @@ -11,6 +11,7 @@ using OWSData.Repositories.Interfaces; using OWSData.SQL; using OWSData.Models.Tables; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.MySQL { diff --git a/src/OWSData/Repositories/Implementations/Postgres/CharactersRepository.cs b/src/OWSData/Repositories/Implementations/Postgres/CharactersRepository.cs index 5fed88d63..366db3941 100644 --- a/src/OWSData/Repositories/Implementations/Postgres/CharactersRepository.cs +++ b/src/OWSData/Repositories/Implementations/Postgres/CharactersRepository.cs @@ -13,6 +13,7 @@ using OWSData.Repositories.Interfaces; using OWSData.Models.Tables; using OWSData.SQL; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.Postgres { diff --git a/src/OWSData/Repositories/Implementations/Postgres/GlobalDataRespository.cs b/src/OWSData/Repositories/Implementations/Postgres/GlobalDataRespository.cs index a1540363a..15dc53d52 100644 --- a/src/OWSData/Repositories/Implementations/Postgres/GlobalDataRespository.cs +++ b/src/OWSData/Repositories/Implementations/Postgres/GlobalDataRespository.cs @@ -13,6 +13,7 @@ using OWSData.Repositories.Interfaces; using OWSData.Models.Tables; using OWSData.SQL; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.Postgres { diff --git a/src/OWSData/Repositories/Implementations/Postgres/InstanceManagementRepository.cs b/src/OWSData/Repositories/Implementations/Postgres/InstanceManagementRepository.cs index 78da652da..3bcb9100e 100644 --- a/src/OWSData/Repositories/Implementations/Postgres/InstanceManagementRepository.cs +++ b/src/OWSData/Repositories/Implementations/Postgres/InstanceManagementRepository.cs @@ -10,6 +10,7 @@ using OWSData.Models.StoredProcs; using OWSData.Repositories.Interfaces; using OWSData.SQL; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.Postgres { diff --git a/src/OWSData/Repositories/Implementations/Postgres/UsersRepository.cs b/src/OWSData/Repositories/Implementations/Postgres/UsersRepository.cs index ec7396d3b..9f5ceac24 100644 --- a/src/OWSData/Repositories/Implementations/Postgres/UsersRepository.cs +++ b/src/OWSData/Repositories/Implementations/Postgres/UsersRepository.cs @@ -11,6 +11,7 @@ using OWSData.Repositories.Interfaces; using OWSData.SQL; using OWSData.Models.Tables; +using OWSShared.Options; namespace OWSData.Repositories.Implementations.Postgres { diff --git a/src/OWSData/Repositories/Interfaces/IZoneServerProcessesRepository.cs b/src/OWSData/Repositories/Interfaces/IZoneServerProcessesRepository.cs index f3aaf3141..2824bc668 100644 --- a/src/OWSData/Repositories/Interfaces/IZoneServerProcessesRepository.cs +++ b/src/OWSData/Repositories/Interfaces/IZoneServerProcessesRepository.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Text; +using OWSShared.Options; namespace OWSData.Repositories.Interfaces { diff --git a/src/OWSGlobalData/OWSGlobalData.csproj b/src/OWSGlobalData/OWSGlobalData.csproj index 9be2e39c1..e8c2a8e7c 100644 --- a/src/OWSGlobalData/OWSGlobalData.csproj +++ b/src/OWSGlobalData/OWSGlobalData.csproj @@ -39,6 +39,7 @@ + diff --git a/src/OWSGlobalData/Startup.cs b/src/OWSGlobalData/Startup.cs index 0e98eac14..3bbb83316 100644 --- a/src/OWSGlobalData/Startup.cs +++ b/src/OWSGlobalData/Startup.cs @@ -75,7 +75,7 @@ public void ConfigureServices(IServiceCollection services) c.IncludeXmlComments(filePath); }); - services.Configure(Configuration.GetSection(OWSData.Models.StorageOptions.SectionName)); + services.Configure(Configuration.GetSection(OWSShared.Options.StorageOptions.SectionName)); services.Configure(Configuration.GetSection(OWSShared.Options.APIPathOptions.SectionName)); services.Configure(Configuration.GetSection(OWSShared.Options.RabbitMQOptions.SectionName)); diff --git a/src/OWSInstanceLauncher/Program.cs b/src/OWSInstanceLauncher/Program.cs index 165c012fa..5b0d0a61a 100644 --- a/src/OWSInstanceLauncher/Program.cs +++ b/src/OWSInstanceLauncher/Program.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using OWSShared.Objects; using Serilog; namespace OWSInstanceLauncher diff --git a/src/OWSShared/Objects/ServerLauncherHealthMonitoring.cs b/src/OWSInstanceLauncher/Services/ServerLauncherHealthMonitoring.cs similarity index 94% rename from src/OWSShared/Objects/ServerLauncherHealthMonitoring.cs rename to src/OWSInstanceLauncher/Services/ServerLauncherHealthMonitoring.cs index 37eb1d54b..4e76d5b78 100644 --- a/src/OWSShared/Objects/ServerLauncherHealthMonitoring.cs +++ b/src/OWSInstanceLauncher/Services/ServerLauncherHealthMonitoring.cs @@ -4,20 +4,16 @@ using OWSData.Models.StoredProcs; using OWSData.Repositories.Interfaces; using OWSShared.Interfaces; -using OWSShared.Messages; using OWSShared.RequestPayloads; +using OWSShared.Options; using System; using System.Collections.Generic; using System.Net.Http; using System.Text; using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; using Serilog; -using MongoDB.Driver.Linq; -using MongoDB.Bson; -namespace OWSShared.Objects +namespace OWSInstanceLauncher.Services { public class ServerLauncherHealthMonitoring : IServerHealthMonitoringJob { @@ -26,7 +22,7 @@ public class ServerLauncherHealthMonitoring : IServerHealthMonitoringJob private readonly IZoneServerProcessesRepository _zoneServerProcessesRepository; private readonly IOWSInstanceLauncherDataRepository _owsInstanceLauncherDataRepository; - public ServerLauncherHealthMonitoring(IOptions OWSInstanceLauncherOptions, IHttpClientFactory httpClientFactory, IZoneServerProcessesRepository zoneServerProcessesRepository, + public ServerLauncherHealthMonitoring(IOptions OWSInstanceLauncherOptions, IHttpClientFactory httpClientFactory, IZoneServerProcessesRepository zoneServerProcessesRepository, IOWSInstanceLauncherDataRepository owsInstanceLauncherDataRepository) { _OWSInstanceLauncherOptions = OWSInstanceLauncherOptions; @@ -91,8 +87,8 @@ private List GetZoneInstancesForWorldServer(int var responseContentAsync = responseMessage.Content.ReadAsStringAsync(); string responseContentString = responseContentAsync.Result; output = JsonSerializer.Deserialize>(responseContentString); - } - else + } + else { output = new List(); } diff --git a/src/OWSShared/Objects/ServerLauncherMQListener.cs b/src/OWSInstanceLauncher/Services/ServerLauncherMQListener.cs similarity index 98% rename from src/OWSShared/Objects/ServerLauncherMQListener.cs rename to src/OWSInstanceLauncher/Services/ServerLauncherMQListener.cs index ddbe95e62..04eb67fa3 100644 --- a/src/OWSShared/Objects/ServerLauncherMQListener.cs +++ b/src/OWSInstanceLauncher/Services/ServerLauncherMQListener.cs @@ -9,16 +9,13 @@ using RabbitMQ.Client; using RabbitMQ.Client.Events; using System; -using System.Collections.Generic; -using System.IO; using System.Net.Http; using System.Text; using System.Text.Json; -using System.Threading; using System.Threading.Tasks; using Serilog; -namespace OWSShared.Objects +namespace OWSInstanceLauncher.Services { public class ServerLauncherMQListener : IInstanceLauncherJob //BackgroundService { @@ -254,10 +251,10 @@ private void HandleServerSpinUpMessage(Guid customerGUID, int worldServerID, int //string PathToDedicatedServer = "E:\\Program Files\\Epic Games\\UE_4.25\\Engine\\Binaries\\Win64\\UE4Editor.exe"; //string ServerArguments = "\"C:\\OWS\\OpenWorldStarterPlugin\\OpenWorldStarter.uproject\" {0}?listen -server -log -nosteam -messaging -port={1}"; - string serverArguments = (_owsInstanceLauncherOptions.Value.IsServerEditor ? "\"" + _owsInstanceLauncherOptions.Value.PathToUProject + "\" ": "") + string serverArguments = (_owsInstanceLauncherOptions.Value.IsServerEditor ? "\"" + _owsInstanceLauncherOptions.Value.PathToUProject + "\" " : "") + "{0}?listen -server " - + (_owsInstanceLauncherOptions.Value.UseServerLog ? "-log " : "") - + (_owsInstanceLauncherOptions.Value.UseNoSteam ? "-nosteam " : "") + + (_owsInstanceLauncherOptions.Value.UseServerLog ? "-log " : "") + + (_owsInstanceLauncherOptions.Value.UseNoSteam ? "-nosteam " : "") + "-port={1} " + "-zoneinstanceid={2}"; @@ -276,7 +273,8 @@ private void HandleServerSpinUpMessage(Guid customerGUID, int worldServerID, int proc.Start(); //proc.WaitForInputIdle(); - _zoneServerProcessesRepository.AddZoneServerProcess(new ZoneServerProcess { + _zoneServerProcessesRepository.AddZoneServerProcess(new ZoneServerProcess + { ZoneInstanceId = zoneInstanceID, MapName = mapName, Port = port, @@ -450,8 +448,8 @@ private async Task UpdateZoneServerStatusReady(int zoneInstanceID) { var instanceManagementHttpClient = _httpClientFactory.CreateClient("OWSInstanceManagement"); - var setZoneInstanceStatusRequestPayload = new - { + var setZoneInstanceStatusRequestPayload = new + { request = new SetZoneInstanceStatusRequestPayload { ZoneInstanceID = zoneInstanceID, diff --git a/src/OWSInstanceLauncher/Services/ServerLauncherShutDown.cs b/src/OWSInstanceLauncher/Services/ServerLauncherShutDown.cs new file mode 100644 index 000000000..97f419fc4 --- /dev/null +++ b/src/OWSInstanceLauncher/Services/ServerLauncherShutDown.cs @@ -0,0 +1,7 @@ +namespace OWSInstanceLauncher.Services +{ + public class ServerLauncherShutDown + { + + } +} diff --git a/src/OWSShared/Objects/TimedHostedService.cs b/src/OWSInstanceLauncher/Services/TimedHostedService.cs similarity index 93% rename from src/OWSShared/Objects/TimedHostedService.cs rename to src/OWSInstanceLauncher/Services/TimedHostedService.cs index be71d0515..6b7154096 100644 --- a/src/OWSShared/Objects/TimedHostedService.cs +++ b/src/OWSInstanceLauncher/Services/TimedHostedService.cs @@ -1,18 +1,13 @@ using Microsoft.Extensions.Hosting; using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using SimpleInjector; using SimpleInjector.Lifestyles; -namespace OWSShared.Objects + +namespace OWSInstanceLauncher.Services { - public class TimedHostedService : IHostedService, IDisposable - where TService : class + public class TimedHostedService : IHostedService, IDisposable where TService : class { private readonly SimpleInjector.Container container; private readonly Settings settings; @@ -98,4 +93,4 @@ public Settings(TimeSpan interval, bool runOnce, Action action, Action } } } -} \ No newline at end of file +} diff --git a/src/OWSInstanceLauncher/Startup.cs b/src/OWSInstanceLauncher/Startup.cs index bc07acad5..e4acc0bf1 100644 --- a/src/OWSInstanceLauncher/Startup.cs +++ b/src/OWSInstanceLauncher/Startup.cs @@ -17,9 +17,9 @@ using OWSShared.Implementations; using OWSShared.Interfaces; using OWSShared.Messages; -using OWSShared.Objects; using SimpleInjector; using Serilog; +using OWSInstanceLauncher.Services; namespace OWSInstanceLauncher { @@ -27,7 +27,7 @@ public class Startup { //Container container; private Container container = new SimpleInjector.Container(); - private OWSData.Models.OWSInstanceLauncherOptions owsInstanceLauncherOptions; + private OWSShared.Options.OWSInstanceLauncherOptions owsInstanceLauncherOptions; public IConfiguration Configuration { get; } @@ -39,8 +39,8 @@ public Startup(IConfiguration configuration) Configuration = configuration; - owsInstanceLauncherOptions = new OWSData.Models.OWSInstanceLauncherOptions(); - Configuration.GetSection(OWSData.Models.OWSInstanceLauncherOptions.SectionName).Bind(owsInstanceLauncherOptions); + owsInstanceLauncherOptions = new OWSShared.Options.OWSInstanceLauncherOptions(); + Configuration.GetSection(OWSShared.Options.OWSInstanceLauncherOptions.SectionName).Bind(owsInstanceLauncherOptions); //Check appsettings.json file for potential errors bool thereWasAStartupError = false; @@ -116,7 +116,7 @@ public void ConfigureServices(IServiceCollection services) .AddViews() .AddApiExplorer(); - services.ConfigureWritable(Configuration.GetSection(OWSData.Models.OWSInstanceLauncherOptions.SectionName)); + services.ConfigureWritable(Configuration.GetSection(OWSShared.Options.OWSInstanceLauncherOptions.SectionName)); services.Configure(Configuration.GetSection(OWSShared.Options.APIPathOptions.SectionName)); services.Configure(Configuration.GetSection(OWSShared.Options.RabbitMQOptions.SectionName)); diff --git a/src/OWSInstanceManagement/Startup.cs b/src/OWSInstanceManagement/Startup.cs index 9fa064067..7489270f6 100644 --- a/src/OWSInstanceManagement/Startup.cs +++ b/src/OWSInstanceManagement/Startup.cs @@ -80,7 +80,7 @@ public void ConfigureServices(IServiceCollection services) c.IncludeXmlComments(filePath); }); - services.Configure(Configuration.GetSection(OWSData.Models.StorageOptions.SectionName)); + services.Configure(Configuration.GetSection(OWSShared.Options.StorageOptions.SectionName)); services.Configure(Configuration.GetSection(OWSShared.Options.APIPathOptions.SectionName)); services.Configure(Configuration.GetSection(OWSShared.Options.RabbitMQOptions.SectionName)); diff --git a/src/OWSManagement/OWSManagement.csproj b/src/OWSManagement/OWSManagement.csproj index 788d15e68..576c8a98a 100644 --- a/src/OWSManagement/OWSManagement.csproj +++ b/src/OWSManagement/OWSManagement.csproj @@ -40,6 +40,7 @@ + diff --git a/src/OWSManagement/Startup.cs b/src/OWSManagement/Startup.cs index af29367ef..370cf5bde 100644 --- a/src/OWSManagement/Startup.cs +++ b/src/OWSManagement/Startup.cs @@ -86,7 +86,7 @@ public void ConfigureServices(IServiceCollection services) c.DefaultRequestHeaders.Add("X-CustomerGUID", owsManagementOptions.OWSAPIKey); }); - services.Configure(Configuration.GetSection(OWSData.Models.StorageOptions.SectionName)); + services.Configure(Configuration.GetSection(OWSShared.Options.StorageOptions.SectionName)); InitializeContainer(services); diff --git a/src/OWSPublicAPI/Startup.cs b/src/OWSPublicAPI/Startup.cs index e8ea3a92b..aeda6435e 100644 --- a/src/OWSPublicAPI/Startup.cs +++ b/src/OWSPublicAPI/Startup.cs @@ -114,7 +114,7 @@ public void ConfigureServices(IServiceCollection services) services.Configure(Configuration.GetSection(OWSShared.Options.PublicAPIOptions.SectionName)); services.Configure(Configuration.GetSection(OWSShared.Options.APIPathOptions.SectionName)); - services.Configure(Configuration.GetSection(OWSData.Models.StorageOptions.SectionName)); + services.Configure(Configuration.GetSection(OWSShared.Options.StorageOptions.SectionName)); // Register And Validate External Login Provider Options // services.ConfigureAndValidate(ExternalLoginProviderOptions.EpicOnlineServices, Configuration.GetSection($"{ExternalLoginProviderOptions.SectionName}:{ExternalLoginProviderOptions.EpicOnlineServices}")); diff --git a/src/OWSShared/Implementations/HubWorldMMOPublicAPICharacterDataValidation.cs b/src/OWSShared/Implementations/HubWorldMMOPublicAPICharacterDataValidation.cs index 80300d1af..49b5c710a 100644 --- a/src/OWSShared/Implementations/HubWorldMMOPublicAPICharacterDataValidation.cs +++ b/src/OWSShared/Implementations/HubWorldMMOPublicAPICharacterDataValidation.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc.Formatters; -using MongoDB.Bson; using OWSShared.Interfaces; using System; using System.Collections.Generic; diff --git a/src/OWSShared/OWSShared.csproj b/src/OWSShared/OWSShared.csproj index cc9dd8ce6..8f61197a5 100644 --- a/src/OWSShared/OWSShared.csproj +++ b/src/OWSShared/OWSShared.csproj @@ -15,8 +15,4 @@ - - - - diff --git a/src/OWSShared/Objects/ServerLauncherShutDown.cs b/src/OWSShared/Objects/ServerLauncherShutDown.cs deleted file mode 100644 index 9943083e4..000000000 --- a/src/OWSShared/Objects/ServerLauncherShutDown.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OWSShared.Objects -{ - public class ServerLauncherShutDown - { - - } -} diff --git a/src/OWSData/Models/OWSInstanceLauncherOptions.cs b/src/OWSShared/Options/OWSInstanceLauncherOptions.cs similarity index 89% rename from src/OWSData/Models/OWSInstanceLauncherOptions.cs rename to src/OWSShared/Options/OWSInstanceLauncherOptions.cs index 6bb2e6921..ef6ba8795 100644 --- a/src/OWSData/Models/OWSInstanceLauncherOptions.cs +++ b/src/OWSShared/Options/OWSInstanceLauncherOptions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OWSData.Models +namespace OWSShared.Options { public class OWSInstanceLauncherOptions { diff --git a/src/OWSData/Models/StorageOptions.cs b/src/OWSShared/Options/StorageOptions.cs similarity index 69% rename from src/OWSData/Models/StorageOptions.cs rename to src/OWSShared/Options/StorageOptions.cs index 4cc64c3a5..b221e3661 100644 --- a/src/OWSData/Models/StorageOptions.cs +++ b/src/OWSShared/Options/StorageOptions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OWSData.Models +namespace OWSShared.Options { public class StorageOptions { diff --git a/src/OWSData/Models/ZoneServerProcess.cs b/src/OWSShared/Options/ZoneServerProcess.cs similarity index 73% rename from src/OWSData/Models/ZoneServerProcess.cs rename to src/OWSShared/Options/ZoneServerProcess.cs index b1110ffd8..0149d7e63 100644 --- a/src/OWSData/Models/ZoneServerProcess.cs +++ b/src/OWSShared/Options/ZoneServerProcess.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OWSData.Models +namespace OWSShared.Options { public class ZoneServerProcess {