From b2f7183f121c65f3e30457feceaa337984edbc76 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Sat, 28 Sep 2019 01:11:05 -0700 Subject: [PATCH] WIP --- Agent/Agent.csproj | 14 -------------- Agent/Services/Utilities.cs | 2 +- Server/Data/ApplicationDbContext.cs | 1 - Server/Server.csproj | 9 --------- Server/Services/PascalCase.cs | 23 +++++++++++++++++++++++ Server/Startup.cs | 12 +++--------- Shared/Models/Device.cs | 3 +++ 7 files changed, 30 insertions(+), 34 deletions(-) create mode 100644 Server/Services/PascalCase.cs diff --git a/Agent/Agent.csproj b/Agent/Agent.csproj index 75f92afe..3b2f30b1 100644 --- a/Agent/Agent.csproj +++ b/Agent/Agent.csproj @@ -38,20 +38,6 @@ - - - System - - - System.Data - - - System.ServiceProcess - - - System.Xml - - diff --git a/Agent/Services/Utilities.cs b/Agent/Services/Utilities.cs index 82617997..930ad82a 100644 --- a/Agent/Services/Utilities.cs +++ b/Agent/Services/Utilities.cs @@ -16,7 +16,7 @@ namespace Remotely.Agent.Services { if (!File.Exists("ConnectionInfo.json")) { - throw new Exception("No connection info available. Please create ConnectionInfo.json file with appropriate values."); + Logger.Write(new Exception("No connection info available. Please create ConnectionInfo.json file with appropriate values.")); } return JsonConvert.DeserializeObject(File.ReadAllText("ConnectionInfo.json")); } diff --git a/Server/Data/ApplicationDbContext.cs b/Server/Data/ApplicationDbContext.cs index daeb0aa3..41928cdf 100644 --- a/Server/Data/ApplicationDbContext.cs +++ b/Server/Data/ApplicationDbContext.cs @@ -40,7 +40,6 @@ namespace Remotely.Server.Data base.OnModelCreating(builder); builder.Entity().ToTable("RemotelyUsers"); - //builder.Entity().ToTable("RemotelyUsers"); builder.Entity() .HasMany(x => x.Devices) diff --git a/Server/Server.csproj b/Server/Server.csproj index 58a3e33e..67658f9d 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -59,7 +59,6 @@ - @@ -155,14 +154,6 @@ - - - - ..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Drawing.dll - - - - PreserveNewest diff --git a/Server/Services/PascalCase.cs b/Server/Services/PascalCase.cs new file mode 100644 index 00000000..0decdfcb --- /dev/null +++ b/Server/Services/PascalCase.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; + +namespace Remotely.Server.Services +{ + public class PascalCase : JsonNamingPolicy + { + public override string ConvertName(string name) + { + if (string.IsNullOrWhiteSpace(name)) + { + return name; + } + + var first = name.First().ToString().ToUpper(); + + return first + new string(name.Skip(1).ToArray()); + } + } +} diff --git a/Server/Startup.cs b/Server/Startup.cs index 7b1816a2..939bb37b 100644 --- a/Server/Startup.cs +++ b/Server/Startup.cs @@ -127,10 +127,10 @@ namespace Remotely.Server }); } - services.AddMvcCore() + services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_3_0).AddJsonOptions(options => { - + options.JsonSerializerOptions.PropertyNamingPolicy = new PascalCase(); }); services.AddSignalR(options => @@ -139,7 +139,7 @@ namespace Remotely.Server }) .AddJsonProtocol(options => { - + options.PayloadSerializerOptions.PropertyNamingPolicy = new PascalCase(); }) .AddMessagePackProtocol(); @@ -233,12 +233,6 @@ namespace Remotely.Server private void ConfigureStaticFiles(IApplicationBuilder app) { - JsonConvert.DefaultSettings = () => - { - var settings = new JsonSerializerSettings(); - settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - return settings; - }; var provider = new FileExtensionContentTypeProvider(); // Add new mappings provider.Mappings[".ps1"] = "application/octet-stream"; diff --git a/Shared/Models/Device.cs b/Shared/Models/Device.cs index 50439cf4..e49b365d 100644 --- a/Shared/Models/Device.cs +++ b/Shared/Models/Device.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; +using System.Text.Json.Serialization; namespace Remotely.Shared.Models { @@ -15,6 +16,8 @@ namespace Remotely.Shared.Models public string AgentVersion { get; set; } public string CurrentUser { get; set; } public string DeviceName { get; set; } + + [JsonIgnore] public virtual ICollection DevicePermissionLinks { get; set; } = new List(); public List Drives { get; set; }