From f1cb86d12deb75f447a9d12c961c7f425441cd34 Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Sun, 3 Jul 2022 11:09:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=BC=96=E8=BE=91=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/Enmus.cs | 1 + Data/ModbusSlave.cs | 2 +- Data/PointMapping.cs | 1 + IoTSharp.Gateway.Modbus.csproj | 3 +-- Pages/PointMapAdmin/Create.cshtml | 8 ++++---- Pages/PointMapAdmin/Edit.cshtml | 6 +++--- Pages/PointMapAdmin/Index.cshtml.cs | 6 +++--- Pages/Shared/_Layout.cshtml | 13 ++++++++++++- Pages/SlaveAdmin/Index.cshtml | 1 + Program.cs | 21 ++++++--------------- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Data/Enmus.cs b/Data/Enmus.cs index 8227ba9..2663b27 100644 --- a/Data/Enmus.cs +++ b/Data/Enmus.cs @@ -19,6 +19,7 @@ namespace IoTSharp.Gateway.Modbus.Data } [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] [JsonConverter(typeof(StringEnumConverter))] + public enum DataType { Boolean, diff --git a/Data/ModbusSlave.cs b/Data/ModbusSlave.cs index 20f5665..590d72b 100644 --- a/Data/ModbusSlave.cs +++ b/Data/ModbusSlave.cs @@ -34,6 +34,6 @@ namespace IoTSharp.Gateway.Modbus.Data /// public string? DeviceNameFormat { get; set; } - public List? PointMappings { get; set; } + public List? PointMappings { get; set; } = new List(); } } diff --git a/Data/PointMapping.cs b/Data/PointMapping.cs index cce15db..a87aa09 100644 --- a/Data/PointMapping.cs +++ b/Data/PointMapping.cs @@ -17,6 +17,7 @@ namespace IoTSharp.Gateway.Modbus.Data /// 如果是DataType为String, 则需指定编码格式CodePage, /// 如果是DataType为Double, 如果Length是2个寄存器就是4个字节, 则是float, 如果是4个寄存器那就是8个字节, 就是double, /// + public DataType DataType { get; set; } /// /// 数据分类 diff --git a/IoTSharp.Gateway.Modbus.csproj b/IoTSharp.Gateway.Modbus.csproj index 9a7bc73..b87704b 100644 --- a/IoTSharp.Gateway.Modbus.csproj +++ b/IoTSharp.Gateway.Modbus.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -26,7 +26,6 @@ - diff --git a/Pages/PointMapAdmin/Create.cshtml b/Pages/PointMapAdmin/Create.cshtml index 90dd519..322ee59 100644 --- a/Pages/PointMapAdmin/Create.cshtml +++ b/Pages/PointMapAdmin/Create.cshtml @@ -1,6 +1,6 @@ @page @model IoTSharp.Gateway.Modbus.Pages.PointMapAdmin.CreateModel - +@using IoTSharp.Gateway.Modbus.Data; @{ ViewData["Title"] = "Create"; } @@ -20,17 +20,17 @@
- +
- +
- +
diff --git a/Pages/PointMapAdmin/Edit.cshtml b/Pages/PointMapAdmin/Edit.cshtml index e153564..cc47137 100644 --- a/Pages/PointMapAdmin/Edit.cshtml +++ b/Pages/PointMapAdmin/Edit.cshtml @@ -21,17 +21,17 @@
- +
- +
- +
diff --git a/Pages/PointMapAdmin/Index.cshtml.cs b/Pages/PointMapAdmin/Index.cshtml.cs index 0b0570b..6537b49 100644 --- a/Pages/PointMapAdmin/Index.cshtml.cs +++ b/Pages/PointMapAdmin/Index.cshtml.cs @@ -20,11 +20,11 @@ namespace IoTSharp.Gateway.Modbus.Pages.PointMapAdmin public IList PointMapping { get;set; } = default!; - public async Task OnGetAsync() + public async Task OnGetAsync(Guid? id) { - if (_context.PointMappings != null) + if (_context.PointMappings != null && id!=null) { - PointMapping = await _context.PointMappings.ToListAsync(); + PointMapping = await _context.PointMappings.Include(pt => pt.Owner).Where(fm => fm.Owner!=null && fm.Owner.Id == id).ToListAsync(); } } } diff --git a/Pages/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml index b137d08..d4499d9 100644 --- a/Pages/Shared/_Layout.cshtml +++ b/Pages/Shared/_Layout.cshtml @@ -1,4 +1,8 @@ - +@using Microsoft.AspNetCore.Identity +@inject SignInManager SignInManager +@inject UserManager UserManager + + @@ -22,6 +26,13 @@ + @if (SignInManager.IsSignedIn(User)) + { + + + } diff --git a/Pages/SlaveAdmin/Index.cshtml b/Pages/SlaveAdmin/Index.cshtml index 770ef0c..a9c4d21 100644 --- a/Pages/SlaveAdmin/Index.cshtml +++ b/Pages/SlaveAdmin/Index.cshtml @@ -45,6 +45,7 @@ Edit | + 点位映射 | Details | Delete diff --git a/Program.cs b/Program.cs index c01ccec..7cbe38c 100644 --- a/Program.cs +++ b/Program.cs @@ -1,7 +1,7 @@ using IoTSharp.Gateway.Modbus.Data; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; -using SilkierQuartz; + namespace IoTSharp.Gateway.Modbus { @@ -18,19 +18,10 @@ namespace IoTSharp.Gateway.Modbus builder.Services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount=false) .AddEntityFrameworkStores(); - builder.Services.AddRazorPages(); - builder.Services.AddSilkierQuartz(option => - { - option.VirtualPathRoot = "/SilkierQuartz"; - option.UseLocalTime = true; - option.DefaultDateFormat = "yyyy-MM-dd"; - option.DefaultTimeFormat = "HH:mm:ss"; - }, auth=> - { - auth.AccessRequirement = SilkierQuartzAuthenticationOptions.SimpleAccessRequirement.AllowAnonymous; - }); + + - + builder.Services.AddRazorPages(); var app = builder.Build(); // Configure the HTTP request pipeline. @@ -52,10 +43,10 @@ namespace IoTSharp.Gateway.Modbus app.UseAuthentication(); app.UseAuthorization(); - app.UseSilkierQuartz(); + app.MapRazorPages(); - + app.Run(); } }