Sicherung
This commit is contained in:
@@ -8,11 +8,11 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
namespace FSI.BT.IR.Plc.Settings.Log.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20241018054354_OrganizationAdded")]
|
||||
partial class OrganizationAdded
|
||||
[Migration("20241018090345_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -49,7 +49,7 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("CreationTimeStamp")
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
@@ -60,17 +60,20 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("ModificationTimeStamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ParameterId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("PlcId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ShortName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10)
|
||||
@@ -79,9 +82,14 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Updated")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
b.HasIndex("ParameterId");
|
||||
|
||||
b.HasIndex("PlcId");
|
||||
|
||||
b.ToTable("Organizations");
|
||||
});
|
||||
@@ -112,13 +120,18 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Disabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("OrganizationId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("PlcId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@@ -127,6 +140,8 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganizationId");
|
||||
|
||||
b.HasIndex("PlcId");
|
||||
|
||||
b.ToTable("Parameters");
|
||||
@@ -142,9 +157,11 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Disabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("IpAdress")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
@@ -153,6 +170,12 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("OrganizationId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("ParameterId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Rack")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@@ -164,6 +187,10 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganizationId");
|
||||
|
||||
b.HasIndex("ParameterId");
|
||||
|
||||
b.ToTable("Plcs");
|
||||
});
|
||||
|
||||
@@ -182,26 +209,71 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
{
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Organization", "Parent")
|
||||
.WithMany("Parents")
|
||||
.HasForeignKey("ParentId");
|
||||
.HasForeignKey("Id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", null)
|
||||
.WithMany("Organizations")
|
||||
.HasForeignKey("ParameterId");
|
||||
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Plc", null)
|
||||
.WithMany("Organizations")
|
||||
.HasForeignKey("PlcId");
|
||||
|
||||
b.Navigation("Parent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", b =>
|
||||
{
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Organization", "Organization")
|
||||
.WithMany()
|
||||
.HasForeignKey("OrganizationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Plc", "Plc")
|
||||
.WithMany()
|
||||
.HasForeignKey("PlcId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organization");
|
||||
|
||||
b.Navigation("Plc");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Plc", b =>
|
||||
{
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Organization", "Organization")
|
||||
.WithMany()
|
||||
.HasForeignKey("OrganizationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", null)
|
||||
.WithMany("Plcs")
|
||||
.HasForeignKey("ParameterId");
|
||||
|
||||
b.Navigation("Organization");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Organization", b =>
|
||||
{
|
||||
b.Navigation("Parents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", b =>
|
||||
{
|
||||
b.Navigation("Organizations");
|
||||
|
||||
b.Navigation("Plcs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Plc", b =>
|
||||
{
|
||||
b.Navigation("Organizations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FSI.BT.IR.Plc.Settings.Log.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Logging",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
ParameterId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Value = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Logging", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Organizations",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", maxLength: 30, nullable: false),
|
||||
ShortName = table.Column<string>(type: "TEXT", maxLength: 10, nullable: false),
|
||||
Description = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
|
||||
ParentId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||
Type = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
Updated = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
FullShortName = table.Column<string>(type: "TEXT", nullable: false),
|
||||
ParameterId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||
PlcId = table.Column<int>(type: "INTEGER", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Organizations", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Parameters",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Description = table.Column<string>(type: "TEXT", nullable: true),
|
||||
OrganizationId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
PlcId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DbNo = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DbStart = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DbSize = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DataType = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DefaultValue = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Disabled = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
Updated = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Parameters", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Parameters_Organizations_OrganizationId",
|
||||
column: x => x.OrganizationId,
|
||||
principalTable: "Organizations",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Plcs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Description = table.Column<string>(type: "TEXT", nullable: true),
|
||||
OrganizationId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
IpAdress = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Rack = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Slot = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Disabled = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
Updated = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
ParameterId = table.Column<int>(type: "INTEGER", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Plcs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Plcs_Organizations_OrganizationId",
|
||||
column: x => x.OrganizationId,
|
||||
principalTable: "Organizations",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Plcs_Parameters_ParameterId",
|
||||
column: x => x.ParameterId,
|
||||
principalTable: "Parameters",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Logging_ParameterId",
|
||||
table: "Logging",
|
||||
column: "ParameterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Organizations_ParameterId",
|
||||
table: "Organizations",
|
||||
column: "ParameterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Organizations_PlcId",
|
||||
table: "Organizations",
|
||||
column: "PlcId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Parameters_OrganizationId",
|
||||
table: "Parameters",
|
||||
column: "OrganizationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Parameters_PlcId",
|
||||
table: "Parameters",
|
||||
column: "PlcId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Plcs_OrganizationId",
|
||||
table: "Plcs",
|
||||
column: "OrganizationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Plcs_ParameterId",
|
||||
table: "Plcs",
|
||||
column: "ParameterId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Logging_Parameters_ParameterId",
|
||||
table: "Logging",
|
||||
column: "ParameterId",
|
||||
principalTable: "Parameters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Organizations_Parameters_ParameterId",
|
||||
table: "Organizations",
|
||||
column: "ParameterId",
|
||||
principalTable: "Parameters",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Organizations_Plcs_PlcId",
|
||||
table: "Organizations",
|
||||
column: "PlcId",
|
||||
principalTable: "Plcs",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Parameters_Plcs_PlcId",
|
||||
table: "Parameters",
|
||||
column: "PlcId",
|
||||
principalTable: "Plcs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Organizations_Parameters_ParameterId",
|
||||
table: "Organizations");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Plcs_Parameters_ParameterId",
|
||||
table: "Plcs");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Organizations_Plcs_PlcId",
|
||||
table: "Organizations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Logging");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Parameters");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Plcs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Organizations");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
namespace FSI.BT.IR.Plc.Settings.Log.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
|
||||
@@ -46,7 +46,7 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("CreationTimeStamp")
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
@@ -57,17 +57,20 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("ModificationTimeStamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ParameterId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("PlcId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ShortName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10)
|
||||
@@ -76,9 +79,14 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Updated")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
b.HasIndex("ParameterId");
|
||||
|
||||
b.HasIndex("PlcId");
|
||||
|
||||
b.ToTable("Organizations");
|
||||
});
|
||||
@@ -109,13 +117,18 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Disabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("OrganizationId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("PlcId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@@ -124,6 +137,8 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganizationId");
|
||||
|
||||
b.HasIndex("PlcId");
|
||||
|
||||
b.ToTable("Parameters");
|
||||
@@ -139,9 +154,11 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Disabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("IpAdress")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
@@ -150,6 +167,12 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("OrganizationId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("ParameterId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Rack")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@@ -161,6 +184,10 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganizationId");
|
||||
|
||||
b.HasIndex("ParameterId");
|
||||
|
||||
b.ToTable("Plcs");
|
||||
});
|
||||
|
||||
@@ -179,26 +206,71 @@ namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
{
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Organization", "Parent")
|
||||
.WithMany("Parents")
|
||||
.HasForeignKey("ParentId");
|
||||
.HasForeignKey("Id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", null)
|
||||
.WithMany("Organizations")
|
||||
.HasForeignKey("ParameterId");
|
||||
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Plc", null)
|
||||
.WithMany("Organizations")
|
||||
.HasForeignKey("PlcId");
|
||||
|
||||
b.Navigation("Parent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", b =>
|
||||
{
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Organization", "Organization")
|
||||
.WithMany()
|
||||
.HasForeignKey("OrganizationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Plc", "Plc")
|
||||
.WithMany()
|
||||
.HasForeignKey("PlcId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organization");
|
||||
|
||||
b.Navigation("Plc");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Plc", b =>
|
||||
{
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Organization", "Organization")
|
||||
.WithMany()
|
||||
.HasForeignKey("OrganizationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", null)
|
||||
.WithMany("Plcs")
|
||||
.HasForeignKey("ParameterId");
|
||||
|
||||
b.Navigation("Organization");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Organization", b =>
|
||||
{
|
||||
b.Navigation("Parents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", b =>
|
||||
{
|
||||
b.Navigation("Organizations");
|
||||
|
||||
b.Navigation("Plcs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Plc", b =>
|
||||
{
|
||||
b.Navigation("Organizations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FSI.BT.IR.Plc.Settings.Log.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20241017110209_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.10");
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Logging", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ParameterId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ParameterId");
|
||||
|
||||
b.ToTable("Logging");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("DataType")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("DbNo")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("DbSize")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("DbStart")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("DefaultValue")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("PlcId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Updated")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlcId");
|
||||
|
||||
b.ToTable("Parameters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Plc", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("IpAdress")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Rack")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Slot")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Updated")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Plcs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Logging", b =>
|
||||
{
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", "Parameter")
|
||||
.WithMany()
|
||||
.HasForeignKey("ParameterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Parameter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FSI.BT.IR.Plc.Settings.Log.Models.Parameter", b =>
|
||||
{
|
||||
b.HasOne("FSI.BT.IR.Plc.Settings.Log.Models.Plc", "Plc")
|
||||
.WithMany()
|
||||
.HasForeignKey("PlcId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Plc");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Plcs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Description = table.Column<string>(type: "TEXT", nullable: false),
|
||||
IpAdress = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Rack = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Slot = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
Updated = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Plcs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Parameters",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Description = table.Column<string>(type: "TEXT", nullable: false),
|
||||
PlcId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DbNo = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DbStart = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DbSize = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DataType = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DefaultValue = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
Updated = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Parameters", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Parameters_Plcs_PlcId",
|
||||
column: x => x.PlcId,
|
||||
principalTable: "Plcs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Logging",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
ParameterId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Value = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Logging", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Logging_Parameters_ParameterId",
|
||||
column: x => x.ParameterId,
|
||||
principalTable: "Parameters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Logging_ParameterId",
|
||||
table: "Logging",
|
||||
column: "ParameterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Parameters_PlcId",
|
||||
table: "Parameters",
|
||||
column: "PlcId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Logging");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Parameters");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Plcs");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FSI.BT.IR.Plc.Settings.Log.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class OrganizationAdded : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Organizations",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", maxLength: 30, nullable: false),
|
||||
ShortName = table.Column<string>(type: "TEXT", maxLength: 10, nullable: false),
|
||||
Description = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
|
||||
ParentId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||
Type = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
CreationTimeStamp = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
ModificationTimeStamp = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
FullShortName = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Organizations", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Organizations_Organizations_ParentId",
|
||||
column: x => x.ParentId,
|
||||
principalTable: "Organizations",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Organizations_ParentId",
|
||||
table: "Organizations",
|
||||
column: "ParentId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Organizations");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
@@ -13,13 +14,19 @@ namespace FSI.BT.IR.Plc.Settings.Log.Models
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Parameter")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public Parameter Parameter { get; set; }
|
||||
|
||||
[ForeignKey(nameof(Parameter.Id))]
|
||||
public int ParameterId { get; set; }
|
||||
|
||||
[DisplayName("Wert")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public string Value { get; set; }
|
||||
|
||||
[DisplayName("Zeitstempel")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public DateTime Timestamp { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,28 +15,37 @@ namespace FSI.BT.IR.Plc.Settings.Log.Models
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Bezeichnung")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
[StringLength(30)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Kurzname")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
[StringLength(10)]
|
||||
public string ShortName { get; set; }
|
||||
|
||||
[DisplayName("Beschreibung")]
|
||||
[StringLength(255)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[ForeignKey(nameof(Id))]
|
||||
[DisplayName("Übergeordnetes Objekt")]
|
||||
public int? ParentId { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(Id))]
|
||||
public virtual Organization? Parent { get; set; }
|
||||
public virtual ICollection<Organization> Parents { get; set; }
|
||||
|
||||
[DisplayName("Type")]
|
||||
[DisplayName("Typ")]
|
||||
public OrganizationType Type { get; set; }
|
||||
|
||||
public DateTime CreationTimeStamp { get; set; }
|
||||
[DisplayName("Erstellungsdatum")]
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
public DateTime ModificationTimeStamp { get; set; }
|
||||
[DisplayName("Bearbeitungsdatum")]
|
||||
public DateTime Updated { get; set; }
|
||||
|
||||
[DisplayName("Bereich")]
|
||||
public string FullShortName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
@@ -10,28 +11,76 @@ namespace FSI.BT.IR.Plc.Settings.Log.Models
|
||||
{
|
||||
public class Parameter
|
||||
{
|
||||
public Parameter()
|
||||
{
|
||||
Organizations = new HashSet<Organization>();
|
||||
Plcs = new HashSet<Plc>();
|
||||
}
|
||||
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Bezeichnung")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public Plc Plc { get; set; }
|
||||
[DisplayName("Beschreibung")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
#region Organization
|
||||
|
||||
[DisplayName("Organisation")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
[ForeignKey(nameof(Organization.Id))]
|
||||
public int OrganizationId { get; set; }
|
||||
|
||||
public virtual Organization Organization { get; set; }
|
||||
|
||||
public virtual ICollection<Organization> Organizations { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Plc
|
||||
|
||||
[DisplayName("SPS")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
[ForeignKey(nameof(Plc.Id))]
|
||||
public int PlcId { get; set; }
|
||||
|
||||
public virtual Plc Plc { get; set; }
|
||||
|
||||
public virtual ICollection<Plc> Plcs { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
[DisplayName("Datenbaustein-Nr.")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public int DbNo { get; set; }
|
||||
|
||||
[DisplayName("Startadresse")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public int DbStart { get; set; }
|
||||
|
||||
[DisplayName("Länge des Datentyps")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public int DbSize { get; set; }
|
||||
|
||||
[DisplayName("Datentyp")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public DataType DataType { get; set; }
|
||||
|
||||
[DisplayName("Standardwert")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public string DefaultValue { get; set; }
|
||||
|
||||
[DisplayName("deaktiviert")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
[DisplayName("Erstellungsdatum")]
|
||||
public DateTime Created { get; set; } = DateTime.Now;
|
||||
|
||||
[DisplayName("Bearbeitungsdatum")]
|
||||
public DateTime Updated { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,20 +11,64 @@ namespace FSI.BT.IR.Plc.Settings.Log.Models
|
||||
{
|
||||
public class Plc
|
||||
{
|
||||
public Plc()
|
||||
{
|
||||
Organizations = new HashSet<Organization>();
|
||||
}
|
||||
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Bezeichnung")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
[DisplayName("Beschreibung")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
public string IpAdress { get; set; }
|
||||
#region Organization
|
||||
|
||||
public int Rack { get; set; }
|
||||
[DisplayName("Organisation")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
[ForeignKey(nameof(Organization.Id))]
|
||||
public int OrganizationId { get; set; }
|
||||
|
||||
public virtual Organization Organization { get; set; }
|
||||
|
||||
public virtual ICollection<Organization> Organizations { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
[DisplayName("IP-Adresse")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public string IpAdress { get; set; }
|
||||
|
||||
[DisplayName("Rack")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public int Rack { get; set; }
|
||||
|
||||
[DisplayName("Slot")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public int Slot { get; set; }
|
||||
|
||||
[DisplayName("deaktiviert")]
|
||||
[Required(ErrorMessage = "Pflichtfeld")]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
[DisplayName("Erstellungsdatum")]
|
||||
public DateTime Created { get; set; } = DateTime.Now;
|
||||
|
||||
[DisplayName("Bearbeitungsdatum")]
|
||||
public DateTime Updated { get; set; } = DateTime.Now;
|
||||
|
||||
[DisplayName("Name")]
|
||||
public string FullName
|
||||
{
|
||||
get
|
||||
{
|
||||
return Organization.FullShortName + " " + Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
29
worker/FSI.BT.IR.Plc.Settings.Log/Models/Statistics.cs
Normal file
29
worker/FSI.BT.IR.Plc.Settings.Log/Models/Statistics.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FSI.BT.IR.Plc.Settings.Log.Models
|
||||
{
|
||||
public class Statistics
|
||||
{
|
||||
public Parameter Parameter { get; set; }
|
||||
|
||||
[DisplayName("Anzahl")]
|
||||
public int Cnt { get; set; }
|
||||
|
||||
[DisplayName("min. Wert")]
|
||||
public double MinValue { get; set; }
|
||||
|
||||
[DisplayName("max. Wert")]
|
||||
public double MaxValue { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class StatisticsDay
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ namespace FSI.BT.IR.Plc.Settings.Log
|
||||
DateTime oldDate = DateTime.Now;
|
||||
|
||||
var plc = new S7Client(); // SPS-Verbindung
|
||||
|
||||
List<Models.Parameter> parameters;
|
||||
List<Models.Logging> loggs;
|
||||
byte[] buffer;
|
||||
@@ -55,77 +56,81 @@ namespace FSI.BT.IR.Plc.Settings.Log
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
if (oldDate.Date != DateTime.Now.Date && _settings.Cfg.CleanInterval > 0 )
|
||||
if (oldDate.Date != DateTime.Now.Date && _settings.Cfg.CleanInterval > 0)
|
||||
{
|
||||
_log.Debug("Neuer Tag.");
|
||||
_log.Debug("Neuer Tag.");
|
||||
CleanLoggTable();
|
||||
}
|
||||
|
||||
parameters = _context.Parameters.ToList();
|
||||
var grpParameters = _context.Parameters.GroupBy(x => x.PlcId);
|
||||
|
||||
foreach (var parameter in parameters)
|
||||
foreach (var grpParameter in grpParameters)
|
||||
{
|
||||
value = string.Empty;
|
||||
logFirstEntry = new();
|
||||
buffer = new byte[parameter.DbSize];
|
||||
|
||||
try
|
||||
{
|
||||
// Verbindung mit SPS-Aufbauen
|
||||
var connectionRslt = plc.ConnectTo(parameter.Plc.IpAdress, parameter.Plc.Rack, parameter.Plc.Slot);
|
||||
var connectionRslt = plc.ConnectTo(grpParameter.First().Plc.IpAdress, grpParameter.First().Plc.Rack, grpParameter.First().Plc.Slot);
|
||||
|
||||
// Verbindungsstatus <20>berpr<70>fen
|
||||
if (connectionRslt == 0) // Verbindung i.O.
|
||||
{
|
||||
_log.Debug(parameter.Plc.Name + " Verbindung hergestellt.");
|
||||
_log.Debug(grpParameter.First().Plc.Name + " Verbindung hergestellt.");
|
||||
}
|
||||
else // Verbindung n.i.O.
|
||||
{
|
||||
_log.Error(parameter.Plc.Name + " Verbindung nicht hergestellt.");
|
||||
_log.Error(parameter.Plc.Name + " Fehler: " + plc.ErrorText(connectionRslt));
|
||||
_log.Error(grpParameter.First().Plc.Name + " Verbindung nicht hergestellt.");
|
||||
_log.Error(grpParameter.First().Plc.Name + " Fehler: " + plc.ErrorText(connectionRslt));
|
||||
// await Task.Delay(UpdateIntervall, cancellationToken); // Warten bis zum n<>chsten Verbindungsversuch (Zeiten aus config.json)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(parameter.Plc.Name + " " + ex.Message);
|
||||
_log.Error(grpParameter.First().Plc.Name + " " + ex.Message);
|
||||
}
|
||||
|
||||
parameters = grpParameter.ToList(); ; //_context.Parameters.OrderBy(x => x.PlcId).ToList();
|
||||
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
value = string.Empty;
|
||||
logFirstEntry = new();
|
||||
buffer = new byte[parameter.DbSize];
|
||||
|
||||
plc.DBRead(parameter.DbNo, parameter.DbStart, parameter.DbSize, buffer); // Wert aus SPS auslesen
|
||||
|
||||
value = GetStringOfValue(buffer, parameter); // Value in Sting, in Abh<62>nigkeit des Datentyps, wandeln
|
||||
_log.Debug(parameter.Name + ": Wert " + value + " wurde ausgelesen" +
|
||||
"");
|
||||
logFirstEntry = loggs.Where(x => x.ParameterId == parameter.Id).FirstOrDefault();
|
||||
|
||||
if (logFirstEntry == null || !value.Equals(logFirstEntry.Value))
|
||||
{
|
||||
Models.Logging logging = new Models.Logging();
|
||||
logging.Value = value;
|
||||
logging.Parameter = parameter;
|
||||
|
||||
_context.Logging.Add(logging);
|
||||
_context.SaveChanges();
|
||||
|
||||
loggs = _context.Logging.OrderByDescending(x => x.Timestamp).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
plc.DBRead(parameter.DbNo, parameter.DbStart, parameter.DbSize, buffer); // Wert aus SPS auslesen
|
||||
|
||||
plc.Disconnect(); // Verbindung zur SPS trennen
|
||||
_log.Debug(parameter.Plc.Name + " Verbindung getrennt.");
|
||||
|
||||
value = GetStringOfValue(buffer, parameter); // Value in Sting, in Abh<62>nigkeit des Datentyps, wandeln
|
||||
_log.Debug(parameter.Name + ": Wert " + value + " wurde ausgelesen" +
|
||||
"");
|
||||
logFirstEntry = loggs.Where(x => x.ParameterId == parameter.Id).FirstOrDefault();
|
||||
|
||||
|
||||
if (logFirstEntry == null || !value.Equals(logFirstEntry.Value))
|
||||
{
|
||||
Models.Logging logging = new Models.Logging();
|
||||
logging.Value = value;
|
||||
logging.Parameter = parameter;
|
||||
|
||||
_context.Logging.Add(logging);
|
||||
_context.SaveChanges();
|
||||
|
||||
loggs = _context.Logging.OrderByDescending(x => x.Timestamp).ToList();
|
||||
}
|
||||
|
||||
_log.Debug(parameter.Plc.Name + " Start Task-Wartezeit");
|
||||
try
|
||||
{
|
||||
await Task.Delay(_settings.Cfg.UpdateInterval, stoppingToken); // Warten bis zum n<>chsten Verbindungsversuch (Zeiten aus config.json)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(parameter.Plc.Name + " " + ex.Message);
|
||||
}
|
||||
_log.Debug(parameter.Plc.Name + " Ende Task-Wartezeit");
|
||||
_log.Debug(grpParameter.First().Plc.Name + " Verbindung getrennt.");
|
||||
}
|
||||
|
||||
_log.Debug("Start Task-Wartezeit");
|
||||
try
|
||||
{
|
||||
await Task.Delay(_settings.Cfg.UpdateInterval, stoppingToken); // Warten bis zum n<>chsten Verbindungsversuch (Zeiten aus config.json)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(ex.Message);
|
||||
}
|
||||
_log.Debug("Ende Task-Wartezeit");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +143,7 @@ namespace FSI.BT.IR.Plc.Settings.Log
|
||||
|
||||
_log.Debug("Datenbereinigung gestartet");
|
||||
|
||||
foreach (var parameter in parameters)
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
loggs = _context.Logging.Where(x => x.ParameterId == parameter.Id).OrderByDescending(x => x.Timestamp).ToList();
|
||||
|
||||
@@ -158,7 +163,7 @@ namespace FSI.BT.IR.Plc.Settings.Log
|
||||
}
|
||||
|
||||
_context.SaveChanges();
|
||||
_log.Info("Datenbereinigung beendet - es wurden " + cntDel.ToString() +" Datens<6E>tze gel<65>scht");
|
||||
_log.Info("Datenbereinigung beendet - es wurden " + cntDel.ToString() + " Datens<6E>tze gel<65>scht");
|
||||
}
|
||||
|
||||
private string GetStringOfValue(byte[] buffer, Models.Parameter parameter)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"UpdateInterval": "1000",
|
||||
"CleanInterval" : "2"
|
||||
"CleanInterval" : "0"
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user