add Voltage and Power fields

This commit is contained in:
2026-01-06 18:43:23 +03:30
parent f75d85dbb7
commit 9334e3e4c2
9 changed files with 2548 additions and 23 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreenHome.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class POWER_VOLTAGE_FIELDS : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<byte>(
name: "Power",
table: "Telemetry",
type: "tinyint",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Voltage",
table: "Telemetry",
type: "int",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Power",
table: "Telemetry");
migrationBuilder.DropColumn(
name: "Voltage",
table: "Telemetry");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreenHome.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class FIX_VOLTAGE_TYPE : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<decimal>(
name: "Voltage",
table: "Telemetry",
type: "decimal(18,2)",
nullable: true,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "Voltage",
table: "Telemetry",
type: "int",
nullable: true,
oldClrType: typeof(decimal),
oldType: "decimal(18,2)",
oldNullable: true);
}
}
}

View File

@@ -740,6 +740,9 @@ namespace GreenHome.Infrastructure.Migrations
b.Property<int>("PersianYear")
.HasColumnType("int");
b.Property<byte?>("Power")
.HasColumnType("tinyint");
b.Property<DateTime>("ServerTimestampUtc")
.HasColumnType("datetime2");
@@ -752,6 +755,9 @@ namespace GreenHome.Infrastructure.Migrations
b.Property<DateTime>("TimestampUtc")
.HasColumnType("datetime2");
b.Property<decimal?>("Voltage")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
b.HasIndex("DeviceId", "ServerTimestampUtc");

View File

@@ -40,7 +40,7 @@ public sealed class TelemetryService : ITelemetryService
// ذخیره زمان سرور در لحظه ثبت
entity.ServerTimestampUtc = DateTime.Now;
var dt = dto.TimestampUtc.ToLocalTime();
var dt = dto.TimestampUtc!.Value.ToLocalTime();
var py = PersianCalendar.GetYear(dt);
var pm = PersianCalendar.GetMonth(dt);
var pd = PersianCalendar.GetDayOfMonth(dt);