diff --git a/IoTGateway.DataAccess/DataContext.cs b/IoTGateway.DataAccess/DataContext.cs index 9a3bc71..c722276 100644 --- a/IoTGateway.DataAccess/DataContext.cs +++ b/IoTGateway.DataAccess/DataContext.cs @@ -80,7 +80,7 @@ namespace IoTGateway.DataAccess { public DataContext CreateDbContext(string[] args) { - return new DataContext("Data Source = ../IoTGateway/iotgateway.db", DBTypeEnum.SQLite); + return new DataContext("Data Source = ../IoTGateway/data/iotgateway.db", DBTypeEnum.SQLite); } } diff --git a/IoTGateway.DataAccess/Migrations/20240719011950_CommentAndIndex.Designer.cs b/IoTGateway.DataAccess/Migrations/20240719011950_CommentAndIndex.Designer.cs new file mode 100644 index 0000000..38a2f94 --- /dev/null +++ b/IoTGateway.DataAccess/Migrations/20240719011950_CommentAndIndex.Designer.cs @@ -0,0 +1,951 @@ +// +using System; +using IoTGateway.DataAccess; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IoTGateway.DataAccess.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20240719011950_CommentAndIndex")] + partial class CommentAndIndex + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.10"); + + modelBuilder.Entity("IoTGateway.Model.Device", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AutoStart") + .HasColumnType("INTEGER") + .HasComment("启动"); + + b.Property("CgUpload") + .HasColumnType("INTEGER") + .HasComment("变化上传"); + + b.Property("CmdPeriod") + .HasColumnType("INTEGER") + .HasComment("指令间隔ms"); + + b.Property("CreateBy") + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT") + .HasComment("描述"); + + b.Property("DeviceName") + .HasColumnType("TEXT") + .HasComment("名称"); + + b.Property("DeviceTypeEnum") + .HasColumnType("INTEGER") + .HasComment("类型(组或设备)"); + + b.Property("DriverId") + .HasColumnType("TEXT") + .HasComment("驱动"); + + b.Property("EnforcePeriod") + .HasColumnType("INTEGER") + .HasComment("归档周期ms"); + + b.Property("Index") + .HasColumnType("INTEGER") + .HasComment("排序"); + + b.Property("ParentId") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("AutoStart"); + + b.HasIndex("DeviceName"); + + b.HasIndex("DeviceTypeEnum"); + + b.HasIndex("DriverId"); + + b.HasIndex("ParentId"); + + b.ToTable("Devices"); + + b.HasComment("设备维护"); + }); + + modelBuilder.Entity("IoTGateway.Model.DeviceConfig", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("DataSide") + .HasColumnType("INTEGER") + .HasComment("属性侧"); + + b.Property("Description") + .HasColumnType("TEXT") + .HasComment("描述"); + + b.Property("DeviceConfigName") + .HasColumnType("TEXT") + .HasComment("名称"); + + b.Property("DeviceId") + .HasColumnType("TEXT") + .HasComment("所属设备"); + + b.Property("EnumInfo") + .HasColumnType("TEXT") + .HasComment("备注"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT") + .HasComment("值"); + + b.HasKey("ID"); + + b.HasIndex("DeviceConfigName"); + + b.HasIndex("DeviceId"); + + b.HasIndex("Value"); + + b.ToTable("DeviceConfigs"); + + b.HasComment("通讯配置"); + }); + + modelBuilder.Entity("IoTGateway.Model.DeviceVariable", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Alias") + .HasColumnType("TEXT") + .HasComment("别名"); + + b.Property("DataType") + .HasColumnType("INTEGER") + .HasComment("数据类型"); + + b.Property("Description") + .HasColumnType("TEXT") + .HasComment("描述"); + + b.Property("DeviceAddress") + .HasColumnType("TEXT") + .HasComment("地址"); + + b.Property("DeviceId") + .HasColumnType("TEXT") + .HasComment("所属设备"); + + b.Property("EndianType") + .HasColumnType("INTEGER") + .HasComment("大小端"); + + b.Property("Expressions") + .HasColumnType("TEXT") + .HasComment("表达式"); + + b.Property("Index") + .HasColumnType("INTEGER") + .HasComment("排序"); + + b.Property("IsTrigger") + .HasColumnType("INTEGER") + .HasComment("触发"); + + b.Property("IsUpload") + .HasColumnType("INTEGER") + .HasComment("上传"); + + b.Property("Method") + .HasColumnType("TEXT") + .HasComment("方法"); + + b.Property("Name") + .HasColumnType("TEXT") + .HasComment("变量名"); + + b.Property("ProtectType") + .HasColumnType("INTEGER") + .HasComment("权限"); + + b.HasKey("ID"); + + b.HasIndex("DataType"); + + b.HasIndex("DeviceAddress"); + + b.HasIndex("DeviceId"); + + b.HasIndex("Method"); + + b.HasIndex("Name"); + + b.ToTable("DeviceVariables"); + + b.HasComment("变量配置"); + }); + + modelBuilder.Entity("IoTGateway.Model.Driver", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AssembleName") + .HasColumnType("TEXT") + .HasComment("程序集名"); + + b.Property("AuthorizesNum") + .HasColumnType("INTEGER") + .HasComment("剩余授权数"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("DriverName") + .HasColumnType("TEXT") + .HasComment("驱动名"); + + b.Property("FileName") + .HasColumnType("TEXT") + .HasComment("文件名"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("Drivers"); + + b.HasComment("驱动管理"); + }); + + modelBuilder.Entity("IoTGateway.Model.RpcLog", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT") + .HasComment("描述"); + + b.Property("DeviceId") + .HasColumnType("TEXT") + .HasComment("所属设备"); + + b.Property("EndTime") + .HasColumnType("TEXT") + .HasComment("结束时间"); + + b.Property("IsSuccess") + .HasColumnType("INTEGER") + .HasComment("是否成功"); + + b.Property("Method") + .HasColumnType("TEXT") + .HasComment("方法"); + + b.Property("Params") + .HasColumnType("TEXT") + .HasComment("请求参数"); + + b.Property("RpcSide") + .HasColumnType("INTEGER") + .HasComment("发起方"); + + b.Property("StartTime") + .HasColumnType("TEXT") + .HasComment("开始时间"); + + b.HasKey("ID"); + + b.HasIndex("DeviceId"); + + b.ToTable("RpcLogs"); + + b.HasComment("RPC日志"); + }); + + modelBuilder.Entity("IoTGateway.Model.SystemConfig", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ClientId") + .HasColumnType("TEXT") + .HasComment("ClientId"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("GatewayName") + .HasColumnType("TEXT") + .HasComment("网关名称"); + + b.Property("IoTPlatformType") + .HasColumnType("INTEGER") + .HasComment("输出平台"); + + b.Property("MqttIp") + .HasColumnType("TEXT") + .HasComment("Mqtt服务器"); + + b.Property("MqttPort") + .HasColumnType("INTEGER") + .HasComment("Mqtt端口"); + + b.Property("MqttUName") + .HasColumnType("TEXT") + .HasComment("Mqtt用户名"); + + b.Property("MqttUPwd") + .HasColumnType("TEXT") + .HasComment("Mqtt密码"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("SystemConfig"); + + b.HasComment("传输配置"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.ActionLog", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ActionName") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property("ActionTime") + .HasColumnType("TEXT"); + + b.Property("ActionUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("REAL"); + + b.Property("IP") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ITCode") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("LogType") + .HasColumnType("INTEGER"); + + b.Property("ModuleName") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property("Remark") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("ActionLogs"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.DataPrivilege", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasColumnType("TEXT"); + + b.Property("GroupCode") + .HasColumnType("TEXT"); + + b.Property("RelateId") + .HasColumnType("TEXT"); + + b.Property("TableName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("UserCode") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("DataPrivileges"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FileAttachment", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ExtraInfo") + .HasColumnType("TEXT"); + + b.Property("FileData") + .HasColumnType("BLOB"); + + b.Property("FileExt") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("HandlerInfo") + .HasColumnType("TEXT"); + + b.Property("Length") + .HasColumnType("INTEGER"); + + b.Property("Path") + .HasColumnType("TEXT"); + + b.Property("SaveMode") + .HasColumnType("TEXT"); + + b.Property("UploadTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FileAttachments"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkGroup", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("GroupCode") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("GroupRemark") + .HasColumnType("TEXT"); + + b.Property("TenantCode") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FrameworkGroups"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ActionName") + .HasColumnType("TEXT"); + + b.Property("ClassName") + .HasColumnType("TEXT"); + + b.Property("DisplayOrder") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("Domain") + .HasColumnType("TEXT"); + + b.Property("FolderOnly") + .HasColumnType("INTEGER"); + + b.Property("Icon") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsInherit") + .HasColumnType("INTEGER"); + + b.Property("IsInside") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("IsPublic") + .HasColumnType("INTEGER"); + + b.Property("MethodName") + .HasColumnType("TEXT"); + + b.Property("ModuleName") + .HasColumnType("TEXT"); + + b.Property("PageName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ParentId") + .HasColumnType("TEXT"); + + b.Property("ShowOnMenu") + .HasColumnType("INTEGER"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("ParentId"); + + b.ToTable("FrameworkMenus"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkRole", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("RoleCode") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("RoleRemark") + .HasColumnType("TEXT"); + + b.Property("TenantCode") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FrameworkRoles"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUser", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Address") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("CellPhone") + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Gender") + .HasColumnType("INTEGER"); + + b.Property("HomePhone") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ITCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsValid") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("PhotoId") + .HasColumnType("TEXT"); + + b.Property("TenantCode") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("ZipCode") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("PhotoId"); + + b.ToTable("FrameworkUsers"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUserGroup", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("GroupCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("UserCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FrameworkUserGroups"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUserRole", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("RoleCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("UserCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FrameworkUserRoles"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FunctionPrivilege", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Allowed") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("MenuItemId") + .HasColumnType("TEXT"); + + b.Property("RoleCode") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("MenuItemId"); + + b.ToTable("FunctionPrivileges"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.PersistedGrant", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreationTime") + .HasColumnType("TEXT"); + + b.Property("Expiration") + .HasColumnType("TEXT"); + + b.Property("RefreshToken") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UserCode") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("PersistedGrants"); + }); + + modelBuilder.Entity("IoTGateway.Model.Device", b => + { + b.HasOne("IoTGateway.Model.Driver", "Driver") + .WithMany() + .HasForeignKey("DriverId"); + + b.HasOne("IoTGateway.Model.Device", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.Navigation("Driver"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("IoTGateway.Model.DeviceConfig", b => + { + b.HasOne("IoTGateway.Model.Device", "Device") + .WithMany("DeviceConfigs") + .HasForeignKey("DeviceId"); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("IoTGateway.Model.DeviceVariable", b => + { + b.HasOne("IoTGateway.Model.Device", "Device") + .WithMany("DeviceVariables") + .HasForeignKey("DeviceId"); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("IoTGateway.Model.RpcLog", b => + { + b.HasOne("IoTGateway.Model.Device", "Device") + .WithMany() + .HasForeignKey("DeviceId"); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b => + { + b.HasOne("WalkingTec.Mvvm.Core.FrameworkMenu", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUser", b => + { + b.HasOne("WalkingTec.Mvvm.Core.FileAttachment", "Photo") + .WithMany() + .HasForeignKey("PhotoId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Photo"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FunctionPrivilege", b => + { + b.HasOne("WalkingTec.Mvvm.Core.FrameworkMenu", "MenuItem") + .WithMany("Privileges") + .HasForeignKey("MenuItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MenuItem"); + }); + + modelBuilder.Entity("IoTGateway.Model.Device", b => + { + b.Navigation("Children"); + + b.Navigation("DeviceConfigs"); + + b.Navigation("DeviceVariables"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b => + { + b.Navigation("Children"); + + b.Navigation("Privileges"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IoTGateway.DataAccess/Migrations/20240719011950_CommentAndIndex.cs b/IoTGateway.DataAccess/Migrations/20240719011950_CommentAndIndex.cs new file mode 100644 index 0000000..8fb850e --- /dev/null +++ b/IoTGateway.DataAccess/Migrations/20240719011950_CommentAndIndex.cs @@ -0,0 +1,1045 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IoTGateway.DataAccess.Migrations +{ + public partial class CommentAndIndex : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterTable( + name: "SystemConfig", + comment: "传输配置"); + + migrationBuilder.AlterTable( + name: "RpcLogs", + comment: "RPC日志"); + + migrationBuilder.AlterTable( + name: "Drivers", + comment: "驱动管理"); + + migrationBuilder.AlterTable( + name: "DeviceVariables", + comment: "变量配置"); + + migrationBuilder.AlterTable( + name: "Devices", + comment: "设备维护"); + + migrationBuilder.AlterTable( + name: "DeviceConfigs", + comment: "通讯配置"); + + migrationBuilder.AlterColumn( + name: "MqttUPwd", + table: "SystemConfig", + type: "TEXT", + nullable: true, + comment: "Mqtt密码", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MqttUName", + table: "SystemConfig", + type: "TEXT", + nullable: true, + comment: "Mqtt用户名", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MqttPort", + table: "SystemConfig", + type: "INTEGER", + nullable: false, + comment: "Mqtt端口", + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "MqttIp", + table: "SystemConfig", + type: "TEXT", + nullable: true, + comment: "Mqtt服务器", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IoTPlatformType", + table: "SystemConfig", + type: "INTEGER", + nullable: false, + comment: "输出平台", + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "GatewayName", + table: "SystemConfig", + type: "TEXT", + nullable: true, + comment: "网关名称", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ClientId", + table: "SystemConfig", + type: "TEXT", + nullable: true, + comment: "ClientId", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "StartTime", + table: "RpcLogs", + type: "TEXT", + nullable: false, + comment: "开始时间", + oldClrType: typeof(DateTime), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "RpcSide", + table: "RpcLogs", + type: "INTEGER", + nullable: false, + comment: "发起方", + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "Params", + table: "RpcLogs", + type: "TEXT", + nullable: true, + comment: "请求参数", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Method", + table: "RpcLogs", + type: "TEXT", + nullable: true, + comment: "方法", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsSuccess", + table: "RpcLogs", + type: "INTEGER", + nullable: false, + comment: "是否成功", + oldClrType: typeof(bool), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "EndTime", + table: "RpcLogs", + type: "TEXT", + nullable: false, + comment: "结束时间", + oldClrType: typeof(DateTime), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "RpcLogs", + type: "TEXT", + nullable: true, + comment: "所属设备", + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "RpcLogs", + type: "TEXT", + nullable: true, + comment: "描述", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FileName", + table: "Drivers", + type: "TEXT", + nullable: true, + comment: "文件名", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DriverName", + table: "Drivers", + type: "TEXT", + nullable: true, + comment: "驱动名", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "AuthorizesNum", + table: "Drivers", + type: "INTEGER", + nullable: false, + comment: "剩余授权数", + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "AssembleName", + table: "Drivers", + type: "TEXT", + nullable: true, + comment: "程序集名", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ProtectType", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + comment: "权限", + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + comment: "变量名", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Method", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + comment: "方法", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsUpload", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + comment: "上传", + oldClrType: typeof(bool), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "IsTrigger", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + comment: "触发", + oldClrType: typeof(bool), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "Index", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + comment: "排序", + oldClrType: typeof(uint), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "Expressions", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + comment: "表达式", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "EndianType", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + comment: "大小端", + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + comment: "所属设备", + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeviceAddress", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + comment: "地址", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + comment: "描述", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DataType", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + comment: "数据类型", + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "Alias", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + comment: "别名", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Index", + table: "Devices", + type: "INTEGER", + nullable: false, + comment: "排序", + oldClrType: typeof(uint), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "EnforcePeriod", + table: "Devices", + type: "INTEGER", + nullable: false, + comment: "归档周期ms", + oldClrType: typeof(uint), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "DriverId", + table: "Devices", + type: "TEXT", + nullable: true, + comment: "驱动", + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeviceTypeEnum", + table: "Devices", + type: "INTEGER", + nullable: false, + comment: "类型(组或设备)", + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "DeviceName", + table: "Devices", + type: "TEXT", + nullable: true, + comment: "名称", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "Devices", + type: "TEXT", + nullable: true, + comment: "描述", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CmdPeriod", + table: "Devices", + type: "INTEGER", + nullable: false, + comment: "指令间隔ms", + oldClrType: typeof(uint), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "CgUpload", + table: "Devices", + type: "INTEGER", + nullable: false, + comment: "变化上传", + oldClrType: typeof(bool), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "AutoStart", + table: "Devices", + type: "INTEGER", + nullable: false, + comment: "启动", + oldClrType: typeof(bool), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "Value", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + comment: "值", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "EnumInfo", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + comment: "备注", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + comment: "所属设备", + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeviceConfigName", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + comment: "名称", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + comment: "描述", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DataSide", + table: "DeviceConfigs", + type: "INTEGER", + nullable: false, + comment: "属性侧", + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceVariables_DataType", + table: "DeviceVariables", + column: "DataType"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceVariables_DeviceAddress", + table: "DeviceVariables", + column: "DeviceAddress"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceVariables_Method", + table: "DeviceVariables", + column: "Method"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceVariables_Name", + table: "DeviceVariables", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_Devices_AutoStart", + table: "Devices", + column: "AutoStart"); + + migrationBuilder.CreateIndex( + name: "IX_Devices_DeviceName", + table: "Devices", + column: "DeviceName"); + + migrationBuilder.CreateIndex( + name: "IX_Devices_DeviceTypeEnum", + table: "Devices", + column: "DeviceTypeEnum"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceConfigs_DeviceConfigName", + table: "DeviceConfigs", + column: "DeviceConfigName"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceConfigs_Value", + table: "DeviceConfigs", + column: "Value"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_DeviceVariables_DataType", + table: "DeviceVariables"); + + migrationBuilder.DropIndex( + name: "IX_DeviceVariables_DeviceAddress", + table: "DeviceVariables"); + + migrationBuilder.DropIndex( + name: "IX_DeviceVariables_Method", + table: "DeviceVariables"); + + migrationBuilder.DropIndex( + name: "IX_DeviceVariables_Name", + table: "DeviceVariables"); + + migrationBuilder.DropIndex( + name: "IX_Devices_AutoStart", + table: "Devices"); + + migrationBuilder.DropIndex( + name: "IX_Devices_DeviceName", + table: "Devices"); + + migrationBuilder.DropIndex( + name: "IX_Devices_DeviceTypeEnum", + table: "Devices"); + + migrationBuilder.DropIndex( + name: "IX_DeviceConfigs_DeviceConfigName", + table: "DeviceConfigs"); + + migrationBuilder.DropIndex( + name: "IX_DeviceConfigs_Value", + table: "DeviceConfigs"); + + migrationBuilder.AlterTable( + name: "SystemConfig", + oldComment: "传输配置"); + + migrationBuilder.AlterTable( + name: "RpcLogs", + oldComment: "RPC日志"); + + migrationBuilder.AlterTable( + name: "Drivers", + oldComment: "驱动管理"); + + migrationBuilder.AlterTable( + name: "DeviceVariables", + oldComment: "变量配置"); + + migrationBuilder.AlterTable( + name: "Devices", + oldComment: "设备维护"); + + migrationBuilder.AlterTable( + name: "DeviceConfigs", + oldComment: "通讯配置"); + + migrationBuilder.AlterColumn( + name: "MqttUPwd", + table: "SystemConfig", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "Mqtt密码"); + + migrationBuilder.AlterColumn( + name: "MqttUName", + table: "SystemConfig", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "Mqtt用户名"); + + migrationBuilder.AlterColumn( + name: "MqttPort", + table: "SystemConfig", + type: "INTEGER", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER", + oldComment: "Mqtt端口"); + + migrationBuilder.AlterColumn( + name: "MqttIp", + table: "SystemConfig", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "Mqtt服务器"); + + migrationBuilder.AlterColumn( + name: "IoTPlatformType", + table: "SystemConfig", + type: "INTEGER", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER", + oldComment: "输出平台"); + + migrationBuilder.AlterColumn( + name: "GatewayName", + table: "SystemConfig", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "网关名称"); + + migrationBuilder.AlterColumn( + name: "ClientId", + table: "SystemConfig", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "ClientId"); + + migrationBuilder.AlterColumn( + name: "StartTime", + table: "RpcLogs", + type: "TEXT", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TEXT", + oldComment: "开始时间"); + + migrationBuilder.AlterColumn( + name: "RpcSide", + table: "RpcLogs", + type: "INTEGER", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER", + oldComment: "发起方"); + + migrationBuilder.AlterColumn( + name: "Params", + table: "RpcLogs", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "请求参数"); + + migrationBuilder.AlterColumn( + name: "Method", + table: "RpcLogs", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "方法"); + + migrationBuilder.AlterColumn( + name: "IsSuccess", + table: "RpcLogs", + type: "INTEGER", + nullable: false, + oldClrType: typeof(bool), + oldType: "INTEGER", + oldComment: "是否成功"); + + migrationBuilder.AlterColumn( + name: "EndTime", + table: "RpcLogs", + type: "TEXT", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TEXT", + oldComment: "结束时间"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "RpcLogs", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true, + oldComment: "所属设备"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "RpcLogs", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "描述"); + + migrationBuilder.AlterColumn( + name: "FileName", + table: "Drivers", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "文件名"); + + migrationBuilder.AlterColumn( + name: "DriverName", + table: "Drivers", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "驱动名"); + + migrationBuilder.AlterColumn( + name: "AuthorizesNum", + table: "Drivers", + type: "INTEGER", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER", + oldComment: "剩余授权数"); + + migrationBuilder.AlterColumn( + name: "AssembleName", + table: "Drivers", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "程序集名"); + + migrationBuilder.AlterColumn( + name: "ProtectType", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER", + oldComment: "权限"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "变量名"); + + migrationBuilder.AlterColumn( + name: "Method", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "方法"); + + migrationBuilder.AlterColumn( + name: "IsUpload", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + oldClrType: typeof(bool), + oldType: "INTEGER", + oldComment: "上传"); + + migrationBuilder.AlterColumn( + name: "IsTrigger", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + oldClrType: typeof(bool), + oldType: "INTEGER", + oldComment: "触发"); + + migrationBuilder.AlterColumn( + name: "Index", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + oldClrType: typeof(uint), + oldType: "INTEGER", + oldComment: "排序"); + + migrationBuilder.AlterColumn( + name: "Expressions", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "表达式"); + + migrationBuilder.AlterColumn( + name: "EndianType", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER", + oldComment: "大小端"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true, + oldComment: "所属设备"); + + migrationBuilder.AlterColumn( + name: "DeviceAddress", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "地址"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "描述"); + + migrationBuilder.AlterColumn( + name: "DataType", + table: "DeviceVariables", + type: "INTEGER", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER", + oldComment: "数据类型"); + + migrationBuilder.AlterColumn( + name: "Alias", + table: "DeviceVariables", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "别名"); + + migrationBuilder.AlterColumn( + name: "Index", + table: "Devices", + type: "INTEGER", + nullable: false, + oldClrType: typeof(uint), + oldType: "INTEGER", + oldComment: "排序"); + + migrationBuilder.AlterColumn( + name: "EnforcePeriod", + table: "Devices", + type: "INTEGER", + nullable: false, + oldClrType: typeof(uint), + oldType: "INTEGER", + oldComment: "归档周期ms"); + + migrationBuilder.AlterColumn( + name: "DriverId", + table: "Devices", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true, + oldComment: "驱动"); + + migrationBuilder.AlterColumn( + name: "DeviceTypeEnum", + table: "Devices", + type: "INTEGER", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER", + oldComment: "类型(组或设备)"); + + migrationBuilder.AlterColumn( + name: "DeviceName", + table: "Devices", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "名称"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "Devices", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "描述"); + + migrationBuilder.AlterColumn( + name: "CmdPeriod", + table: "Devices", + type: "INTEGER", + nullable: false, + oldClrType: typeof(uint), + oldType: "INTEGER", + oldComment: "指令间隔ms"); + + migrationBuilder.AlterColumn( + name: "CgUpload", + table: "Devices", + type: "INTEGER", + nullable: false, + oldClrType: typeof(bool), + oldType: "INTEGER", + oldComment: "变化上传"); + + migrationBuilder.AlterColumn( + name: "AutoStart", + table: "Devices", + type: "INTEGER", + nullable: false, + oldClrType: typeof(bool), + oldType: "INTEGER", + oldComment: "启动"); + + migrationBuilder.AlterColumn( + name: "Value", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "值"); + + migrationBuilder.AlterColumn( + name: "EnumInfo", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "备注"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true, + oldComment: "所属设备"); + + migrationBuilder.AlterColumn( + name: "DeviceConfigName", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "名称"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "DeviceConfigs", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true, + oldComment: "描述"); + + migrationBuilder.AlterColumn( + name: "DataSide", + table: "DeviceConfigs", + type: "INTEGER", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER", + oldComment: "属性侧"); + } + } +} diff --git a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs index dc79ac7..ff5b1bd 100644 --- a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs +++ b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs @@ -24,13 +24,16 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("AutoStart") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("启动"); b.Property("CgUpload") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("变化上传"); b.Property("CmdPeriod") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("指令间隔ms"); b.Property("CreateBy") .HasColumnType("TEXT"); @@ -39,22 +42,28 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("Description") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("描述"); b.Property("DeviceName") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("名称"); b.Property("DeviceTypeEnum") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("类型(组或设备)"); b.Property("DriverId") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("驱动"); b.Property("EnforcePeriod") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("归档周期ms"); b.Property("Index") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("排序"); b.Property("ParentId") .HasColumnType("TEXT"); @@ -67,11 +76,19 @@ namespace IoTGateway.DataAccess.Migrations b.HasKey("ID"); + b.HasIndex("AutoStart"); + + b.HasIndex("DeviceName"); + + b.HasIndex("DeviceTypeEnum"); + b.HasIndex("DriverId"); b.HasIndex("ParentId"); b.ToTable("Devices"); + + b.HasComment("设备维护"); }); modelBuilder.Entity("IoTGateway.Model.DeviceConfig", b => @@ -88,19 +105,24 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("DataSide") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("属性侧"); b.Property("Description") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("描述"); b.Property("DeviceConfigName") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("名称"); b.Property("DeviceId") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("所属设备"); b.Property("EnumInfo") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("备注"); b.Property("UpdateBy") .HasMaxLength(50) @@ -110,13 +132,20 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("Value") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("值"); b.HasKey("ID"); + b.HasIndex("DeviceConfigName"); + b.HasIndex("DeviceId"); + b.HasIndex("Value"); + b.ToTable("DeviceConfigs"); + + b.HasComment("通讯配置"); }); modelBuilder.Entity("IoTGateway.Model.DeviceVariable", b => @@ -126,49 +155,72 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("Alias") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("别名"); b.Property("DataType") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("数据类型"); b.Property("Description") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("描述"); b.Property("DeviceAddress") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("地址"); b.Property("DeviceId") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("所属设备"); b.Property("EndianType") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("大小端"); b.Property("Expressions") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("表达式"); b.Property("Index") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("排序"); b.Property("IsTrigger") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("触发"); b.Property("IsUpload") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("上传"); b.Property("Method") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("方法"); b.Property("Name") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("变量名"); b.Property("ProtectType") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("权限"); b.HasKey("ID"); + b.HasIndex("DataType"); + + b.HasIndex("DeviceAddress"); + b.HasIndex("DeviceId"); + b.HasIndex("Method"); + + b.HasIndex("Name"); + b.ToTable("DeviceVariables"); + + b.HasComment("变量配置"); }); modelBuilder.Entity("IoTGateway.Model.Driver", b => @@ -178,10 +230,12 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("AssembleName") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("程序集名"); b.Property("AuthorizesNum") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("剩余授权数"); b.Property("CreateBy") .HasMaxLength(50) @@ -191,10 +245,12 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("DriverName") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("驱动名"); b.Property("FileName") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("文件名"); b.Property("UpdateBy") .HasMaxLength(50) @@ -206,6 +262,8 @@ namespace IoTGateway.DataAccess.Migrations b.HasKey("ID"); b.ToTable("Drivers"); + + b.HasComment("驱动管理"); }); modelBuilder.Entity("IoTGateway.Model.RpcLog", b => @@ -215,34 +273,44 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("Description") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("描述"); b.Property("DeviceId") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("所属设备"); b.Property("EndTime") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("结束时间"); b.Property("IsSuccess") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("是否成功"); b.Property("Method") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("方法"); b.Property("Params") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("请求参数"); b.Property("RpcSide") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("发起方"); b.Property("StartTime") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("开始时间"); b.HasKey("ID"); b.HasIndex("DeviceId"); b.ToTable("RpcLogs"); + + b.HasComment("RPC日志"); }); modelBuilder.Entity("IoTGateway.Model.SystemConfig", b => @@ -252,7 +320,8 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("ClientId") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("ClientId"); b.Property("CreateBy") .HasMaxLength(50) @@ -262,22 +331,28 @@ namespace IoTGateway.DataAccess.Migrations .HasColumnType("TEXT"); b.Property("GatewayName") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("网关名称"); b.Property("IoTPlatformType") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("输出平台"); b.Property("MqttIp") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("Mqtt服务器"); b.Property("MqttPort") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasComment("Mqtt端口"); b.Property("MqttUName") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("Mqtt用户名"); b.Property("MqttUPwd") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasComment("Mqtt密码"); b.Property("UpdateBy") .HasMaxLength(50) @@ -289,6 +364,8 @@ namespace IoTGateway.DataAccess.Migrations b.HasKey("ID"); b.ToTable("SystemConfig"); + + b.HasComment("传输配置"); }); modelBuilder.Entity("WalkingTec.Mvvm.Core.ActionLog", b => diff --git a/IoTGateway.Model/Device.cs b/IoTGateway.Model/Device.cs index 65a5b3e..e050dd2 100644 --- a/IoTGateway.Model/Device.cs +++ b/IoTGateway.Model/Device.cs @@ -1,37 +1,52 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Runtime.CompilerServices; +using Microsoft.EntityFrameworkCore; using WalkingTec.Mvvm.Core; namespace IoTGateway.Model { + [Comment("设备维护")] + [Index(nameof(DeviceName))] + [Index(nameof(AutoStart))] + [Index(nameof(DeviceTypeEnum))] public class Device : TreePoco, IBasePoco { + [Comment("名称")] [Display(Name = "DeviceName")] public string DeviceName { get; set; } + [Comment("排序")] [Display(Name = "Sort")] public uint Index { get; set; } + [Comment("描述")] [Display(Name = "Description")] public string Description { get; set; } public Driver Driver { get; set; } + [Comment("驱动")] [Display(Name = "Driver")] public Guid? DriverId { get; set; } + [Comment("启动")] [Display(Name = "AutoStart")] public bool AutoStart { get; set; } + [Comment("变化上传")] [Display(Name = "ChangeUpload")] public bool CgUpload { get; set; } + [Comment("归档周期ms")] [Display(Name = "EnforcePeriodms")] public uint EnforcePeriod { get; set; } + [Comment("指令间隔ms")] [Display(Name = "CmdPeriodms")] public uint CmdPeriod { get; set; } + [Comment("类型(组或设备)")] [Display(Name = "Type")] public DeviceTypeEnum DeviceTypeEnum { get; set; } diff --git a/IoTGateway.Model/DeviceConfig.cs b/IoTGateway.Model/DeviceConfig.cs index 2821689..08d7733 100644 --- a/IoTGateway.Model/DeviceConfig.cs +++ b/IoTGateway.Model/DeviceConfig.cs @@ -1,22 +1,38 @@ -using System; +using Microsoft.EntityFrameworkCore; +using System; using System.ComponentModel.DataAnnotations; using WalkingTec.Mvvm.Core; namespace IoTGateway.Model { + [Comment("通讯配置")] + [Index(nameof(DeviceConfigName))] + [Index(nameof(Value))] public class DeviceConfig : BasePoco { + [Comment("名称")] [Display(Name = "ConfigName")] public string DeviceConfigName { get; set; } + + [Comment("属性侧")] [Display(Name = "DataSide")] public DataSide DataSide { get; set; } + + [Comment("描述")] [Display(Name = "Description")] public string Description { get; set; } + + [Comment("值")] [Display(Name = "Value")] public string Value { get; set; } + + [Comment("备注")] [Display(Name = "Remark")] public string EnumInfo { get; set; } + public Device Device { get; set; } + + [Comment("所属设备")] [Display(Name = "Device")] public Guid? DeviceId { get; set; } } diff --git a/IoTGateway.Model/DeviceVariable.cs b/IoTGateway.Model/DeviceVariable.cs index 78d29dd..27dfdae 100644 --- a/IoTGateway.Model/DeviceVariable.cs +++ b/IoTGateway.Model/DeviceVariable.cs @@ -5,70 +5,101 @@ using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using WalkingTec.Mvvm.Core; +using Microsoft.EntityFrameworkCore; namespace IoTGateway.Model { + [Comment("变量配置")] + [Index(nameof(Name))] + [Index(nameof(Method))] + [Index(nameof(DeviceAddress))] + [Index(nameof(DataType))] public class DeviceVariable : TopBasePoco, IVariable { + [Comment("变量名")] [Display(Name = "VariableName")] public string Name { get; set; } + [Comment("描述")] [Display(Name = "Description")] public string Description { get; set; } + [Comment("方法")] [Display(Name = "Method")] public string Method { get; set; } + [Comment("地址")] [Display(Name = "Address")] public string DeviceAddress { get; set; } + [Comment("数据类型")] [Display(Name = "DataType")] public DataTypeEnum DataType { get; set; } + [Comment("触发")] [Display(Name = "IsTrigger")] public bool IsTrigger { get; set; } + [Comment("大小端")] [Display(Name = "EndianType")] public EndianEnum EndianType { get; set; } + [Comment("表达式")] [Display(Name = "Expressions")] public string Expressions { get; set; } + [Comment("上传")] [Display(Name = "Upload")] public bool IsUpload { get; set; } + [Comment("权限")] [Display(Name = "Permissions")] public ProtectTypeEnum ProtectType { get; set; } + [Comment("排序")] [Display(Name = "Sort")] public uint Index { get; set; } [Newtonsoft.Json.JsonIgnore] public Device Device { get; set; } + [Comment("所属设备")] [Display(Name = "Device")] public Guid? DeviceId { get; set; } + [Comment("别名")] [Display(Name = "Alias")] public string Alias { get; set; } + [Comment("原值")] [NotMapped] [Display(Name = "RawValue")] public object Value { get; set; } + + [Comment("计算后的值")] [NotMapped] [Display(Name = "CookedValue")] public object CookedValue { get; set; } + + [Comment("错误信息")] [NotMapped] [Display(Name = "Message")] public string Message { get; set; } + + [Comment("更新时间")] [NotMapped] [Display(Name = "Timestamp")] public DateTime Timestamp { get; set; } + + [Comment("状态")] [NotMapped] [Display(Name = "Status")] [JsonConverter(typeof(StringEnumConverter))] public VaribaleStatusTypeEnum StatusType { get; set; } = VaribaleStatusTypeEnum.UnKnow; + [Comment("最新三次原值")] [NotMapped][Display(Name = "MostRecentValues")] public object[] Values { get; set; } = new object[3]; + + [Comment("最新三次计算后的值")] [NotMapped][Display(Name = "MostRecentCookedValues")] public object[] CookedValues { get; set; } = new object[3]; public void EnqueueVariable(object value) { diff --git a/IoTGateway.Model/Driver.cs b/IoTGateway.Model/Driver.cs index 24a80db..142188c 100644 --- a/IoTGateway.Model/Driver.cs +++ b/IoTGateway.Model/Driver.cs @@ -1,17 +1,26 @@ -using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using WalkingTec.Mvvm.Core; namespace IoTGateway.Model { + [Comment("驱动管理")] public class Driver : BasePoco { + [Comment("驱动名")] [Display(Name = "DriverName")] public string DriverName { get; set; } + + [Comment("文件名")] [Display(Name = "FileName")] public string FileName { get; set; } + + [Comment("程序集名")] [Display(Name = "AssembleName")] public string AssembleName { get; set; } + + [Comment("剩余授权数")] [Display(Name = "Remains")] public int AuthorizesNum { get; set; } } diff --git a/IoTGateway.Model/RpcLog.cs b/IoTGateway.Model/RpcLog.cs index a2a3e32..b431ad2 100644 --- a/IoTGateway.Model/RpcLog.cs +++ b/IoTGateway.Model/RpcLog.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.EntityFrameworkCore; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; @@ -8,31 +9,40 @@ using WalkingTec.Mvvm.Core; namespace IoTGateway.Model { + [Comment("RPC日志")] public class RpcLog:TopBasePoco { + [Comment("发起方")] [Display(Name = "RpcSide")] - public RpcSide RpcSide { get; set; } + public RpcSide RpcSide { get; set; } + [Comment("开始时间")] [Display(Name = "StartTime")] public DateTime StartTime { get; set; } public Device Device { get; set; } + [Comment("所属设备")] [Display(Name = "Device")] public Guid? DeviceId { get; set; } + [Comment("方法")] [Display(Name = "Method")] public string Method { get; set; } + [Comment("请求参数")] [Display(Name = "Parameters")] public string Params { get; set; } + [Comment("结束时间")] [Display(Name = "EndTime")] public DateTime EndTime { get; set; } + [Comment("是否成功")] [Display(Name = "IsSuccess")] public bool IsSuccess { get; set; } + [Comment("描述")] [Display(Name = "Description")] public string Description { get; set; } } diff --git a/IoTGateway.Model/SystemConfig.cs b/IoTGateway.Model/SystemConfig.cs index 0d6f2c9..f056949 100644 --- a/IoTGateway.Model/SystemConfig.cs +++ b/IoTGateway.Model/SystemConfig.cs @@ -1,22 +1,37 @@ -using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; using WalkingTec.Mvvm.Core; namespace IoTGateway.Model { + [Comment("传输配置")] public class SystemConfig : BasePoco { + [Comment("网关名称")] [Display(Name = "GatewayName")] public string GatewayName { get; set; } + + [Comment("ClientId")] [Display(Name = "ClientId")] public string ClientId { get; set; } + + [Comment("Mqtt服务器")] [Display(Name = "MqttServer ")] public string MqttIp { get; set; } + + [Comment("Mqtt端口")] [Display(Name = "MqttPort")] public int MqttPort { get; set; } + + [Comment("Mqtt用户名")] [Display(Name = "UserName")] public string MqttUName { get; set; } + + [Comment("Mqtt密码")] [Display(Name = "Password")] public string MqttUPwd { get; set; } + + [Comment("输出平台")] [Display(Name = "OutputPlatform")] public IoTPlatformType IoTPlatformType { get; set; } } diff --git a/IoTGateway/IoTGateway.csproj b/IoTGateway/IoTGateway.csproj index 2b5fed3..04bd479 100644 --- a/IoTGateway/IoTGateway.csproj +++ b/IoTGateway/IoTGateway.csproj @@ -33,7 +33,7 @@ - + Always diff --git a/IoTGateway/appsettings.json b/IoTGateway/appsettings.json index fe47841..d455cf1 100644 --- a/IoTGateway/appsettings.json +++ b/IoTGateway/appsettings.json @@ -29,7 +29,7 @@ "Connections": [ { "Key": "default", - "Value": "Data Source = iotgateway.db", + "Value": "Data Source = ./data/iotgateway.db", "DbContext": "DataContext", "DBType": "SQLite" //DataBase, you can choose mysql,sqlserver,pgsql,sqlite,oracle } diff --git a/IoTGateway/iotgateway.db b/IoTGateway/data/iotgateway.db similarity index 69% rename from IoTGateway/iotgateway.db rename to IoTGateway/data/iotgateway.db index 851daa3..d538f51 100644 Binary files a/IoTGateway/iotgateway.db and b/IoTGateway/data/iotgateway.db differ