From cbe6c5f8ccda8d5750fe1c15c2aa2a5d7049762b Mon Sep 17 00:00:00 2001 From: wq1234wq Date: Thu, 10 Nov 2022 19:33:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=84=E5=88=99=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221109174343_addflowexfield.Designer.cs | 2644 +++++++++++++++++ .../20221109174343_addflowexfield.cs | 92 + .../ApplicationDbContextModelSnapshot.cs | 21 + IoTSharp.Data/Flow.cs | 8 + IoTSharp/Controllers/RulesController.cs | 269 +- IoTSharp/IoTSharp.xml | 15 + IoTSharp/Models/Rule/ModelWorkFlow.cs | 55 +- 7 files changed, 3086 insertions(+), 18 deletions(-) create mode 100644 IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/20221109174343_addflowexfield.Designer.cs create mode 100644 IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/20221109174343_addflowexfield.cs diff --git a/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/20221109174343_addflowexfield.Designer.cs b/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/20221109174343_addflowexfield.Designer.cs new file mode 100644 index 000000000..4c58d3884 --- /dev/null +++ b/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/20221109174343_addflowexfield.Designer.cs @@ -0,0 +1,2644 @@ +// +using System; +using IoTSharp.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IoTSharp.Data.MySql.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20221109174343_addflowexfield")] + partial class addflowexfield + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IoTSharp.Data.Alarm", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AckDateTime") + .HasColumnType("datetime(6)"); + + b.Property("AlarmDetail") + .HasColumnType("longtext"); + + b.Property("AlarmStatus") + .HasColumnType("int"); + + b.Property("AlarmType") + .HasColumnType("longtext"); + + b.Property("ClearDateTime") + .HasColumnType("datetime(6)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("EndDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OriginatorId") + .HasColumnType("char(36)"); + + b.Property("OriginatorType") + .HasColumnType("int"); + + b.Property("Propagate") + .HasColumnType("tinyint(1)"); + + b.Property("Serverity") + .HasColumnType("int"); + + b.Property("StartDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("Alarms"); + }); + + modelBuilder.Entity("IoTSharp.Data.Asset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AssetType") + .HasColumnType("longtext"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("Deleted") + .HasColumnType("tinyint(1)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("Assets"); + }); + + modelBuilder.Entity("IoTSharp.Data.AssetRelation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AssetId") + .HasColumnType("char(36)"); + + b.Property("DataCatalog") + .HasColumnType("int"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("KeyName") + .HasColumnType("longtext"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("AssetRelations"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActionData") + .HasColumnType("JSON"); + + b.Property("ActionName") + .HasColumnType("longtext"); + + b.Property("ActionResult") + .HasColumnType("JSON"); + + b.Property("ActiveDateTime") + .HasColumnType("timestamp"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("ObjectID") + .HasColumnType("char(36)"); + + b.Property("ObjectName") + .HasColumnType("longtext"); + + b.Property("ObjectType") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("longtext"); + + b.Property("UserName") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuditLog"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AuthToken") + .HasColumnType("longtext"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("Deleted") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuthorizedKeys"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseDictionary", b => + { + b.Property("DictionaryId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Dictionary18NKeyName") + .HasColumnType("longtext"); + + b.Property("DictionaryColor") + .HasColumnType("longtext"); + + b.Property("DictionaryDesc") + .HasColumnType("longtext"); + + b.Property("DictionaryGroupId") + .HasColumnType("bigint"); + + b.Property("DictionaryIcon") + .HasColumnType("longtext"); + + b.Property("DictionaryName") + .HasColumnType("longtext"); + + b.Property("DictionaryPattern") + .HasColumnType("longtext"); + + b.Property("DictionaryStatus") + .HasColumnType("int"); + + b.Property("DictionaryTag") + .HasColumnType("longtext"); + + b.Property("DictionaryValue") + .HasColumnType("longtext"); + + b.Property("DictionaryValueType") + .HasColumnType("int"); + + b.Property("DictionaryValueTypeName") + .HasColumnType("longtext"); + + b.HasKey("DictionaryId"); + + b.ToTable("BaseDictionaries"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseDictionaryGroup", b => + { + b.Property("DictionaryGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DictionaryGroup18NKeyName") + .HasColumnType("longtext"); + + b.Property("DictionaryGroupDesc") + .HasColumnType("longtext"); + + b.Property("DictionaryGroupKey") + .HasColumnType("longtext"); + + b.Property("DictionaryGroupName") + .HasColumnType("longtext"); + + b.Property("DictionaryGroupStatus") + .HasColumnType("int"); + + b.Property("DictionaryGroupValueType") + .HasColumnType("int"); + + b.Property("DictionaryGroupValueTypeName") + .HasColumnType("longtext"); + + b.HasKey("DictionaryGroupId"); + + b.ToTable("BaseDictionaryGroups"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseEvent", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BizData") + .HasColumnType("longtext"); + + b.Property("Bizid") + .HasColumnType("longtext"); + + b.Property("CreaterDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("EventDesc") + .HasColumnType("longtext"); + + b.Property("EventName") + .HasColumnType("longtext"); + + b.Property("EventStaus") + .HasColumnType("int"); + + b.Property("FlowRuleRuleId") + .HasColumnType("char(36)"); + + b.Property("MataData") + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("EventId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("FlowRuleRuleId"); + + b.HasIndex("TenantId"); + + b.ToTable("BaseEvents"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseI18N", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AddDate") + .HasColumnType("datetime(6)"); + + b.Property("KeyName") + .HasColumnType("longtext"); + + b.Property("ResouceDesc") + .HasColumnType("longtext"); + + b.Property("ResouceGroupId") + .HasColumnType("int"); + + b.Property("ResourceId") + .HasColumnType("bigint"); + + b.Property("ResourceKey") + .HasColumnType("longtext"); + + b.Property("ResourceTag") + .HasColumnType("longtext"); + + b.Property("ResourceType") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("ValueBG") + .HasColumnType("longtext"); + + b.Property("ValueCS") + .HasColumnType("longtext"); + + b.Property("ValueDA") + .HasColumnType("longtext"); + + b.Property("ValueDEDE") + .HasColumnType("longtext"); + + b.Property("ValueELGR") + .HasColumnType("longtext"); + + b.Property("ValueENGR") + .HasColumnType("longtext"); + + b.Property("ValueENUS") + .HasColumnType("longtext"); + + b.Property("ValueESES") + .HasColumnType("longtext"); + + b.Property("ValueFI") + .HasColumnType("longtext"); + + b.Property("ValueFRFR") + .HasColumnType("longtext"); + + b.Property("ValueHE") + .HasColumnType("longtext"); + + b.Property("ValueHRHR") + .HasColumnType("longtext"); + + b.Property("ValueHU") + .HasColumnType("longtext"); + + b.Property("ValueITIT") + .HasColumnType("longtext"); + + b.Property("ValueJAJP") + .HasColumnType("longtext"); + + b.Property("ValueKOKR") + .HasColumnType("longtext"); + + b.Property("ValueNL") + .HasColumnType("longtext"); + + b.Property("ValuePLPL") + .HasColumnType("longtext"); + + b.Property("ValuePT") + .HasColumnType("longtext"); + + b.Property("ValueSLSL") + .HasColumnType("longtext"); + + b.Property("ValueSR") + .HasColumnType("longtext"); + + b.Property("ValueSV") + .HasColumnType("longtext"); + + b.Property("ValueTRTR") + .HasColumnType("longtext"); + + b.Property("ValueUK") + .HasColumnType("longtext"); + + b.Property("ValueVI") + .HasColumnType("longtext"); + + b.Property("ValueZHCN") + .HasColumnType("longtext"); + + b.Property("ValueZHTW") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("BaseI18Ns"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Address") + .HasColumnType("longtext"); + + b.Property("City") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("Deleted") + .HasColumnType("tinyint(1)"); + + b.Property("Email") + .HasColumnType("longtext"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Phone") + .HasColumnType("longtext"); + + b.Property("Province") + .HasColumnType("longtext"); + + b.Property("Street") + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("Customer"); + }); + + modelBuilder.Entity("IoTSharp.Data.DataStorage", b => + { + b.Property("Catalog") + .HasColumnType("int") + .HasColumnOrder(0); + + b.Property("DeviceId") + .HasColumnType("char(36)") + .HasColumnOrder(1); + + b.Property("KeyName") + .HasColumnType("varchar(255)") + .HasColumnOrder(2); + + b.Property("DataSide") + .HasColumnType("int") + .HasColumnOrder(4); + + b.Property("DateTime") + .HasColumnType("timestamp") + .HasColumnOrder(3); + + b.Property("Type") + .HasColumnType("int") + .HasColumnOrder(5); + + b.Property("Value_Binary") + .HasColumnType("longblob"); + + b.Property("Value_Boolean") + .HasColumnType("tinyint(1)"); + + b.Property("Value_DateTime") + .HasColumnType("timestamp"); + + b.Property("Value_Double") + .HasColumnType("double"); + + b.Property("Value_Json") + .HasColumnType("JSON"); + + b.Property("Value_Long") + .HasColumnType("bigint"); + + b.Property("Value_String") + .HasColumnType("longtext"); + + b.Property("Value_XML") + .HasColumnType("longtext"); + + b.HasKey("Catalog", "DeviceId", "KeyName"); + + b.HasIndex("Catalog"); + + b.HasIndex("Catalog", "DeviceId"); + + b.ToTable("DataStorage"); + + b.HasDiscriminator("Catalog").HasValue(0); + }); + + modelBuilder.Entity("IoTSharp.Data.Device", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AuthorizedKeyId") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("Deleted") + .HasColumnType("tinyint(1)"); + + b.Property("DeviceModelId") + .HasColumnType("char(36)"); + + b.Property("DeviceType") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("OwnerId") + .HasColumnType("char(36)"); + + b.Property("ProduceId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Timeout") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizedKeyId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ProduceId"); + + b.HasIndex("TenantId"); + + b.ToTable("Device"); + + b.HasDiscriminator("DeviceType").HasValue(0); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceDiagram", b => + { + b.Property("DiagramId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreateDate") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("DiagramDesc") + .HasColumnType("longtext"); + + b.Property("DiagramImage") + .HasColumnType("longtext"); + + b.Property("DiagramName") + .HasColumnType("longtext"); + + b.Property("DiagramStatus") + .HasColumnType("int"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("DiagramId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DeviceDiagrams"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b => + { + b.Property("GraphId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreateDate") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("DeviceDiagramDiagramId") + .HasColumnType("char(36)"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("GraphElementId") + .HasColumnType("longtext"); + + b.Property("GraphFill") + .HasColumnType("longtext"); + + b.Property("GraphHeight") + .HasColumnType("int"); + + b.Property("GraphPostionX") + .HasColumnType("int"); + + b.Property("GraphPostionY") + .HasColumnType("int"); + + b.Property("GraphShape") + .HasColumnType("longtext"); + + b.Property("GraphStroke") + .HasColumnType("longtext"); + + b.Property("GraphStrokeWidth") + .HasColumnType("int"); + + b.Property("GraphTextAnchor") + .HasColumnType("longtext"); + + b.Property("GraphTextFill") + .HasColumnType("longtext"); + + b.Property("GraphTextFontFamily") + .HasColumnType("longtext"); + + b.Property("GraphTextFontSize") + .HasColumnType("int"); + + b.Property("GraphTextRefX") + .HasColumnType("int"); + + b.Property("GraphTextRefY") + .HasColumnType("int"); + + b.Property("GraphTextVerticalAnchor") + .HasColumnType("longtext"); + + b.Property("GraphWidth") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("GraphId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("DeviceDiagramDiagramId"); + + b.HasIndex("TenantId"); + + b.ToTable("DeviceGraphs"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraphToolBox", b => + { + b.Property("ToolBoxId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CommondParam") + .HasColumnType("longtext"); + + b.Property("CommondType") + .HasColumnType("longtext"); + + b.Property("CreateDate") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("DeviceId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("ToolBoxIcon") + .HasColumnType("longtext"); + + b.Property("ToolBoxName") + .HasColumnType("longtext"); + + b.Property("ToolBoxOffsetLeftPer") + .HasColumnType("int"); + + b.Property("ToolBoxOffsetTopPer") + .HasColumnType("int"); + + b.Property("ToolBoxOffsetX") + .HasColumnType("int"); + + b.Property("ToolBoxOffsetY") + .HasColumnType("int"); + + b.Property("ToolBoxRequestUri") + .HasColumnType("longtext"); + + b.Property("ToolBoxStatus") + .HasColumnType("int"); + + b.Property("ToolBoxType") + .HasColumnType("longtext"); + + b.HasKey("ToolBoxId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DeviceGraphToolBoxes"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("IdentityId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IdentityType") + .HasColumnType("int"); + + b.Property("IdentityValue") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("DeviceId") + .IsUnique(); + + b.ToTable("DeviceIdentities"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModel", b => + { + b.Property("DeviceModelId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("ModelDesc") + .HasColumnType("longtext"); + + b.Property("ModelName") + .HasColumnType("longtext"); + + b.Property("ModelStatus") + .HasColumnType("int"); + + b.HasKey("DeviceModelId"); + + b.ToTable("DeviceModels"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b => + { + b.Property("CommandId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CommandI18N") + .HasColumnType("longtext"); + + b.Property("CommandName") + .HasColumnType("longtext"); + + b.Property("CommandParams") + .HasColumnType("longtext"); + + b.Property("CommandStatus") + .HasColumnType("int"); + + b.Property("CommandTemplate") + .HasColumnType("longtext"); + + b.Property("CommandTitle") + .HasColumnType("longtext"); + + b.Property("CommandType") + .HasColumnType("int"); + + b.Property("CreateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("DeviceModelId") + .HasColumnType("char(36)"); + + b.HasKey("CommandId"); + + b.HasIndex("DeviceModelId"); + + b.ToTable("DeviceModelCommands"); + }); + + modelBuilder.Entity("IoTSharp.Data.DevicePort", b => + { + b.Property("PortId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreateDate") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("bigint"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("PortDesc") + .HasColumnType("longtext"); + + b.Property("PortElementId") + .HasColumnType("longtext"); + + b.Property("PortName") + .HasColumnType("longtext"); + + b.Property("PortPhyType") + .HasColumnType("int"); + + b.Property("PortPic") + .HasColumnType("longtext"); + + b.Property("PortStatus") + .HasColumnType("int"); + + b.Property("PortType") + .HasColumnType("int"); + + b.HasKey("PortId"); + + b.ToTable("DevicePorts"); + }); + + modelBuilder.Entity("IoTSharp.Data.DevicePortMapping", b => + { + b.Property("MappingId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreateDate") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("MappingIndex") + .HasColumnType("int"); + + b.Property("MappingStatus") + .HasColumnType("int"); + + b.Property("SourceDeviceId") + .HasColumnType("char(36)"); + + b.Property("SourceElementId") + .HasColumnType("longtext"); + + b.Property("SourceId") + .HasColumnType("longtext"); + + b.Property("TargeId") + .HasColumnType("longtext"); + + b.Property("TargetDeviceId") + .HasColumnType("char(36)"); + + b.Property("TargetElementId") + .HasColumnType("longtext"); + + b.HasKey("MappingId"); + + b.ToTable("DevicePortMappings"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceRule", b => + { + b.Property("DeviceRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConfigDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ConfigUser") + .HasColumnType("char(36)"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("EnableTrace") + .HasColumnType("int"); + + b.Property("FlowRuleRuleId") + .HasColumnType("char(36)"); + + b.HasKey("DeviceRuleId"); + + b.HasIndex("DeviceId"); + + b.HasIndex("FlowRuleRuleId"); + + b.ToTable("DeviceRules"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldInfo", b => + { + b.Property("FieldId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("FieldCode") + .HasColumnType("longtext"); + + b.Property("FieldCreateDate") + .HasColumnType("datetime(6)"); + + b.Property("FieldEditDate") + .HasColumnType("datetime(6)"); + + b.Property("FieldI18nKey") + .HasColumnType("longtext"); + + b.Property("FieldMaxLength") + .HasColumnType("int"); + + b.Property("FieldName") + .HasColumnType("longtext"); + + b.Property("FieldPattern") + .HasColumnType("longtext"); + + b.Property("FieldPocoTypeName") + .HasColumnType("longtext"); + + b.Property("FieldStatus") + .HasColumnType("int"); + + b.Property("FieldUIElement") + .HasColumnType("bigint"); + + b.Property("FieldUIElementSchema") + .HasColumnType("longtext"); + + b.Property("FieldUnit") + .HasColumnType("longtext"); + + b.Property("FieldValue") + .HasColumnType("longtext"); + + b.Property("FieldValueDataSource") + .HasColumnType("longtext"); + + b.Property("FieldValueLocalDataSource") + .HasColumnType("longtext"); + + b.Property("FieldValueType") + .HasColumnType("int"); + + b.Property("FieldValueTypeName") + .HasColumnType("longtext"); + + b.Property("FormId") + .HasColumnType("bigint"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("IsRequired") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("FieldId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DynamicFormFieldInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldValueInfo", b => + { + b.Property("FieldValueId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BizId") + .HasColumnType("bigint"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("FieldCode") + .HasColumnType("longtext"); + + b.Property("FieldCreateDate") + .HasColumnType("datetime(6)"); + + b.Property("FieldId") + .HasColumnType("bigint"); + + b.Property("FieldName") + .HasColumnType("longtext"); + + b.Property("FieldUnit") + .HasColumnType("longtext"); + + b.Property("FieldValue") + .HasColumnType("longtext"); + + b.Property("FieldValueType") + .HasColumnType("bigint"); + + b.Property("FromId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("FieldValueId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DynamicFormFieldValueInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormInfo", b => + { + b.Property("FormId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BizId") + .HasColumnType("bigint"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("FormCreator") + .HasColumnType("bigint"); + + b.Property("FormDesc") + .HasColumnType("longtext"); + + b.Property("FormLayout") + .HasColumnType("longtext"); + + b.Property("FormName") + .HasColumnType("longtext"); + + b.Property("FormSchame") + .HasColumnType("longtext"); + + b.Property("FormStatus") + .HasColumnType("int"); + + b.Property("FromCreateDate") + .HasColumnType("datetime(6)"); + + b.Property("IsCompact") + .HasColumnType("tinyint(1)"); + + b.Property("ModelClass") + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Url") + .HasColumnType("longtext"); + + b.HasKey("FormId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DynamicFormInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.Flow", b => + { + b.Property("FlowId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Conditionexpression") + .HasColumnType("longtext"); + + b.Property("CreateDate") + .HasColumnType("datetime(6)"); + + b.Property("CreateId") + .HasColumnType("char(36)"); + + b.Property("Createor") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("ExecutorId") + .HasColumnType("char(36)"); + + b.Property("FlowClass") + .HasColumnType("longtext"); + + b.Property("FlowIcon") + .HasColumnType("longtext"); + + b.Property("FlowNameSpace") + .HasColumnType("longtext"); + + b.Property("FlowRuleRuleId") + .HasColumnType("char(36)"); + + b.Property("FlowShapeType") + .HasColumnType("longtext"); + + b.Property("FlowStatus") + .HasColumnType("int"); + + b.Property("FlowTag") + .HasColumnType("longtext"); + + b.Property("FlowType") + .HasColumnType("longtext"); + + b.Property("Flowdesc") + .HasColumnType("longtext"); + + b.Property("Flowname") + .HasColumnType("longtext"); + + b.Property("Incoming") + .HasColumnType("longtext"); + + b.Property("Left") + .HasColumnType("longtext"); + + b.Property("NodeProcessClass") + .HasColumnType("longtext"); + + b.Property("NodeProcessMethod") + .HasColumnType("longtext"); + + b.Property("NodeProcessParams") + .HasColumnType("longtext"); + + b.Property("NodeProcessScript") + .HasColumnType("longtext"); + + b.Property("NodeProcessScriptType") + .HasColumnType("longtext"); + + b.Property("NodeProcessType") + .HasColumnType("longtext"); + + b.Property("ObjectId") + .HasColumnType("longtext"); + + b.Property("Outgoing") + .HasColumnType("longtext"); + + b.Property("SourceId") + .HasColumnType("longtext"); + + b.Property("TargetId") + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("TestStatus") + .HasColumnType("int"); + + b.Property("Tester") + .HasColumnType("char(36)"); + + b.Property("TesterDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Top") + .HasColumnType("longtext"); + + b.Property("bpmnid") + .HasColumnType("longtext"); + + b.HasKey("FlowId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("ExecutorId"); + + b.HasIndex("FlowRuleRuleId"); + + b.HasIndex("TenantId"); + + b.ToTable("Flows"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowOperation", b => + { + b.Property("OperationId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AddDate") + .HasColumnType("datetime(6)"); + + b.Property("BaseEventEventId") + .HasColumnType("char(36)"); + + b.Property("BizId") + .HasColumnType("longtext"); + + b.Property("Data") + .HasColumnType("longtext"); + + b.Property("FlowId") + .HasColumnType("char(36)"); + + b.Property("FlowRuleRuleId") + .HasColumnType("char(36)"); + + b.Property("NodeStatus") + .HasColumnType("int"); + + b.Property("OperationDesc") + .HasColumnType("longtext"); + + b.Property("Step") + .HasColumnType("int"); + + b.Property("Tag") + .HasColumnType("longtext"); + + b.Property("bpmnid") + .HasColumnType("longtext"); + + b.HasKey("OperationId"); + + b.HasIndex("BaseEventEventId"); + + b.HasIndex("FlowId"); + + b.HasIndex("FlowRuleRuleId"); + + b.ToTable("FlowOperations"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowRule", b => + { + b.Property("RuleId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatTime") + .HasColumnType("datetime(6)"); + + b.Property("CreateId") + .HasColumnType("char(36)"); + + b.Property("Creator") + .HasColumnType("longtext"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("DefinitionsXml") + .HasColumnType("longtext"); + + b.Property("Describes") + .HasColumnType("longtext"); + + b.Property("ExecutableCode") + .HasColumnType("longtext"); + + b.Property("MountType") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ParentRuleId") + .HasColumnType("char(36)"); + + b.Property("RuleDesc") + .HasColumnType("longtext"); + + b.Property("RuleStatus") + .HasColumnType("int"); + + b.Property("RuleType") + .HasColumnType("int"); + + b.Property("Runner") + .HasColumnType("longtext"); + + b.Property("SubVersion") + .HasColumnType("double"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Version") + .HasColumnType("double"); + + b.HasKey("RuleId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("FlowRules"); + }); + + modelBuilder.Entity("IoTSharp.Data.Produce", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("DefaultDeviceType") + .HasColumnType("int"); + + b.Property("DefaultIdentityType") + .HasColumnType("int"); + + b.Property("DefaultTimeout") + .HasColumnType("int"); + + b.Property("Deleted") + .HasColumnType("tinyint(1)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("GatewayConfiguration") + .HasColumnType("longtext"); + + b.Property("GatewayType") + .HasColumnType("int"); + + b.Property("Icon") + .HasColumnType("longtext"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("Produces"); + }); + + modelBuilder.Entity("IoTSharp.Data.ProduceDictionary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Customer") + .HasColumnType("char(36)"); + + b.Property("DataType") + .HasColumnType("int"); + + b.Property("DefaultValue") + .HasColumnType("longtext"); + + b.Property("Deleted") + .HasColumnType("tinyint(1)"); + + b.Property("Display") + .HasColumnType("tinyint(1)"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("KeyDesc") + .HasColumnType("longtext"); + + b.Property("KeyName") + .HasColumnType("longtext"); + + b.Property("Place0") + .HasColumnType("longtext"); + + b.Property("Place1") + .HasColumnType("longtext"); + + b.Property("Place2") + .HasColumnType("longtext"); + + b.Property("Place3") + .HasColumnType("longtext"); + + b.Property("Place4") + .HasColumnType("longtext"); + + b.Property("Place5") + .HasColumnType("longtext"); + + b.Property("PlaceOrder0") + .HasColumnType("longtext"); + + b.Property("PlaceOrder1") + .HasColumnType("longtext"); + + b.Property("PlaceOrder2") + .HasColumnType("longtext"); + + b.Property("PlaceOrder3") + .HasColumnType("longtext"); + + b.Property("PlaceOrder4") + .HasColumnType("longtext"); + + b.Property("PlaceOrder5") + .HasColumnType("longtext"); + + b.Property("ProduceId") + .HasColumnType("char(36)"); + + b.Property("Tag") + .HasColumnType("longtext"); + + b.Property("Unit") + .HasColumnType("longtext"); + + b.Property("UnitConvert") + .HasColumnType("tinyint(1)"); + + b.Property("UnitExpression") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("ProduceId"); + + b.ToTable("ProduceDictionaries"); + }); + + modelBuilder.Entity("IoTSharp.Data.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AddedDate") + .HasColumnType("datetime(6)"); + + b.Property("ExpiryDate") + .HasColumnType("datetime(6)"); + + b.Property("IsRevorked") + .HasColumnType("tinyint(1)"); + + b.Property("IsUsed") + .HasColumnType("tinyint(1)"); + + b.Property("JwtId") + .HasColumnType("longtext"); + + b.Property("Token") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("IoTSharp.Data.Relationship", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("IdentityUserId") + .HasColumnType("varchar(255)"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("IdentityUserId"); + + b.HasIndex("TenantId"); + + b.ToTable("Relationship"); + }); + + modelBuilder.Entity("IoTSharp.Data.RuleTaskExecutor", b => + { + b.Property("ExecutorId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AddDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("DefaultConfig") + .HasColumnType("longtext"); + + b.Property("ExecutorDesc") + .HasColumnType("longtext"); + + b.Property("ExecutorName") + .HasColumnType("longtext"); + + b.Property("ExecutorStatus") + .HasColumnType("int"); + + b.Property("MataData") + .HasColumnType("longtext"); + + b.Property("Path") + .HasColumnType("longtext"); + + b.Property("Tag") + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("TestStatus") + .HasColumnType("int"); + + b.Property("Tester") + .HasColumnType("char(36)"); + + b.Property("TesterDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TypeName") + .HasColumnType("longtext"); + + b.HasKey("ExecutorId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("RuleTaskExecutors"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionEvent", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Creator") + .HasColumnType("char(36)"); + + b.Property("CustomerId") + .HasColumnType("char(36)"); + + b.Property("EventDesc") + .HasColumnType("longtext"); + + b.Property("EventName") + .HasColumnType("longtext"); + + b.Property("EventNameSpace") + .HasColumnType("longtext"); + + b.Property("EventParam") + .HasColumnType("longtext"); + + b.Property("EventStatus") + .HasColumnType("int"); + + b.Property("EventTag") + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("EventId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("SubscriptionEvents"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionTask", b => + { + b.Property("BindId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EventId") + .HasColumnType("char(36)"); + + b.Property("RuleTaskExecutorExecutorId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubscriptionEventId") + .HasColumnType("char(36)"); + + b.Property("TaskConfig") + .HasColumnType("longtext"); + + b.HasKey("BindId"); + + b.HasIndex("RuleTaskExecutorExecutorId"); + + b.HasIndex("SubscriptionEventId"); + + b.ToTable("SubscriptionTasks"); + }); + + modelBuilder.Entity("IoTSharp.Data.TelemetryData", b => + { + b.Property("DeviceId") + .HasColumnType("char(36)") + .HasColumnOrder(1); + + b.Property("KeyName") + .HasColumnType("varchar(255)") + .HasColumnOrder(2); + + b.Property("DateTime") + .HasColumnType("timestamp") + .HasColumnOrder(3); + + b.Property("DataSide") + .HasColumnType("int") + .HasColumnOrder(4); + + b.Property("Type") + .HasColumnType("int") + .HasColumnOrder(5); + + b.Property("Value_Binary") + .HasColumnType("longblob"); + + b.Property("Value_Boolean") + .HasColumnType("tinyint(1)"); + + b.Property("Value_DateTime") + .HasColumnType("timestamp"); + + b.Property("Value_Double") + .HasColumnType("double"); + + b.Property("Value_Json") + .HasColumnType("JSON"); + + b.Property("Value_Long") + .HasColumnType("bigint"); + + b.Property("Value_String") + .HasColumnType("longtext"); + + b.Property("Value_XML") + .HasColumnType("longtext"); + + b.HasKey("DeviceId", "KeyName", "DateTime"); + + b.HasIndex("DeviceId"); + + b.HasIndex("KeyName"); + + b.HasIndex("DeviceId", "KeyName"); + + b.ToTable("TelemetryData"); + }); + + modelBuilder.Entity("IoTSharp.Data.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Address") + .HasColumnType("longtext"); + + b.Property("City") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("Deleted") + .HasColumnType("tinyint(1)"); + + b.Property("EMail") + .HasColumnType("longtext"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Phone") + .HasColumnType("longtext"); + + b.Property("Province") + .HasColumnType("longtext"); + + b.Property("Street") + .HasColumnType("longtext"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Tenant"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("SecurityStamp") + .HasColumnType("longtext"); + + b.Property("TwoFactorEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("ProviderKey") + .HasColumnType("varchar(255)"); + + b.Property("ProviderDisplayName") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("RoleId") + .HasColumnType("varchar(255)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("IoTSharp.Data.AttributeLatest", b => + { + b.HasBaseType("IoTSharp.Data.DataStorage"); + + b.HasDiscriminator().HasValue(2); + }); + + modelBuilder.Entity("IoTSharp.Data.Gateway", b => + { + b.HasBaseType("IoTSharp.Data.Device"); + + b.HasDiscriminator().HasValue(1); + }); + + modelBuilder.Entity("IoTSharp.Data.ProduceData", b => + { + b.HasBaseType("IoTSharp.Data.DataStorage"); + + b.Property("OwnerId") + .HasColumnType("char(36)"); + + b.HasIndex("OwnerId"); + + b.HasDiscriminator().HasValue(5); + }); + + modelBuilder.Entity("IoTSharp.Data.TelemetryLatest", b => + { + b.HasBaseType("IoTSharp.Data.DataStorage"); + + b.HasDiscriminator().HasValue(4); + }); + + modelBuilder.Entity("IoTSharp.Data.Alarm", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Asset", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.AssetRelation", b => + { + b.HasOne("IoTSharp.Data.Asset", null) + .WithMany("OwnedAssets") + .HasForeignKey("AssetId"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuditLog", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseEvent", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("FlowRule"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany("Customers") + .HasForeignKey("TenantId"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Device", b => + { + b.HasOne("IoTSharp.Data.AuthorizedKey", null) + .WithMany("Devices") + .HasForeignKey("AuthorizedKeyId"); + + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany("Devices") + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Gateway", "Owner") + .WithMany("Children") + .HasForeignKey("OwnerId"); + + b.HasOne("IoTSharp.Data.Produce", null) + .WithMany("Devices") + .HasForeignKey("ProduceId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany("Devices") + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceDiagram", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.DeviceDiagram", "DeviceDiagram") + .WithMany() + .HasForeignKey("DeviceDiagramDiagramId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("DeviceDiagram"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraphToolBox", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b => + { + b.HasOne("IoTSharp.Data.Device", "Device") + .WithOne("DeviceIdentity") + .HasForeignKey("IoTSharp.Data.DeviceIdentity", "DeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b => + { + b.HasOne("IoTSharp.Data.DeviceModel", "DeviceModel") + .WithMany("DeviceModelCommands") + .HasForeignKey("DeviceModelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DeviceModel"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceRule", b => + { + b.HasOne("IoTSharp.Data.Device", "Device") + .WithMany() + .HasForeignKey("DeviceId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.Navigation("Device"); + + b.Navigation("FlowRule"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldInfo", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldValueInfo", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormInfo", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Flow", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor") + .WithMany() + .HasForeignKey("ExecutorId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Executor"); + + b.Navigation("FlowRule"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowOperation", b => + { + b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") + .WithMany() + .HasForeignKey("BaseEventEventId"); + + b.HasOne("IoTSharp.Data.Flow", "Flow") + .WithMany() + .HasForeignKey("FlowId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.Navigation("BaseEvent"); + + b.Navigation("Flow"); + + b.Navigation("FlowRule"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowRule", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Produce", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.ProduceDictionary", b => + { + b.HasOne("IoTSharp.Data.Produce", null) + .WithMany("Dictionaries") + .HasForeignKey("ProduceId"); + }); + + modelBuilder.Entity("IoTSharp.Data.RefreshToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("IoTSharp.Data.Relationship", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "IdentityUser") + .WithMany() + .HasForeignKey("IdentityUserId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("IdentityUser"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.RuleTaskExecutor", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionEvent", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionTask", b => + { + b.HasOne("IoTSharp.Data.RuleTaskExecutor", "RuleTaskExecutor") + .WithMany() + .HasForeignKey("RuleTaskExecutorExecutorId"); + + b.HasOne("IoTSharp.Data.SubscriptionEvent", "Subscription") + .WithMany() + .HasForeignKey("SubscriptionEventId"); + + b.Navigation("RuleTaskExecutor"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IoTSharp.Data.ProduceData", b => + { + b.HasOne("IoTSharp.Data.Produce", "Owner") + .WithMany("DefaultAttributes") + .HasForeignKey("OwnerId"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("IoTSharp.Data.Asset", b => + { + b.Navigation("OwnedAssets"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Device", b => + { + b.Navigation("DeviceIdentity"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModel", b => + { + b.Navigation("DeviceModelCommands"); + }); + + modelBuilder.Entity("IoTSharp.Data.Produce", b => + { + b.Navigation("DefaultAttributes"); + + b.Navigation("Devices"); + + b.Navigation("Dictionaries"); + }); + + modelBuilder.Entity("IoTSharp.Data.Tenant", b => + { + b.Navigation("Customers"); + + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Gateway", b => + { + b.Navigation("Children"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/20221109174343_addflowexfield.cs b/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/20221109174343_addflowexfield.cs new file mode 100644 index 000000000..a6cf4c048 --- /dev/null +++ b/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/20221109174343_addflowexfield.cs @@ -0,0 +1,92 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IoTSharp.Data.MySql.Migrations +{ + public partial class addflowexfield : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "FlowClass", + table: "Flows", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "FlowIcon", + table: "Flows", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "FlowNameSpace", + table: "Flows", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "FlowShapeType", + table: "Flows", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "FlowTag", + table: "Flows", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "Left", + table: "Flows", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "Top", + table: "Flows", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "FlowClass", + table: "Flows"); + + migrationBuilder.DropColumn( + name: "FlowIcon", + table: "Flows"); + + migrationBuilder.DropColumn( + name: "FlowNameSpace", + table: "Flows"); + + migrationBuilder.DropColumn( + name: "FlowShapeType", + table: "Flows"); + + migrationBuilder.DropColumn( + name: "FlowTag", + table: "Flows"); + + migrationBuilder.DropColumn( + name: "Left", + table: "Flows"); + + migrationBuilder.DropColumn( + name: "Top", + table: "Flows"); + } + } +} diff --git a/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs b/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs index 7557f4e24..142c3f83e 100644 --- a/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/IoTSharp.Data.Storage/IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1241,12 +1241,27 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ExecutorId") .HasColumnType("char(36)"); + b.Property("FlowClass") + .HasColumnType("longtext"); + + b.Property("FlowIcon") + .HasColumnType("longtext"); + + b.Property("FlowNameSpace") + .HasColumnType("longtext"); + b.Property("FlowRuleRuleId") .HasColumnType("char(36)"); + b.Property("FlowShapeType") + .HasColumnType("longtext"); + b.Property("FlowStatus") .HasColumnType("int"); + b.Property("FlowTag") + .HasColumnType("longtext"); + b.Property("FlowType") .HasColumnType("longtext"); @@ -1259,6 +1274,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Incoming") .HasColumnType("longtext"); + b.Property("Left") + .HasColumnType("longtext"); + b.Property("NodeProcessClass") .HasColumnType("longtext"); @@ -1301,6 +1319,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TesterDateTime") .HasColumnType("datetime(6)"); + b.Property("Top") + .HasColumnType("longtext"); + b.Property("bpmnid") .HasColumnType("longtext"); diff --git a/IoTSharp.Data/Flow.cs b/IoTSharp.Data/Flow.cs index 973fac8dc..7e9d6a69b 100644 --- a/IoTSharp.Data/Flow.cs +++ b/IoTSharp.Data/Flow.cs @@ -42,5 +42,13 @@ public class Flow:IJustMy public Customer Customer { get; set; } + public string Top { get; set; } + public string Left { get; set; } + + public string FlowClass { get; set; } + public string FlowNameSpace { get; set; } + public string FlowIcon{ get; set; } + public string FlowTag { get; set; } + public string FlowShapeType { get; set; } } } \ No newline at end of file diff --git a/IoTSharp/Controllers/RulesController.cs b/IoTSharp/Controllers/RulesController.cs index 833b61c18..fda38f27d 100644 --- a/IoTSharp/Controllers/RulesController.cs +++ b/IoTSharp/Controllers/RulesController.cs @@ -21,6 +21,10 @@ using System.Linq.Expressions; using System.Threading.Tasks; using ShardingCore.Extensions; +using Esprima.Ast; +using InfluxDB.Client.Api.Domain; +using System.CodeDom.Compiler; +using Humanizer; namespace IoTSharp.Controllers { @@ -145,11 +149,11 @@ public async Task> Delete(Guid id) { try { - _context.FlowOperations.RemoveRange(_context.FlowOperations.Where(c=>c.FlowRule.RuleId==id).ToList()); + _context.FlowOperations.RemoveRange(_context.FlowOperations.Where(c => c.FlowRule.RuleId == id).ToList()); await _context.SaveChangesAsync(); - _context.BaseEvents.RemoveRange(_context.BaseEvents.Where(c=>c.FlowRule.RuleId==id).ToList()); + _context.BaseEvents.RemoveRange(_context.BaseEvents.Where(c => c.FlowRule.RuleId == id).ToList()); await _context.SaveChangesAsync(); - _context.Flows.RemoveRange(_context.Flows.Where(c=>c.FlowRule.RuleId==id).ToList()); + _context.Flows.RemoveRange(_context.Flows.Where(c => c.FlowRule.RuleId == id).ToList()); await _context.SaveChangesAsync(); _context.DeviceRules.RemoveRange(_context.DeviceRules.Where(c => c.FlowRule.RuleId == id).ToList()); await _context.SaveChangesAsync(); @@ -328,7 +332,7 @@ public async Task>> GetRuleDevices([FromQuery var profile = this.GetUserProfile(); - Expression> condition = x => x.Device.Customer.Id == profile.Customer && !x.Device.Deleted && x.Device.Tenant.Id == profile.Tenant&&x.FlowRule.RuleId==m.ruleId; + Expression> condition = x => x.Device.Customer.Id == profile.Customer && !x.Device.Deleted && x.Device.Tenant.Id == profile.Tenant && x.FlowRule.RuleId == m.ruleId; if (!string.IsNullOrEmpty(m.Name)) { if (System.Text.RegularExpressions.Regex.IsMatch(m.Name, @"(?im)^[{(]?[0-9A-F]{8}[-]?(?:[0-9A-F]{4}[-]?){3}[0-9A-F]{12}[)}]?$")) @@ -343,13 +347,17 @@ public async Task>> GetRuleDevices([FromQuery } - var rows =await _context.DeviceRules.Include(c => c.FlowRule).Include(c => c.Device).Where(condition) + var rows = await _context.DeviceRules.Include(c => c.FlowRule).Include(c => c.Device).Where(condition) .Select(c => new DeviceRuleDto() { - Id = c.Device.Id, DeviceType = c.Device.DeviceType, EnableTrace = c.EnableTrace, Name = c.Device.Name, Timeout = c.Device.Timeout + Id = c.Device.Id, + DeviceType = c.Device.DeviceType, + EnableTrace = c.EnableTrace, + Name = c.Device.Name, + Timeout = c.Device.Timeout }).Skip(m.offset * m.limit).Take(m.limit).ToListAsync(); - var total =await _context.DeviceRules.Include(c => c.FlowRule).Include(c => c.Device).Where(condition).Select(c=>c.Device).AsSplitQuery().CountAsync(); - return new ApiResult>(ApiCode.Success, "Ok", new PagedData { rows=rows,total= total }); + var total = await _context.DeviceRules.Include(c => c.FlowRule).Include(c => c.Device).Where(condition).Select(c => c.Device).AsSplitQuery().CountAsync(); + return new ApiResult>(ApiCode.Success, "Ok", new PagedData { rows = rows, total = total }); } [HttpGet] @@ -481,7 +489,8 @@ public ApiResult SaveDiagram(ModelWorkFlow m) Createor = profile.Id, CreateDate = CreateDate, Customer = rule.Customer, - Tenant = rule.Tenant, Flowdesc = JsonConvert.SerializeObject(c.BizObject.profile??new object()) + Tenant = rule.Tenant, + Flowdesc = JsonConvert.SerializeObject(c.BizObject.profile ?? new object()) }); _context.Flows.AddRange(fw); @@ -648,6 +657,232 @@ public ApiResult SaveDiagram(ModelWorkFlow m) return new ApiResult(ApiCode.Success, "Ok", true); } + + [HttpPost] + + public ApiResult SaveDiagramV(ModelDiagram m) + { + var profile = this.GetUserProfile(); + var CreatorId = Guid.NewGuid(); + var CreateDate = DateTime.Now; + var rule = _context.FlowRules.Include(c => c.Customer).Include(c => c.Tenant).AsSplitQuery().FirstOrDefault(c => c.RuleId == m.RuleId); + rule.Creator = profile.Id.ToString(); + rule.CreateId = CreatorId; + _context.Flows.Where(c => c.FlowRule.RuleId == rule.RuleId).ToList().ForEach(c => + { + c.FlowStatus = -1; + }); + _context.FlowRules.Update(rule); + _context.SaveChanges(); + foreach (var item in m.nodes) + { + switch (item.nodetype) + { + + case "basic": + { + + var node = new Flow + { + FlowRule = rule, + Flowname = item.name, + bpmnid = item.nodeId, + FlowType = item.nodetype, + FlowStatus = 1, + CreateId = CreatorId, + Createor = profile.Id, + CreateDate = CreateDate, + Customer = rule.Customer, + Tenant = rule.Tenant, + + FlowClass = item.@class, + FlowNameSpace = item.@namespace, + FlowIcon = item.icon, + Top = item.top, + Left = item.left + }; + _context.Flows.AddRange(node); + _context.SaveChanges(); + } + break; + case "executor": + { + var node = new Flow + { + FlowRule = rule, + Flowname = item.name, + bpmnid = item.nodeId, + FlowType = item.nodetype, + NodeProcessParams = item.content, + + NodeProcessClass = item.mata, + FlowStatus = 1, + CreateId = CreatorId, + Createor = profile.Id, + CreateDate = CreateDate, + Customer = rule.Customer, + Tenant = rule.Tenant, + + FlowClass = item.@class, + FlowNameSpace = item.@namespace, + FlowIcon = item.icon, + Top=item.top, + Left = item.left + }; + _context.Flows.AddRange(node); + _context.SaveChanges(); + } + break; + case "script": + { + var node = new Flow + { + FlowRule = rule, + Flowname = item.name, + bpmnid = item.nodeId, + FlowType = item.nodetype, + NodeProcessScript = item.content, + NodeProcessScriptType = item.mata, + FlowStatus = 1, + CreateId = CreatorId, + Createor = profile.Id, + CreateDate = CreateDate, + Customer = rule.Customer, + Tenant = rule.Tenant, + + FlowClass = item.@class, + FlowNameSpace = item.@namespace, + FlowIcon = item.icon, + Top = item.top, + Left = item.left + }; + _context.Flows.AddRange(node); + _context.SaveChanges(); + } + break; + + } + + } + + + foreach (var item in m.lines) + { + + var node = new Flow + { + FlowRule = rule, + Flowname = item.linename, + bpmnid = item.lineId, + FlowType = "line", + TargetId = item.targetId, + SourceId = item.sourceId, + Conditionexpression = item.condition, + FlowStatus = 1, + CreateId = CreatorId, + Createor = profile.Id, + CreateDate = CreateDate, + Customer = rule.Customer, + Tenant = rule.Tenant + }; + _context.Flows.AddRange(node); + _context.SaveChanges(); + + } + + + + return new ApiResult(ApiCode.Success, "Ok", true); + } + + [HttpGet] + public async Task> GetDiagramV(Guid id) + { + var profile = this.GetUserProfile(); + var ruleflow = await _context.FlowRules.FirstOrDefaultAsync(c => c.RuleId == id && c.Tenant.Id == profile.Tenant); + var flows = _context.Flows.Where(c => c.FlowRule.RuleId == id && c.FlowStatus > 0 && c.Tenant.Id == profile.Tenant).ToList(); + ModelDiagram m = new ModelDiagram(); + m.lines = new List(); + m.nodes = new List(); + foreach (var item in flows) + { + switch (item.FlowType) + { + case "line": + { + m.lines.Add(new LineObject() + { + sourceId = item.SourceId, + linename = item.Flowname, + targetId = item.TargetId, + condition = item.Conditionexpression, + lineId = item.bpmnid + }); + } + break; + case "basic": + { + m.nodes.Add(new NodeObject() + { + + nodeId = item.bpmnid, + nodetype = item.FlowType, + name = item.Flowname, + @class = item.FlowClass, + @namespace = item.FlowNameSpace, + icon = item.FlowIcon, + top = item.Top, + left = item.Left + }); + } + break; + case "script": + { + m.nodes.Add(new NodeObject() + { + + nodeId = item.bpmnid, + nodetype = item.FlowType, + name = item.Flowname, + content = item.NodeProcessScript, + mata = item.NodeProcessScriptType, + @class = item.FlowClass, + @namespace = item.FlowNameSpace, + icon = item.FlowIcon, + top = item.Top, + left = item.Left + }); + } + break; + case "executor": + { + m.nodes.Add(new NodeObject() + { + + nodeId = item.bpmnid, + nodetype = item.FlowType, + name = item.Flowname, + content = item.NodeProcessParams, + mata = item.NodeProcessClass, + @class = item.FlowClass, + @namespace = item.FlowNameSpace, + icon = item.FlowIcon, + top = item.Top, + left = item.Left + + }); + } + break; + + + + } + } + + return new ApiResult(ApiCode.Success, "Ok", m); + } + + [HttpGet] public async Task> GetDiagram(Guid id) { @@ -1130,7 +1365,7 @@ public async Task> GetDiagram(Guid id) break; } } - return new ApiResult(ApiCode.Success, "rule has been removed", activity); + return new ApiResult(ApiCode.Success, "Ok", activity); } [HttpPost] @@ -1149,7 +1384,7 @@ public async Task> Active([FromBody] JObject form) var testabizId = Guid.NewGuid().ToString(); //根据业务保存起来,用来查询执行事件和步骤 var result = await _flowRuleProcessor.RunFlowRules(ruleid, d, Guid.Empty, FlowRuleRunType.TestPurpose, testabizId); - _context.SaveFlowResult(Guid.Empty, ruleid,result); + _context.SaveFlowResult(Guid.Empty, ruleid, result); return new ApiResult(ApiCode.Success, "test complete", result.OrderBy(c => c.Step). Where(c => c.BaseEvent.Bizid == testabizId).ToList() .GroupBy(c => c.Step).Select(c => new @@ -1233,8 +1468,8 @@ private async Task GetCreatorName(BaseEventDto dto) public ApiResult GetFlowOperations(Guid eventId) { var profile = this.GetUserProfile(); - var _event = _context.BaseEvents.Include(c=>c.FlowRule).AsSplitQuery().SingleOrDefault(c => c.EventId == eventId); - var _operations = _context.FlowOperations.Include(c=>c.Flow).Where(c => c.BaseEvent == _event).AsSplitQuery().ToList(); + var _event = _context.BaseEvents.Include(c => c.FlowRule).AsSplitQuery().SingleOrDefault(c => c.EventId == eventId); + var _operations = _context.FlowOperations.Include(c => c.Flow).Where(c => c.BaseEvent == _event).AsSplitQuery().ToList(); @@ -1248,8 +1483,8 @@ public ApiResult GetFlowOperations(Guid eventId) var source = _operations.FirstOrDefault(c => c.Flow.bpmnid == item.SourceId); if (target != null && source != null) { - - links.Add(new {source= source.Flow.Flowname?? source.bpmnid, target=target.Flow.Flowname ?? target.bpmnid, value= (target.AddDate - source.AddDate).Value.TotalMilliseconds }); + + links.Add(new { source = source.Flow.Flowname ?? source.bpmnid, target = target.Flow.Flowname ?? target.bpmnid, value = (target.AddDate - source.AddDate).Value.TotalMilliseconds }); var _sourcename = source.Flow.Flowname ?? source.bpmnid; var _targetname = target.Flow.Flowname ?? target.bpmnid; if (nodes.All(c => c != _sourcename)) @@ -1272,9 +1507,9 @@ public ApiResult GetFlowOperations(Guid eventId) return new ApiResult(ApiCode.Success, "OK", new { steps, - charts=new + charts = new { - sankey=new { links, nodes= nodes.Select(c=>new { name=c}).ToList() } + sankey = new { links, nodes = nodes.Select(c => new { name = c }).ToList() } } }); } diff --git a/IoTSharp/IoTSharp.xml b/IoTSharp/IoTSharp.xml index 29f7f8958..c0face09f 100644 --- a/IoTSharp/IoTSharp.xml +++ b/IoTSharp/IoTSharp.xml @@ -1108,6 +1108,21 @@ 业务Id(第三方唯一Id,用于取回事件以及记录的标识) 返回所有节点的记录信息,需要保存则保存 + + + 节点分组类型 (脚本,执行器) + + + + + 节点内容(脚本时为脚本内容,执行器时为配置) + + + + + + + 一个强类型的资源类,用于查找本地化的字符串等。 diff --git a/IoTSharp/Models/Rule/ModelWorkFlow.cs b/IoTSharp/Models/Rule/ModelWorkFlow.cs index 080c86481..6cb498ea7 100644 --- a/IoTSharp/Models/Rule/ModelWorkFlow.cs +++ b/IoTSharp/Models/Rule/ModelWorkFlow.cs @@ -1,4 +1,7 @@ -namespace IoTSharp.Models.Rule +using System; +using System.Collections.Generic; + +namespace IoTSharp.Models.Rule { public class ModelWorkFlow { @@ -6,4 +9,54 @@ public class ModelWorkFlow public string Biz { get; set; } } + + + + public class ModelDiagram + { + public List nodes { get; set; } + + public List lines { get; set; } + + public Guid RuleId { get; set; } + } + + + + public class LineObject + { + public string sourceId { get; set; } + public string targetId { get; set; } + public string linename { get; set; } + public string condition { get; set; } + public string lineId { get; set; } + } + + + + public class NodeObject + { + public string nodeId { get; set; } + /// + /// 节点分组类型 (脚本,执行器) + /// + + public string nodetype { get; set; } + /// + /// 节点内容(脚本时为脚本内容,执行器时为配置) + /// + public string content { get; set; } + /// + /// + /// + public string mata { get; set; } + + public string name { get; set; } + public string @namespace { get; set; } + public string top { get; set; } + public string left { get; set; } + + public string icon { get; set; } + public string @class { get; set; } + } } \ No newline at end of file From c9237c8433793b15917d88044662c68492a23645 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 10 Nov 2022 11:46:57 +0000 Subject: [PATCH 2/2] updating submodules --- IoTSharp/ClientAppVue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IoTSharp/ClientAppVue b/IoTSharp/ClientAppVue index 0e11045c6..0c556282d 160000 --- a/IoTSharp/ClientAppVue +++ b/IoTSharp/ClientAppVue @@ -1 +1 @@ -Subproject commit 0e11045c631d577044b3c1341633ba3b7235f841 +Subproject commit 0c556282d06ca8df6583fc9b5e284bc1e8a73ec5