update identity
This commit is contained in:
parent
a3ecde2815
commit
70eac8a9c8
|
|
@ -1,5 +1,5 @@
|
|||
@inherits LayoutComponentBase
|
||||
|
||||
@using MudBlazor
|
||||
|
||||
<div class="app-shell">
|
||||
<AuthorizeView>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script>
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
|
||||
<script>
|
||||
function toggleSidebar() {
|
||||
let sidebar = document.querySelector(".sidebar");
|
||||
sidebar.classList.toggle("collapsed");
|
||||
|
|
@ -43,17 +45,7 @@
|
|||
|
||||
public NavModel[] Navs = [
|
||||
new(){Icon = "mdi-view-dashboard", Path="/", Label = "Dashboard", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-file-cog", Path="/", Label = "Script Manager", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-file-code", Path="/", Label = "Script Editor", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-flag-checkered", Path="/", Label = "Missions", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-map-legend", Path="/", Label = "Maps", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-robot-mower", Path="/", Label = "Robots", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-robot-industrial", Path="/", Label = "Robot Models", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-monitor-eye", Path="/", Label = "Monitor", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-traffic-light", Path="/", Label = "Traffic", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-factory", Path="/", Label = "Open ACS", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-math-log", Path="/", Label = "Logs", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-account", Path="/", Label = "User", Match = NavLinkMatch.All},
|
||||
new(){Icon = "mdi-map-legend", Path="/", Label = "Maps-manager", Match = NavLinkMatch.All},
|
||||
];
|
||||
|
||||
private bool collapseNavMenu = true;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,5 @@ namespace RobotApp.Data
|
|||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
54
RobotApp/Data/ApplicationDbExtensions.cs
Normal file
54
RobotApp/Data/ApplicationDbExtensions.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace RobotApp.Data;
|
||||
|
||||
public static class ApplicationDbExtensions
|
||||
{
|
||||
public static async Task SeedApplicationDbAsync(this IServiceProvider serviceProvider)
|
||||
{
|
||||
using var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope();
|
||||
|
||||
using var appDb = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||
|
||||
await appDb.Database.MigrateAsync();
|
||||
//await appDb.Database.EnsureCreatedAsync();
|
||||
await appDb.SaveChangesAsync();
|
||||
|
||||
await scope.ServiceProvider.SeedRolesAsync();
|
||||
await scope.ServiceProvider.SeedUsersAsync();
|
||||
}
|
||||
|
||||
private static async Task SeedRolesAsync(this IServiceProvider serviceProvider)
|
||||
{
|
||||
var roleManager = serviceProvider.GetRequiredService<RoleManager<ApplicationRole>>();
|
||||
|
||||
if (!await roleManager.RoleExistsAsync("Administrator"))
|
||||
{
|
||||
await roleManager.CreateAsync(new ApplicationRole()
|
||||
{
|
||||
Name = "Administrator",
|
||||
NormalizedName = "ADMINISTRATOR",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task SeedUsersAsync(this IServiceProvider serviceProvider)
|
||||
{
|
||||
using var userManager = serviceProvider.GetRequiredService<UserManager<ApplicationUser>>();
|
||||
if (await userManager.FindByNameAsync("admin") is null)
|
||||
{
|
||||
var admin = new ApplicationUser()
|
||||
{
|
||||
UserName = "admin",
|
||||
Email = "administrator@phenikaa-x.com",
|
||||
NormalizedUserName = "ADMINISTRATOR",
|
||||
NormalizedEmail = "ADMINISTRATOR@PHENIKAA-X.COM",
|
||||
EmailConfirmed = true,
|
||||
};
|
||||
|
||||
await userManager.CreateAsync(admin, "robotics");
|
||||
await userManager.AddToRoleAsync(admin, "Administrator");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ namespace RobotApp.Migrations
|
|||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
|
|
@ -59,16 +59,16 @@ namespace RobotApp.Migrations
|
|||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("bit");
|
||||
|
|
@ -97,7 +97,7 @@ namespace RobotApp.Migrations
|
|||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
|
|
@ -126,10 +126,10 @@ namespace RobotApp.Migrations
|
|||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.IsRequired()
|
||||
|
|
@ -151,10 +151,10 @@ namespace RobotApp.Migrations
|
|||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
|
|
@ -176,7 +176,7 @@ namespace RobotApp.Migrations
|
|||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
|
|
@ -216,7 +216,7 @@ namespace RobotApp.Migrations
|
|||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("Text");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace RobotApp.Migrations
|
|||
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
||||
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
||||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
ConcurrencyStamp = table.Column<string>(type: "Text", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
|
|
@ -35,10 +35,10 @@ namespace RobotApp.Migrations
|
|||
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
||||
NormalizedEmail = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
||||
EmailConfirmed = table.Column<bool>(type: "bit", nullable: false),
|
||||
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
SecurityStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
PasswordHash = table.Column<string>(type: "Text", nullable: true),
|
||||
SecurityStamp = table.Column<string>(type: "Text", nullable: true),
|
||||
ConcurrencyStamp = table.Column<string>(type: "Text", nullable: true),
|
||||
PhoneNumber = table.Column<string>(type: "Text", nullable: true),
|
||||
PhoneNumberConfirmed = table.Column<bool>(type: "bit", nullable: false),
|
||||
TwoFactorEnabled = table.Column<bool>(type: "bit", nullable: false),
|
||||
LockoutEnd = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
|
|
@ -57,8 +57,8 @@ namespace RobotApp.Migrations
|
|||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
ClaimType = table.Column<string>(type: "Text", nullable: true),
|
||||
ClaimValue = table.Column<string>(type: "Text", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
|
|
@ -78,8 +78,8 @@ namespace RobotApp.Migrations
|
|||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
ClaimType = table.Column<string>(type: "Text", nullable: true),
|
||||
ClaimValue = table.Column<string>(type: "Text", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
|
|
@ -98,7 +98,7 @@ namespace RobotApp.Migrations
|
|||
{
|
||||
LoginProvider = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ProviderKey = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ProviderDisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
ProviderDisplayName = table.Column<string>(type: "Text", nullable: true),
|
||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
|
|
@ -143,7 +143,7 @@ namespace RobotApp.Migrations
|
|||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
LoginProvider = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
Value = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
Value = table.Column<string>(type: "Text", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
|
|
|
|||
268
RobotApp/Data/Migrations/20250926020848_initDb.Designer.cs
generated
Normal file
268
RobotApp/Data/Migrations/20250926020848_initDb.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using RobotApp.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RobotApp.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20250926020848_initDb")]
|
||||
partial class initDb
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.9");
|
||||
|
||||
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.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")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.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")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotApp.Data.ApplicationRole", 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("RobotApp.Data.ApplicationUser", 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.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("RobotApp.Data.ApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("RobotApp.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.HasOne("RobotApp.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.HasOne("RobotApp.Data.ApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("RobotApp.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.HasOne("RobotApp.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
721
RobotApp/Data/Migrations/20250926020848_initDb.cs
Normal file
721
RobotApp/Data/Migrations/20250926020848_initDb.cs
Normal file
|
|
@ -0,0 +1,721 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RobotApp.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class initDb : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "UserNameIndex",
|
||||
table: "AspNetUsers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "RoleNameIndex",
|
||||
table: "AspNetRoles");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Value",
|
||||
table: "AspNetUserTokens",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Name",
|
||||
table: "AspNetUserTokens",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LoginProvider",
|
||||
table: "AspNetUserTokens",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserId",
|
||||
table: "AspNetUserTokens",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserName",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(256)",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "TwoFactorEnabled",
|
||||
table: "AspNetUsers",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "bit");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "SecurityStamp",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "PhoneNumberConfirmed",
|
||||
table: "AspNetUsers",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "bit");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "PhoneNumber",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "PasswordHash",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "NormalizedUserName",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(256)",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "NormalizedEmail",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(256)",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<DateTimeOffset>(
|
||||
name: "LockoutEnd",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTimeOffset),
|
||||
oldType: "datetimeoffset",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "LockoutEnabled",
|
||||
table: "AspNetUsers",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "bit");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "EmailConfirmed",
|
||||
table: "AspNetUsers",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "bit");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Email",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(256)",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ConcurrencyStamp",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "AccessFailedCount",
|
||||
table: "AspNetUsers",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Id",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "RoleId",
|
||||
table: "AspNetUserRoles",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserId",
|
||||
table: "AspNetUserRoles",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserId",
|
||||
table: "AspNetUserLogins",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ProviderDisplayName",
|
||||
table: "AspNetUserLogins",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ProviderKey",
|
||||
table: "AspNetUserLogins",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LoginProvider",
|
||||
table: "AspNetUserLogins",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserId",
|
||||
table: "AspNetUserClaims",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ClaimValue",
|
||||
table: "AspNetUserClaims",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ClaimType",
|
||||
table: "AspNetUserClaims",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "AspNetUserClaims",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int")
|
||||
.Annotation("Sqlite:Autoincrement", true)
|
||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "NormalizedName",
|
||||
table: "AspNetRoles",
|
||||
type: "TEXT",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(256)",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Name",
|
||||
table: "AspNetRoles",
|
||||
type: "TEXT",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(256)",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ConcurrencyStamp",
|
||||
table: "AspNetRoles",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Id",
|
||||
table: "AspNetRoles",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "RoleId",
|
||||
table: "AspNetRoleClaims",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ClaimValue",
|
||||
table: "AspNetRoleClaims",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ClaimType",
|
||||
table: "AspNetRoleClaims",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "Text",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "AspNetRoleClaims",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int")
|
||||
.Annotation("Sqlite:Autoincrement", true)
|
||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "UserNameIndex",
|
||||
table: "AspNetUsers",
|
||||
column: "NormalizedUserName",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "RoleNameIndex",
|
||||
table: "AspNetRoles",
|
||||
column: "NormalizedName",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "UserNameIndex",
|
||||
table: "AspNetUsers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "RoleNameIndex",
|
||||
table: "AspNetRoles");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Value",
|
||||
table: "AspNetUserTokens",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Name",
|
||||
table: "AspNetUserTokens",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LoginProvider",
|
||||
table: "AspNetUserTokens",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserId",
|
||||
table: "AspNetUserTokens",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserName",
|
||||
table: "AspNetUsers",
|
||||
type: "nvarchar(256)",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "TwoFactorEnabled",
|
||||
table: "AspNetUsers",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "SecurityStamp",
|
||||
table: "AspNetUsers",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "PhoneNumberConfirmed",
|
||||
table: "AspNetUsers",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "PhoneNumber",
|
||||
table: "AspNetUsers",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "PasswordHash",
|
||||
table: "AspNetUsers",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "NormalizedUserName",
|
||||
table: "AspNetUsers",
|
||||
type: "nvarchar(256)",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "NormalizedEmail",
|
||||
table: "AspNetUsers",
|
||||
type: "nvarchar(256)",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<DateTimeOffset>(
|
||||
name: "LockoutEnd",
|
||||
table: "AspNetUsers",
|
||||
type: "datetimeoffset",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTimeOffset),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "LockoutEnabled",
|
||||
table: "AspNetUsers",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "EmailConfirmed",
|
||||
table: "AspNetUsers",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Email",
|
||||
table: "AspNetUsers",
|
||||
type: "nvarchar(256)",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ConcurrencyStamp",
|
||||
table: "AspNetUsers",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "AccessFailedCount",
|
||||
table: "AspNetUsers",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Id",
|
||||
table: "AspNetUsers",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "RoleId",
|
||||
table: "AspNetUserRoles",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserId",
|
||||
table: "AspNetUserRoles",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserId",
|
||||
table: "AspNetUserLogins",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ProviderDisplayName",
|
||||
table: "AspNetUserLogins",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ProviderKey",
|
||||
table: "AspNetUserLogins",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LoginProvider",
|
||||
table: "AspNetUserLogins",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "UserId",
|
||||
table: "AspNetUserClaims",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ClaimValue",
|
||||
table: "AspNetUserClaims",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ClaimType",
|
||||
table: "AspNetUserClaims",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "AspNetUserClaims",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER")
|
||||
.Annotation("Sqlite:Autoincrement", true)
|
||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "NormalizedName",
|
||||
table: "AspNetRoles",
|
||||
type: "nvarchar(256)",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Name",
|
||||
table: "AspNetRoles",
|
||||
type: "nvarchar(256)",
|
||||
maxLength: 256,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldMaxLength: 256,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ConcurrencyStamp",
|
||||
table: "AspNetRoles",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Id",
|
||||
table: "AspNetRoles",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "RoleId",
|
||||
table: "AspNetRoleClaims",
|
||||
type: "nvarchar(450)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ClaimValue",
|
||||
table: "AspNetRoleClaims",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ClaimType",
|
||||
table: "AspNetRoleClaims",
|
||||
type: "Text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "AspNetRoleClaims",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER")
|
||||
.Annotation("Sqlite:Autoincrement", true)
|
||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "UserNameIndex",
|
||||
table: "AspNetUsers",
|
||||
column: "NormalizedUserName",
|
||||
unique: true,
|
||||
filter: "[NormalizedUserName] IS NOT NULL");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "RoleNameIndex",
|
||||
table: "AspNetRoles",
|
||||
column: "NormalizedName",
|
||||
unique: true,
|
||||
filter: "[NormalizedName] IS NOT NULL");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
// <auto-generated />
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using RobotApp.Data;
|
||||
|
||||
|
|
@ -16,121 +15,23 @@ namespace RobotApp.Migrations
|
|||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("RobotApp.Data.ApplicationUser", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||
.HasColumnType("datetimeoffset");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex")
|
||||
.HasFilter("[NormalizedUserName] IS NOT NULL");
|
||||
|
||||
b.ToTable("AspNetUsers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("RoleNameIndex")
|
||||
.HasFilter("[NormalizedName] IS NOT NULL");
|
||||
|
||||
b.ToTable("AspNetRoles", (string)null);
|
||||
});
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.9");
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
|
|
@ -143,19 +44,17 @@ namespace RobotApp.Migrations
|
|||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
|
|
@ -167,17 +66,17 @@ namespace RobotApp.Migrations
|
|||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
|
|
@ -189,10 +88,10 @@ namespace RobotApp.Migrations
|
|||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
|
|
@ -204,25 +103,115 @@ namespace RobotApp.Migrations
|
|||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotApp.Data.ApplicationRole", 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("RobotApp.Data.ApplicationUser", 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.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
b.HasOne("RobotApp.Data.ApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
|
|
@ -249,7 +238,7 @@ namespace RobotApp.Migrations
|
|||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
b.HasOne("RobotApp.Data.ApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
namespace RobotApp.Modbus;
|
||||
|
||||
|
||||
public enum RegisterOrder
|
||||
{
|
||||
LowHigh = 0,
|
||||
HighLow = 1
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Components.Authorization;
|
|||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MudBlazor.Services;
|
||||
using RobotApp.Client.Pages;
|
||||
using RobotApp.Components;
|
||||
using RobotApp.Components.Account;
|
||||
using RobotApp.Data;
|
||||
|
|
@ -23,9 +22,6 @@ builder.Services.AddScoped<AuthenticationStateProvider, IdentityRevalidatingAuth
|
|||
builder.Services.AddMudServices();
|
||||
builder.Services.AddAuthorization();
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
|
||||
?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
||||
Action<DbContextOptionsBuilder> appDbOptions = options => options.UseSqlite(connectionString, b => b.MigrationsAssembly("RobotApp"));
|
||||
|
||||
|
|
@ -50,6 +46,7 @@ builder.Services.AddSingleton<RobotConnection>();
|
|||
builder.Services.AddHostedService(sp => sp.GetRequiredService<RobotConnection>());
|
||||
|
||||
var app = builder.Build();
|
||||
await app.Services.SeedApplicationDbAsync();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@
|
|||
<UserSecretsId>aspnet-RobotApp-1f61caa2-bbbb-40cd-88b6-409b408a84ea</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Layout\**" />
|
||||
<Content Remove="Layout\**" />
|
||||
<EmbeddedResource Remove="Layout\**" />
|
||||
<None Remove="Layout\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\RobotApp.Client\RobotApp.Client.csproj" />
|
||||
<ProjectReference Include="..\RobotApp.Common.Shares\RobotApp.Common.Shares.csproj" />
|
||||
|
|
@ -24,7 +31,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Layout\" />
|
||||
<Folder Include="Services\Robot\Simulation\" />
|
||||
<Folder Include="wwwroot\lib\" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace RobotApp.Modbus;
|
||||
namespace RobotApp.Services.Exceptions;
|
||||
|
||||
public class ModbusException : Exception
|
||||
{
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
using Microsoft.AspNetCore.Connections;
|
||||
using RobotApp.Services.Exceptions;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace RobotApp.Modbus;
|
||||
namespace RobotApp.Services;
|
||||
|
||||
public class ModbusTcpClient(string IpAddress, int Port, byte ClientId) : IDisposable
|
||||
{
|
||||
|
|
@ -100,9 +101,9 @@ public class ModbusTcpClient(string IpAddress, int Port, byte ClientId) : IDispo
|
|||
}
|
||||
}
|
||||
|
||||
private byte[] Write(byte functionCode, UInt16 startingAddress, UInt16 quantity, CancellationToken? cancellationToken = null)
|
||||
private byte[] Write(byte functionCode, ushort startingAddress, ushort quantity, CancellationToken? cancellationToken = null)
|
||||
=> Write(functionCode, startingAddress, quantity, [], cancellationToken);
|
||||
private byte[] Write(byte functionCode, UInt16 startingAddress, UInt16 quantity, byte[] multipleData, CancellationToken? cancellationToken = null)
|
||||
private byte[] Write(byte functionCode, ushort startingAddress, ushort quantity, byte[] multipleData, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -176,43 +177,43 @@ public class ModbusTcpClient(string IpAddress, int Port, byte ClientId) : IDispo
|
|||
}
|
||||
}
|
||||
|
||||
public bool[] ReadDiscreteInputs(UInt16 startingAddress, UInt16 quantity, CancellationToken? cancellationToken = null)
|
||||
public bool[] ReadDiscreteInputs(ushort startingAddress, ushort quantity, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
if (startingAddress > 65535 | quantity > 2000)
|
||||
{
|
||||
throw new ArgumentException("Starting address must be 0 - 65535; quantity must be 0 - 2000");
|
||||
}
|
||||
var data = Write(0x02, startingAddress, quantity, cancellationToken);
|
||||
if (data.Length - 1 < ((quantity - 1) / 8)) return [];
|
||||
if (data.Length - 1 < (quantity - 1) / 8) return [];
|
||||
bool[] response = new bool[quantity];
|
||||
for (int i = 0; i < quantity; i++)
|
||||
{
|
||||
int intData = data[i / 8];
|
||||
int mask = Convert.ToInt32(Math.Pow(2, (i % 8)));
|
||||
int mask = Convert.ToInt32(Math.Pow(2, i % 8));
|
||||
response[i] = Convert.ToBoolean((intData & mask) / mask);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public bool[] ReadCoils(UInt16 startingAddress, UInt16 quantity, CancellationToken? cancellationToken = null)
|
||||
public bool[] ReadCoils(ushort startingAddress, ushort quantity, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
if (startingAddress > 65535 | quantity > 2000)
|
||||
{
|
||||
throw new ArgumentException("Starting address must be 0 - 65535; quantity must be 0 - 2000");
|
||||
}
|
||||
var data = Write(0x01, startingAddress, quantity, cancellationToken);
|
||||
if (data.Length - 1 < ((quantity - 1) / 8)) return [];
|
||||
if (data.Length - 1 < (quantity - 1) / 8) return [];
|
||||
bool[] response = new bool[quantity];
|
||||
for (int i = 0; i < quantity; i++)
|
||||
{
|
||||
int intData = data[i / 8];
|
||||
int mask = Convert.ToInt32(Math.Pow(2, (i % 8)));
|
||||
int mask = Convert.ToInt32(Math.Pow(2, i % 8));
|
||||
response[i] = Convert.ToBoolean((intData & mask) / mask);
|
||||
}
|
||||
return (response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public int[] ReadHoldingRegisters(UInt16 startingAddress, UInt16 quantity, CancellationToken? cancellationToken = null)
|
||||
public int[] ReadHoldingRegisters(ushort startingAddress, ushort quantity, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
if (startingAddress > 65535 | quantity > 125)
|
||||
{
|
||||
|
|
@ -223,12 +224,12 @@ public class ModbusTcpClient(string IpAddress, int Port, byte ClientId) : IDispo
|
|||
int[] response = new int[quantity];
|
||||
for (int i = 0; i < quantity; i++)
|
||||
{
|
||||
response[i] = (data[i * 2] << 8) | data[i * 2 + 1];
|
||||
response[i] = data[i * 2] << 8 | data[i * 2 + 1];
|
||||
}
|
||||
return (response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public int[] ReadInputRegisters(UInt16 startingAddress, UInt16 quantity, CancellationToken? cancellationToken = null)
|
||||
public int[] ReadInputRegisters(ushort startingAddress, ushort quantity, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
if (startingAddress > 65535 | quantity > 125)
|
||||
{
|
||||
|
|
@ -239,22 +240,22 @@ public class ModbusTcpClient(string IpAddress, int Port, byte ClientId) : IDispo
|
|||
int[] response = new int[quantity];
|
||||
for (int i = 0; i < quantity; i++)
|
||||
{
|
||||
response[i] = (data[i * 2] << 8) | data[i * 2 + 1];
|
||||
response[i] = data[i * 2] << 8 | data[i * 2 + 1];
|
||||
}
|
||||
return (response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public void WriteSingleCoil(UInt16 startingAddress, bool value, CancellationToken? cancellationToken = null)
|
||||
public void WriteSingleCoil(ushort startingAddress, bool value, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
Write(0x05, startingAddress, value ? (UInt16)0xFF00 : (UInt16)0x0000, cancellationToken);
|
||||
Write(0x05, startingAddress, value ? (ushort)0xFF00 : (ushort)0x0000, cancellationToken);
|
||||
}
|
||||
|
||||
public void WriteSingleRegister(UInt16 startingAddress, UInt16 value, CancellationToken? cancellationToken = null)
|
||||
public void WriteSingleRegister(ushort startingAddress, ushort value, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
Write(0x06, startingAddress, value, cancellationToken);
|
||||
}
|
||||
|
||||
public void WriteMultipleCoils(UInt16 startingAddress, bool[] values, CancellationToken? cancellationToken = null)
|
||||
public void WriteMultipleCoils(ushort startingAddress, bool[] values, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
if (values == null || values.Length == 0)
|
||||
throw new ArgumentException("Values cannot be null or empty", nameof(values));
|
||||
|
|
@ -272,13 +273,13 @@ public class ModbusTcpClient(string IpAddress, int Port, byte ClientId) : IDispo
|
|||
{
|
||||
if (values[i])
|
||||
{
|
||||
data[1 + (i / 8)] |= (byte)(1 << (i % 8));
|
||||
data[1 + i / 8] |= (byte)(1 << i % 8);
|
||||
}
|
||||
}
|
||||
Write(0x0F, startingAddress, (UInt16)values.Length, data, cancellationToken);
|
||||
Write(0x0F, startingAddress, (ushort)values.Length, data, cancellationToken);
|
||||
}
|
||||
|
||||
public void WriteMultipleRegisters(UInt16 startingAddress, UInt16[] values, CancellationToken? cancellationToken = null)
|
||||
public void WriteMultipleRegisters(ushort startingAddress, ushort[] values, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
if (values == null || values.Length == 0)
|
||||
throw new ArgumentException("Values cannot be null or empty", nameof(values));
|
||||
|
|
@ -297,10 +298,10 @@ public class ModbusTcpClient(string IpAddress, int Port, byte ClientId) : IDispo
|
|||
data[1 + i * 2] = (byte)(values[i] >> 8);
|
||||
data[2 + i * 2] = (byte)(values[i] & 0xFF);
|
||||
}
|
||||
Write(0x10, startingAddress, (UInt16)values.Length, data, cancellationToken);
|
||||
Write(0x10, startingAddress, (ushort)values.Length, data, cancellationToken);
|
||||
}
|
||||
|
||||
public int[] ReadWriteMultipleRegisters(UInt16 startingAddressRead, UInt16 quantityRead, UInt16 startingAddressWrite, UInt16[] values, CancellationToken? cancellationToken = null)
|
||||
public int[] ReadWriteMultipleRegisters(ushort startingAddressRead, ushort quantityRead, ushort startingAddressWrite, ushort[] values, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
if (values == null || values.Length == 0)
|
||||
throw new ArgumentException("Values cannot be null or empty", nameof(values));
|
||||
|
|
@ -329,7 +330,7 @@ public class ModbusTcpClient(string IpAddress, int Port, byte ClientId) : IDispo
|
|||
var response = new int[quantityRead];
|
||||
for (int i = 0; i < quantityRead; i++)
|
||||
{
|
||||
response[i] = (receivedData[i * 2] << 8) | receivedData[i * 2 + 1];
|
||||
response[i] = receivedData[i * 2] << 8 | receivedData[i * 2 + 1];
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
|
@ -337,7 +338,7 @@ public class ModbusTcpClient(string IpAddress, int Port, byte ClientId) : IDispo
|
|||
public bool Available(int timeout)
|
||||
{
|
||||
System.Net.NetworkInformation.Ping pingSender = new ();
|
||||
IPAddress address = System.Net.IPAddress.Parse(IpAddress);
|
||||
IPAddress address = IPAddress.Parse(IpAddress);
|
||||
|
||||
string data = "phenikaaX";
|
||||
byte[] buffer = System.Text.Encoding.ASCII.GetBytes(data);
|
||||
BIN
RobotApp/robot.db
Normal file
BIN
RobotApp/robot.db
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user