diff --git a/Server/Data/ApplicationDbContext.cs b/Server/Data/ApplicationDbContext.cs index 8d1c5eca..51df2716 100644 --- a/Server/Data/ApplicationDbContext.cs +++ b/Server/Data/ApplicationDbContext.cs @@ -92,12 +92,11 @@ namespace Remotely.Server.Data x => JsonSerializer.Serialize(x, null), x => JsonSerializer.Deserialize>(x, null)); - builder.Entity() - .HasNoKey(); - - builder.Entity() - .HasNoKey(); + //builder.Entity() + // .HasNoKey(); + //builder.Entity() + // .HasNoKey(); builder.Entity() .HasOne(x => x.Organization) @@ -137,6 +136,10 @@ namespace Remotely.Server.Data // This only supports millisecond precision, but should be sufficient for most use cases. foreach (var entityType in builder.Model.GetEntityTypes()) { + if (entityType.IsKeyless) + { + continue; + } var properties = entityType.ClrType.GetProperties().Where(p => p.PropertyType == typeof(DateTimeOffset) || p.PropertyType == typeof(DateTimeOffset?)); foreach (var property in properties) @@ -144,7 +147,7 @@ namespace Remotely.Server.Data builder .Entity(entityType.Name) .Property(property.Name) - .HasConversion(new DateTimeOffsetToBinaryConverter()); + .HasConversion(new DateTimeOffsetToStringConverter()); } } } diff --git a/Server/Migrations/20200305075755_Initial.Designer.cs b/Server/Migrations/20200305230311_Initial.Designer.cs similarity index 92% rename from Server/Migrations/20200305075755_Initial.Designer.cs rename to Server/Migrations/20200305230311_Initial.Designer.cs index 3d6c29c2..3e65317a 100644 --- a/Server/Migrations/20200305075755_Initial.Designer.cs +++ b/Server/Migrations/20200305230311_Initial.Designer.cs @@ -9,7 +9,7 @@ using Remotely.Server.Data; namespace Remotely.Server.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20200305075755_Initial")] + [Migration("20200305230311_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -93,8 +93,8 @@ namespace Remotely.Server.Migrations b.Property("LockoutEnabled") .HasColumnType("INTEGER"); - b.Property("LockoutEnd") - .HasColumnType("INTEGER"); + b.Property("LockoutEnd") + .HasColumnType("TEXT"); b.Property("NormalizedEmail") .HasColumnType("TEXT") @@ -225,8 +225,8 @@ namespace Remotely.Server.Migrations b.Property("ID") .HasColumnType("TEXT"); - b.Property("LastUsed") - .HasColumnType("INTEGER"); + b.Property("LastUsed") + .HasColumnType("TEXT"); b.Property("Name") .HasColumnType("TEXT") @@ -279,8 +279,9 @@ namespace Remotely.Server.Migrations b.Property("TargetDeviceIDs") .HasColumnType("TEXT"); - b.Property("TimeStamp") - .HasColumnType("INTEGER"); + b.Property("TimeStamp") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("ID"); @@ -322,8 +323,9 @@ namespace Remotely.Server.Migrations b.Property("IsOnline") .HasColumnType("INTEGER"); - b.Property("LastOnline") - .HasColumnType("INTEGER"); + b.Property("LastOnline") + .IsRequired() + .HasColumnType("TEXT"); b.Property("OSArchitecture") .HasColumnType("INTEGER"); @@ -409,8 +411,9 @@ namespace Remotely.Server.Migrations b.Property("StackTrace") .HasColumnType("TEXT"); - b.Property("TimeStamp") - .HasColumnType("INTEGER"); + b.Property("TimeStamp") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("ID"); @@ -419,36 +422,14 @@ namespace Remotely.Server.Migrations b.ToTable("EventLogs"); }); - modelBuilder.Entity("Remotely.Shared.Models.GenericCommandResult", b => - { - b.Property("CommandResultID") - .HasColumnType("TEXT"); - - b.Property("CommandType") - .HasColumnType("TEXT"); - - b.Property("DeviceID") - .HasColumnType("TEXT"); - - b.Property("ErrorOutput") - .HasColumnType("TEXT"); - - b.Property("StandardOutput") - .HasColumnType("TEXT"); - - b.Property("TimeStamp") - .HasColumnType("INTEGER"); - - b.ToTable("GenericCommandResult"); - }); - modelBuilder.Entity("Remotely.Shared.Models.InviteLink", b => { b.Property("ID") .HasColumnType("TEXT"); - b.Property("DateSent") - .HasColumnType("INTEGER"); + b.Property("DateSent") + .IsRequired() + .HasColumnType("TEXT"); b.Property("InvitedUser") .HasColumnType("TEXT"); @@ -483,20 +464,6 @@ namespace Remotely.Server.Migrations b.ToTable("Organizations"); }); - modelBuilder.Entity("Remotely.Shared.Models.PSCoreCommandResult", b => - { - b.Property("CommandResultID") - .HasColumnType("TEXT"); - - b.Property("DeviceID") - .HasColumnType("TEXT"); - - b.Property("TimeStamp") - .HasColumnType("INTEGER"); - - b.ToTable("PSCoreCommandResult"); - }); - modelBuilder.Entity("Remotely.Shared.Models.SharedFile", b => { b.Property("ID") @@ -514,8 +481,9 @@ namespace Remotely.Server.Migrations b.Property("OrganizationID") .HasColumnType("TEXT"); - b.Property("Timestamp") - .HasColumnType("INTEGER"); + b.Property("Timestamp") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("ID"); diff --git a/Server/Migrations/20200305075755_Initial.cs b/Server/Migrations/20200305230311_Initial.cs similarity index 92% rename from Server/Migrations/20200305075755_Initial.cs rename to Server/Migrations/20200305230311_Initial.cs index e106bbd7..3d80ef35 100644 --- a/Server/Migrations/20200305075755_Initial.cs +++ b/Server/Migrations/20200305230311_Initial.cs @@ -21,21 +21,6 @@ namespace Remotely.Server.Migrations table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); - migrationBuilder.CreateTable( - name: "GenericCommandResult", - columns: table => new - { - DeviceID = table.Column(nullable: true), - CommandResultID = table.Column(nullable: true), - CommandType = table.Column(nullable: true), - StandardOutput = table.Column(nullable: true), - ErrorOutput = table.Column(nullable: true), - TimeStamp = table.Column(nullable: false) - }, - constraints: table => - { - }); - migrationBuilder.CreateTable( name: "Organizations", columns: table => new @@ -48,18 +33,6 @@ namespace Remotely.Server.Migrations table.PrimaryKey("PK_Organizations", x => x.ID); }); - migrationBuilder.CreateTable( - name: "PSCoreCommandResult", - columns: table => new - { - CommandResultID = table.Column(nullable: true), - DeviceID = table.Column(nullable: true), - TimeStamp = table.Column(nullable: false) - }, - constraints: table => - { - }); - migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new @@ -86,7 +59,7 @@ namespace Remotely.Server.Migrations columns: table => new { ID = table.Column(nullable: false), - LastUsed = table.Column(nullable: true), + LastUsed = table.Column(nullable: true), Name = table.Column(maxLength: 200, nullable: true), OrganizationID = table.Column(nullable: true), Secret = table.Column(nullable: true), @@ -115,7 +88,7 @@ namespace Remotely.Server.Migrations TargetDeviceIDs = table.Column(nullable: true), PSCoreResults = table.Column(nullable: true), CommandResults = table.Column(nullable: true), - TimeStamp = table.Column(nullable: false), + TimeStamp = table.Column(nullable: false), OrganizationID = table.Column(nullable: true) }, constraints: table => @@ -158,7 +131,7 @@ namespace Remotely.Server.Migrations Source = table.Column(nullable: true), StackTrace = table.Column(nullable: true), OrganizationID = table.Column(nullable: true), - TimeStamp = table.Column(nullable: false) + TimeStamp = table.Column(nullable: false) }, constraints: table => { @@ -178,7 +151,7 @@ namespace Remotely.Server.Migrations ID = table.Column(nullable: false), InvitedUser = table.Column(nullable: true), IsAdmin = table.Column(nullable: false), - DateSent = table.Column(nullable: false), + DateSent = table.Column(nullable: false), OrganizationID = table.Column(nullable: true), ResetUrl = table.Column(nullable: true) }, @@ -209,7 +182,7 @@ namespace Remotely.Server.Migrations PhoneNumber = table.Column(nullable: true), PhoneNumberConfirmed = table.Column(nullable: false), TwoFactorEnabled = table.Column(nullable: false), - LockoutEnd = table.Column(nullable: true), + LockoutEnd = table.Column(nullable: true), LockoutEnabled = table.Column(nullable: false), AccessFailedCount = table.Column(nullable: false), Discriminator = table.Column(nullable: false), @@ -236,7 +209,7 @@ namespace Remotely.Server.Migrations FileName = table.Column(nullable: true), ContentType = table.Column(nullable: true), FileContents = table.Column(nullable: true), - Timestamp = table.Column(nullable: false), + Timestamp = table.Column(nullable: false), OrganizationID = table.Column(nullable: true) }, constraints: table => @@ -266,7 +239,7 @@ namespace Remotely.Server.Migrations UsedStorage = table.Column(nullable: false), Is64Bit = table.Column(nullable: false), IsOnline = table.Column(nullable: false), - LastOnline = table.Column(nullable: false), + LastOnline = table.Column(nullable: false), OrganizationID = table.Column(nullable: true), OSArchitecture = table.Column(nullable: false), OSDescription = table.Column(nullable: true), @@ -541,18 +514,12 @@ namespace Remotely.Server.Migrations migrationBuilder.DropTable( name: "EventLogs"); - migrationBuilder.DropTable( - name: "GenericCommandResult"); - migrationBuilder.DropTable( name: "InviteLinks"); migrationBuilder.DropTable( name: "PermissionLinks"); - migrationBuilder.DropTable( - name: "PSCoreCommandResult"); - migrationBuilder.DropTable( name: "SharedFiles"); diff --git a/Server/Migrations/ApplicationDbContextModelSnapshot.cs b/Server/Migrations/ApplicationDbContextModelSnapshot.cs index 1c16b053..c45f7d99 100644 --- a/Server/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Server/Migrations/ApplicationDbContextModelSnapshot.cs @@ -91,8 +91,8 @@ namespace Remotely.Server.Migrations b.Property("LockoutEnabled") .HasColumnType("INTEGER"); - b.Property("LockoutEnd") - .HasColumnType("INTEGER"); + b.Property("LockoutEnd") + .HasColumnType("TEXT"); b.Property("NormalizedEmail") .HasColumnType("TEXT") @@ -223,8 +223,8 @@ namespace Remotely.Server.Migrations b.Property("ID") .HasColumnType("TEXT"); - b.Property("LastUsed") - .HasColumnType("INTEGER"); + b.Property("LastUsed") + .HasColumnType("TEXT"); b.Property("Name") .HasColumnType("TEXT") @@ -277,8 +277,9 @@ namespace Remotely.Server.Migrations b.Property("TargetDeviceIDs") .HasColumnType("TEXT"); - b.Property("TimeStamp") - .HasColumnType("INTEGER"); + b.Property("TimeStamp") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("ID"); @@ -320,8 +321,9 @@ namespace Remotely.Server.Migrations b.Property("IsOnline") .HasColumnType("INTEGER"); - b.Property("LastOnline") - .HasColumnType("INTEGER"); + b.Property("LastOnline") + .IsRequired() + .HasColumnType("TEXT"); b.Property("OSArchitecture") .HasColumnType("INTEGER"); @@ -407,8 +409,9 @@ namespace Remotely.Server.Migrations b.Property("StackTrace") .HasColumnType("TEXT"); - b.Property("TimeStamp") - .HasColumnType("INTEGER"); + b.Property("TimeStamp") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("ID"); @@ -417,36 +420,14 @@ namespace Remotely.Server.Migrations b.ToTable("EventLogs"); }); - modelBuilder.Entity("Remotely.Shared.Models.GenericCommandResult", b => - { - b.Property("CommandResultID") - .HasColumnType("TEXT"); - - b.Property("CommandType") - .HasColumnType("TEXT"); - - b.Property("DeviceID") - .HasColumnType("TEXT"); - - b.Property("ErrorOutput") - .HasColumnType("TEXT"); - - b.Property("StandardOutput") - .HasColumnType("TEXT"); - - b.Property("TimeStamp") - .HasColumnType("INTEGER"); - - b.ToTable("GenericCommandResult"); - }); - modelBuilder.Entity("Remotely.Shared.Models.InviteLink", b => { b.Property("ID") .HasColumnType("TEXT"); - b.Property("DateSent") - .HasColumnType("INTEGER"); + b.Property("DateSent") + .IsRequired() + .HasColumnType("TEXT"); b.Property("InvitedUser") .HasColumnType("TEXT"); @@ -481,20 +462,6 @@ namespace Remotely.Server.Migrations b.ToTable("Organizations"); }); - modelBuilder.Entity("Remotely.Shared.Models.PSCoreCommandResult", b => - { - b.Property("CommandResultID") - .HasColumnType("TEXT"); - - b.Property("DeviceID") - .HasColumnType("TEXT"); - - b.Property("TimeStamp") - .HasColumnType("INTEGER"); - - b.ToTable("PSCoreCommandResult"); - }); - modelBuilder.Entity("Remotely.Shared.Models.SharedFile", b => { b.Property("ID") @@ -512,8 +479,9 @@ namespace Remotely.Server.Migrations b.Property("OrganizationID") .HasColumnType("TEXT"); - b.Property("Timestamp") - .HasColumnType("INTEGER"); + b.Property("Timestamp") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("ID"); diff --git a/Shared/Models/CommandResult.cs b/Shared/Models/CommandResult.cs index ff4743eb..59abdb4e 100644 --- a/Shared/Models/CommandResult.cs +++ b/Shared/Models/CommandResult.cs @@ -16,7 +16,9 @@ namespace Remotely.Shared.Models public string SenderUserID { get; set; } public string SenderConnectionID { get; set; } public string[] TargetDeviceIDs { get; set; } + [NotMapped] public ICollection PSCoreResults { get; set; } = new List(); + [NotMapped] public ICollection CommandResults { get; set; } = new List(); public DateTimeOffset TimeStamp { get; set; } = DateTimeOffset.Now; [JsonIgnore] diff --git a/Shared/Models/GenericCommandResult.cs b/Shared/Models/GenericCommandResult.cs index e0dcb299..48e17b8b 100644 --- a/Shared/Models/GenericCommandResult.cs +++ b/Shared/Models/GenericCommandResult.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Text; namespace Remotely.Shared.Models diff --git a/Shared/Models/PSCoreCommandResult.cs b/Shared/Models/PSCoreCommandResult.cs index 5ed42133..438022e5 100644 --- a/Shared/Models/PSCoreCommandResult.cs +++ b/Shared/Models/PSCoreCommandResult.cs @@ -9,17 +9,11 @@ namespace Remotely.Shared.Models { public string CommandResultID { get; set; } public string DeviceID { get; set; } - [NotMapped] public List VerboseOutput { get; set; } - [NotMapped] public List DebugOutput { get; set; } - [NotMapped] public List ErrorOutput { get; set; } - [NotMapped] public string HostOutput { get; set; } - [NotMapped] public List InformationOutput { get; set; } - [NotMapped] public List WarningOutput { get; set; } public DateTimeOffset TimeStamp { get; set; } = DateTimeOffset.Now; }