inital
This commit is contained in:
43
OCPP.Core.Database/ChargePoint.cs
Normal file
43
OCPP.Core.Database/ChargePoint.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* OCPP.Core - https://github.com/dallmann-consulting/OCPP.Core
|
||||
* Copyright (C) 2020-2021 dallmann consulting GmbH.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database
|
||||
{
|
||||
public partial class ChargePoint
|
||||
{
|
||||
public ChargePoint()
|
||||
{
|
||||
Transactions = new HashSet<Transaction>();
|
||||
}
|
||||
|
||||
public string ChargePointId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string ClientCertThumb { get; set; }
|
||||
|
||||
public virtual ICollection<Transaction> Transactions { get; set; }
|
||||
}
|
||||
}
|
||||
35
OCPP.Core.Database/ChargeTag.cs
Normal file
35
OCPP.Core.Database/ChargeTag.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* OCPP.Core - https://github.com/dallmann-consulting/OCPP.Core
|
||||
* Copyright (C) 2020-2021 dallmann consulting GmbH.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database
|
||||
{
|
||||
public partial class ChargeTag
|
||||
{
|
||||
public string TagId { get; set; }
|
||||
public string TagName { get; set; }
|
||||
public string ParentTagId { get; set; }
|
||||
public DateTime? ExpiryDate { get; set; }
|
||||
public bool? Blocked { get; set; }
|
||||
}
|
||||
}
|
||||
40
OCPP.Core.Database/ConnectorStatus.cs
Normal file
40
OCPP.Core.Database/ConnectorStatus.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* OCPP.Core - https://github.com/dallmann-consulting/OCPP.Core
|
||||
* Copyright (C) 2020-2021 dallmann consulting GmbH.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database
|
||||
{
|
||||
public partial class ConnectorStatus
|
||||
{
|
||||
public string ChargePointId { get; set; }
|
||||
public int ConnectorId { get; set; }
|
||||
|
||||
public string ConnectorName { get; set; }
|
||||
|
||||
public string LastStatus { get; set; }
|
||||
public DateTime? LastStatusTime { get; set; }
|
||||
|
||||
public double? LastMeter { get; set; }
|
||||
public DateTime? LastMeterTime { get; set; }
|
||||
}
|
||||
}
|
||||
46
OCPP.Core.Database/ConnectorStatusView.cs
Normal file
46
OCPP.Core.Database/ConnectorStatusView.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* OCPP.Core - https://github.com/dallmann-consulting/OCPP.Core
|
||||
* Copyright (C) 2020-2021 dallmann consulting GmbH.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database
|
||||
{
|
||||
public partial class ConnectorStatusView
|
||||
{
|
||||
public string ChargePointId { get; set; }
|
||||
public int ConnectorId { get; set; }
|
||||
public string ConnectorName { get; set; }
|
||||
public string LastStatus { get; set; }
|
||||
public DateTime? LastStatusTime { get; set; }
|
||||
public double? LastMeter { get; set; }
|
||||
public DateTime? LastMeterTime { get; set; }
|
||||
public int? TransactionId { get; set; }
|
||||
public string StartTagId { get; set; }
|
||||
public DateTime? StartTime { get; set; }
|
||||
public double? MeterStart { get; set; }
|
||||
public string StartResult { get; set; }
|
||||
public string StopTagId { get; set; }
|
||||
public DateTime? StopTime { get; set; }
|
||||
public double? MeterStop { get; set; }
|
||||
public string StopReason { get; set; }
|
||||
}
|
||||
}
|
||||
29
OCPP.Core.Database/DbContextExtensions.cs
Normal file
29
OCPP.Core.Database/DbContextExtensions.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OCPP.Core.Database
|
||||
{
|
||||
public static class DbContextExtensions
|
||||
{
|
||||
public static void AddOCPPDbContext(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
string sqlServerConnectionString = configuration.GetConnectionString("SqlServer");
|
||||
string sqliteConnectionString = configuration.GetConnectionString("SQLite");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(sqlServerConnectionString))
|
||||
{
|
||||
services.AddDbContext<OCPPCoreContext>(options => options.UseSqlite(sqliteConnectionString));
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddDbContext<OCPPCoreContext>(options => options.UseSqlServer(sqlServerConnectionString));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
OCPP.Core.Database/MessageLog.cs
Normal file
37
OCPP.Core.Database/MessageLog.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* OCPP.Core - https://github.com/dallmann-consulting/OCPP.Core
|
||||
* Copyright (C) 2020-2021 dallmann consulting GmbH.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database
|
||||
{
|
||||
public partial class MessageLog
|
||||
{
|
||||
public int LogId { get; set; }
|
||||
public DateTime LogTime { get; set; }
|
||||
public string ChargePointId { get; set; }
|
||||
public int? ConnectorId { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string Result { get; set; }
|
||||
public string ErrorCode { get; set; }
|
||||
}
|
||||
}
|
||||
293
OCPP.Core.Database/Migrations/20240405204318_TransactionsIndex.Designer.cs
generated
Normal file
293
OCPP.Core.Database/Migrations/20240405204318_TransactionsIndex.Designer.cs
generated
Normal file
@@ -0,0 +1,293 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using OCPP.Core.Database;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(OCPPCoreContext))]
|
||||
[Migration("20240405204318_TransactionsIndex")]
|
||||
partial class TransactionsIndex
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ChargePoint", b =>
|
||||
{
|
||||
b.Property<string>("ChargePointId")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("ClientCertThumb")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("ChargePointId");
|
||||
|
||||
b.HasIndex(new[] { "ChargePointId" }, "ChargePoint_Identifier")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ChargePoint", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ChargeTag", b =>
|
||||
{
|
||||
b.Property<string>("TagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<bool?>("Blocked")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime?>("ExpiryDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("ParentTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("TagName")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)");
|
||||
|
||||
b.HasKey("TagId")
|
||||
.HasName("PK_ChargeKeys");
|
||||
|
||||
b.ToTable("ChargeTags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ConnectorStatus", b =>
|
||||
{
|
||||
b.Property<string>("ChargePointId")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<int>("ConnectorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ConnectorName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<double?>("LastMeter")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("LastMeterTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("LastStatus")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<DateTime?>("LastStatusTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("ChargePointId", "ConnectorId");
|
||||
|
||||
b.ToTable("ConnectorStatus", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ConnectorStatusView", b =>
|
||||
{
|
||||
b.Property<string>("ChargePointId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<int>("ConnectorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ConnectorName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<double?>("LastMeter")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("LastMeterTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("LastStatus")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<DateTime?>("LastStatusTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<double?>("MeterStart")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<double?>("MeterStop")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("StartResult")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("StartTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<DateTime?>("StartTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("StopReason")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("StopTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<DateTime?>("StopTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("TransactionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.ToTable((string)null);
|
||||
|
||||
b.ToView("ConnectorStatusView", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.MessageLog", b =>
|
||||
{
|
||||
b.Property<int>("LogId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("LogId"));
|
||||
|
||||
b.Property<string>("ChargePointId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<int?>("ConnectorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ErrorCode")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<DateTime>("LogTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("Result")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("LogId");
|
||||
|
||||
b.HasIndex(new[] { "LogTime" }, "IX_MessageLog_ChargePointId");
|
||||
|
||||
b.ToTable("MessageLog", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.Transaction", b =>
|
||||
{
|
||||
b.Property<int>("TransactionId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TransactionId"));
|
||||
|
||||
b.Property<string>("ChargePointId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<int>("ConnectorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("MeterStart")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<double?>("MeterStop")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("StartResult")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("StartTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<DateTime>("StartTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("StopReason")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("StopTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<DateTime?>("StopTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Uid")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("TransactionId");
|
||||
|
||||
b.HasIndex("ChargePointId", "ConnectorId");
|
||||
|
||||
b.ToTable("Transactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.Transaction", b =>
|
||||
{
|
||||
b.HasOne("OCPP.Core.Database.ChargePoint", "ChargePoint")
|
||||
.WithMany("Transactions")
|
||||
.HasForeignKey("ChargePointId")
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK_Transactions_ChargePoint");
|
||||
|
||||
b.Navigation("ChargePoint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ChargePoint", b =>
|
||||
{
|
||||
b.Navigation("Transactions");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class TransactionsIndex : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Transactions_ChargePointId_ConnectorId",
|
||||
table: "Transactions",
|
||||
columns: new[] { "ChargePointId", "ConnectorId" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Transactions_ChargePointId_ConnectorId",
|
||||
table: "Transactions");
|
||||
}
|
||||
}
|
||||
}
|
||||
290
OCPP.Core.Database/Migrations/OCPPCoreContextModelSnapshot.cs
Normal file
290
OCPP.Core.Database/Migrations/OCPPCoreContextModelSnapshot.cs
Normal file
@@ -0,0 +1,290 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using OCPP.Core.Database;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(OCPPCoreContext))]
|
||||
partial class OCPPCoreContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ChargePoint", b =>
|
||||
{
|
||||
b.Property<string>("ChargePointId")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("ClientCertThumb")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("ChargePointId");
|
||||
|
||||
b.HasIndex(new[] { "ChargePointId" }, "ChargePoint_Identifier")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ChargePoint", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ChargeTag", b =>
|
||||
{
|
||||
b.Property<string>("TagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<bool?>("Blocked")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime?>("ExpiryDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("ParentTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("TagName")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)");
|
||||
|
||||
b.HasKey("TagId")
|
||||
.HasName("PK_ChargeKeys");
|
||||
|
||||
b.ToTable("ChargeTags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ConnectorStatus", b =>
|
||||
{
|
||||
b.Property<string>("ChargePointId")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<int>("ConnectorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ConnectorName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<double?>("LastMeter")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("LastMeterTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("LastStatus")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<DateTime?>("LastStatusTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("ChargePointId", "ConnectorId");
|
||||
|
||||
b.ToTable("ConnectorStatus", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ConnectorStatusView", b =>
|
||||
{
|
||||
b.Property<string>("ChargePointId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<int>("ConnectorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ConnectorName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<double?>("LastMeter")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("LastMeterTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("LastStatus")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<DateTime?>("LastStatusTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<double?>("MeterStart")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<double?>("MeterStop")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("StartResult")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("StartTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<DateTime?>("StartTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("StopReason")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("StopTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<DateTime?>("StopTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("TransactionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.ToTable((string)null);
|
||||
|
||||
b.ToView("ConnectorStatusView", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.MessageLog", b =>
|
||||
{
|
||||
b.Property<int>("LogId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("LogId"));
|
||||
|
||||
b.Property<string>("ChargePointId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<int?>("ConnectorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ErrorCode")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<DateTime>("LogTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("Result")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("LogId");
|
||||
|
||||
b.HasIndex(new[] { "LogTime" }, "IX_MessageLog_ChargePointId");
|
||||
|
||||
b.ToTable("MessageLog", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.Transaction", b =>
|
||||
{
|
||||
b.Property<int>("TransactionId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TransactionId"));
|
||||
|
||||
b.Property<string>("ChargePointId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<int>("ConnectorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("MeterStart")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<double?>("MeterStop")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("StartResult")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("StartTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<DateTime>("StartTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("StopReason")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("StopTagId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<DateTime?>("StopTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Uid")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("TransactionId");
|
||||
|
||||
b.HasIndex("ChargePointId", "ConnectorId");
|
||||
|
||||
b.ToTable("Transactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.Transaction", b =>
|
||||
{
|
||||
b.HasOne("OCPP.Core.Database.ChargePoint", "ChargePoint")
|
||||
.WithMany("Transactions")
|
||||
.HasForeignKey("ChargePointId")
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK_Transactions_ChargePoint");
|
||||
|
||||
b.Navigation("ChargePoint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OCPP.Core.Database.ChargePoint", b =>
|
||||
{
|
||||
b.Navigation("Transactions");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
21
OCPP.Core.Database/OCPP.Core.Database.csproj
Normal file
21
OCPP.Core.Database/OCPP.Core.Database.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Version>1.3.2</Version>
|
||||
<Company>dallmann consulting GmbH</Company>
|
||||
<Product>OCPP.Core</Product>
|
||||
<Authors>Ulrich Dallmann</Authors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
139
OCPP.Core.Database/OCPPCoreContext.cs
Normal file
139
OCPP.Core.Database/OCPPCoreContext.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* OCPP.Core - https://github.com/dallmann-consulting/OCPP.Core
|
||||
* Copyright (C) 2020-2021 dallmann consulting GmbH.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database
|
||||
{
|
||||
public partial class OCPPCoreContext : DbContext
|
||||
{
|
||||
public OCPPCoreContext(DbContextOptions<OCPPCoreContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<ChargePoint> ChargePoints { get; set; }
|
||||
public virtual DbSet<ChargeTag> ChargeTags { get; set; }
|
||||
public virtual DbSet<ConnectorStatus> ConnectorStatuses { get; set; }
|
||||
public virtual DbSet<MessageLog> MessageLogs { get; set; }
|
||||
public virtual DbSet<Transaction> Transactions { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<ChargePoint>(entity =>
|
||||
{
|
||||
entity.ToTable("ChargePoint");
|
||||
|
||||
entity.HasIndex(e => e.ChargePointId, "ChargePoint_Identifier")
|
||||
.IsUnique();
|
||||
|
||||
entity.Property(e => e.ChargePointId).HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.Comment).HasMaxLength(200);
|
||||
|
||||
entity.Property(e => e.Name).HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.Username).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.Password).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.ClientCertThumb).HasMaxLength(100);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ChargeTag>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.TagId)
|
||||
.HasName("PK_ChargeKeys");
|
||||
|
||||
entity.Property(e => e.TagId).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.ParentTagId).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.TagName).HasMaxLength(200);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ConnectorStatus>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.ChargePointId, e.ConnectorId });
|
||||
|
||||
entity.ToTable("ConnectorStatus");
|
||||
|
||||
entity.Property(e => e.ChargePointId).HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.ConnectorName).HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.LastStatus).HasMaxLength(100);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<MessageLog>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.LogId);
|
||||
|
||||
entity.ToTable("MessageLog");
|
||||
|
||||
entity.HasIndex(e => e.LogTime, "IX_MessageLog_ChargePointId");
|
||||
|
||||
entity.Property(e => e.ChargePointId)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.ErrorCode).HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.Message)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Transaction>(entity =>
|
||||
{
|
||||
entity.Property(e => e.Uid).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.ChargePointId)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.StartResult).HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.StartTagId).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.StopReason).HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.StopTagId).HasMaxLength(50);
|
||||
|
||||
entity.HasOne(d => d.ChargePoint)
|
||||
.WithMany(p => p.Transactions)
|
||||
.HasForeignKey(d => d.ChargePointId)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("FK_Transactions_ChargePoint");
|
||||
|
||||
entity.HasIndex(e => new { e.ChargePointId, e.ConnectorId });
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
||||
}
|
||||
44
OCPP.Core.Database/Transaction.cs
Normal file
44
OCPP.Core.Database/Transaction.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* OCPP.Core - https://github.com/dallmann-consulting/OCPP.Core
|
||||
* Copyright (C) 2020-2021 dallmann consulting GmbH.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OCPP.Core.Database
|
||||
{
|
||||
public partial class Transaction
|
||||
{
|
||||
public int TransactionId { get; set; }
|
||||
public string Uid { get; set; }
|
||||
public string ChargePointId { get; set; }
|
||||
public int ConnectorId { get; set; }
|
||||
public string StartTagId { get; set; }
|
||||
public DateTime StartTime { get; set; }
|
||||
public double MeterStart { get; set; }
|
||||
public string StartResult { get; set; }
|
||||
public string StopTagId { get; set; }
|
||||
public DateTime? StopTime { get; set; }
|
||||
public double? MeterStop { get; set; }
|
||||
public string StopReason { get; set; }
|
||||
|
||||
public virtual ChargePoint ChargePoint { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user