From 367f8a5384fba3ad1d5f2956d95fd63d79d19d9a Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Tue, 29 Jan 2019 16:53:48 +0800 Subject: [PATCH] add audit log and Data Side --- IoTSharp.Hub/Controllers/DevicesController.cs | 12 +- IoTSharp.Hub/Data/ApplicationDbContext.cs | 11 + IoTSharp.Hub/Data/AuditLog.cs | 24 + IoTSharp.Hub/Data/DataStorage.cs | 4 + IoTSharp.Hub/Data/Enums.cs | 18 +- .../20190129085237_AuditLog.Designer.cs | 561 ++++++++++++++++++ .../Migrations/20190129085237_AuditLog.cs | 71 +++ .../ApplicationDbContextModelSnapshot.cs | 53 +- doc/IoTSharp.dbs | 159 ++--- doc/IoTSharp.dbs.bak | 148 ++--- 10 files changed, 916 insertions(+), 145 deletions(-) create mode 100644 IoTSharp.Hub/Data/AuditLog.cs create mode 100644 IoTSharp.Hub/Data/Migrations/20190129085237_AuditLog.Designer.cs create mode 100644 IoTSharp.Hub/Data/Migrations/20190129085237_AuditLog.cs diff --git a/IoTSharp.Hub/Controllers/DevicesController.cs b/IoTSharp.Hub/Controllers/DevicesController.cs index b9582cac..a171cb89 100644 --- a/IoTSharp.Hub/Controllers/DevicesController.cs +++ b/IoTSharp.Hub/Controllers/DevicesController.cs @@ -200,14 +200,14 @@ namespace IoTSharp.Hub.Controllers } else { - var result = await SaveAsync(telemetrys, device.FirstOrDefault()); + var result = await SaveAsync(telemetrys, device.FirstOrDefault(), DataSide.ClientSide); return Ok(new ApiResult(result.ret > 0 ? ApiCode.Success : ApiCode.NothingToDo, result.ret > 0 ? "OK" : "No Telemetry save", result.exceptions)); } } [AllowAnonymous] - [HttpPost("{access_token}/Attribute")] - public async Task>> Attribute(string access_token, Dictionary attributes) + [HttpPost("{access_token}/Attributes")] + public async Task>> Attributes(string access_token, Dictionary attributes) { Dic exceptions = new Dic(); var deviceIdentity = from id in _context.DeviceIdentities where id.IdentityId == access_token && id.IdentityType == IdentityType.AccessToken select id; @@ -218,7 +218,7 @@ namespace IoTSharp.Hub.Controllers } else { - var result = await SaveAsync(attributes, device.FirstOrDefault()); + var result = await SaveAsync(attributes, device.FirstOrDefault(), DataSide.ClientSide); return Ok(new ApiResult(result.ret > 0 ? ApiCode.Success : ApiCode.NothingToDo, result.ret > 0 ? "OK" : "No Attribute save", result.exceptions)); } } @@ -231,7 +231,7 @@ namespace IoTSharp.Hub.Controllers /// /// /// - private async Task<(int ret, Dic exceptions)> SaveAsync(Dictionary data, Device device) where L : DataStorage, new() where D : DataStorage, new() + private async Task<(int ret, Dic exceptions)> SaveAsync(Dictionary data, Device device, DataSide dataSide) where L : DataStorage, new() where D : DataStorage, new() { Dic exceptions = new Dic(); data.ToList().ForEach(kp => @@ -253,7 +253,7 @@ namespace IoTSharp.Hub.Controllers } else { - var t2 = new L() { DateTime = DateTime.Now, Device = device, Id = Guid.NewGuid(), KeyName = kp.Key }; + var t2 = new L() { DateTime = DateTime.Now, Device = device, Id = Guid.NewGuid(), KeyName = kp.Key, DataSide= dataSide }; FillKVToModel(kp, t2); _context.Set().Add(t2); } diff --git a/IoTSharp.Hub/Data/ApplicationDbContext.cs b/IoTSharp.Hub/Data/ApplicationDbContext.cs index a6874d00..5da704c3 100644 --- a/IoTSharp.Hub/Data/ApplicationDbContext.cs +++ b/IoTSharp.Hub/Data/ApplicationDbContext.cs @@ -96,6 +96,16 @@ namespace IoTSharp.Hub.Data modelBuilder.Entity() .Property(b => b.Value_XML) .HasColumnType("xml"); + + modelBuilder.Entity() + .Property(b => b.ActionData) + .HasColumnType("jsonb"); + + modelBuilder.Entity() + .Property(b => b.ActionResult) + .HasColumnType("jsonb"); + + } private void ForSqlServer(ModelBuilder modelBuilder) @@ -127,5 +137,6 @@ namespace IoTSharp.Hub.Data public DbSet AttributeData { get; set; } public DbSet TelemetryLatest { get; set; } public DbSet DeviceIdentities { get; set; } + public DbSet AuditLog { get; set; } } } \ No newline at end of file diff --git a/IoTSharp.Hub/Data/AuditLog.cs b/IoTSharp.Hub/Data/AuditLog.cs new file mode 100644 index 00000000..5da8e5af --- /dev/null +++ b/IoTSharp.Hub/Data/AuditLog.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace IoTSharp.Hub.Data +{ + public class AuditLog + { + public Guid Id { get; set; } = Guid.NewGuid(); + public Tenant Tenant { get; set; } + public Customer Customer { get; set; } + public string UserId { get; set; } + public string UserName { get; set; } + public Guid ObjectID { get; set; } + public string ObjectName { get; set; } + public ObjectType ObjectType { get; set; } = ObjectType.Unknow; + public string ActionName { get; set; } + public string ActionData { get; set; } + public string ActionResult { get; set; } + public DateTime ActiveDateTime { get; set; } = DateTime.Now; + + } +} diff --git a/IoTSharp.Hub/Data/DataStorage.cs b/IoTSharp.Hub/Data/DataStorage.cs index 978bb064..63e6bdd8 100644 --- a/IoTSharp.Hub/Data/DataStorage.cs +++ b/IoTSharp.Hub/Data/DataStorage.cs @@ -15,6 +15,10 @@ namespace IoTSharp.Hub.Data [Required] public Device Device { get; set; } + [Required] + [EnumDataType(typeof(DataSide))] + public DataSide DataSide { get; set; } = DataSide.AnySide; + [Required] [EnumDataType(typeof(DataCatalog))] public DataCatalog Catalog { get; set; } diff --git a/IoTSharp.Hub/Data/Enums.cs b/IoTSharp.Hub/Data/Enums.cs index 527ccd78..772dbbf5 100644 --- a/IoTSharp.Hub/Data/Enums.cs +++ b/IoTSharp.Hub/Data/Enums.cs @@ -36,7 +36,12 @@ namespace IoTSharp.Hub.Data TelemetryData, TelemetryLatest, } - + public enum DataSide + { + AnySide, + ServerSide, + ClientSide, + } public enum UserRole { Anonymous, @@ -70,4 +75,15 @@ namespace IoTSharp.Hub.Data DevicePassword, X509Certificate } + public enum ObjectType + { + Unknow, + Device, + Tenant, + Customer, + User, + MQTTBroker, + MQTTClient + + } } \ No newline at end of file diff --git a/IoTSharp.Hub/Data/Migrations/20190129085237_AuditLog.Designer.cs b/IoTSharp.Hub/Data/Migrations/20190129085237_AuditLog.Designer.cs new file mode 100644 index 00000000..664d1528 --- /dev/null +++ b/IoTSharp.Hub/Data/Migrations/20190129085237_AuditLog.Designer.cs @@ -0,0 +1,561 @@ +// +using System; +using IoTSharp.Hub.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace IoTSharp.Hub.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20190129085237_AuditLog")] + partial class AuditLog + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .HasAnnotation("ProductVersion", "2.2.1-servicing-10028") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + modelBuilder.Entity("IoTSharp.Hub.Data.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ActionData") + .HasColumnType("jsonb"); + + b.Property("ActionName"); + + b.Property("ActionResult") + .HasColumnType("jsonb"); + + b.Property("ActiveDateTime"); + + b.Property("CustomerId"); + + b.Property("ObjectID"); + + b.Property("ObjectName"); + + b.Property("ObjectType"); + + b.Property("TenantId"); + + b.Property("UserId"); + + b.Property("UserName"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuditLog"); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Address"); + + b.Property("City"); + + b.Property("Country"); + + b.Property("Email"); + + b.Property("Name"); + + b.Property("Phone"); + + b.Property("Province"); + + b.Property("Street"); + + b.Property("TenantId"); + + b.Property("ZipCode"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("Customer"); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.DataStorage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Catalog"); + + b.Property("DataSide"); + + b.Property("DateTime"); + + b.Property("KeyName") + .IsRequired(); + + b.Property("Type"); + + b.Property("Value_Binary"); + + b.Property("Value_Boolean"); + + b.Property("Value_Double"); + + b.Property("Value_Json") + .HasColumnType("jsonb"); + + b.Property("Value_Long"); + + b.Property("Value_String"); + + b.Property("Value_XML") + .HasColumnType("xml"); + + b.HasKey("Id"); + + b.ToTable("DataStorage"); + + b.HasDiscriminator("Catalog").HasValue(0); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.Device", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CustomerId"); + + b.Property("Name"); + + b.Property("TenantId"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("Device"); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.DeviceIdentity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DeviceId"); + + b.Property("IdentityId") + .IsRequired(); + + b.Property("IdentityType"); + + b.Property("IdentityValue"); + + b.HasKey("Id"); + + b.HasIndex("DeviceId"); + + b.ToTable("DeviceIdentities"); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.Relationship", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CustomerId"); + + b.Property("IdentityUserId"); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("IdentityUserId"); + + b.HasIndex("TenantId"); + + b.ToTable("Relationship"); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Address"); + + b.Property("City"); + + b.Property("Country"); + + b.Property("EMail"); + + b.Property("Name"); + + b.Property("Phone"); + + b.Property("Province"); + + b.Property("Street"); + + b.Property("ZipCode"); + + b.HasKey("Id"); + + b.ToTable("Tenant"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Name") + .HasMaxLength(256); + + b.Property("NormalizedName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("RoleId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AccessFailedCount"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Email") + .HasMaxLength(256); + + b.Property("EmailConfirmed"); + + b.Property("LockoutEnabled"); + + b.Property("LockoutEnd"); + + b.Property("NormalizedEmail") + .HasMaxLength(256); + + b.Property("NormalizedUserName") + .HasMaxLength(256); + + b.Property("PasswordHash"); + + b.Property("PhoneNumber"); + + b.Property("PhoneNumberConfirmed"); + + b.Property("SecurityStamp"); + + b.Property("TwoFactorEnabled"); + + b.Property("UserName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasName("UserNameIndex"); + + b.ToTable("AspNetUsers"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider"); + + b.Property("ProviderKey"); + + b.Property("ProviderDisplayName"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId"); + + b.Property("RoleId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId"); + + b.Property("LoginProvider"); + + b.Property("Name"); + + b.Property("Value"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.AttributeData", b => + { + b.HasBaseType("IoTSharp.Hub.Data.DataStorage"); + + b.Property("DeviceId"); + + b.HasIndex("DeviceId"); + + b.HasDiscriminator().HasValue(1); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.AttributeLatest", b => + { + b.HasBaseType("IoTSharp.Hub.Data.DataStorage"); + + b.Property("DeviceId") + .HasColumnName("AttributeLatest_DeviceId"); + + b.HasIndex("DeviceId"); + + b.HasDiscriminator().HasValue(2); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryData", b => + { + b.HasBaseType("IoTSharp.Hub.Data.DataStorage"); + + b.Property("DeviceId") + .HasColumnName("TelemetryData_DeviceId"); + + b.HasIndex("DeviceId"); + + b.HasDiscriminator().HasValue(3); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryLatest", b => + { + b.HasBaseType("IoTSharp.Hub.Data.DataStorage"); + + b.Property("DeviceId") + .HasColumnName("TelemetryLatest_DeviceId"); + + b.HasIndex("DeviceId"); + + b.HasDiscriminator().HasValue(4); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.AuditLog", b => + { + b.HasOne("IoTSharp.Hub.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b => + { + b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant") + .WithMany("Customers") + .HasForeignKey("TenantId"); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.Device", b => + { + b.HasOne("IoTSharp.Hub.Data.Customer", "Customer") + .WithMany("Devices") + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant") + .WithMany("Devices") + .HasForeignKey("TenantId"); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.DeviceIdentity", b => + { + b.HasOne("IoTSharp.Hub.Data.Device", "Device") + .WithMany() + .HasForeignKey("DeviceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.Relationship", b => + { + b.HasOne("IoTSharp.Hub.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "IdentityUser") + .WithMany() + .HasForeignKey("IdentityUserId"); + + b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.AttributeData", b => + { + b.HasOne("IoTSharp.Hub.Data.Device", "Device") + .WithMany("AttributeData") + .HasForeignKey("DeviceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.AttributeLatest", b => + { + b.HasOne("IoTSharp.Hub.Data.Device", "Device") + .WithMany("AttributeLatest") + .HasForeignKey("DeviceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryData", b => + { + b.HasOne("IoTSharp.Hub.Data.Device", "Device") + .WithMany("TelemetryData") + .HasForeignKey("DeviceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryLatest", b => + { + b.HasOne("IoTSharp.Hub.Data.Device", "Device") + .WithMany("TelemetryLatest") + .HasForeignKey("DeviceId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IoTSharp.Hub/Data/Migrations/20190129085237_AuditLog.cs b/IoTSharp.Hub/Data/Migrations/20190129085237_AuditLog.cs new file mode 100644 index 00000000..50e29b22 --- /dev/null +++ b/IoTSharp.Hub/Data/Migrations/20190129085237_AuditLog.cs @@ -0,0 +1,71 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace IoTSharp.Hub.Migrations +{ + public partial class AuditLog : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DataSide", + table: "DataStorage", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "AuditLog", + columns: table => new + { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + CustomerId = table.Column(nullable: true), + UserId = table.Column(nullable: true), + UserName = table.Column(nullable: true), + ObjectID = table.Column(nullable: false), + ObjectName = table.Column(nullable: true), + ObjectType = table.Column(nullable: false), + ActionName = table.Column(nullable: true), + ActionData = table.Column(type: "jsonb", nullable: true), + ActionResult = table.Column(type: "jsonb", nullable: true), + ActiveDateTime = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AuditLog", x => x.Id); + table.ForeignKey( + name: "FK_AuditLog_Customer_CustomerId", + column: x => x.CustomerId, + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_AuditLog_Tenant_TenantId", + column: x => x.TenantId, + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_AuditLog_CustomerId", + table: "AuditLog", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_AuditLog_TenantId", + table: "AuditLog", + column: "TenantId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AuditLog"); + + migrationBuilder.DropColumn( + name: "DataSide", + table: "DataStorage"); + } + } +} diff --git a/IoTSharp.Hub/Data/Migrations/ApplicationDbContextModelSnapshot.cs b/IoTSharp.Hub/Data/Migrations/ApplicationDbContextModelSnapshot.cs index 19c6ecd7..ca52d0fd 100644 --- a/IoTSharp.Hub/Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/IoTSharp.Hub/Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -16,9 +16,47 @@ namespace IoTSharp.Hub.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") + .HasAnnotation("ProductVersion", "2.2.1-servicing-10028") .HasAnnotation("Relational:MaxIdentifierLength", 63); + modelBuilder.Entity("IoTSharp.Hub.Data.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ActionData") + .HasColumnType("jsonb"); + + b.Property("ActionName"); + + b.Property("ActionResult") + .HasColumnType("jsonb"); + + b.Property("ActiveDateTime"); + + b.Property("CustomerId"); + + b.Property("ObjectID"); + + b.Property("ObjectName"); + + b.Property("ObjectType"); + + b.Property("TenantId"); + + b.Property("UserId"); + + b.Property("UserName"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuditLog"); + }); + modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b => { b.Property("Id") @@ -58,6 +96,8 @@ namespace IoTSharp.Hub.Migrations b.Property("Catalog"); + b.Property("DataSide"); + b.Property("DateTime"); b.Property("KeyName") @@ -385,6 +425,17 @@ namespace IoTSharp.Hub.Migrations b.HasDiscriminator().HasValue(4); }); + modelBuilder.Entity("IoTSharp.Hub.Data.AuditLog", b => + { + b.HasOne("IoTSharp.Hub.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + }); + modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b => { b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant") diff --git a/doc/IoTSharp.dbs b/doc/IoTSharp.dbs index beda539b..f797d4ad 100644 --- a/doc/IoTSharp.dbs +++ b/doc/IoTSharp.dbs @@ -44,8 +44,8 @@ - - + + @@ -78,8 +78,8 @@
- - + + @@ -116,52 +116,6 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -184,6 +138,53 @@
+ + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -206,11 +207,27 @@
+ + + + + + + + + + + + + + + +
- + @@ -220,18 +237,18 @@ - - + + - - - + + +
@@ -258,27 +275,27 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + + - diff --git a/doc/IoTSharp.dbs.bak b/doc/IoTSharp.dbs.bak index 1cf72cc0..eecc1bf4 100644 --- a/doc/IoTSharp.dbs.bak +++ b/doc/IoTSharp.dbs.bak @@ -116,9 +116,9 @@
- +
- + @@ -127,9 +127,40 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -152,9 +183,6 @@ - - -
@@ -179,48 +207,31 @@
- - - - - - - + + + + + - + -
- - - - - - - - - - - - + -
- - - - - - - - - - - - - + + + + + + + + + + +
@@ -236,9 +247,6 @@ - - -
@@ -250,23 +258,37 @@ - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -276,12 +298,9 @@ - - - @@ -308,10 +327,7 @@ - - -