diff --git a/IoTSharp.Data.PostgreSQL/Migrations/20211217110202_modyfyflowoperation.Designer.cs b/IoTSharp.Data.PostgreSQL/Migrations/20211217110202_modyfyflowoperation.Designer.cs new file mode 100644 index 0000000000000000000000000000000000000000..90edf3dafed80d473ad27d1006fa8718010526b5 --- /dev/null +++ b/IoTSharp.Data.PostgreSQL/Migrations/20211217110202_modyfyflowoperation.Designer.cs @@ -0,0 +1,1871 @@ +// +using System; +using IoTSharp.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace IoTSharp.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20211217110202_modyfyflowoperation")] + partial class modyfyflowoperation + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 63) + .HasAnnotation("ProductVersion", "5.0.12") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + modelBuilder.Entity("IoTSharp.Data.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ActionData") + .HasColumnType("jsonb"); + + b.Property("ActionName") + .HasColumnType("text"); + + b.Property("ActionResult") + .HasColumnType("jsonb"); + + b.Property("ActiveDateTime") + .HasColumnType("timestamp without time zone"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("ObjectID") + .HasColumnType("uuid"); + + b.Property("ObjectName") + .HasColumnType("text"); + + b.Property("ObjectType") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("text"); + + b.Property("UserName") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuditLog"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AuthToken") + .HasColumnType("text"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuthorizedKeys"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseDictionary", b => + { + b.Property("DictionaryId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Dictionary18NKeyName") + .HasColumnType("text"); + + b.Property("DictionaryColor") + .HasColumnType("text"); + + b.Property("DictionaryDesc") + .HasColumnType("text"); + + b.Property("DictionaryGroupId") + .HasColumnType("bigint"); + + b.Property("DictionaryIcon") + .HasColumnType("text"); + + b.Property("DictionaryName") + .HasColumnType("text"); + + b.Property("DictionaryPattern") + .HasColumnType("text"); + + b.Property("DictionaryStatus") + .HasColumnType("integer"); + + b.Property("DictionaryTag") + .HasColumnType("text"); + + b.Property("DictionaryValue") + .HasColumnType("text"); + + b.Property("DictionaryValueType") + .HasColumnType("integer"); + + b.Property("DictionaryValueTypeName") + .HasColumnType("text"); + + b.HasKey("DictionaryId"); + + b.ToTable("BaseDictionaries"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseDictionaryGroup", b => + { + b.Property("DictionaryGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("DictionaryGroup18NKeyName") + .HasColumnType("text"); + + b.Property("DictionaryGroupDesc") + .HasColumnType("text"); + + b.Property("DictionaryGroupKey") + .HasColumnType("text"); + + b.Property("DictionaryGroupName") + .HasColumnType("text"); + + b.Property("DictionaryGroupStatus") + .HasColumnType("integer"); + + b.Property("DictionaryGroupValueType") + .HasColumnType("integer"); + + b.Property("DictionaryGroupValueTypeName") + .HasColumnType("text"); + + b.HasKey("DictionaryGroupId"); + + b.ToTable("BaseDictionaryGroups"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseEvent", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BizData") + .HasColumnType("text"); + + b.Property("Bizid") + .HasColumnType("text"); + + b.Property("CreaterDateTime") + .HasColumnType("timestamp without time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("EventDesc") + .HasColumnType("text"); + + b.Property("EventName") + .HasColumnType("text"); + + b.Property("EventStaus") + .HasColumnType("integer"); + + b.Property("FlowRuleRuleId") + .HasColumnType("uuid"); + + b.Property("MataData") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("EventId"); + + b.HasIndex("FlowRuleRuleId"); + + b.ToTable("BaseEvents"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseI18N", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("AddDate") + .HasColumnType("timestamp without time zone"); + + b.Property("KeyName") + .HasColumnType("text"); + + b.Property("ResouceDesc") + .HasColumnType("text"); + + b.Property("ResouceGroupId") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("bigint"); + + b.Property("ResourceKey") + .HasColumnType("text"); + + b.Property("ResourceTag") + .HasColumnType("text"); + + b.Property("ResourceType") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("ValueBG") + .HasColumnType("text"); + + b.Property("ValueCS") + .HasColumnType("text"); + + b.Property("ValueDA") + .HasColumnType("text"); + + b.Property("ValueDEDE") + .HasColumnType("text"); + + b.Property("ValueELGR") + .HasColumnType("text"); + + b.Property("ValueENGR") + .HasColumnType("text"); + + b.Property("ValueENUS") + .HasColumnType("text"); + + b.Property("ValueESES") + .HasColumnType("text"); + + b.Property("ValueFI") + .HasColumnType("text"); + + b.Property("ValueFRFR") + .HasColumnType("text"); + + b.Property("ValueHE") + .HasColumnType("text"); + + b.Property("ValueHRHR") + .HasColumnType("text"); + + b.Property("ValueHU") + .HasColumnType("text"); + + b.Property("ValueITIT") + .HasColumnType("text"); + + b.Property("ValueJAJP") + .HasColumnType("text"); + + b.Property("ValueKOKR") + .HasColumnType("text"); + + b.Property("ValueNL") + .HasColumnType("text"); + + b.Property("ValuePLPL") + .HasColumnType("text"); + + b.Property("ValuePT") + .HasColumnType("text"); + + b.Property("ValueSLSL") + .HasColumnType("text"); + + b.Property("ValueSR") + .HasColumnType("text"); + + b.Property("ValueSV") + .HasColumnType("text"); + + b.Property("ValueTRTR") + .HasColumnType("text"); + + b.Property("ValueUK") + .HasColumnType("text"); + + b.Property("ValueVI") + .HasColumnType("text"); + + b.Property("ValueZHCN") + .HasColumnType("text"); + + b.Property("ValueZHTW") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BaseI18Ns"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("Country") + .HasColumnType("text"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("Province") + .HasColumnType("text"); + + b.Property("Street") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("ZipCode") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("Customer"); + }); + + modelBuilder.Entity("IoTSharp.Data.DataStorage", b => + { + b.Property("Catalog") + .HasColumnType("integer"); + + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("KeyName") + .HasColumnType("text"); + + b.Property("DataSide") + .HasColumnType("integer"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("Value_Binary") + .HasColumnType("bytea"); + + b.Property("Value_Boolean") + .HasColumnType("boolean"); + + b.Property("Value_DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Value_Double") + .HasColumnType("double precision"); + + b.Property("Value_Json") + .HasColumnType("jsonb"); + + b.Property("Value_Long") + .HasColumnType("bigint"); + + b.Property("Value_String") + .HasColumnType("text"); + + b.Property("Value_XML") + .HasColumnType("xml"); + + 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("uuid"); + + b.Property("AuthorizedKeyId") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DeviceType") + .HasColumnType("integer"); + + b.Property("LastActive") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Online") + .HasColumnType("boolean"); + + b.Property("OwnerId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Timeout") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizedKeyId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("TenantId"); + + b.ToTable("Device"); + + b.HasDiscriminator("DeviceType").HasValue(0); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceDiagram", b => + { + b.Property("DiagramId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("DiagramDesc") + .HasColumnType("text"); + + b.Property("DiagramImage") + .HasColumnType("text"); + + b.Property("DiagramName") + .HasColumnType("text"); + + b.Property("DiagramStatus") + .HasColumnType("integer"); + + b.Property("IsDefault") + .HasColumnType("boolean"); + + b.HasKey("DiagramId"); + + b.ToTable("DeviceDiagrams"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b => + { + b.Property("GraphId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("DeviceDiagramDiagramId") + .HasColumnType("uuid"); + + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("GraphElementId") + .HasColumnType("text"); + + b.Property("GraphFill") + .HasColumnType("text"); + + b.Property("GraphHeight") + .HasColumnType("numeric"); + + b.Property("GraphPostionX") + .HasColumnType("numeric"); + + b.Property("GraphPostionY") + .HasColumnType("numeric"); + + b.Property("GraphShape") + .HasColumnType("text"); + + b.Property("GraphStroke") + .HasColumnType("text"); + + b.Property("GraphStrokeWidth") + .HasColumnType("numeric"); + + b.Property("GraphTextAnchor") + .HasColumnType("text"); + + b.Property("GraphTextFill") + .HasColumnType("text"); + + b.Property("GraphTextFontFamily") + .HasColumnType("text"); + + b.Property("GraphTextFontSize") + .HasColumnType("numeric"); + + b.Property("GraphTextRefX") + .HasColumnType("numeric"); + + b.Property("GraphTextRefY") + .HasColumnType("numeric"); + + b.Property("GraphTextVerticalAnchor") + .HasColumnType("text"); + + b.Property("GraphWidth") + .HasColumnType("numeric"); + + b.HasKey("GraphId"); + + b.HasIndex("DeviceDiagramDiagramId"); + + b.ToTable("DeviceGraphs"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraphToolBox", b => + { + b.Property("ToolBoxId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CommondParam") + .HasColumnType("text"); + + b.Property("CommondType") + .HasColumnType("text"); + + b.Property("CreateDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("DeviceId") + .HasColumnType("bigint"); + + b.Property("ToolBoxIcon") + .HasColumnType("text"); + + b.Property("ToolBoxName") + .HasColumnType("text"); + + b.Property("ToolBoxOffsetLeftPer") + .HasColumnType("numeric"); + + b.Property("ToolBoxOffsetTopPer") + .HasColumnType("numeric"); + + b.Property("ToolBoxOffsetX") + .HasColumnType("numeric"); + + b.Property("ToolBoxOffsetY") + .HasColumnType("numeric"); + + b.Property("ToolBoxRequestUri") + .HasColumnType("text"); + + b.Property("ToolBoxStatus") + .HasColumnType("integer"); + + b.Property("ToolBoxType") + .HasColumnType("text"); + + b.HasKey("ToolBoxId"); + + b.ToTable("DeviceGraphToolBoxes"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("IdentityId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IdentityType") + .HasColumnType("integer"); + + b.Property("IdentityValue") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("DeviceId"); + + b.ToTable("DeviceIdentities"); + }); + + modelBuilder.Entity("IoTSharp.Data.DevicePort", b => + { + b.Property("PortId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Creator") + .HasColumnType("bigint"); + + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("PortDesc") + .HasColumnType("text"); + + b.Property("PortElementId") + .HasColumnType("text"); + + b.Property("PortName") + .HasColumnType("text"); + + b.Property("PortPhyType") + .HasColumnType("integer"); + + b.Property("PortPic") + .HasColumnType("text"); + + b.Property("PortStatus") + .HasColumnType("integer"); + + b.Property("PortType") + .HasColumnType("integer"); + + b.HasKey("PortId"); + + b.ToTable("DevicePorts"); + }); + + modelBuilder.Entity("IoTSharp.Data.DevicePortMapping", b => + { + b.Property("MappingId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("MappingIndex") + .HasColumnType("numeric"); + + b.Property("MappingStatus") + .HasColumnType("integer"); + + b.Property("SourceDeviceId") + .HasColumnType("uuid"); + + b.Property("SourceElementId") + .HasColumnType("text"); + + b.Property("SourceId") + .HasColumnType("text"); + + b.Property("TargeId") + .HasColumnType("text"); + + b.Property("TargetDeviceId") + .HasColumnType("uuid"); + + b.Property("TargetElementId") + .HasColumnType("text"); + + b.HasKey("MappingId"); + + b.ToTable("DevicePortMappings"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceRule", b => + { + b.Property("DeviceRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConfigDateTime") + .HasColumnType("timestamp without time zone"); + + b.Property("ConfigUser") + .HasColumnType("uuid"); + + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("EnableTrace") + .HasColumnType("integer"); + + b.Property("FlowRuleRuleId") + .HasColumnType("uuid"); + + b.HasKey("DeviceRuleId"); + + b.HasIndex("DeviceId"); + + b.HasIndex("FlowRuleRuleId"); + + b.ToTable("DeviceRules"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldInfo", b => + { + b.Property("FieldId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("FieldCode") + .HasColumnType("text"); + + b.Property("FieldCreateDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FieldEditDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FieldI18nKey") + .HasColumnType("text"); + + b.Property("FieldMaxLength") + .HasColumnType("integer"); + + b.Property("FieldName") + .HasColumnType("text"); + + b.Property("FieldPattern") + .HasColumnType("text"); + + b.Property("FieldPocoTypeName") + .HasColumnType("text"); + + b.Property("FieldStatus") + .HasColumnType("integer"); + + b.Property("FieldUIElement") + .HasColumnType("bigint"); + + b.Property("FieldUIElementSchema") + .HasColumnType("text"); + + b.Property("FieldUnit") + .HasColumnType("text"); + + b.Property("FieldValue") + .HasColumnType("text"); + + b.Property("FieldValueDataSource") + .HasColumnType("text"); + + b.Property("FieldValueLocalDataSource") + .HasColumnType("text"); + + b.Property("FieldValueType") + .HasColumnType("integer"); + + b.Property("FieldValueTypeName") + .HasColumnType("text"); + + b.Property("FormId") + .HasColumnType("bigint"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsRequired") + .HasColumnType("boolean"); + + b.HasKey("FieldId"); + + b.ToTable("DynamicFormFieldInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldValueInfo", b => + { + b.Property("FieldValueId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("BizId") + .HasColumnType("bigint"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("FieldCode") + .HasColumnType("text"); + + b.Property("FieldCreateDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FieldId") + .HasColumnType("bigint"); + + b.Property("FieldName") + .HasColumnType("text"); + + b.Property("FieldUnit") + .HasColumnType("text"); + + b.Property("FieldValue") + .HasColumnType("text"); + + b.Property("FieldValueType") + .HasColumnType("bigint"); + + b.Property("FromId") + .HasColumnType("bigint"); + + b.HasKey("FieldValueId"); + + b.ToTable("DynamicFormFieldValueInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormInfo", b => + { + b.Property("FormId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("BizId") + .HasColumnType("bigint"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("FormCreator") + .HasColumnType("bigint"); + + b.Property("FormDesc") + .HasColumnType("text"); + + b.Property("FormLayout") + .HasColumnType("text"); + + b.Property("FormName") + .HasColumnType("text"); + + b.Property("FormSchame") + .HasColumnType("text"); + + b.Property("FormStatus") + .HasColumnType("integer"); + + b.Property("FromCreateDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsCompact") + .HasColumnType("boolean"); + + b.Property("ModelClass") + .HasColumnType("text"); + + b.Property("Url") + .HasColumnType("text"); + + b.HasKey("FormId"); + + b.ToTable("DynamicFormInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.Flow", b => + { + b.Property("FlowId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Conditionexpression") + .HasColumnType("text"); + + b.Property("CreateDate") + .HasColumnType("timestamp without time zone"); + + b.Property("CreateId") + .HasColumnType("uuid"); + + b.Property("Createor") + .HasColumnType("uuid"); + + b.Property("ExecutorId") + .HasColumnType("uuid"); + + b.Property("FlowRuleRuleId") + .HasColumnType("uuid"); + + b.Property("FlowStatus") + .HasColumnType("integer"); + + b.Property("FlowType") + .HasColumnType("text"); + + b.Property("Flowdesc") + .HasColumnType("text"); + + b.Property("Flowname") + .HasColumnType("text"); + + b.Property("Incoming") + .HasColumnType("text"); + + b.Property("NodeProcessClass") + .HasColumnType("text"); + + b.Property("NodeProcessMethod") + .HasColumnType("text"); + + b.Property("NodeProcessParams") + .HasColumnType("text"); + + b.Property("NodeProcessScript") + .HasColumnType("text"); + + b.Property("NodeProcessScriptType") + .HasColumnType("text"); + + b.Property("NodeProcessType") + .HasColumnType("text"); + + b.Property("ObjectId") + .HasColumnType("text"); + + b.Property("Outgoing") + .HasColumnType("text"); + + b.Property("SourceId") + .HasColumnType("text"); + + b.Property("TargetId") + .HasColumnType("text"); + + b.Property("TestStatus") + .HasColumnType("integer"); + + b.Property("Tester") + .HasColumnType("uuid"); + + b.Property("TesterDateTime") + .HasColumnType("timestamp without time zone"); + + b.Property("bpmnid") + .HasColumnType("text"); + + b.HasKey("FlowId"); + + b.HasIndex("ExecutorId"); + + b.HasIndex("FlowRuleRuleId"); + + b.ToTable("Flows"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowOperation", b => + { + b.Property("OperationId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddDate") + .HasColumnType("timestamp without time zone"); + + b.Property("BaseEventId") + .HasColumnType("uuid"); + + b.Property("BizId") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("FlowId") + .HasColumnType("uuid"); + + b.Property("FlowRuleId") + .HasColumnType("uuid"); + + b.Property("NodeStatus") + .HasColumnType("integer"); + + b.Property("OperationDesc") + .HasColumnType("text"); + + b.Property("Step") + .HasColumnType("integer"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("bpmnid") + .HasColumnType("text"); + + b.HasKey("OperationId"); + + b.HasIndex("BaseEventId"); + + b.HasIndex("FlowId"); + + b.HasIndex("FlowRuleId"); + + b.ToTable("FlowOperations"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowRule", b => + { + b.Property("RuleId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatTime") + .HasColumnType("timestamp without time zone"); + + b.Property("CreateId") + .HasColumnType("uuid"); + + b.Property("Creator") + .HasColumnType("text"); + + b.Property("DefinitionsXml") + .HasColumnType("text"); + + b.Property("Describes") + .HasColumnType("text"); + + b.Property("ExecutableCode") + .HasColumnType("text"); + + b.Property("MountType") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentRuleId") + .HasColumnType("uuid"); + + b.Property("RuleDesc") + .HasColumnType("text"); + + b.Property("RuleStatus") + .HasColumnType("integer"); + + b.Property("RuleType") + .HasColumnType("integer"); + + b.Property("Runner") + .HasColumnType("text"); + + b.Property("SubVersion") + .HasColumnType("double precision"); + + b.HasKey("RuleId"); + + b.ToTable("FlowRules"); + }); + + modelBuilder.Entity("IoTSharp.Data.Relationship", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("IdentityUserId") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + 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("uuid"); + + b.Property("AddDateTime") + .HasColumnType("timestamp without time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("DefaultConfig") + .HasColumnType("text"); + + b.Property("ExecutorDesc") + .HasColumnType("text"); + + b.Property("ExecutorName") + .HasColumnType("text"); + + b.Property("ExecutorStatus") + .HasColumnType("integer"); + + b.Property("MataData") + .HasColumnType("text"); + + b.Property("Path") + .HasColumnType("text"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TestStatus") + .HasColumnType("integer"); + + b.Property("Tester") + .HasColumnType("uuid"); + + b.Property("TesterDateTime") + .HasColumnType("timestamp without time zone"); + + b.Property("TypeName") + .HasColumnType("text"); + + b.HasKey("ExecutorId"); + + b.ToTable("RuleTaskExecutors"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionEvent", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDateTime") + .HasColumnType("timestamp without time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("EventDesc") + .HasColumnType("text"); + + b.Property("EventName") + .HasColumnType("text"); + + b.Property("EventNameSpace") + .HasColumnType("text"); + + b.Property("EventParam") + .HasColumnType("text"); + + b.Property("EventStatus") + .HasColumnType("integer"); + + b.Property("EventTag") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("EventId"); + + b.ToTable("SubscriptionEvents"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionTask", b => + { + b.Property("BindId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("EventId") + .HasColumnType("uuid"); + + b.Property("RuleTaskExecutorExecutorId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SubscriptionEventId") + .HasColumnType("uuid"); + + b.Property("TaskConfig") + .HasColumnType("text"); + + b.HasKey("BindId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("RuleTaskExecutorExecutorId"); + + b.HasIndex("SubscriptionEventId"); + + b.ToTable("SubscriptionTasks"); + }); + + modelBuilder.Entity("IoTSharp.Data.TelemetryData", b => + { + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("KeyName") + .HasColumnType("text"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("DataSide") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("Value_Binary") + .HasColumnType("bytea"); + + b.Property("Value_Boolean") + .HasColumnType("boolean"); + + b.Property("Value_DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Value_Double") + .HasColumnType("double precision"); + + b.Property("Value_Json") + .HasColumnType("jsonb"); + + b.Property("Value_Long") + .HasColumnType("bigint"); + + b.Property("Value_String") + .HasColumnType("text"); + + b.Property("Value_XML") + .HasColumnType("xml"); + + 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("uuid"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("Country") + .HasColumnType("text"); + + b.Property("EMail") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("Province") + .HasColumnType("text"); + + b.Property("Street") + .HasColumnType("text"); + + b.Property("ZipCode") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Tenant"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("IoTSharp.Data.AttributeLatest", b => + { + b.HasBaseType("IoTSharp.Data.DataStorage"); + + b.HasDiscriminator().HasValue(2); + }); + + modelBuilder.Entity("IoTSharp.Data.TelemetryLatest", b => + { + b.HasBaseType("IoTSharp.Data.DataStorage"); + + b.HasDiscriminator().HasValue(4); + }); + + modelBuilder.Entity("IoTSharp.Data.Gateway", b => + { + b.HasBaseType("IoTSharp.Data.Device"); + + b.HasDiscriminator().HasValue(1); + }); + + 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.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.Navigation("FlowRule"); + }); + + 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.Tenant", "Tenant") + .WithMany("Devices") + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b => + { + b.HasOne("IoTSharp.Data.DeviceDiagram", "DeviceDiagram") + .WithMany() + .HasForeignKey("DeviceDiagramDiagramId"); + + b.Navigation("DeviceDiagram"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b => + { + b.HasOne("IoTSharp.Data.Device", "Device") + .WithMany() + .HasForeignKey("DeviceId"); + + b.Navigation("Device"); + }); + + 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.Flow", b => + { + b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor") + .WithMany() + .HasForeignKey("ExecutorId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.Navigation("Executor"); + + b.Navigation("FlowRule"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowOperation", b => + { + b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") + .WithMany() + .HasForeignKey("BaseEventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IoTSharp.Data.Flow", "Flow") + .WithMany() + .HasForeignKey("FlowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BaseEvent"); + + b.Navigation("Flow"); + + b.Navigation("FlowRule"); + }); + + 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.SubscriptionTask", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IoTSharp.Data.RuleTaskExecutor", "RuleTaskExecutor") + .WithMany() + .HasForeignKey("RuleTaskExecutorExecutorId"); + + b.HasOne("IoTSharp.Data.SubscriptionEvent", "Subscription") + .WithMany() + .HasForeignKey("SubscriptionEventId"); + + b.Navigation("Customer"); + + 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.AuthorizedKey", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.Navigation("Devices"); + }); + + 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.PostgreSQL/Migrations/20211217110202_modyfyflowoperation.cs b/IoTSharp.Data.PostgreSQL/Migrations/20211217110202_modyfyflowoperation.cs new file mode 100644 index 0000000000000000000000000000000000000000..499fd7486ff0809e75a963b87e07715231c0cb79 --- /dev/null +++ b/IoTSharp.Data.PostgreSQL/Migrations/20211217110202_modyfyflowoperation.cs @@ -0,0 +1,182 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace IoTSharp.Migrations +{ + public partial class modyfyflowoperation : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.AlterColumn( + name: "FlowId", + table: "FlowOperations", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "BaseEventId", + table: "FlowOperations", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FlowRuleId", + table: "FlowOperations", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_BaseEventId", + table: "FlowOperations", + column: "BaseEventId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_FlowRuleId", + table: "FlowOperations", + column: "FlowRuleId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventId", + table: "FlowOperations", + column: "BaseEventId", + principalTable: "BaseEvents", + principalColumn: "EventId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleId", + table: "FlowOperations", + column: "FlowRuleId", + principalTable: "FlowRules", + principalColumn: "RuleId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations", + column: "FlowId", + principalTable: "Flows", + principalColumn: "FlowId", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.AlterColumn( + name: "FlowId", + table: "FlowOperations", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AddColumn( + name: "BaseEventEventId", + table: "FlowOperations", + type: "uuid", + nullable: true); + + migrationBuilder.AddColumn( + name: "FlowRuleRuleId", + table: "FlowOperations", + type: "uuid", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_BaseEventEventId", + table: "FlowOperations", + column: "BaseEventEventId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_FlowRuleRuleId", + table: "FlowOperations", + column: "FlowRuleRuleId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventEventId", + table: "FlowOperations", + column: "BaseEventEventId", + principalTable: "BaseEvents", + principalColumn: "EventId", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleRuleId", + table: "FlowOperations", + column: "FlowRuleRuleId", + principalTable: "FlowRules", + principalColumn: "RuleId", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations", + column: "FlowId", + principalTable: "Flows", + principalColumn: "FlowId", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/IoTSharp.Data.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/IoTSharp.Data.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 557ece188f33e1070f9cc1e07ab1db428c155659..854010f4674e06fc2822d6b93080dab17bf7c1ab 100644 --- a/IoTSharp.Data.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/IoTSharp.Data.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1050,7 +1050,7 @@ namespace IoTSharp.Migrations b.Property("AddDate") .HasColumnType("timestamp without time zone"); - b.Property("BaseEventEventId") + b.Property("BaseEventId") .HasColumnType("uuid"); b.Property("BizId") @@ -1059,10 +1059,10 @@ namespace IoTSharp.Migrations b.Property("Data") .HasColumnType("text"); - b.Property("FlowId") + b.Property("FlowId") .HasColumnType("uuid"); - b.Property("FlowRuleRuleId") + b.Property("FlowRuleId") .HasColumnType("uuid"); b.Property("NodeStatus") @@ -1082,11 +1082,11 @@ namespace IoTSharp.Migrations b.HasKey("OperationId"); - b.HasIndex("BaseEventEventId"); + b.HasIndex("BaseEventId"); b.HasIndex("FlowId"); - b.HasIndex("FlowRuleRuleId"); + b.HasIndex("FlowRuleId"); b.ToTable("FlowOperations"); }); @@ -1724,15 +1724,21 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") .WithMany() - .HasForeignKey("BaseEventEventId"); + .HasForeignKey("BaseEventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("IoTSharp.Data.Flow", "Flow") .WithMany() - .HasForeignKey("FlowId"); + .HasForeignKey("FlowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") .WithMany() - .HasForeignKey("FlowRuleRuleId"); + .HasForeignKey("FlowRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("BaseEvent"); diff --git a/IoTSharp.Data/FlowOperation.cs b/IoTSharp.Data/FlowOperation.cs index fc550574103e0af16c2d01fead814ecf2934cd68..5c5edbbaf998eec60e23f82aef8090c3c7c0770b 100644 --- a/IoTSharp.Data/FlowOperation.cs +++ b/IoTSharp.Data/FlowOperation.cs @@ -23,11 +23,11 @@ namespace IoTSharp.Data public string BizId { get; set; } public string bpmnid { get; set; } public Flow Flow { get; set; } - + public Guid FlowId { get; set; } public FlowRule FlowRule { get; set; } - + public Guid FlowRuleId { get; set; } public BaseEvent BaseEvent { get; set; } - + public Guid BaseEventId { get; set; } public int Step { get; set; } public string Tag { get; set; } } diff --git a/IoTSharp/ClientApp/src/app/routes/device/devicelist/devicelist.component.ts b/IoTSharp/ClientApp/src/app/routes/device/devicelist/devicelist.component.ts index dd46327f1dd9fe5caa3a3f8fb3c01f5a4d1370cb..ea595636c28f955f88e838071218ac92c4b82536 100644 --- a/IoTSharp/ClientApp/src/app/routes/device/devicelist/devicelist.component.ts +++ b/IoTSharp/ClientApp/src/app/routes/device/devicelist/devicelist.component.ts @@ -97,7 +97,7 @@ export class DevicelistComponent implements OnInit, OnDestroy { { title: '名称', index: 'name', render: 'name' }, { title: '设备类型', index: 'deviceType', type: 'tag', tag: this.DeviceTAG }, { title: '在线状态', index: 'online', type: 'badge', badge: this.BADGE }, - { title: '最后活动时间', index: 'lastActive' }, + { title: '最后活动时间', index: 'lastActive',type:'date' }, { title: '认证方式', index: 'identityType', type: 'tag', tag: this.TAG }, { title: '操作', diff --git a/IoTSharp/ClientApp/src/app/routes/flow/diagram/diagram.component.html b/IoTSharp/ClientApp/src/app/routes/flow/diagram/diagram.component.html index 57629f9b6f849a19deab2489d07e2c4f345889d8..8199c83c93eeee4a372101b6804fa647e1332f9a 100644 --- a/IoTSharp/ClientApp/src/app/routes/flow/diagram/diagram.component.html +++ b/IoTSharp/ClientApp/src/app/routes/flow/diagram/diagram.component.html @@ -80,10 +80,7 @@ - - - - + diff --git a/IoTSharp/ClientApp/src/app/routes/flow/floweventview/floweventview.component.ts b/IoTSharp/ClientApp/src/app/routes/flow/floweventview/floweventview.component.ts index d0a509b7d51aa6eb83b7ee89003ed08af7a92628..5ed18a0ec3dfea8dcb1b8112b597af7e7bee060b 100644 --- a/IoTSharp/ClientApp/src/app/routes/flow/floweventview/floweventview.component.ts +++ b/IoTSharp/ClientApp/src/app/routes/flow/floweventview/floweventview.component.ts @@ -36,7 +36,7 @@ export class FloweventviewComponent implements OnInit, OnDestroy { this.flowview.diagramdata = x.data; this.flowview.loadXml(); }), - ), this.http.get('api/rules/getFlowOperstions?eventId=' + this.event.eventId).pipe( + ), this.http.get('api/rules/GetFlowOperations?eventId=' + this.event.eventId).pipe( map((x) => { if(x.data.length>0){ diff --git a/IoTSharp/Controllers/RulesController.cs b/IoTSharp/Controllers/RulesController.cs index 04e33a7b03814a814cb912eae84b77dce037dee4..11186d59152857fb1acaaee303846b77ed1ef4ba 100644 --- a/IoTSharp/Controllers/RulesController.cs +++ b/IoTSharp/Controllers/RulesController.cs @@ -1069,22 +1069,30 @@ namespace IoTSharp.Controllers var d = formdata.Value().ToObject(typeof(ExpandoObject)); var testabizId = Guid.NewGuid().ToString(); //根据业务保存起来,用来查询执行事件和步骤 - var result = await _flowRuleProcessor.RunFlowRules(ruleid, d, Guid.Empty, EventType.TestPurpose, testabizId); + if (result.Count > 0) + { + result.ForEach(c => + { + _context.FlowOperations.Add(new FlowOperation() + { + AddDate = c.AddDate, + BaseEventId = c.BaseEventId, + BizId = c.BizId, + Data = c.Data, + FlowId = c.FlowId, + FlowRuleId = c.FlowRuleId, + NodeStatus = c.NodeStatus, + OperationDesc = c.OperationDesc, + OperationId = new Guid(), + Step = c.Step, + Tag = c.Tag, + bpmnid = c.bpmnid + }); + _context.SaveChanges(); + }); - //result.ForEach(c => - //{ - // _context.FlowOperations.Add(new FlowOperation() - // { - // AddDate = c.AddDate, BaseEvent = c.BaseEvent, BizId = c.BizId, Data = c.Data, Flow = c.Flow, FlowRule = c.FlowRule, NodeStatus = c.NodeStatus, OperationDesc = c.OperationDesc, OperationId = c.OperationId, Step = c.Step, Tag = c.Tag, bpmnid = c.bpmnid - - - // }); - // _context.SaveChanges(); - //}); - - - + } 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 @@ -1174,9 +1182,9 @@ namespace IoTSharp.Controllers [HttpGet("[action]")] - public ApiResult GetFlowOperstions(Guid eventId) + public ApiResult GetFlowOperations(Guid eventId) { - return new ApiResult(ApiCode.Success, "OK", _context.FlowOperations.Where(c => c.BaseEvent.EventId == eventId).ToList().OrderBy(c => c.Step). + return new ApiResult(ApiCode.Success, "OK", _context.FlowOperations.Where(c => c.BaseEventId == eventId).ToList().OrderBy(c => c.Step). ToList() .GroupBy(c => c.Step).Select(c => new { @@ -1321,10 +1329,6 @@ namespace IoTSharp.Controllers var data = JsonConvert.DeserializeObject(m.Data) as JObject; var d = data.ToObject(typeof(ExpandoObject)); var result = await this._flowRuleProcessor.TestCondition(m.ruleId, m.flowId, d); - - - - return new ApiResult(ApiCode.Success, "Ok", result); } diff --git a/IoTSharp/Dtos/FlowOperationDto.cs b/IoTSharp/Dtos/FlowOperationDto.cs new file mode 100644 index 0000000000000000000000000000000000000000..b7ef365b5eaf02de99e56402c3a9be306817a02d --- /dev/null +++ b/IoTSharp/Dtos/FlowOperationDto.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace IoTSharp.Dtos +{ + public class FlowOperationDto + { + public Guid OperationId { get; set; } + public DateTime? AddDate { get; set; } + /// + /// 节点处理状态,0 创建完 + /// + public int? NodeStatus { get; set; } + public string OperationDesc { get; set; } + public string Data { get; set; } + public string BizId { get; set; } + public string bpmnid { get; set; } + public Guid ruleid { get; set; } + + + public Guid flowid { get; set; } + public Guid eventid { get; set; } + public int Step { get; set; } + } +} diff --git a/IoTSharp/FlowRuleEngine/FlowRuleProcessor.cs b/IoTSharp/FlowRuleEngine/FlowRuleProcessor.cs index d6bab570a2a44e17569e1a6c84e0cc1bc457d66b..0a04e434cfcadbd715d5b7d8bab855b9ed252440 100644 --- a/IoTSharp/FlowRuleEngine/FlowRuleProcessor.cs +++ b/IoTSharp/FlowRuleEngine/FlowRuleProcessor.cs @@ -117,7 +117,11 @@ namespace IoTSharp.FlowRuleEngine bpmnid = "", AddDate = DateTime.Now, FlowRule = rule, + FlowRuleId = rule.RuleId, + BaseEventId = @event.EventId, + FlowId = start.FlowId, Flow = start, + Data = JsonConvert.SerializeObject(data), NodeStatus = 1, OperationDesc = "未能找到启动节点", @@ -137,6 +141,9 @@ namespace IoTSharp.FlowRuleEngine AddDate = DateTime.Now, FlowRule = rule, Flow = start, + FlowRuleId = rule.RuleId, + BaseEventId = @event.EventId, + FlowId = start.FlowId, Data = JsonConvert.SerializeObject(data), NodeStatus = 1, OperationDesc = "进入开始节点", @@ -157,6 +164,12 @@ namespace IoTSharp.FlowRuleEngine AddDate = DateTime.Now, FlowRule = @event.FlowRule, Flow = item, + + + + FlowRuleId = rule.RuleId, + BaseEventId = @event.EventId, + FlowId = start.FlowId, Data = JsonConvert.SerializeObject(data), NodeStatus = 1, OperationDesc = "Condition(" + (string.IsNullOrEmpty(item.Conditionexpression) @@ -204,6 +217,11 @@ namespace IoTSharp.FlowRuleEngine AddDate = DateTime.Now, FlowRule = peroperation.BaseEvent.FlowRule, Flow = flow, + + + FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId, + BaseEventId = peroperation.BaseEvent.EventId, + FlowId = flow.FlowId, Data = JsonConvert.SerializeObject(data), NodeStatus = 1, OperationDesc = "Condition(" + (string.IsNullOrEmpty(flow.Conditionexpression) @@ -227,6 +245,9 @@ namespace IoTSharp.FlowRuleEngine AddDate = DateTime.Now, FlowRule = peroperation.BaseEvent.FlowRule, Flow = flow, + FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId, + BaseEventId = peroperation.BaseEvent.EventId, + FlowId = flow.FlowId, Data = JsonConvert.SerializeObject(data), NodeStatus = 1, OperationDesc = "Run" + flow.NodeProcessScriptType + "Task:" + flow.Flowname, @@ -355,6 +376,9 @@ namespace IoTSharp.FlowRuleEngine AddDate = DateTime.Now, FlowRule = peroperation.BaseEvent.FlowRule, Flow = item, + FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId, + BaseEventId = peroperation.BaseEvent.EventId, + FlowId = item.FlowId, Data = JsonConvert.SerializeObject(obj), NodeStatus = 1, OperationDesc = "Execute(" + @@ -387,6 +411,9 @@ namespace IoTSharp.FlowRuleEngine AddDate = DateTime.Now, FlowRule = peroperation.BaseEvent.FlowRule, Flow = item, + FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId, + BaseEventId = peroperation.BaseEvent.EventId, + FlowId = item.FlowId, Data = JsonConvert.SerializeObject(data), NodeStatus = 1, OperationDesc = "执行条件(" + (string.IsNullOrEmpty(item.Conditionexpression) @@ -411,10 +438,16 @@ namespace IoTSharp.FlowRuleEngine if (end != null) { + + + end.FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId; + end.BaseEventId = peroperation.BaseEvent.EventId; + end.FlowId = flow.FlowId; end.bpmnid = flow.bpmnid; end.AddDate = DateTime.Now; end.FlowRule = peroperation.BaseEvent.FlowRule; end.Flow = flow; + end.Data = JsonConvert.SerializeObject(data); end.NodeStatus = 1; end.OperationDesc = "处理完成"; @@ -424,6 +457,10 @@ namespace IoTSharp.FlowRuleEngine else { end = new FlowOperation(); + + end.FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId; + end.BaseEventId = peroperation.BaseEvent.EventId; + end.FlowId = flow.FlowId; end.OperationId = Guid.NewGuid(); end.bpmnid = flow.bpmnid; end.AddDate = DateTime.Now; diff --git a/IoTSharp/IoTSharp.xml b/IoTSharp/IoTSharp.xml index e62881bad18ea8ce0899c00bc042d3ae50c0b01b..d506affe76e45e85ce3504ad355cfe0c3a1be86c 100644 --- a/IoTSharp/IoTSharp.xml +++ b/IoTSharp/IoTSharp.xml @@ -579,6 +579,11 @@ 客户 + + + 节点处理状态,0 创建完 + + 系统管理员用户名