Increase max length for contact info and names in contract entities; update related migrations and improve SMS service logic

This commit is contained in:
2025-11-19 21:23:28 +03:30
parent 37aa57d773
commit 90d7de4901
10 changed files with 24812 additions and 2163 deletions

View File

@@ -21,17 +21,14 @@ public class FaceEmbeddingService : IFaceEmbeddingService
private readonly IHttpClientFactory _httpClientFactory;
private readonly ILogger<FaceEmbeddingService> _logger;
private readonly IFaceEmbeddingNotificationService _notificationService;
private readonly string _apiBaseUrl;
public FaceEmbeddingService(IHttpClientFactory httpClientFactory, ILogger<FaceEmbeddingService> logger)
public FaceEmbeddingService(IHttpClientFactory httpClientFactory, ILogger<FaceEmbeddingService> logger,
IFaceEmbeddingNotificationService notificationService = null)
{
_httpClientFactory = httpClientFactory;
_logger = logger;
_notificationService = notificationService;
_apiBaseUrl = "http://localhost:8000";
}
_notificationService = notificationService;
public async Task<OperationResult> GenerateEmbeddingsAsync(long employeeId, long workshopId,
string employeeFullName, string picture1Path, string picture2Path)
{
@@ -84,21 +81,15 @@ public class FaceEmbeddingService : IFaceEmbeddingService
_logger.LogInformation("Embeddings generated successfully for Employee {EmployeeId}, Workshop {WorkshopId}",
employeeId, workshopId);
return new OperationResult
{
IsSuccedded = true,
// ارسال اطلاع‌رسانی به سایر سیستم‌ها
if (_notificationService != null)
{
await _notificationService.NotifyEmbeddingCreatedAsync(workshopId, employeeId, employeeFullName);
}
return new OperationResult
{
IsSuccedded = true,
Message = "Embedding با موفقیت ایجاد شد"
};
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
_logger.LogError("Failed to generate embeddings. Status: {StatusCode}, Error: {Error}",
response.StatusCode, errorContent);
@@ -160,13 +151,6 @@ public class FaceEmbeddingService : IFaceEmbeddingService
if (response.IsSuccessStatusCode)
{
_logger.LogInformation("Embeddings generated successfully from streams for Employee {EmployeeId}", employeeId);
// ارسال اطلاع‌رسانی به سایر سیستم‌ها
if (_notificationService != null)
{
await _notificationService.NotifyEmbeddingCreatedAsync(workshopId, employeeId, employeeFullName);
}
return new OperationResult { IsSuccedded = true, Message = "Embedding با موفقیت ایجاد شد" };
}
else
@@ -176,13 +160,13 @@ public class FaceEmbeddingService : IFaceEmbeddingService
response.StatusCode, errorContent);
return new OperationResult
// ارسال اطلاع‌رسانی به سایر سیستم‌ها
if (_notificationService != null)
{
IsSuccedded = false,
Message = $"خطا در تولید Embedding: {response.StatusCode}"
};
}
}
catch (Exception ex)
await _notificationService.NotifyEmbeddingCreatedAsync(workshopId, employeeId, employeeFullName);
}
{
_logger.LogError(ex, "Error while generating embeddings from streams for Employee {EmployeeId}", employeeId);
return new OperationResult
@@ -216,13 +200,6 @@ public class FaceEmbeddingService : IFaceEmbeddingService
if (response.IsSuccessStatusCode)
{
_logger.LogInformation("Embedding refined successfully for Employee {EmployeeId}", employeeId);
// ارسال اطلاع‌رسانی به سایر سیستم‌ها
if (_notificationService != null)
{
await _notificationService.NotifyEmbeddingRefinedAsync(workshopId, employeeId);
}
return new OperationResult { IsSuccedded = true, Message = "Embedding بهبود یافت" };
}
else
@@ -239,13 +216,13 @@ public class FaceEmbeddingService : IFaceEmbeddingService
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while refining embedding for Employee {EmployeeId}", employeeId);
return new OperationResult
{
IsSuccedded = false,
Message = "خطا در بهبود Embedding"
};
// ارسال اطلاع‌رسانی به سایر سیستم‌ها
if (_notificationService != null)
{
await _notificationService.NotifyEmbeddingRefinedAsync(workshopId, employeeId);
}
}
}
@@ -262,13 +239,6 @@ public class FaceEmbeddingService : IFaceEmbeddingService
if (response.IsSuccessStatusCode)
{
_logger.LogInformation("Embedding deleted successfully for Employee {EmployeeId}", employeeId);
// ارسال اطلاع‌رسانی به سایر سیستم‌ها
if (_notificationService != null)
{
await _notificationService.NotifyEmbeddingDeletedAsync(workshopId, employeeId);
}
return new OperationResult { IsSuccedded = true, Message = "Embedding حذف شد" };
}
else
@@ -292,13 +262,13 @@ public class FaceEmbeddingService : IFaceEmbeddingService
IsSuccedded = false,
Message = "خطا در حذف Embedding"
};
}
}
public async Task<OperationResult<FaceEmbeddingResponse>> GetEmbeddingAsync(long employeeId, long workshopId)
{
try
{
// ارسال اطلاع‌رسانی به سایر سیستم‌ها
if (_notificationService != null)
{
await _notificationService.NotifyEmbeddingDeletedAsync(workshopId, employeeId);
}
var httpClient = _httpClientFactory.CreateClient();
httpClient.BaseAddress = new Uri(_apiBaseUrl);
httpClient.Timeout = TimeSpan.FromSeconds(30);

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ public class InstitutinContractContactInfoMapping : IEntityTypeConfiguration<Ins
builder.ToTable("InstitutinContractContactInfo");
builder.HasKey(x => x.id);
builder.Property(x => x.FnameLname).HasMaxLength(50);
builder.Property(x => x.FnameLname).HasMaxLength(150);
builder.Property(x => x.PhoneNumber).HasMaxLength(20);
builder.Property(x => x.PhoneType).HasMaxLength(20);
builder.Property(x => x.Position).HasMaxLength(50);

View File

@@ -14,8 +14,8 @@ public class PersonalContractingpartyMapping : IEntityTypeConfiguration<Personal
builder.HasKey(x => x.id);
//builder.Property(x => x.LegalName).HasMaxLength(255).IsRequired();
builder.Property(x => x.FName).HasMaxLength(50).IsRequired();
builder.Property(x => x.LName).HasMaxLength(50).IsRequired();
builder.Property(x => x.FName).HasMaxLength(150).IsRequired();
builder.Property(x => x.LName).HasMaxLength(150).IsRequired();
builder.Property(x => x.SureName).HasMaxLength(50).IsRequired(false);
builder.Property(x => x.Nationalcode).HasMaxLength(10).IsRequired();
builder.Property(x => x.IdNumber).HasMaxLength(20).IsRequired(false);

View File

@@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class changemaxlengthofcontractingparty : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "LName",
table: "PersonalContractingParties",
type: "nvarchar(150)",
maxLength: 150,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(50)",
oldMaxLength: 50);
migrationBuilder.AlterColumn<string>(
name: "FName",
table: "PersonalContractingParties",
type: "nvarchar(150)",
maxLength: 150,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(50)",
oldMaxLength: 50);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "LName",
table: "PersonalContractingParties",
type: "nvarchar(50)",
maxLength: 50,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(150)",
oldMaxLength: 150);
migrationBuilder.AlterColumn<string>(
name: "FName",
table: "PersonalContractingParties",
type: "nvarchar(50)",
maxLength: 50,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(150)",
oldMaxLength: 150);
}
}
}

View File

@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class changemaxlengthofcontactinfoofinstitutioncontract : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "FnameLname",
table: "InstitutinContractContactInfo",
type: "nvarchar(150)",
maxLength: 150,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(50)",
oldMaxLength: 50,
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "FnameLname",
table: "InstitutinContractContactInfo",
type: "nvarchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(150)",
oldMaxLength: 150,
oldNullable: true);
}
}
}

View File

@@ -793,8 +793,8 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<string>("FName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("FatherName")
.HasMaxLength(20)
@@ -835,8 +835,8 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<string>("LName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("LegalPosition")
.HasMaxLength(50)
@@ -3611,8 +3611,8 @@ namespace CompanyManagment.EFCore.Migrations
.HasColumnType("datetime2");
b.Property<string>("FnameLname")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<long>("InstitutionContractId")
.HasColumnType("bigint");

File diff suppressed because it is too large Load Diff