diff --git a/IoTSharp.Data.SqlServer/Migrations/20220212091230_SQLServerSchema2022.Designer.cs b/IoTSharp.Data.SqlServer/Migrations/20220212100016_SQLServerSchema2022.Designer.cs similarity index 97% rename from IoTSharp.Data.SqlServer/Migrations/20220212091230_SQLServerSchema2022.Designer.cs rename to IoTSharp.Data.SqlServer/Migrations/20220212100016_SQLServerSchema2022.Designer.cs index beb1562fed2fc8ba5bffbf45ddea9c5328c7cb0d..1f07cc1a0f58df7e2347cb872a8ada50addf9128 100644 --- a/IoTSharp.Data.SqlServer/Migrations/20220212091230_SQLServerSchema2022.Designer.cs +++ b/IoTSharp.Data.SqlServer/Migrations/20220212100016_SQLServerSchema2022.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace IoTSharp.Data.SqlServer.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20220212091230_SQLServerSchema2022")] + [Migration("20220212100016_SQLServerSchema2022")] partial class SQLServerSchema2022 { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -926,7 +926,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("Creator") .HasColumnType("uniqueidentifier"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uniqueidentifier"); b.Property("FieldCode") @@ -941,7 +941,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldI18nKey") .HasColumnType("nvarchar(max)"); - b.Property("FieldMaxLength") + b.Property("FieldMaxLength") .HasColumnType("int"); b.Property("FieldName") @@ -953,10 +953,10 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldPocoTypeName") .HasColumnType("nvarchar(max)"); - b.Property("FieldStatus") + b.Property("FieldStatus") .HasColumnType("int"); - b.Property("FieldUIElement") + b.Property("FieldUIElement") .HasColumnType("bigint"); b.Property("FieldUIElementSchema") @@ -974,22 +974,22 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldValueLocalDataSource") .HasColumnType("nvarchar(max)"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("int"); b.Property("FieldValueTypeName") .HasColumnType("nvarchar(max)"); - b.Property("FormId") + b.Property("FormId") .HasColumnType("bigint"); - b.Property("IsEnabled") + b.Property("IsEnabled") .HasColumnType("bit"); - b.Property("IsRequired") + b.Property("IsRequired") .HasColumnType("bit"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("FieldId"); @@ -1009,13 +1009,13 @@ namespace IoTSharp.Data.SqlServer.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FieldValueId"), 1L, 1); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("uniqueidentifier"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uniqueidentifier"); b.Property("FieldCode") @@ -1024,7 +1024,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldCreateDate") .HasColumnType("datetime2"); - b.Property("FieldId") + b.Property("FieldId") .HasColumnType("bigint"); b.Property("FieldName") @@ -1036,13 +1036,13 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldValue") .HasColumnType("nvarchar(max)"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("bigint"); - b.Property("FromId") + b.Property("FromId") .HasColumnType("bigint"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("FieldValueId"); @@ -1062,16 +1062,16 @@ namespace IoTSharp.Data.SqlServer.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FormId"), 1L, 1); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("uniqueidentifier"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uniqueidentifier"); - b.Property("FormCreator") + b.Property("FormCreator") .HasColumnType("bigint"); b.Property("FormDesc") @@ -1086,7 +1086,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FormSchame") .HasColumnType("nvarchar(max)"); - b.Property("FormStatus") + b.Property("FormStatus") .HasColumnType("int"); b.Property("FromCreateDate") @@ -1098,7 +1098,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("ModelClass") .HasColumnType("nvarchar(max)"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.Property("Url") @@ -1237,7 +1237,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FlowRuleRuleId") .HasColumnType("uniqueidentifier"); - b.Property("NodeStatus") + b.Property("NodeStatus") .HasColumnType("int"); b.Property("OperationDesc") @@ -1462,7 +1462,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("Creator") .HasColumnType("uniqueidentifier"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uniqueidentifier"); b.Property("EventDesc") @@ -1483,7 +1483,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("EventTag") .HasColumnType("nvarchar(max)"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.Property("Type") @@ -2025,15 +2025,11 @@ namespace IoTSharp.Data.SqlServer.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2044,15 +2040,11 @@ namespace IoTSharp.Data.SqlServer.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2063,15 +2055,11 @@ namespace IoTSharp.Data.SqlServer.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2190,15 +2178,11 @@ namespace IoTSharp.Data.SqlServer.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); diff --git a/IoTSharp.Data.SqlServer/Migrations/20220212091230_SQLServerSchema2022.cs b/IoTSharp.Data.SqlServer/Migrations/20220212100016_SQLServerSchema2022.cs similarity index 98% rename from IoTSharp.Data.SqlServer/Migrations/20220212091230_SQLServerSchema2022.cs rename to IoTSharp.Data.SqlServer/Migrations/20220212100016_SQLServerSchema2022.cs index 11ee101297590b74c906ef87196b60c1c9d65510..cd0a9a83fde0c664006ce220bf4a78a0f1db651d 100644 --- a/IoTSharp.Data.SqlServer/Migrations/20220212091230_SQLServerSchema2022.cs +++ b/IoTSharp.Data.SqlServer/Migrations/20220212100016_SQLServerSchema2022.cs @@ -579,27 +579,27 @@ namespace IoTSharp.Data.SqlServer.Migrations .Annotation("SqlServer:Identity", "1, 1"), FieldName = table.Column(type: "nvarchar(max)", nullable: true), FieldValue = table.Column(type: "nvarchar(max)", nullable: true), - FieldValueType = table.Column(type: "int", nullable: true), - FormId = table.Column(type: "bigint", nullable: true), + FieldValueType = table.Column(type: "int", nullable: false), + FormId = table.Column(type: "bigint", nullable: false), Creator = table.Column(type: "uniqueidentifier", nullable: false), FieldCreateDate = table.Column(type: "datetime2", nullable: true), FieldEditDate = table.Column(type: "datetime2", nullable: true), FieldCode = table.Column(type: "nvarchar(max)", nullable: true), FieldUnit = table.Column(type: "nvarchar(max)", nullable: true), - IsRequired = table.Column(type: "bit", nullable: true), - IsEnabled = table.Column(type: "bit", nullable: true), - FieldStatus = table.Column(type: "int", nullable: true), + IsRequired = table.Column(type: "bit", nullable: false), + IsEnabled = table.Column(type: "bit", nullable: false), + FieldStatus = table.Column(type: "int", nullable: false), FieldI18nKey = table.Column(type: "nvarchar(max)", nullable: true), FieldValueDataSource = table.Column(type: "nvarchar(max)", nullable: true), FieldValueLocalDataSource = table.Column(type: "nvarchar(max)", nullable: true), FieldPattern = table.Column(type: "nvarchar(max)", nullable: true), - FieldMaxLength = table.Column(type: "int", nullable: true), + FieldMaxLength = table.Column(type: "int", nullable: false), FieldValueTypeName = table.Column(type: "nvarchar(max)", nullable: true), - FieldUIElement = table.Column(type: "bigint", nullable: true), + FieldUIElement = table.Column(type: "bigint", nullable: false), FieldUIElementSchema = table.Column(type: "nvarchar(max)", nullable: true), FieldPocoTypeName = table.Column(type: "nvarchar(max)", nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false) + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CustomerId = table.Column(type: "uniqueidentifier", nullable: true) }, constraints: table => { @@ -608,14 +608,12 @@ namespace IoTSharp.Data.SqlServer.Migrations name: "FK_DynamicFormFieldInfos_Customer_CustomerId", column: x => x.CustomerId, principalTable: "Customer", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); table.ForeignKey( name: "FK_DynamicFormFieldInfos_Tenant_TenantId", column: x => x.TenantId, principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -624,18 +622,18 @@ namespace IoTSharp.Data.SqlServer.Migrations { FieldValueId = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), - FieldId = table.Column(type: "bigint", nullable: true), + FieldId = table.Column(type: "bigint", nullable: false), FieldName = table.Column(type: "nvarchar(max)", nullable: true), FieldValue = table.Column(type: "nvarchar(max)", nullable: true), - FromId = table.Column(type: "bigint", nullable: true), + FromId = table.Column(type: "bigint", nullable: false), Creator = table.Column(type: "uniqueidentifier", nullable: false), FieldCreateDate = table.Column(type: "datetime2", nullable: true), FieldCode = table.Column(type: "nvarchar(max)", nullable: true), FieldUnit = table.Column(type: "nvarchar(max)", nullable: true), - FieldValueType = table.Column(type: "bigint", nullable: true), - BizId = table.Column(type: "bigint", nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false) + FieldValueType = table.Column(type: "bigint", nullable: false), + BizId = table.Column(type: "bigint", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CustomerId = table.Column(type: "uniqueidentifier", nullable: true) }, constraints: table => { @@ -644,14 +642,12 @@ namespace IoTSharp.Data.SqlServer.Migrations name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", column: x => x.CustomerId, principalTable: "Customer", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); table.ForeignKey( name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", column: x => x.TenantId, principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -660,11 +656,11 @@ namespace IoTSharp.Data.SqlServer.Migrations { FormId = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), - BizId = table.Column(type: "bigint", nullable: true), - FormCreator = table.Column(type: "bigint", nullable: true), + BizId = table.Column(type: "bigint", nullable: false), + FormCreator = table.Column(type: "bigint", nullable: false), FormName = table.Column(type: "nvarchar(max)", nullable: true), FormDesc = table.Column(type: "nvarchar(max)", nullable: true), - FormStatus = table.Column(type: "int", nullable: true), + FormStatus = table.Column(type: "int", nullable: false), FormSchame = table.Column(type: "nvarchar(max)", nullable: true), ModelClass = table.Column(type: "nvarchar(max)", nullable: true), Url = table.Column(type: "nvarchar(max)", nullable: true), @@ -672,8 +668,8 @@ namespace IoTSharp.Data.SqlServer.Migrations FromCreateDate = table.Column(type: "datetime2", nullable: true), FormLayout = table.Column(type: "nvarchar(max)", nullable: true), IsCompact = table.Column(type: "bit", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false) + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CustomerId = table.Column(type: "uniqueidentifier", nullable: true) }, constraints: table => { @@ -682,14 +678,12 @@ namespace IoTSharp.Data.SqlServer.Migrations name: "FK_DynamicFormInfos_Customer_CustomerId", column: x => x.CustomerId, principalTable: "Customer", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); table.ForeignKey( name: "FK_DynamicFormInfos_Tenant_TenantId", column: x => x.TenantId, principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -809,8 +803,8 @@ namespace IoTSharp.Data.SqlServer.Migrations EventTag = table.Column(type: "nvarchar(max)", nullable: true), CreateDateTime = table.Column(type: "datetime2", nullable: false), Creator = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: false), - CustomerId = table.Column(type: "uniqueidentifier", nullable: false) + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CustomerId = table.Column(type: "uniqueidentifier", nullable: true) }, constraints: table => { @@ -819,14 +813,12 @@ namespace IoTSharp.Data.SqlServer.Migrations name: "FK_SubscriptionEvents_Customer_CustomerId", column: x => x.CustomerId, principalTable: "Customer", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); table.ForeignKey( name: "FK_SubscriptionEvents_Tenant_TenantId", column: x => x.TenantId, principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -1099,7 +1091,7 @@ namespace IoTSharp.Data.SqlServer.Migrations { OperationId = table.Column(type: "uniqueidentifier", nullable: false), AddDate = table.Column(type: "datetime2", nullable: true), - NodeStatus = table.Column(type: "int", nullable: true), + NodeStatus = table.Column(type: "int", nullable: false), OperationDesc = table.Column(type: "nvarchar(max)", nullable: true), Data = table.Column(type: "nvarchar(max)", nullable: true), BizId = table.Column(type: "nvarchar(max)", nullable: true), diff --git a/IoTSharp.Data.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs b/IoTSharp.Data.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs index f605d31ee34e0f98fe4dbe3752024d93fd68707d..a6b84408604fc2bcd7fd74e412d1206ea94df778 100644 --- a/IoTSharp.Data.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/IoTSharp.Data.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs @@ -924,7 +924,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("Creator") .HasColumnType("uniqueidentifier"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uniqueidentifier"); b.Property("FieldCode") @@ -939,7 +939,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldI18nKey") .HasColumnType("nvarchar(max)"); - b.Property("FieldMaxLength") + b.Property("FieldMaxLength") .HasColumnType("int"); b.Property("FieldName") @@ -951,10 +951,10 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldPocoTypeName") .HasColumnType("nvarchar(max)"); - b.Property("FieldStatus") + b.Property("FieldStatus") .HasColumnType("int"); - b.Property("FieldUIElement") + b.Property("FieldUIElement") .HasColumnType("bigint"); b.Property("FieldUIElementSchema") @@ -972,22 +972,22 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldValueLocalDataSource") .HasColumnType("nvarchar(max)"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("int"); b.Property("FieldValueTypeName") .HasColumnType("nvarchar(max)"); - b.Property("FormId") + b.Property("FormId") .HasColumnType("bigint"); - b.Property("IsEnabled") + b.Property("IsEnabled") .HasColumnType("bit"); - b.Property("IsRequired") + b.Property("IsRequired") .HasColumnType("bit"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("FieldId"); @@ -1007,13 +1007,13 @@ namespace IoTSharp.Data.SqlServer.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FieldValueId"), 1L, 1); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("uniqueidentifier"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uniqueidentifier"); b.Property("FieldCode") @@ -1022,7 +1022,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldCreateDate") .HasColumnType("datetime2"); - b.Property("FieldId") + b.Property("FieldId") .HasColumnType("bigint"); b.Property("FieldName") @@ -1034,13 +1034,13 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FieldValue") .HasColumnType("nvarchar(max)"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("bigint"); - b.Property("FromId") + b.Property("FromId") .HasColumnType("bigint"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("FieldValueId"); @@ -1060,16 +1060,16 @@ namespace IoTSharp.Data.SqlServer.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FormId"), 1L, 1); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("uniqueidentifier"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uniqueidentifier"); - b.Property("FormCreator") + b.Property("FormCreator") .HasColumnType("bigint"); b.Property("FormDesc") @@ -1084,7 +1084,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FormSchame") .HasColumnType("nvarchar(max)"); - b.Property("FormStatus") + b.Property("FormStatus") .HasColumnType("int"); b.Property("FromCreateDate") @@ -1096,7 +1096,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("ModelClass") .HasColumnType("nvarchar(max)"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.Property("Url") @@ -1235,7 +1235,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("FlowRuleRuleId") .HasColumnType("uniqueidentifier"); - b.Property("NodeStatus") + b.Property("NodeStatus") .HasColumnType("int"); b.Property("OperationDesc") @@ -1460,7 +1460,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("Creator") .HasColumnType("uniqueidentifier"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uniqueidentifier"); b.Property("EventDesc") @@ -1481,7 +1481,7 @@ namespace IoTSharp.Data.SqlServer.Migrations b.Property("EventTag") .HasColumnType("nvarchar(max)"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.Property("Type") @@ -2023,15 +2023,11 @@ namespace IoTSharp.Data.SqlServer.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2042,15 +2038,11 @@ namespace IoTSharp.Data.SqlServer.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2061,15 +2053,11 @@ namespace IoTSharp.Data.SqlServer.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2188,15 +2176,11 @@ namespace IoTSharp.Data.SqlServer.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); diff --git a/IoTSharp/Controllers/RulesController.cs b/IoTSharp/Controllers/RulesController.cs index eee6000e96fa48e9cb1b89f24962abafeb08bd91..ea16607c614c0c4f95192ba59978e61f180142cd 100644 --- a/IoTSharp/Controllers/RulesController.cs +++ b/IoTSharp/Controllers/RulesController.cs @@ -326,31 +326,22 @@ namespace IoTSharp.Controllers public ApiResult SaveDiagram(ModelWorkFlow m) { var profile = this.GetUserProfile(); - var activity = JsonConvert.DeserializeObject(m.Biz); + var activity = JsonConvert.DeserializeObject(m.Biz); var CreatorId = Guid.NewGuid(); var CreateDate = DateTime.Now; var rule = _context.FlowRules.FirstOrDefault(c => c.RuleId == activity.RuleId); - rule.DefinitionsXml = m.Xml; rule.Creator = profile.Id.ToString(); - rule.CreateId = CreatorId; - - // _context.Flows.RemoveRange(_context.Flows.Where(c => c.FlowRule.RuleId == rule.RuleId).ToList()); - - _context.Flows.Where(c => c.FlowRule.RuleId == rule.RuleId).ToList().ForEach(c => + _context.Flows.Where(c => c.FlowRule.RuleId == rule.RuleId).ForEach(c => { c.FlowStatus = -1; }); - - _context.SaveChanges(); - _context.FlowRules.Update(rule); _context.SaveChanges(); - if (activity.BaseBpmnObjects != null) { - _context.Flows.AddRange(activity.BaseBpmnObjects.Select(c => new Flow + var fw = activity.BaseBpmnObjects.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -362,14 +353,15 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant } - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.StartEvents != null) { - _context.Flows.AddRange(activity.StartEvents.Select(c => new Flow + var fw = activity.StartEvents.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -379,14 +371,15 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.EndEvents != null) { - _context.Flows.AddRange(activity.EndEvents.Select(c => new Flow + var fw = activity.EndEvents.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -396,14 +389,15 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.SequenceFlows != null) { - _context.Flows.AddRange(activity.SequenceFlows.Select(c => new Flow + var fw = activity.SequenceFlows.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -417,14 +411,15 @@ namespace IoTSharp.Controllers NodeProcessParams = c.BizObject.NodeProcessParams, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.Tasks != null) { - _context.Flows.AddRange(activity.Tasks.Select(c => new Flow + var fw = activity.Tasks.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -438,14 +433,15 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.DataInputAssociations != null) { - _context.Flows.AddRange(activity.DataInputAssociations.Select(c => new Flow + var fw = activity.DataInputAssociations.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -455,14 +451,15 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.DataOutputAssociations != null) { - _context.Flows.AddRange(activity.DataOutputAssociations.Select(c => new Flow + var fw = activity.DataOutputAssociations.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -472,14 +469,15 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.TextAnnotations != null) { - _context.Flows.AddRange(activity.TextAnnotations.Select(c => new Flow + var fw = activity.TextAnnotations.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -489,14 +487,15 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.Containers != null) { - _context.Flows.AddRange(activity.Containers.Select(c => new Flow + var fw = activity.Containers.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -506,8 +505,9 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } @@ -523,14 +523,13 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, }).ToList()); _context.SaveChanges(); } if (activity.DataStoreReferences != null) { - _context.Flows.AddRange(activity.DataStoreReferences.Select(c => new Flow + var fw = activity.DataStoreReferences.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -540,14 +539,15 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.Lane != null) { - _context.Flows.AddRange(activity.Lane.Select(c => new Flow + var fw = activity.Lane.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -557,14 +557,15 @@ namespace IoTSharp.Controllers CreateId = CreatorId, Createor = profile.Id, CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + }); + fw.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fw); _context.SaveChanges(); } if (activity.LaneSet != null) { - _context.Flows.AddRange(activity.LaneSet.Select(c => new Flow + var fws = activity.LaneSet.Select(c => new Flow { FlowRule = rule, Flowname = c.BizObject.Flowname, @@ -573,9 +574,10 @@ namespace IoTSharp.Controllers FlowStatus = 1, CreateId = CreatorId, Createor = profile.Id, - CreateDate = CreateDate, - Tenant = new Tenant() { Id = profile.Tenant }, - }).ToList()); + CreateDate = CreateDate + }); + fws.ForEach(f => _context.JustFill(this, f)); + _context.Flows.AddRange(fws); _context.SaveChanges(); } return new ApiResult(ApiCode.Success, "Ok", true); @@ -1086,11 +1088,10 @@ namespace IoTSharp.Controllers var list = result.Select(c => new FlowOperation { AddDate = c.AddDate, - BaseEvent = new BaseEvent() { EventId = c.BaseEvent.EventId }, BizId = c.BizId, Data = c.Data, - Flow = new Flow() { FlowId = c.Flow.FlowId }, - FlowRule = new FlowRule() { RuleId = c.FlowRule.RuleId }, + Flow = c.Flow, + FlowRule = c.FlowRule, NodeStatus = c.NodeStatus, OperationDesc = c.OperationDesc, OperationId = new Guid(), diff --git a/IoTSharp/IoTSharp.xml b/IoTSharp/IoTSharp.xml index 4f16d0084d76423e647d3c1d0e086ca9d336fb94..c4f49652733a5d8c4e21fe17e7b796dc31208005 100644 --- a/IoTSharp/IoTSharp.xml +++ b/IoTSharp/IoTSharp.xml @@ -380,11 +380,11 @@ - + - - - + + + @@ -401,11 +401,11 @@ - + - - - + + +