添加管理页面

master
MysticBoy 3 years ago
parent 7c8195f8f1
commit 7bd515ff8e

1
.gitignore vendored

@ -7,3 +7,4 @@
/obj
/SQlLiteDatabase.db
/IoTSharp.Gateway.Modbus.csproj.user
/.vs/ProjectEvaluation

@ -9,5 +9,9 @@ namespace IoTSharp.Gateway.Modbus.Data
: base(options)
{
}
public DbSet<ModbusSlave> ModbusSlaves { get; set; }
public DbSet<PointMapping> PointMappings { get; set; }
}
}

@ -0,0 +1,37 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace IoTSharp.Gateway.Modbus.Data
{
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
[JsonConverter(typeof(StringEnumConverter))]
public enum FunCode
{
ReadCoils =1,
ReadDiscreteInputs=2,
ReadMultipleHoldingRegisters = 3,
ReadInputRegisters=4,
WriteSingleCoil=5,
WriteSingleHoldingRegister=6,
WriteMultipleCoils=15,
WriteMultipleHoldingRegisters=16
}
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
[JsonConverter(typeof(StringEnumConverter))]
public enum DataType
{
Boolean,
String,
Long,
Double,
DateTime
}
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
[JsonConverter(typeof(StringEnumConverter))]
public enum DataCatalog
{
AttributeData,
TelemetryData,
}
}

@ -0,0 +1,351 @@
// <auto-generated />
using System;
using IoTSharp.Gateway.Modbus.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace IoTSharp.Gateway.Modbus.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20220626162542_ModBusDataMapping")]
partial class ModBusDataMapping
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.6");
modelBuilder.Entity("IoTSharp.Gateway.Modbus.Data.ModbusSlave", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("DeviceName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DeviceNameFormat")
.HasColumnType("TEXT");
b.Property<string>("Slave")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("TimeOut")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("ModbusSlaves");
});
modelBuilder.Entity("IoTSharp.Gateway.Modbus.Data.PointMapping", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<int>("Address")
.HasColumnType("INTEGER");
b.Property<int>("CodePage")
.HasColumnType("INTEGER");
b.Property<int>("DataCatalog")
.HasColumnType("INTEGER");
b.Property<string>("DataName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("DataType")
.HasColumnType("INTEGER");
b.Property<string>("DateTimeFormat")
.HasColumnType("TEXT");
b.Property<int>("FunCode")
.HasColumnType("INTEGER");
b.Property<int>("Length")
.HasColumnType("INTEGER");
b.Property<Guid?>("OwnerId")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("PointMappings");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("AccessFailedCount")
.HasColumnType("INTEGER");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<bool>("EmailConfirmed")
.HasColumnType("INTEGER");
b.Property<bool>("LockoutEnabled")
.HasColumnType("INTEGER");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("TEXT");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("PasswordHash")
.HasColumnType("TEXT");
b.Property<string>("PhoneNumber")
.HasColumnType("TEXT");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("SecurityStamp")
.HasColumnType("TEXT");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("ProviderDisplayName")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.HasColumnType("TEXT");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("Value")
.HasColumnType("TEXT");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("IoTSharp.Gateway.Modbus.Data.PointMapping", b =>
{
b.HasOne("IoTSharp.Gateway.Modbus.Data.ModbusSlave", "Owner")
.WithMany("PointMappings")
.HasForeignKey("OwnerId");
b.Navigation("Owner");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", 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<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IoTSharp.Gateway.Modbus.Data.ModbusSlave", b =>
{
b.Navigation("PointMappings");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,67 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IoTSharp.Gateway.Modbus.Migrations
{
public partial class ModBusDataMapping : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ModbusSlaves",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Slave = table.Column<string>(type: "TEXT", nullable: false),
TimeOut = table.Column<int>(type: "INTEGER", nullable: false),
DeviceName = table.Column<string>(type: "TEXT", nullable: false),
DeviceNameFormat = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ModbusSlaves", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PointMappings",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
DataName = table.Column<string>(type: "TEXT", nullable: false),
DataType = table.Column<int>(type: "INTEGER", nullable: false),
DataCatalog = table.Column<int>(type: "INTEGER", nullable: false),
FunCode = table.Column<int>(type: "INTEGER", nullable: false),
Address = table.Column<int>(type: "INTEGER", nullable: false),
Length = table.Column<int>(type: "INTEGER", nullable: false),
DateTimeFormat = table.Column<string>(type: "TEXT", nullable: true),
CodePage = table.Column<int>(type: "INTEGER", nullable: false),
OwnerId = table.Column<Guid>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PointMappings", x => x.Id);
table.ForeignKey(
name: "FK_PointMappings_ModbusSlaves_OwnerId",
column: x => x.OwnerId,
principalTable: "ModbusSlaves",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_PointMappings_OwnerId",
table: "PointMappings",
column: "OwnerId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PointMappings");
migrationBuilder.DropTable(
name: "ModbusSlaves");
}
}
}

@ -17,6 +17,72 @@ namespace IoTSharp.Gateway.Modbus.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.6");
modelBuilder.Entity("IoTSharp.Gateway.Modbus.Data.ModbusSlave", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("DeviceName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DeviceNameFormat")
.HasColumnType("TEXT");
b.Property<string>("Slave")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("TimeOut")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("ModbusSlaves");
});
modelBuilder.Entity("IoTSharp.Gateway.Modbus.Data.PointMapping", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<int>("Address")
.HasColumnType("INTEGER");
b.Property<int>("CodePage")
.HasColumnType("INTEGER");
b.Property<int>("DataCatalog")
.HasColumnType("INTEGER");
b.Property<string>("DataName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("DataType")
.HasColumnType("INTEGER");
b.Property<string>("DateTimeFormat")
.HasColumnType("TEXT");
b.Property<int>("FunCode")
.HasColumnType("INTEGER");
b.Property<int>("Length")
.HasColumnType("INTEGER");
b.Property<Guid?>("OwnerId")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("PointMappings");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
@ -213,6 +279,15 @@ namespace IoTSharp.Gateway.Modbus.Migrations
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("IoTSharp.Gateway.Modbus.Data.PointMapping", b =>
{
b.HasOne("IoTSharp.Gateway.Modbus.Data.ModbusSlave", "Owner")
.WithMany("PointMappings")
.HasForeignKey("OwnerId");
b.Navigation("Owner");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
@ -263,6 +338,11 @@ namespace IoTSharp.Gateway.Modbus.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IoTSharp.Gateway.Modbus.Data.ModbusSlave", b =>
{
b.Navigation("PointMappings");
});
#pragma warning restore 612, 618
}
}

@ -0,0 +1,39 @@
using System.ComponentModel.DataAnnotations;
namespace IoTSharp.Gateway.Modbus.Data
{
public class ModbusSlave
{
[Key]
public Guid Id { get; set; }
/// <summary>
///
/// </summary>
/// <example>
/// DTU: dtu://dev.ttyS0:115200
/// DTU: dtu://COM1:115200
/// TCP: tcp://www.host.com:602
// DTU over TCP: DTUoverTCP://www.host.com:602
/// </example>
[Required]
public Uri Slave { get; set; }
/// <summary>
/// 连接超时和读取写入超时 按秒
/// </summary>
public int TimeOut { get; set; }
[Required]
public string DeviceName { get; set; }
/// <summary>
/// 如果为空, 则直接使用 DeviceName ,
/// 否则, 使用 PointMapping 里面的 映射ID作为设备名称。 {Name}-{ID} , 前提是PointMappings中要有 如果没有, 则为空。
/// </summary>
public string? DeviceNameFormat { get; set; }
public List<PointMapping>? PointMappings { get; set; }
}
}

@ -0,0 +1,47 @@
using System.ComponentModel.DataAnnotations;
namespace IoTSharp.Gateway.Modbus.Data
{
public class PointMapping
{
[Key]
public Guid Id { get; set; }
[Required]
public string DataName { get; set; }
/// <summary>
/// 如果是DataType为 Long , 如果是Length一个寄存器那么就是int16 , 如果是2个寄存器 就是 in32, 如果是4个寄存器 int64 4字节就是int64
/// 如果是DataType为DateTime 如果Lenght为 4 就是 秒时间戳, 如果超过4 字节, 则需指定时间格式 yyyyMMddHHmmss
/// 如果是DataType为String 则需指定编码格式CodePage
/// 如果是DataType为Double 如果Length是2个寄存器就是4个字节 则是float 如果是4个寄存器那就是8个字节 就是double
/// </summary>
public DataType DataType { get; set; }
/// <summary>
/// 数据分类
/// </summary>
public DataCatalog DataCatalog { get; set; }
public FunCode FunCode { get; set; }
public int Address { get; set; }
/// <summary>
/// 如果是读取寄存器, 那么一个寄存器就是2字节 如果是线圈, 那就是 1位。 一个字节为 8位。
/// </summary>
public int Length { get; set; }
/// <summary>
/// 默认不转换
/// </summary>
public string? DateTimeFormat { get; set; }
/// <summary>
/// 默认 65001 简体中文 936 繁体 950
/// </summary>
public int CodePage { get; set; } = 65001;
public ModbusSlave? Owner { get; set; }
}
}

@ -14,17 +14,19 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AMWD.Modbus.Common" Version="1.2.0" />
<PackageReference Include="AMWD.Modbus.Proxy" Version="1.2.0" />
<PackageReference Include="AMWD.Modbus.Serial" Version="1.2.0" />
<PackageReference Include="AMWD.Modbus.Tcp" Version="1.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.6" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.16.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\Migrations\" />
<Folder Include="Migrations\" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.6" />
<PackageReference Include="SilkierQuartz" Version="5.0.356" />
</ItemGroup>
</Project>

@ -0,0 +1,6 @@
namespace IoTSharp.Gateway.Modbus.Jobs
{
public class ModbusPoll
{
}
}

@ -0,0 +1,69 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.PointMapAdmin.CreateModel
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>PointMapping</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="PointMapping.DataName" class="control-label"></label>
<input asp-for="PointMapping.DataName" class="form-control" />
<span asp-validation-for="PointMapping.DataName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.DataType" class="control-label"></label>
<select asp-for="PointMapping.DataType" class="form-control"></select>
<span asp-validation-for="PointMapping.DataType" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.DataCatalog" class="control-label"></label>
<select asp-for="PointMapping.DataCatalog" class="form-control"></select>
<span asp-validation-for="PointMapping.DataCatalog" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.FunCode" class="control-label"></label>
<select asp-for="PointMapping.FunCode" class="form-control"></select>
<span asp-validation-for="PointMapping.FunCode" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.Address" class="control-label"></label>
<input asp-for="PointMapping.Address" class="form-control" />
<span asp-validation-for="PointMapping.Address" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.Length" class="control-label"></label>
<input asp-for="PointMapping.Length" class="form-control" />
<span asp-validation-for="PointMapping.Length" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.DateTimeFormat" class="control-label"></label>
<input asp-for="PointMapping.DateTimeFormat" class="form-control" />
<span asp-validation-for="PointMapping.DateTimeFormat" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.CodePage" class="control-label"></label>
<input asp-for="PointMapping.CodePage" class="form-control" />
<span asp-validation-for="PointMapping.CodePage" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.PointMapAdmin
{
public class CreateModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public CreateModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
public IActionResult OnGet()
{
return Page();
}
[BindProperty]
public PointMapping PointMapping { get; set; } = default!;
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid || _context.PointMappings == null || PointMapping == null)
{
return Page();
}
_context.PointMappings.Add(PointMapping);
await _context.SaveChangesAsync();
return RedirectToPage("./Index");
}
}
}

@ -0,0 +1,70 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.PointMapAdmin.DeleteModel
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>PointMapping</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.DataName)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.DataName)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.DataType)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.DataType)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.DataCatalog)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.DataCatalog)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.FunCode)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.FunCode)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.Address)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.Address)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.Length)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.Length)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.DateTimeFormat)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.DateTimeFormat)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.CodePage)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.CodePage)
</dd>
</dl>
<form method="post">
<input type="hidden" asp-for="PointMapping.Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>
</div>

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.PointMapAdmin
{
public class DeleteModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public DeleteModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
[BindProperty]
public PointMapping PointMapping { get; set; } = default!;
public async Task<IActionResult> OnGetAsync(Guid? id)
{
if (id == null || _context.PointMappings == null)
{
return NotFound();
}
var pointmapping = await _context.PointMappings.FirstOrDefaultAsync(m => m.Id == id);
if (pointmapping == null)
{
return NotFound();
}
else
{
PointMapping = pointmapping;
}
return Page();
}
public async Task<IActionResult> OnPostAsync(Guid? id)
{
if (id == null || _context.PointMappings == null)
{
return NotFound();
}
var pointmapping = await _context.PointMappings.FindAsync(id);
if (pointmapping != null)
{
PointMapping = pointmapping;
_context.PointMappings.Remove(PointMapping);
await _context.SaveChangesAsync();
}
return RedirectToPage("./Index");
}
}
}

@ -0,0 +1,67 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.PointMapAdmin.DetailsModel
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>PointMapping</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.DataName)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.DataName)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.DataType)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.DataType)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.DataCatalog)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.DataCatalog)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.FunCode)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.FunCode)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.Address)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.Address)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.Length)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.Length)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.DateTimeFormat)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.DateTimeFormat)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.PointMapping.CodePage)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PointMapping.CodePage)
</dd>
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.PointMapping?.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.PointMapAdmin
{
public class DetailsModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public DetailsModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
public PointMapping PointMapping { get; set; } = default!;
public async Task<IActionResult> OnGetAsync(Guid? id)
{
if (id == null || _context.PointMappings == null)
{
return NotFound();
}
var pointmapping = await _context.PointMappings.FirstOrDefaultAsync(m => m.Id == id);
if (pointmapping == null)
{
return NotFound();
}
else
{
PointMapping = pointmapping;
}
return Page();
}
}
}

@ -0,0 +1,70 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.PointMapAdmin.EditModel
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>PointMapping</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="PointMapping.Id" />
<div class="form-group">
<label asp-for="PointMapping.DataName" class="control-label"></label>
<input asp-for="PointMapping.DataName" class="form-control" />
<span asp-validation-for="PointMapping.DataName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.DataType" class="control-label"></label>
<select asp-for="PointMapping.DataType" class="form-control"></select>
<span asp-validation-for="PointMapping.DataType" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.DataCatalog" class="control-label"></label>
<select asp-for="PointMapping.DataCatalog" class="form-control"></select>
<span asp-validation-for="PointMapping.DataCatalog" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.FunCode" class="control-label"></label>
<select asp-for="PointMapping.FunCode" class="form-control"></select>
<span asp-validation-for="PointMapping.FunCode" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.Address" class="control-label"></label>
<input asp-for="PointMapping.Address" class="form-control" />
<span asp-validation-for="PointMapping.Address" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.Length" class="control-label"></label>
<input asp-for="PointMapping.Length" class="form-control" />
<span asp-validation-for="PointMapping.Length" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.DateTimeFormat" class="control-label"></label>
<input asp-for="PointMapping.DateTimeFormat" class="form-control" />
<span asp-validation-for="PointMapping.DateTimeFormat" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PointMapping.CodePage" class="control-label"></label>
<input asp-for="PointMapping.CodePage" class="form-control" />
<span asp-validation-for="PointMapping.CodePage" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="./Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.PointMapAdmin
{
public class EditModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public EditModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
[BindProperty]
public PointMapping PointMapping { get; set; } = default!;
public async Task<IActionResult> OnGetAsync(Guid? id)
{
if (id == null || _context.PointMappings == null)
{
return NotFound();
}
var pointmapping = await _context.PointMappings.FirstOrDefaultAsync(m => m.Id == id);
if (pointmapping == null)
{
return NotFound();
}
PointMapping = pointmapping;
return Page();
}
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Attach(PointMapping).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!PointMappingExists(PointMapping.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToPage("./Index");
}
private bool PointMappingExists(Guid id)
{
return (_context.PointMappings?.Any(e => e.Id == id)).GetValueOrDefault();
}
}
}

@ -0,0 +1,78 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.PointMapAdmin.IndexModel
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<p>
<a asp-page="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.PointMapping[0].DataName)
</th>
<th>
@Html.DisplayNameFor(model => model.PointMapping[0].DataType)
</th>
<th>
@Html.DisplayNameFor(model => model.PointMapping[0].DataCatalog)
</th>
<th>
@Html.DisplayNameFor(model => model.PointMapping[0].FunCode)
</th>
<th>
@Html.DisplayNameFor(model => model.PointMapping[0].Address)
</th>
<th>
@Html.DisplayNameFor(model => model.PointMapping[0].Length)
</th>
<th>
@Html.DisplayNameFor(model => model.PointMapping[0].DateTimeFormat)
</th>
<th>
@Html.DisplayNameFor(model => model.PointMapping[0].CodePage)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.PointMapping) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.DataName)
</td>
<td>
@Html.DisplayFor(modelItem => item.DataType)
</td>
<td>
@Html.DisplayFor(modelItem => item.DataCatalog)
</td>
<td>
@Html.DisplayFor(modelItem => item.FunCode)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.Length)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateTimeFormat)
</td>
<td>
@Html.DisplayFor(modelItem => item.CodePage)
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.PointMapAdmin
{
public class IndexModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public IndexModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
public IList<PointMapping> PointMapping { get;set; } = default!;
public async Task OnGetAsync()
{
if (_context.PointMappings != null)
{
PointMapping = await _context.PointMappings.ToListAsync();
}
}
}
}

@ -0,0 +1,49 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.SlaveAdmin.CreateModel
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>ModbusSlave</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="ModbusSlave.Slave" class="control-label"></label>
<input asp-for="ModbusSlave.Slave" class="form-control" />
<span asp-validation-for="ModbusSlave.Slave" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ModbusSlave.TimeOut" class="control-label"></label>
<input asp-for="ModbusSlave.TimeOut" class="form-control" />
<span asp-validation-for="ModbusSlave.TimeOut" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ModbusSlave.DeviceName" class="control-label"></label>
<input asp-for="ModbusSlave.DeviceName" class="form-control" />
<span asp-validation-for="ModbusSlave.DeviceName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ModbusSlave.DeviceNameFormat" class="control-label"></label>
<input asp-for="ModbusSlave.DeviceNameFormat" class="form-control" />
<span asp-validation-for="ModbusSlave.DeviceNameFormat" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.SlaveAdmin
{
public class CreateModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public CreateModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
public IActionResult OnGet()
{
return Page();
}
[BindProperty]
public ModbusSlave ModbusSlave { get; set; } = default!;
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid || _context.ModbusSlaves == null || ModbusSlave == null)
{
return Page();
}
_context.ModbusSlaves.Add(ModbusSlave);
await _context.SaveChangesAsync();
return RedirectToPage("./Index");
}
}
}

@ -0,0 +1,46 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.SlaveAdmin.DeleteModel
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>ModbusSlave</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ModbusSlave.Slave)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ModbusSlave.Slave)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ModbusSlave.TimeOut)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ModbusSlave.TimeOut)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ModbusSlave.DeviceName)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ModbusSlave.DeviceName)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ModbusSlave.DeviceNameFormat)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ModbusSlave.DeviceNameFormat)
</dd>
</dl>
<form method="post">
<input type="hidden" asp-for="ModbusSlave.Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>
</div>

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.SlaveAdmin
{
public class DeleteModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public DeleteModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
[BindProperty]
public ModbusSlave ModbusSlave { get; set; } = default!;
public async Task<IActionResult> OnGetAsync(Guid? id)
{
if (id == null || _context.ModbusSlaves == null)
{
return NotFound();
}
var modbusslave = await _context.ModbusSlaves.FirstOrDefaultAsync(m => m.Id == id);
if (modbusslave == null)
{
return NotFound();
}
else
{
ModbusSlave = modbusslave;
}
return Page();
}
public async Task<IActionResult> OnPostAsync(Guid? id)
{
if (id == null || _context.ModbusSlaves == null)
{
return NotFound();
}
var modbusslave = await _context.ModbusSlaves.FindAsync(id);
if (modbusslave != null)
{
ModbusSlave = modbusslave;
_context.ModbusSlaves.Remove(ModbusSlave);
await _context.SaveChangesAsync();
}
return RedirectToPage("./Index");
}
}
}

@ -0,0 +1,43 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.SlaveAdmin.DetailsModel
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>ModbusSlave</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ModbusSlave.Slave)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ModbusSlave.Slave)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ModbusSlave.TimeOut)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ModbusSlave.TimeOut)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ModbusSlave.DeviceName)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ModbusSlave.DeviceName)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ModbusSlave.DeviceNameFormat)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ModbusSlave.DeviceNameFormat)
</dd>
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.ModbusSlave?.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.SlaveAdmin
{
public class DetailsModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public DetailsModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
public ModbusSlave ModbusSlave { get; set; } = default!;
public async Task<IActionResult> OnGetAsync(Guid? id)
{
if (id == null || _context.ModbusSlaves == null)
{
return NotFound();
}
var modbusslave = await _context.ModbusSlaves.FirstOrDefaultAsync(m => m.Id == id);
if (modbusslave == null)
{
return NotFound();
}
else
{
ModbusSlave = modbusslave;
}
return Page();
}
}
}

@ -0,0 +1,50 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.SlaveAdmin.EditModel
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>ModbusSlave</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="ModbusSlave.Id" />
<div class="form-group">
<label asp-for="ModbusSlave.Slave" class="control-label"></label>
<input asp-for="ModbusSlave.Slave" class="form-control" />
<span asp-validation-for="ModbusSlave.Slave" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ModbusSlave.TimeOut" class="control-label"></label>
<input asp-for="ModbusSlave.TimeOut" class="form-control" />
<span asp-validation-for="ModbusSlave.TimeOut" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ModbusSlave.DeviceName" class="control-label"></label>
<input asp-for="ModbusSlave.DeviceName" class="form-control" />
<span asp-validation-for="ModbusSlave.DeviceName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ModbusSlave.DeviceNameFormat" class="control-label"></label>
<input asp-for="ModbusSlave.DeviceNameFormat" class="form-control" />
<span asp-validation-for="ModbusSlave.DeviceNameFormat" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="./Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.SlaveAdmin
{
public class EditModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public EditModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
[BindProperty]
public ModbusSlave ModbusSlave { get; set; } = default!;
public async Task<IActionResult> OnGetAsync(Guid? id)
{
if (id == null || _context.ModbusSlaves == null)
{
return NotFound();
}
var modbusslave = await _context.ModbusSlaves.FirstOrDefaultAsync(m => m.Id == id);
if (modbusslave == null)
{
return NotFound();
}
ModbusSlave = modbusslave;
return Page();
}
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Attach(ModbusSlave).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!ModbusSlaveExists(ModbusSlave.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToPage("./Index");
}
private bool ModbusSlaveExists(Guid id)
{
return (_context.ModbusSlaves?.Any(e => e.Id == id)).GetValueOrDefault();
}
}
}

@ -0,0 +1,54 @@
@page
@model IoTSharp.Gateway.Modbus.Pages.SlaveAdmin.IndexModel
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<p>
<a asp-page="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.ModbusSlave[0].Slave)
</th>
<th>
@Html.DisplayNameFor(model => model.ModbusSlave[0].TimeOut)
</th>
<th>
@Html.DisplayNameFor(model => model.ModbusSlave[0].DeviceName)
</th>
<th>
@Html.DisplayNameFor(model => model.ModbusSlave[0].DeviceNameFormat)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.ModbusSlave) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Slave)
</td>
<td>
@Html.DisplayFor(modelItem => item.TimeOut)
</td>
<td>
@Html.DisplayFor(modelItem => item.DeviceName)
</td>
<td>
@Html.DisplayFor(modelItem => item.DeviceNameFormat)
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IoTSharp.Gateway.Modbus.Data;
namespace IoTSharp.Gateway.Modbus.Pages.SlaveAdmin
{
public class IndexModel : PageModel
{
private readonly IoTSharp.Gateway.Modbus.Data.ApplicationDbContext _context;
public IndexModel(IoTSharp.Gateway.Modbus.Data.ApplicationDbContext context)
{
_context = context;
}
public IList<ModbusSlave> ModbusSlave { get;set; } = default!;
public async Task OnGetAsync()
{
if (_context.ModbusSlaves != null)
{
ModbusSlave = await _context.ModbusSlaves.ToListAsync();
}
}
}
}

@ -1,6 +1,7 @@
using IoTSharp.Gateway.Modbus.Data;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using SilkierQuartz;
namespace IoTSharp.Gateway.Modbus
{
@ -9,7 +10,6 @@ namespace IoTSharp.Gateway.Modbus
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
builder.Services.AddDbContext<ApplicationDbContext>(options =>
@ -19,6 +19,17 @@ namespace IoTSharp.Gateway.Modbus
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount=false)
.AddEntityFrameworkStores<ApplicationDbContext>();
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;
});
var app = builder.Build();
@ -41,7 +52,8 @@ namespace IoTSharp.Gateway.Modbus
app.UseAuthentication();
app.UseAuthorization();
app.UseSilkierQuartz();
app.MapRazorPages();
app.Run();

Loading…
Cancel
Save