diff --git a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 index cf75876..115715d 100644 Binary files a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 and b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/IoTGateway/v17/.futdcache.v1 b/.vs/IoTGateway/v17/.futdcache.v1 index 863778e..87e8746 100644 Binary files a/.vs/IoTGateway/v17/.futdcache.v1 and b/.vs/IoTGateway/v17/.futdcache.v1 differ diff --git a/.vs/IoTGateway/v17/.suo b/.vs/IoTGateway/v17/.suo index 3d423f6..2ff88bb 100644 Binary files a/.vs/IoTGateway/v17/.suo and b/.vs/IoTGateway/v17/.suo differ diff --git a/.vs/IoTGateway/v17/fileList.bin b/.vs/IoTGateway/v17/fileList.bin index a408187..eedc452 100644 Binary files a/.vs/IoTGateway/v17/fileList.bin and b/.vs/IoTGateway/v17/fileList.bin differ diff --git a/IoTGateway.DataAccess/Migrations/20220517053158_changepublish.Designer.cs b/IoTGateway.DataAccess/Migrations/20220517053158_changepublish.Designer.cs new file mode 100644 index 0000000..186ee21 --- /dev/null +++ b/IoTGateway.DataAccess/Migrations/20220517053158_changepublish.Designer.cs @@ -0,0 +1,853 @@ +// +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("20220517053158_changepublish")] + partial class changepublish + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.1"); + + modelBuilder.Entity("IoTGateway.Model.Device", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AutoStart") + .HasColumnType("INTEGER"); + + b.Property("CgUpload") + .HasColumnType("INTEGER"); + + b.Property("CreateBy") + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DeviceName") + .HasColumnType("TEXT"); + + b.Property("DeviceTypeEnum") + .HasColumnType("INTEGER"); + + b.Property("DriverId") + .HasColumnType("TEXT"); + + b.Property("EnforcePeriod") + .HasColumnType("INTEGER"); + + b.Property("Index") + .HasColumnType("INTEGER"); + + b.Property("ParentId") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("DriverId"); + + b.HasIndex("ParentId"); + + b.ToTable("Devices"); + }); + + 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"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DeviceConfigName") + .HasColumnType("TEXT"); + + b.Property("DeviceId") + .HasColumnType("TEXT"); + + b.Property("EnumInfo") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("DeviceId"); + + b.ToTable("DeviceConfigs"); + }); + + modelBuilder.Entity("IoTGateway.Model.DeviceVariable", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("DataType") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DeviceAddress") + .HasColumnType("TEXT"); + + b.Property("DeviceId") + .HasColumnType("TEXT"); + + b.Property("Expressions") + .HasColumnType("TEXT"); + + b.Property("Method") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ProtectType") + .HasColumnType("INTEGER"); + + b.HasKey("ID"); + + b.HasIndex("DeviceId"); + + b.ToTable("DeviceVariables"); + }); + + modelBuilder.Entity("IoTGateway.Model.Driver", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AssembleName") + .HasColumnType("TEXT"); + + b.Property("AuthorizesNum") + .HasColumnType("INTEGER"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("DriverName") + .HasColumnType("TEXT"); + + b.Property("FileName") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("Drivers"); + }); + + modelBuilder.Entity("IoTGateway.Model.RpcLog", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DeviceId") + .HasColumnType("TEXT"); + + b.Property("EndTime") + .HasColumnType("TEXT"); + + b.Property("IsSuccess") + .HasColumnType("INTEGER"); + + b.Property("Method") + .HasColumnType("TEXT"); + + b.Property("Params") + .HasColumnType("TEXT"); + + b.Property("RpcSide") + .HasColumnType("INTEGER"); + + b.Property("StartTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("DeviceId"); + + b.ToTable("RpcLogs"); + }); + + modelBuilder.Entity("IoTGateway.Model.SystemConfig", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("GatewayName") + .HasColumnType("TEXT"); + + b.Property("IoTPlatformType") + .HasColumnType("INTEGER"); + + b.Property("MqttIp") + .HasColumnType("TEXT"); + + b.Property("MqttPort") + .HasColumnType("INTEGER"); + + b.Property("MqttUName") + .HasColumnType("TEXT"); + + b.Property("MqttUPwd") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("SystemConfig"); + }); + + 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/20220517053158_changepublish.cs b/IoTGateway.DataAccess/Migrations/20220517053158_changepublish.cs new file mode 100644 index 0000000..eef5400 --- /dev/null +++ b/IoTGateway.DataAccess/Migrations/20220517053158_changepublish.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IoTGateway.DataAccess.Migrations +{ + public partial class changepublish : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CgUpload", + table: "Devices", + type: "INTEGER", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "EnforcePeriod", + table: "Devices", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CgUpload", + table: "Devices"); + + migrationBuilder.DropColumn( + name: "EnforcePeriod", + table: "Devices"); + } + } +} diff --git a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs index 3f6f2b9..38d417e 100644 --- a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs +++ b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs @@ -26,6 +26,9 @@ namespace IoTGateway.DataAccess.Migrations b.Property("AutoStart") .HasColumnType("INTEGER"); + b.Property("CgUpload") + .HasColumnType("INTEGER"); + b.Property("CreateBy") .HasColumnType("TEXT"); @@ -44,6 +47,9 @@ namespace IoTGateway.DataAccess.Migrations b.Property("DriverId") .HasColumnType("TEXT"); + b.Property("EnforcePeriod") + .HasColumnType("INTEGER"); + b.Property("Index") .HasColumnType("INTEGER"); diff --git a/IoTGateway.Model/Device.cs b/IoTGateway.Model/Device.cs index 911303e..7a5cb7d 100644 --- a/IoTGateway.Model/Device.cs +++ b/IoTGateway.Model/Device.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using WalkingTec.Mvvm.Core; namespace IoTGateway.Model @@ -23,9 +20,15 @@ namespace IoTGateway.Model [Display(Name = "驱动")] public Guid? DriverId { get; set; } - [Display(Name = "自启动")] + [Display(Name = "启动")] public bool AutoStart { get; set; } + [Display(Name = "变化上传")] + public bool CgUpload { get; set; } + + [Display(Name = "归档周期ms")] + public uint EnforcePeriod { get; set; } + [Display(Name = "类型")] public DeviceTypeEnum DeviceTypeEnum { get; set; } diff --git a/IoTGateway.ViewModel/BasicData/DeviceVMs/CopyVM.cs b/IoTGateway.ViewModel/BasicData/DeviceVMs/CopyVM.cs index e8e121c..8bcd0f8 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceVMs/CopyVM.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceVMs/CopyVM.cs @@ -38,6 +38,8 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVMs ID = Guid.NewGuid(), DeviceName = $"{device.DeviceName}-Copy{i}", AutoStart = false, + CgUpload = device.CgUpload, + EnforcePeriod = device.EnforcePeriod, ParentId = device.ParentId, CreateBy = this.Wtm.LoginUserInfo.Name, CreateTime = DateTime.Now, diff --git a/IoTGateway.ViewModel/BasicData/DeviceVMs/DeviceListVM.cs b/IoTGateway.ViewModel/BasicData/DeviceVMs/DeviceListVM.cs index 84315e4..d1135fc 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceVMs/DeviceListVM.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceVMs/DeviceListVM.cs @@ -37,11 +37,13 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVMs return new List>{ this.MakeGridHeader(x => x.DeviceName), this.MakeGridHeader(x => x.Index), - this.MakeGridHeader(x => x.Description), + //this.MakeGridHeader(x => x.Description), this.MakeGridHeader(x => x.DriverName_view), this.MakeGridHeader(x => x.AutoStart), + this.MakeGridHeader(x => x.CgUpload), + this.MakeGridHeader(x => x.EnforcePeriod), this.MakeGridHeader(x => x.DeviceTypeEnum), - this.MakeGridHeader(x => x.DeviceName_view), + //this.MakeGridHeader(x => x.DeviceName_view), this.MakeGridHeader(x=>"copy").SetHide().SetFormat((a,b)=>{ if(a.DeviceTypeEnum== DeviceTypeEnum.Device) return "true"; @@ -52,7 +54,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVMs return "true"; return "false"; }), - this.MakeGridHeaderAction(width: 280) + this.MakeGridHeaderAction(width: 300) }; } @@ -96,6 +98,8 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVMs Index = y.Index, DeviceName = "    " + y.DeviceName, AutoStart = y.AutoStart, + CgUpload = y.CgUpload, + EnforcePeriod = y.EnforcePeriod, Description = y.Description, DeviceTypeEnum = y.DeviceTypeEnum, DriverName_view = y.Driver?.DriverName, diff --git a/IoTGateway/Areas/BasicData/Views/Device/Create.cshtml b/IoTGateway/Areas/BasicData/Views/Device/Create.cshtml index 4d8abe3..6aafbc2 100644 --- a/IoTGateway/Areas/BasicData/Views/Device/Create.cshtml +++ b/IoTGateway/Areas/BasicData/Views/Device/Create.cshtml @@ -2,15 +2,17 @@ @inject IStringLocalizer Localizer; - - - - - - - - - + + + + + + + + + + + diff --git a/IoTGateway/Areas/BasicData/Views/Device/Edit.cshtml b/IoTGateway/Areas/BasicData/Views/Device/Edit.cshtml index e89dc3e..915603c 100644 --- a/IoTGateway/Areas/BasicData/Views/Device/Edit.cshtml +++ b/IoTGateway/Areas/BasicData/Views/Device/Edit.cshtml @@ -13,6 +13,8 @@ + + } } diff --git a/IoTGateway/iotgateway.db b/IoTGateway/iotgateway.db index 17446f0..5900ba8 100644 Binary files a/IoTGateway/iotgateway.db and b/IoTGateway/iotgateway.db differ diff --git a/Plugins/Plugin/MyMqttClient.cs b/Plugins/Plugin/MyMqttClient.cs index 462d7c2..9e43c3c 100644 --- a/Plugins/Plugin/MyMqttClient.cs +++ b/Plugins/Plugin/MyMqttClient.cs @@ -329,6 +329,7 @@ namespace Plugin var toSend = new Dictionary { { _devicename, obj } }; return Client.PublishAsync("gateway/attributes", JsonConvert.SerializeObject(toSend)); } + public void ResponseRpc(RpcResponse rpcResponse) { try @@ -418,34 +419,83 @@ namespace Plugin return Task.CompletedTask; } + private Dictionary> LastTelemetrys = new(0); + + /// + /// 判断是否推送遥测数据 + /// + /// 设备 + /// 遥测 + /// + private bool CanPubTelemetry(Device device, Dictionary> SendModel) + { + bool canPub = false; + try + { + //第一次上传 + if (!LastTelemetrys.ContainsKey(device.DeviceName)) + canPub = true; + else + { + //变化上传 + if (device.CgUpload) + { + //是否超过归档周期 + if (SendModel[device.DeviceName][0].TS - LastTelemetrys[device.DeviceName][0].TS > device.EnforcePeriod) + canPub = true; + //是否变化 + else + { + if (JsonConvert.SerializeObject(SendModel[device.DeviceName]) != JsonConvert.SerializeObject(LastTelemetrys[device.DeviceName])) + canPub = true; + + } + } + //非变化上传 + else + canPub = true; + } + } + catch (Exception e) + { + canPub = true; + Console.WriteLine(e); + } + LastTelemetrys[device.DeviceName] = SendModel[device.DeviceName]; + return canPub; + } public void PublishTelemetry(Device device, Dictionary> SendModel) { try { - switch (_systemConfig.IoTPlatformType) + if (CanPubTelemetry(device, SendModel)) { - case IoTPlatformType.ThingsBoard: - Client.PublishAsync("v1/gateway/telemetry", JsonConvert.SerializeObject(SendModel)); - break; - case IoTPlatformType.IoTSharp: - foreach (var payload in SendModel[device.DeviceName]) - { - UploadISTelemetryDataAsync(device.DeviceName, payload.Values); - } - break; - case IoTPlatformType.ThingsCloud: - foreach (var payload in SendModel[device.DeviceName]) - { - UploadTCTelemetryDataAsync(device.DeviceName, payload.Values); - } - break; - case IoTPlatformType.AliCloudIoT: - case IoTPlatformType.TencentIoTHub: - case IoTPlatformType.BaiduIoTCore: - case IoTPlatformType.OneNET: - default: - break; + switch (_systemConfig.IoTPlatformType) + { + case IoTPlatformType.ThingsBoard: + Client.PublishAsync("v1/gateway/telemetry", JsonConvert.SerializeObject(SendModel)); + break; + case IoTPlatformType.IoTSharp: + foreach (var payload in SendModel[device.DeviceName]) + { + UploadISTelemetryDataAsync(device.DeviceName, payload.Values); + } + break; + case IoTPlatformType.ThingsCloud: + foreach (var payload in SendModel[device.DeviceName]) + { + UploadTCTelemetryDataAsync(device.DeviceName, payload.Values); + } + break; + case IoTPlatformType.AliCloudIoT: + case IoTPlatformType.TencentIoTHub: + case IoTPlatformType.BaiduIoTCore: + case IoTPlatformType.OneNET: + default: + break; + } } + foreach (var payload in SendModel[device.DeviceName]) { foreach (var kv in payload.Values) diff --git a/iotgateway.db b/iotgateway.db index 17446f0..5900ba8 100644 Binary files a/iotgateway.db and b/iotgateway.db differ