Compare commits

..

2 Commits

210 changed files with 4965 additions and 20204 deletions

View File

@@ -37,7 +37,7 @@ jobs:
& "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" `
-verb:sync ` -verb:sync `
-source:contentPath="$publishFolder" ` -source:contentPath="$publishFolder" `
-dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R",authType="Basic" ` -dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R2rNpdnetP3j>q5b18",authType="Basic" `
-allowUntrusted ` -allowUntrusted `
-enableRule:AppOffline -enableRule:AppOffline

View File

@@ -6,7 +6,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentValidation" Version="12.1.1" />
<PackageReference Include="IPE.SmsIR" Version="1.2.7" /> <PackageReference Include="IPE.SmsIR" Version="1.2.7" />
<PackageReference Include="EPPlus" Version="8.4.0" /> <PackageReference Include="EPPlus" Version="8.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.3.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.3.0" />

View File

@@ -56,11 +56,6 @@ public class AuthHelper : IAuthHelper
return Tools.DeserializeFromBsonList<int>(permissions); //Mahan return Tools.DeserializeFromBsonList<int>(permissions); //Mahan
} }
public bool HasPermission(int permission)
{
return GetPermissions().Any(x => x == permission);
}
public long CurrentAccountId() public long CurrentAccountId()
{ {
return IsAuthenticated() return IsAuthenticated()
@@ -204,7 +199,7 @@ public class AuthHelper : IAuthHelper
new("WorkshopSlug",slug), new("WorkshopSlug",slug),
new("WorkshopId", account.WorkshopId.ToString()), new("WorkshopId", account.WorkshopId.ToString()),
new("WorkshopName",account.WorkshopName??""), new("WorkshopName",account.WorkshopName??""),
new("pm.userId", account.PmUserId.ToString()), new("pm.userId", account.PmUserId?.ToString() ?? "0"),
}; };

View File

@@ -33,9 +33,4 @@ public enum TypeOfSmsSetting
/// </summary> /// </summary>
LegalAction, LegalAction,
/// <summary>
/// پیامک تایید قراداد
/// </summary>
InstitutionContractConfirm,
} }

View File

@@ -11,7 +11,6 @@ public interface IFaceEmbeddingService
Task<OperationResult> RefineEmbeddingAsync(long employeeId, long workshopId, float[] embedding, float confidence, Dictionary<string, object> metadata = null); Task<OperationResult> RefineEmbeddingAsync(long employeeId, long workshopId, float[] embedding, float confidence, Dictionary<string, object> metadata = null);
Task<OperationResult> DeleteEmbeddingAsync(long employeeId, long workshopId); Task<OperationResult> DeleteEmbeddingAsync(long employeeId, long workshopId);
Task<OperationResult<FaceEmbeddingResponse>> GetEmbeddingAsync(long employeeId, long workshopId); Task<OperationResult<FaceEmbeddingResponse>> GetEmbeddingAsync(long employeeId, long workshopId);
Task<OperationResult> UpdateEmbeddingFullNameAsync(long employeeId, long workshopId, string newFullName);
} }
public class FaceEmbeddingResponse public class FaceEmbeddingResponse

View File

@@ -12,7 +12,6 @@ public interface IAuthHelper
string CurrentAccountRole(); string CurrentAccountRole();
AuthViewModel CurrentAccountInfo(); AuthViewModel CurrentAccountInfo();
List<int> GetPermissions(); List<int> GetPermissions();
bool HasPermission(int permission);
long CurrentAccountId(); long CurrentAccountId();
string CurrentAccountMobile(); string CurrentAccountMobile();

View File

@@ -27,7 +27,7 @@ public interface ISmsService
Task<double> GetCreditAmount(); Task<double> GetCreditAmount();
public Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId, string typeOfSms = null); public Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId);
public Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName, public Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
long contractingPartyId, long institutionContractId); long contractingPartyId, long institutionContractId);

View File

@@ -39,15 +39,4 @@ public static class StaticWorkshopAccounts
/// که کاربر همچنان به کارگاه دسترسی دارد /// که کاربر همچنان به کارگاه دسترسی دارد
/// </summary> /// </summary>
public static DateTime ContinuesWorkingDate = new DateTime(2150, 1, 1); public static DateTime ContinuesWorkingDate = new DateTime(2150, 1, 1);
/// <summary>
/// لیستی آی دی نقش هایی که مسئول بیمه کارگاه هستند
/// 7 : بیمه ارشد
/// 8 : بیمه ساده
/// </summary>
public static List<long> InsuranceAccountsRoleIds = [7, 8];
} }

View File

@@ -17,7 +17,7 @@ public class ExcelGenerator
{ {
public ExcelGenerator() public ExcelGenerator()
{ {
OfficeOpenXml.ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
} }
public static byte[] GenerateExcel<T>(List<T> obj, string date = "") where T : class public static byte[] GenerateExcel<T>(List<T> obj, string date = "") where T : class
{ {

View File

@@ -1,10 +1,7 @@
#nullable enable using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using FluentValidation;
using Microsoft.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -30,14 +27,6 @@ public class CustomExceptionHandler : IExceptionHandler
(string Detail, string Title, int StatusCode, Dictionary<string, object>? Extra) details = exception switch (string Detail, string Title, int StatusCode, Dictionary<string, object>? Extra) details = exception switch
{ {
ValidationException validationException =>
(
validationException.Errors.FirstOrDefault()?.ErrorMessage ?? "One or more validation errors occurred.",
"Validation Error",
context.Response.StatusCode = StatusCodes.Status400BadRequest,
null
),
InternalServerException => InternalServerException =>
( (
exception.Message, exception.Message,
@@ -45,7 +34,6 @@ public class CustomExceptionHandler : IExceptionHandler
context.Response.StatusCode = StatusCodes.Status500InternalServerError, context.Response.StatusCode = StatusCodes.Status500InternalServerError,
null null
), ),
BadRequestException bre => BadRequestException bre =>
( (
exception.Message, exception.Message,
@@ -53,7 +41,6 @@ public class CustomExceptionHandler : IExceptionHandler
context.Response.StatusCode = StatusCodes.Status400BadRequest, context.Response.StatusCode = StatusCodes.Status400BadRequest,
bre.Extra bre.Extra
), ),
NotFoundException => NotFoundException =>
( (
exception.Message, exception.Message,
@@ -61,7 +48,6 @@ public class CustomExceptionHandler : IExceptionHandler
context.Response.StatusCode = StatusCodes.Status404NotFound, context.Response.StatusCode = StatusCodes.Status404NotFound,
null null
), ),
UnAuthorizeException => UnAuthorizeException =>
( (
exception.Message, exception.Message,
@@ -69,7 +55,6 @@ public class CustomExceptionHandler : IExceptionHandler
context.Response.StatusCode = StatusCodes.Status401Unauthorized, context.Response.StatusCode = StatusCodes.Status401Unauthorized,
null null
), ),
_ => _ =>
( (
exception.Message, exception.Message,
@@ -88,6 +73,8 @@ public class CustomExceptionHandler : IExceptionHandler
Extensions = details.Extra ?? new Dictionary<string, object>() Extensions = details.Extra ?? new Dictionary<string, object>()
}; };
problemDetails.Extensions.Add("traceId", context.TraceIdentifier); problemDetails.Extensions.Add("traceId", context.TraceIdentifier);
await context.Response.WriteAsJsonAsync(problemDetails, cancellationToken: cancellationToken); await context.Response.WriteAsJsonAsync(problemDetails, cancellationToken: cancellationToken);

View File

@@ -18,387 +18,329 @@ namespace _0_Framework.Infrastructure;
/// </summary> /// </summary>
public class FaceEmbeddingService : IFaceEmbeddingService public class FaceEmbeddingService : IFaceEmbeddingService
{ {
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClientFactory _httpClientFactory;
private readonly ILogger<FaceEmbeddingService> _logger; private readonly ILogger<FaceEmbeddingService> _logger;
private readonly IFaceEmbeddingNotificationService _notificationService; private readonly IFaceEmbeddingNotificationService _notificationService;
private readonly string _apiBaseUrl; private readonly string _apiBaseUrl;
public FaceEmbeddingService(IHttpClientFactory httpClientFactory, ILogger<FaceEmbeddingService> logger, public FaceEmbeddingService(IHttpClientFactory httpClientFactory, ILogger<FaceEmbeddingService> logger,
IFaceEmbeddingNotificationService notificationService = null) IFaceEmbeddingNotificationService notificationService = null)
{ {
_httpClientFactory = httpClientFactory; _httpClientFactory = httpClientFactory;
_logger = logger; _logger = logger;
_notificationService = notificationService; _notificationService = notificationService;
_apiBaseUrl = "http://localhost:8000"; _apiBaseUrl = "http://localhost:8000";
} }
public async Task<OperationResult> GenerateEmbeddingsAsync(long employeeId, long workshopId, public async Task<OperationResult> GenerateEmbeddingsAsync(long employeeId, long workshopId,
string employeeFullName, string picture1Path, string picture2Path) string employeeFullName, string picture1Path, string picture2Path)
{ {
try try
{ {
var httpClient = _httpClientFactory.CreateClient(); var httpClient = _httpClientFactory.CreateClient();
httpClient.BaseAddress = new Uri(_apiBaseUrl); httpClient.BaseAddress = new Uri(_apiBaseUrl);
httpClient.Timeout = TimeSpan.FromSeconds(30); httpClient.Timeout = TimeSpan.FromSeconds(30);
using var content = new MultipartFormDataContent(); using var content = new MultipartFormDataContent();
// Add form fields // Add form fields
content.Add(new StringContent(employeeId.ToString()), "employee_id"); content.Add(new StringContent(employeeId.ToString()), "employee_id");
content.Add(new StringContent(workshopId.ToString()), "workshop_id"); content.Add(new StringContent(workshopId.ToString()), "workshop_id");
content.Add(new StringContent(employeeFullName ?? ""), "employee_full_name"); content.Add(new StringContent(employeeFullName ?? ""), "employee_full_name");
// Add picture files // Add picture files
if (File.Exists(picture1Path)) if (File.Exists(picture1Path))
{ {
var picture1Bytes = await File.ReadAllBytesAsync(picture1Path); var picture1Bytes = await File.ReadAllBytesAsync(picture1Path);
var picture1Content = new ByteArrayContent(picture1Bytes); var picture1Content = new ByteArrayContent(picture1Bytes);
picture1Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); picture1Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
content.Add(picture1Content, "picture1", "1.jpg"); content.Add(picture1Content, "picture1", "1.jpg");
} }
else else
{ {
_logger.LogWarning("Picture1 not found at path: {Path}", picture1Path); _logger.LogWarning("Picture1 not found at path: {Path}", picture1Path);
return new OperationResult { IsSuccedded = false, Message = "تصویر اول یافت نشد" }; return new OperationResult { IsSuccedded = false, Message = "تصویر اول یافت نشد" };
} }
if (File.Exists(picture2Path)) if (File.Exists(picture2Path))
{ {
var picture2Bytes = await File.ReadAllBytesAsync(picture2Path); var picture2Bytes = await File.ReadAllBytesAsync(picture2Path);
var picture2Content = new ByteArrayContent(picture2Bytes); var picture2Content = new ByteArrayContent(picture2Bytes);
picture2Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); picture2Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
content.Add(picture2Content, "picture2", "2.jpg"); content.Add(picture2Content, "picture2", "2.jpg");
} }
else else
{ {
_logger.LogWarning("Picture2 not found at path: {Path}", picture2Path); _logger.LogWarning("Picture2 not found at path: {Path}", picture2Path);
return new OperationResult { IsSuccedded = false, Message = "تصویر دوم یافت نشد" }; return new OperationResult { IsSuccedded = false, Message = "تصویر دوم یافت نشد" };
} }
// Send request to Python API // Send request to Python API
var response = await httpClient.PostAsync("embeddings", content); var response = await httpClient.PostAsync("embeddings", content);
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
var responseContent = await response.Content.ReadAsStringAsync(); var responseContent = await response.Content.ReadAsStringAsync();
_logger.LogInformation( _logger.LogInformation("Embeddings generated successfully for Employee {EmployeeId}, Workshop {WorkshopId}",
"Embeddings generated successfully for Employee {EmployeeId}, Workshop {WorkshopId}", employeeId, workshopId);
employeeId, workshopId);
// ارسال اطلاع‌رسانی به سایر سیستم‌ها // ارسال اطلاع‌رسانی به سایر سیستم‌ها
if (_notificationService != null) if (_notificationService != null)
{ {
await _notificationService.NotifyEmbeddingCreatedAsync(workshopId, employeeId, employeeFullName); await _notificationService.NotifyEmbeddingCreatedAsync(workshopId, employeeId, employeeFullName);
} }
return new OperationResult return new OperationResult
{ {
IsSuccedded = true, IsSuccedded = true,
Message = "Embedding با موفقیت ایجاد شد" Message = "Embedding با موفقیت ایجاد شد"
}; };
} }
else else
{ {
var errorContent = await response.Content.ReadAsStringAsync(); var errorContent = await response.Content.ReadAsStringAsync();
_logger.LogError("Failed to generate embeddings. Status: {StatusCode}, Error: {Error}", _logger.LogError("Failed to generate embeddings. Status: {StatusCode}, Error: {Error}",
response.StatusCode, errorContent); response.StatusCode, errorContent);
return new OperationResult return new OperationResult
{ {
IsSuccedded = false, IsSuccedded = false,
Message = $"خطا در تولید Embedding: {response.StatusCode}" Message = $"خطا در تولید Embedding: {response.StatusCode}"
}; };
} }
} }
catch (HttpRequestException ex) catch (HttpRequestException ex)
{ {
_logger.LogError(ex, "HTTP error while calling embeddings API for Employee {EmployeeId}", employeeId); _logger.LogError(ex, "HTTP error while calling embeddings API for Employee {EmployeeId}", employeeId);
return new OperationResult return new OperationResult
{ {
IsSuccedded = false, IsSuccedded = false,
Message = "خطا در ارتباط با سرور Embedding" Message = "خطا در ارتباط با سرور Embedding"
}; };
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error while calling embeddings API for Employee {EmployeeId}", employeeId); _logger.LogError(ex, "Error while calling embeddings API for Employee {EmployeeId}", employeeId);
return new OperationResult return new OperationResult
{ {
IsSuccedded = false, IsSuccedded = false,
Message = "خطای غیرمنتظره در تولید Embedding" Message = "خطای غیرمنتظره در تولید Embedding"
}; };
} }
} }
public async Task<OperationResult> GenerateEmbeddingsFromStreamAsync(long employeeId, long workshopId, public async Task<OperationResult> GenerateEmbeddingsFromStreamAsync(long employeeId, long workshopId,
string employeeFullName, Stream picture1Stream, Stream picture2Stream) string employeeFullName, Stream picture1Stream, Stream picture2Stream)
{ {
try try
{ {
var httpClient = _httpClientFactory.CreateClient(); var httpClient = _httpClientFactory.CreateClient();
httpClient.BaseAddress = new Uri(_apiBaseUrl); httpClient.BaseAddress = new Uri(_apiBaseUrl);
httpClient.Timeout = TimeSpan.FromSeconds(30); httpClient.Timeout = TimeSpan.FromSeconds(30);
using var content = new MultipartFormDataContent(); using var content = new MultipartFormDataContent();
// Add form fields // Add form fields
content.Add(new StringContent(employeeId.ToString()), "employee_id"); content.Add(new StringContent(employeeId.ToString()), "employee_id");
content.Add(new StringContent(workshopId.ToString()), "workshop_id"); content.Add(new StringContent(workshopId.ToString()), "workshop_id");
content.Add(new StringContent(employeeFullName ?? ""), "employee_full_name"); content.Add(new StringContent(employeeFullName ?? ""), "employee_full_name");
// Add picture streams // Add picture streams
var picture1Content = new StreamContent(picture1Stream); var picture1Content = new StreamContent(picture1Stream);
picture1Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); picture1Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
content.Add(picture1Content, "picture1", "1.jpg"); content.Add(picture1Content, "picture1", "1.jpg");
var picture2Content = new StreamContent(picture2Stream); var picture2Content = new StreamContent(picture2Stream);
picture2Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); picture2Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
content.Add(picture2Content, "picture2", "2.jpg"); content.Add(picture2Content, "picture2", "2.jpg");
// Send request to Python API // Send request to Python API
var response = await httpClient.PostAsync("embeddings", content); var response = await httpClient.PostAsync("embeddings", content);
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
_logger.LogInformation("Embeddings generated successfully from streams for Employee {EmployeeId}", _logger.LogInformation("Embeddings generated successfully from streams for Employee {EmployeeId}", employeeId);
employeeId);
// ارسال اطلاع‌رسانی به سایر سیستم‌ها
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 from streams. Status: {StatusCode}, Error: {Error}",
response.StatusCode, errorContent);
// ارسال اطلاع‌رسانی به سایر سیستم‌ها return new OperationResult
if (_notificationService != null) {
{ IsSuccedded = false,
await _notificationService.NotifyEmbeddingCreatedAsync(workshopId, employeeId, employeeFullName); Message = $"خطا در تولید Embedding: {response.StatusCode}"
} };
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while generating embeddings from streams for Employee {EmployeeId}", employeeId);
return new OperationResult
{
IsSuccedded = false,
Message = "خطا در تولید Embedding"
};
}
}
return new OperationResult { IsSuccedded = true, Message = "Embedding با موفقیت ایجاد شد" }; public async Task<OperationResult> RefineEmbeddingAsync(long employeeId, long workshopId, float[] embedding,
} float confidence, Dictionary<string, object> metadata = null)
else {
{ try
var errorContent = await response.Content.ReadAsStringAsync(); {
_logger.LogError("Failed to generate embeddings from streams. Status: {StatusCode}, Error: {Error}", var httpClient = _httpClientFactory.CreateClient();
response.StatusCode, errorContent); httpClient.BaseAddress = new Uri(_apiBaseUrl);
httpClient.Timeout = TimeSpan.FromSeconds(30);
return new OperationResult var requestBody = new
{ {
IsSuccedded = false, employeeId,
Message = $"خطا در تولید Embedding: {response.StatusCode}" workshopId,
}; embedding,
} confidence,
} metadata = metadata ?? new Dictionary<string, object>()
catch (Exception ex) };
{
_logger.LogError(ex, "Error while generating embeddings from streams for Employee {EmployeeId}",
employeeId);
return new OperationResult
{
IsSuccedded = false,
Message = "خطا در تولید Embedding"
};
}
}
public async Task<OperationResult> RefineEmbeddingAsync(long employeeId, long workshopId, float[] embedding, var response = await httpClient.PostAsJsonAsync("embeddings/refine", requestBody);
float confidence, Dictionary<string, object> metadata = null)
{
try
{
var httpClient = _httpClientFactory.CreateClient();
httpClient.BaseAddress = new Uri(_apiBaseUrl);
httpClient.Timeout = TimeSpan.FromSeconds(30);
var requestBody = new if (response.IsSuccessStatusCode)
{ {
employeeId, _logger.LogInformation("Embedding refined successfully for Employee {EmployeeId}", employeeId);
workshopId,
embedding, // ارسال اطلاع‌رسانی به سایر سیستم‌ها
confidence, if (_notificationService != null)
metadata = metadata ?? new Dictionary<string, object>() {
}; await _notificationService.NotifyEmbeddingRefinedAsync(workshopId, employeeId);
}
return new OperationResult { IsSuccedded = true, Message = "Embedding بهبود یافت" };
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
_logger.LogError("Failed to refine embedding. Status: {StatusCode}, Error: {Error}",
response.StatusCode, errorContent);
var response = await httpClient.PostAsJsonAsync("embeddings/refine", requestBody); return new OperationResult
{
IsSuccedded = false,
Message = $"خطا در بهبود Embedding: {response.StatusCode}"
};
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while refining embedding for Employee {EmployeeId}", employeeId);
return new OperationResult
{
IsSuccedded = false,
Message = "خطا در بهبود Embedding"
};
}
}
if (response.IsSuccessStatusCode) public async Task<OperationResult> DeleteEmbeddingAsync(long employeeId, long workshopId)
{ {
_logger.LogInformation("Embedding refined successfully for Employee {EmployeeId}", employeeId); try
{
var httpClient = _httpClientFactory.CreateClient();
httpClient.BaseAddress = new Uri(_apiBaseUrl);
httpClient.Timeout = TimeSpan.FromSeconds(30);
// ارسال اطلاع‌رسانی به سایر سیستم‌ها var response = await httpClient.DeleteAsync($"embeddings/{workshopId}/{employeeId}");
if (_notificationService != null)
{
await _notificationService.NotifyEmbeddingRefinedAsync(workshopId, employeeId);
}
return new OperationResult { IsSuccedded = true, Message = "Embedding بهبود یافت" }; if (response.IsSuccessStatusCode)
} {
else _logger.LogInformation("Embedding deleted successfully for Employee {EmployeeId}", employeeId);
{
var errorContent = await response.Content.ReadAsStringAsync(); // ارسال اطلاع‌رسانی به سایر سیستم‌ها
_logger.LogError("Failed to refine embedding. Status: {StatusCode}, Error: {Error}", if (_notificationService != null)
response.StatusCode, errorContent); {
await _notificationService.NotifyEmbeddingDeletedAsync(workshopId, employeeId);
}
return new OperationResult { IsSuccedded = true, Message = "Embedding حذف شد" };
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
_logger.LogError("Failed to delete embedding. Status: {StatusCode}, Error: {Error}",
response.StatusCode, errorContent);
return new OperationResult return new OperationResult
{ {
IsSuccedded = false, IsSuccedded = false,
Message = $"خطا در بهبود Embedding: {response.StatusCode}" Message = $"خطا در حذف Embedding: {response.StatusCode}"
}; };
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error while refining embedding for Employee {EmployeeId}", employeeId); _logger.LogError(ex, "Error while deleting embedding for Employee {EmployeeId}", employeeId);
return new OperationResult return new OperationResult
{ {
IsSuccedded = false, IsSuccedded = false,
Message = "خطا در بهبود Embedding" Message = "خطا در حذف Embedding"
}; };
} }
} }
public async Task<OperationResult> DeleteEmbeddingAsync(long employeeId, long workshopId) public async Task<OperationResult<FaceEmbeddingResponse>> GetEmbeddingAsync(long employeeId, long workshopId)
{ {
try try
{ {
var httpClient = _httpClientFactory.CreateClient(); var httpClient = _httpClientFactory.CreateClient();
httpClient.BaseAddress = new Uri(_apiBaseUrl); httpClient.BaseAddress = new Uri(_apiBaseUrl);
httpClient.Timeout = TimeSpan.FromSeconds(30); httpClient.Timeout = TimeSpan.FromSeconds(30);
var response = await httpClient.DeleteAsync($"embeddings/{workshopId}/{employeeId}"); var response = await httpClient.GetAsync($"embeddings/{workshopId}/{employeeId}");
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
_logger.LogInformation("Embedding deleted successfully for Employee {EmployeeId}", employeeId); var content = await response.Content.ReadAsStringAsync();
var embeddingData = JsonSerializer.Deserialize<FaceEmbeddingResponse>(content,
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
// ارسال اطلاع‌رسانی به سایر سیستم‌ها _logger.LogInformation("Embedding retrieved successfully for Employee {EmployeeId}", employeeId);
if (_notificationService != null)
{
await _notificationService.NotifyEmbeddingDeletedAsync(workshopId, employeeId);
}
return new OperationResult { IsSuccedded = true, Message = "Embedding حذف شد" }; return new OperationResult<FaceEmbeddingResponse>
} {
else IsSuccedded = true,
{ Message = "Embedding دریافت شد",
var errorContent = await response.Content.ReadAsStringAsync(); Data = embeddingData
_logger.LogError("Failed to delete embedding. Status: {StatusCode}, Error: {Error}", };
response.StatusCode, errorContent); }
else
return new OperationResult {
{ var errorContent = await response.Content.ReadAsStringAsync();
IsSuccedded = false, _logger.LogError("Failed to get embedding. Status: {StatusCode}, Error: {Error}",
Message = $"خطا در حذف Embedding: {response.StatusCode}" response.StatusCode, errorContent);
};
} return new OperationResult<FaceEmbeddingResponse>
} {
catch (Exception ex) IsSuccedded = false,
{ Message = $"خطا در دریافت Embedding: {response.StatusCode}"
_logger.LogError(ex, "Error while deleting embedding for Employee {EmployeeId}", employeeId); };
return new OperationResult }
{ }
IsSuccedded = false, catch (Exception ex)
Message = "خطا در حذف Embedding" {
}; _logger.LogError(ex, "Error while getting embedding for Employee {EmployeeId}", employeeId);
} return new OperationResult<FaceEmbeddingResponse>
} {
IsSuccedded = false,
public async Task<OperationResult<FaceEmbeddingResponse>> GetEmbeddingAsync(long employeeId, long workshopId) Message = "خطا در دریافت Embedding"
{ };
try }
{ }
var httpClient = _httpClientFactory.CreateClient(); }
httpClient.BaseAddress = new Uri(_apiBaseUrl);
httpClient.Timeout = TimeSpan.FromSeconds(30);
var response = await httpClient.GetAsync($"embeddings/{workshopId}/{employeeId}");
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var embeddingData = JsonSerializer.Deserialize<FaceEmbeddingResponse>(content,
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
_logger.LogInformation("Embedding retrieved successfully for Employee {EmployeeId}", employeeId);
return new OperationResult<FaceEmbeddingResponse>
{
IsSuccedded = true,
Message = "Embedding دریافت شد",
Data = embeddingData
};
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
_logger.LogError("Failed to get embedding. Status: {StatusCode}, Error: {Error}",
response.StatusCode, errorContent);
return new OperationResult<FaceEmbeddingResponse>
{
IsSuccedded = false,
Message = $"خطا در دریافت Embedding: {response.StatusCode}"
};
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while getting embedding for Employee {EmployeeId}", employeeId);
return new OperationResult<FaceEmbeddingResponse>
{
IsSuccedded = false,
Message = "خطا در دریافت Embedding"
};
}
}
public async Task<OperationResult> UpdateEmbeddingFullNameAsync(long employeeId, long workshopId,
string newFullName)
{
try
{
var httpClient = _httpClientFactory.CreateClient();
httpClient.BaseAddress = new Uri(_apiBaseUrl);
httpClient.Timeout = TimeSpan.FromSeconds(30);
var requestBody = new
{
employee_id = employeeId,
workshop_id = workshopId,
employee_full_name = newFullName
};
var response = await httpClient.PutAsJsonAsync("embeddings/update-name", requestBody);
if (response.IsSuccessStatusCode)
{
_logger.LogInformation("Employee Name Changed For {EmployeeId} In workshop ={WorkshopId}", employeeId,
workshopId);
// ارسال اطلاع‌رسانی به سایر سیستم‌ها
if (_notificationService != null)
{
//await _notificationService.NotifyEmbeddingRefinedAsync(workshopId, employeeId);
}
return new OperationResult { IsSuccedded = true, Message = "عملیات با موفقیت انجام شد" };
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
_logger.LogError("Failed to refine embedding. Status: {StatusCode}, Error: {Error}",
response.StatusCode, errorContent);
return new OperationResult
{
IsSuccedded = false,
Message = $"خطا در بهبود Embedding: {response.StatusCode}"
};
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while Changing EmployeeFullName for Employee {EmployeeId}", employeeId);
return new OperationResult
{
IsSuccedded = false,
Message = "خطا در بهبود Embedding"
};
}
}
}

View File

@@ -1,4 +1,6 @@
namespace AccountManagement.Application.Contracts.Account; using System.Collections.Generic;
namespace AccountManagement.Application.Contracts.Account;
public class EditAccount : CreateAccount public class EditAccount : CreateAccount
{ {

View File

@@ -1,4 +1,10 @@
namespace AccountManagement.Application.Contracts.Account; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountManagement.Application.Contracts.Account;
public class EditClientAccount : RegisterAccount public class EditClientAccount : RegisterAccount
{ {

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Shared.Contracts.PmUser.Queries; using AccountManagement.Application.Contracts.ProgramManager;
namespace AccountManagement.Application.Contracts.Account; namespace AccountManagement.Application.Contracts.Account;
@@ -74,8 +74,12 @@ public interface IAccountApplication
void CameraLogin(CameraLoginRequest request); void CameraLogin(CameraLoginRequest request);
Task<GetPmUserDto> GetPmUserAsync(long accountId); /// <summary>
/// دریافت کاربر پروگرام منیجر با اکانت آی دی
/// </summary>
/// <param name="accountId"></param>
/// <returns></returns>
Task<GetPmUserDto> GetPmUserByAccountId(long accountId);
} }
public class CameraLoginRequest public class CameraLoginRequest

View File

@@ -1,4 +1,10 @@
using System.ComponentModel.DataAnnotations; using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _0_Framework.Application;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
namespace AccountManagement.Application.Contracts.Account; namespace AccountManagement.Application.Contracts.Account;

View File

@@ -1,4 +1,10 @@
namespace AccountManagement.Application.Contracts.Account; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountManagement.Application.Contracts.Account;
public class WorkshopSelectList public class WorkshopSelectList
{ {

View File

@@ -1,8 +1,9 @@
namespace Shared.Contracts.PmUser.Queries; using System.Collections.Generic;
namespace AccountManagement.Application.Contracts.ProgramManager;
public class GetPmUserDto public class GetPmUserDto
{ {
public long Id { get; set; }
/// <summary> /// <summary>
/// نام و نام خانوادگی /// نام و نام خانوادگی
/// </summary> /// </summary>
@@ -42,7 +43,7 @@ public class GetPmUserDto
public List<long> Roles { get; set; } public List<long> Roles { get; set; }
public List<RoleListDto>? RoleListDto { get; set; } public List<RoleListDto> RoleListDto { get; set; }
} }

View File

@@ -0,0 +1,28 @@
using System.Collections.Generic;
namespace AccountManagement.Application.Contracts.ProgramManager;
public record GetPmRolesDto
{
/// <summary>
/// آی دی نقش
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام نقش
/// </summary>
public string RoleName { get; set; }
/// <summary>
/// آی دی نقش در گزارشگیر
/// </summary>
public long? GozareshgirRoleId { get; set; }
/// <summary>
/// لیست کدهای دسترسی
/// </summary>
public List<int> Permissions { get; set; }
}

View File

@@ -2,9 +2,13 @@
using _0_Framework.Application.Sms; using _0_Framework.Application.Sms;
using _0_Framework.Exceptions; using _0_Framework.Exceptions;
using AccountManagement.Application.Contracts.Account; using AccountManagement.Application.Contracts.Account;
using AccountManagement.Application.Contracts.ProgramManagerApiResult;
using AccountManagement.Domain.AccountAgg; using AccountManagement.Domain.AccountAgg;
using AccountManagement.Domain.AccountLeftWorkAgg; using AccountManagement.Domain.AccountLeftWorkAgg;
using AccountManagement.Domain.CameraAccountAgg; using AccountManagement.Domain.CameraAccountAgg;
using AccountManagement.Domain.InternalApiCaller;
using AccountManagement.Domain.PmDomains.PmRoleUserAgg;
using AccountManagement.Domain.PmDomains.PmUserAgg;
using AccountManagement.Domain.PositionAgg; using AccountManagement.Domain.PositionAgg;
using AccountManagement.Domain.RoleAgg; using AccountManagement.Domain.RoleAgg;
using AccountManagement.Domain.SubAccountAgg; using AccountManagement.Domain.SubAccountAgg;
@@ -13,14 +17,25 @@ using AccountManagement.Domain.SubAccountRoleAgg;
using Company.Domain._common; using Company.Domain._common;
using Company.Domain.WorkshopAgg; using Company.Domain.WorkshopAgg;
using Company.Domain.WorkshopSubAccountAgg; using Company.Domain.WorkshopSubAccountAgg;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.JsonPatch.Operations;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Security.Claims;
using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AccountManagement.Application.Contracts.ProgramManager;
using Shared.Contracts.PmUser.Commands; using Shared.Contracts.PmUser;
using Shared.Contracts.PmUser.Queries; using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
//using AccountManagement.Domain.RoleAgg; //using AccountManagement.Domain.RoleAgg;
@@ -42,13 +57,12 @@ public class AccountApplication : IAccountApplication
private readonly ISubAccountRoleRepository _subAccountRoleRepository; private readonly ISubAccountRoleRepository _subAccountRoleRepository;
private readonly IWorkshopSubAccountRepository _workshopSubAccountRepository; private readonly IWorkshopSubAccountRepository _workshopSubAccountRepository;
private readonly ISubAccountPermissionSubtitle1Repository _accountPermissionSubtitle1Repository; private readonly ISubAccountPermissionSubtitle1Repository _accountPermissionSubtitle1Repository;
private readonly IPmUserRepository _pmUserRepository;
private readonly IUnitOfWork _unitOfWork; private readonly IUnitOfWork _unitOfWork;
private readonly IPmUserQueryService _pmUserQueryService; private readonly IPmUserQueryService _pmUserQueryService;
private readonly IPmUserCommandService _pmUserCommandService;
public AccountApplication(IAccountRepository accountRepository, IPasswordHasher passwordHasher, public AccountApplication(IAccountRepository accountRepository, IPasswordHasher passwordHasher,
IFileUploader fileUploader, IAuthHelper authHelper, IRoleRepository roleRepository, IWorker worker, ISmsService smsService, ICameraAccountRepository cameraAccountRepository, IPositionRepository positionRepository, IAccountLeftworkRepository accountLeftworkRepository, IWorkshopRepository workshopRepository, ISubAccountRepository subAccountRepository, ISubAccountRoleRepository subAccountRoleRepository, IWorkshopSubAccountRepository workshopSubAccountRepository, ISubAccountPermissionSubtitle1Repository accountPermissionSubtitle1Repository, IUnitOfWork unitOfWork, IPmUserQueryService pmUserQueryService, IPmUserCommandService pmUserCommandService) IFileUploader fileUploader, IAuthHelper authHelper, IRoleRepository roleRepository, IWorker worker, ISmsService smsService, ICameraAccountRepository cameraAccountRepository, IPositionRepository positionRepository, IAccountLeftworkRepository accountLeftworkRepository, IWorkshopRepository workshopRepository, ISubAccountRepository subAccountRepository, ISubAccountRoleRepository subAccountRoleRepository, IWorkshopSubAccountRepository workshopSubAccountRepository, ISubAccountPermissionSubtitle1Repository accountPermissionSubtitle1Repository, IUnitOfWork unitOfWork, IPmUserRepository pmUserRepository, IPmUserQueryService pmUserQueryService)
{ {
_authHelper = authHelper; _authHelper = authHelper;
_roleRepository = roleRepository; _roleRepository = roleRepository;
@@ -62,9 +76,8 @@ public class AccountApplication : IAccountApplication
_workshopSubAccountRepository = workshopSubAccountRepository; _workshopSubAccountRepository = workshopSubAccountRepository;
_accountPermissionSubtitle1Repository = accountPermissionSubtitle1Repository; _accountPermissionSubtitle1Repository = accountPermissionSubtitle1Repository;
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_pmUserRepository = pmUserRepository;
_pmUserQueryService = pmUserQueryService; _pmUserQueryService = pmUserQueryService;
_pmUserCommandService = pmUserCommandService;
_fileUploader = fileUploader; _fileUploader = fileUploader;
_passwordHasher = passwordHasher; _passwordHasher = passwordHasher;
_accountRepository = accountRepository; _accountRepository = accountRepository;
@@ -155,18 +168,40 @@ public class AccountApplication : IAccountApplication
if (command.IsProgramManagerUser) if (command.IsProgramManagerUser)
{ {
if (command.UserRoles == null)
return operation.Failed("حداقل یک نقش برای کاربر مدیریت پروژه لازم است"); try
var pmUserRoles = command.UserRoles.Where(x => x > 0).ToList();
var createPm = await _pmUserCommandService.Create(new CreatePmUserDto(command.Fullname, command.Username, account.Password, command.Mobile,
null, account.id, pmUserRoles));
if (!createPm.isSuccess)
{ {
_unitOfWork.RollbackAccountContext(); if (_pmUserRepository.Exists(x => x.FullName == command.Fullname))
return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر"); {
_unitOfWork.RollbackAccountContext();
return operation.Failed("نام و خانوادگی تکراری است");
}
if (_pmUserRepository.Exists(x => x.UserName == command.Username))
{
_unitOfWork.RollbackAccountContext();
return operation.Failed("نام کاربری تکراری است");
}
if (_pmUserRepository.Exists(x => !string.IsNullOrWhiteSpace(x.Mobile) && x.Mobile == command.Mobile))
{
_unitOfWork.RollbackAccountContext();
return operation.Failed("این شماره همراه قبلا به فرد دیگری اختصاص داده شده است");
}
var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
var create = new PmUser(command.Fullname, command.Username, command.Password, command.Mobile,
null, account.id, userRoles);
await _pmUserRepository.CreateAsync(create);
await _pmUserRepository.SaveChangesAsync();
}
catch (Exception e)
{
_unitOfWork.RollbackAccountContext();
return operation.Failed("خطا در ایجاد کاربر پروگرام منیجر");
} }
//var url = "api/user/create"; //var url = "api/user/create";
//var key = SecretKeys.ProgramManagerInternalApi; //var key = SecretKeys.ProgramManagerInternalApi;
@@ -252,29 +287,31 @@ public class AccountApplication : IAccountApplication
// $"api/user/{account.id}", // $"api/user/{account.id}",
// key // key
//); //);
var userResult =await _pmUserQueryService.GetPmUserDataByAccountId(account.id); var userResult = _pmUserRepository.GetByPmUsertoEditbyAccountId(account.id).GetAwaiter().GetResult();
if (command.UserRoles == null)
return operation.Failed("حداقل یک نقش برای کاربر مدیریت پروژه لازم است");
var pmUserRoles = command.UserRoles.Where(x => x > 0).ToList();
//اگر کاربر در پروگرام منیجر قبلا ایجاد شده //اگر کاربر در پروگرام منیجر قبلا ایجاد شده
if (userResult.Id >0) if (userResult != null)
{ {
if (!command.UserRoles.Any()) if (!command.UserRoles.Any())
{ {
_unitOfWork.RollbackAccountContext(); _unitOfWork.RollbackAccountContext();
return operation.Failed("حداقل یک نقش باید انتخاب شود"); return operation.Failed("حداقل یک نقش باید انتخاب شود");
} }
var editPm =await _pmUserCommandService.Edit(new EditPmUserDto(command.Fullname, command.Username, command.Mobile, account.id, pmUserRoles, try
command.IsProgramManagerUser)); {
if (!editPm.isSuccess)
var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
userResult.Edit(command.Fullname, command.Username, command.Mobile, userRoles, command.IsProgramManagerUser);
await _pmUserRepository.SaveChangesAsync();
}
catch (Exception)
{ {
_unitOfWork.RollbackAccountContext(); _unitOfWork.RollbackAccountContext();
return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر"); return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر");
} }
//var parameters = new EditUserCommand( //var parameters = new EditUserCommand(
// command.Fullname, // command.Fullname,
// command.Username, // command.Username,
@@ -315,19 +352,39 @@ public class AccountApplication : IAccountApplication
return operation.Failed("حداقل یک نقش باید انتخاب شود"); return operation.Failed("حداقل یک نقش باید انتخاب شود");
} }
if (_pmUserRepository.Exists(x => x.FullName == command.Fullname))
var createPm = await _pmUserCommandService.Create(new CreatePmUserDto(command.Fullname, command.Username, account.Password, command.Mobile,
null, account.id, pmUserRoles));
if (!createPm.isSuccess)
{ {
_unitOfWork.RollbackAccountContext();
return operation.Failed("نام و خانوادگی تکراری است");
}
if (_pmUserRepository.Exists(x => x.UserName == command.Username))
{
_unitOfWork.RollbackAccountContext();
return operation.Failed("نام کاربری تکراری است");
}
if (_pmUserRepository.Exists(x => !string.IsNullOrWhiteSpace(x.Mobile) && x.Mobile == command.Mobile))
{
_unitOfWork.RollbackAccountContext();
return operation.Failed("این شماره همراه قبلا به فرد دیگری اختصاص داده شده است");
}
try
{
var userRoles = command.UserRoles.Where(x => x > 0).Select(x => new PmRoleUser(x)).ToList();
var create = new PmUser(command.Fullname, command.Username, account.Password, command.Mobile,
null, account.id, userRoles);
await _pmUserRepository.CreateAsync(create);
await _pmUserRepository.SaveChangesAsync();
}
catch (Exception)
{
_unitOfWork.RollbackAccountContext(); _unitOfWork.RollbackAccountContext();
return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر"); return operation.Failed("خطا در ویرایش کاربر پروگرام منیجر");
} }
//var parameters = new CreateProgramManagerUser( //var parameters = new CreateProgramManagerUser(
@@ -400,23 +457,6 @@ public class AccountApplication : IAccountApplication
.Permissions .Permissions
.Select(x => x.Code) .Select(x => x.Code)
.ToList(); .ToList();
//PmPermission
var PmUserData = _pmUserQueryService.GetPmUserDataByAccountId(account.id).GetAwaiter().GetResult();
if (PmUserData.AccountId > 0 && PmUserData.IsActive)
{
var pmUserPermissions =
PmUserData.RoleListDto != null
? PmUserData.RoleListDto
.SelectMany(x => x.Permissions)
.Where(p => p != 99)
.Distinct()
.ToList()
: new List<int>();
permissions.AddRange(pmUserPermissions);
}
int? positionValue; int? positionValue;
if (account.PositionId != null) if (account.PositionId != null)
{ {
@@ -426,7 +466,7 @@ public class AccountApplication : IAccountApplication
{ {
positionValue = null; positionValue = null;
} }
var pmUserId = PmUserData.AccountId > 0 ? PmUserData.AccountId : null; var pmUserId = _pmUserQueryService.GetCurrentPmUserIdFromAccountId(account.id).GetAwaiter().GetResult();
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
, account.Username, account.Mobile, account.ProfilePhoto, , account.Username, account.Mobile, account.ProfilePhoto,
permissions, account.RoleName, account.AdminAreaPermission, permissions, account.RoleName, account.AdminAreaPermission,
@@ -1020,8 +1060,8 @@ public class AccountApplication : IAccountApplication
_authHelper.CameraSignIn(authViewModel); _authHelper.CameraSignIn(authViewModel);
} }
public async Task<GetPmUserDto> GetPmUserAsync(long accountId) public async Task<GetPmUserDto> GetPmUserByAccountId(long accountId)
{ {
return await _pmUserQueryService.GetPmUserDataByAccountId(accountId); return await _pmUserRepository.GetPmUserByAccountId(accountId);
} }
} }

View File

@@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _0_Framework.Application; using _0_Framework.Application;
using AccountManagement.Application.Contracts.Account; using AccountManagement.Application.Contracts.Account;
using AccountManagement.Application.Contracts.CameraAccount; using AccountManagement.Application.Contracts.CameraAccount;

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using _0_Framework.Application; using _0_Framework.Application;

View File

@@ -4,7 +4,13 @@ using AccountManagement.Domain.RoleAgg;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using AccountManagement.Application.Contracts.ProgramManagerApiResult;
using AccountManagement.Domain.InternalApiCaller;
using Company.Domain._common; using Company.Domain._common;
using AccountManagement.Application.Contracts.Ticket;
using AccountManagement.Domain.PmDomains.PmPermissionAgg;
using AccountManagement.Domain.PmDomains.PmRoleAgg;
using AccountManagement.Domain.PmDomains.PmUserAgg;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using Shared.Contracts.PmRole.Commands; using Shared.Contracts.PmRole.Commands;
using GetPmRolesDto = Shared.Contracts.PmRole.Queries.GetPmRolesDto; using GetPmRolesDto = Shared.Contracts.PmRole.Queries.GetPmRolesDto;
@@ -16,15 +22,18 @@ namespace AccountManagement.Application;
public class RoleApplication : IRoleApplication public class RoleApplication : IRoleApplication
{ {
private readonly IRoleRepository _roleRepository; private readonly IRoleRepository _roleRepository;
private readonly IPmRoleRepository _pmRoleRepository;
private readonly IPmUserRepository _pmUserRepository;
private readonly IPmRoleQueryService _pmRoleQueryService; private readonly IPmRoleQueryService _pmRoleQueryService;
private readonly IPmRoleCommandService _pmRoleCommandService; private readonly IPmRoleCommandService _pmRoleCommandService;
private readonly IUnitOfWork _unitOfWork; private readonly IUnitOfWork _unitOfWork;
public RoleApplication(IRoleRepository roleRepository, IUnitOfWork unitOfWork, IPmRoleQueryService pmRoleQueryService, IPmRoleCommandService pmRoleCommandService) public RoleApplication(IRoleRepository roleRepository, IUnitOfWork unitOfWork, IPmRoleRepository pmRoleRepository, IPmUserRepository pmUserRepository, IPmRoleQueryService pmRoleQueryService, IPmRoleCommandService pmRoleCommandService)
{ {
_roleRepository = roleRepository; _roleRepository = roleRepository;
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_pmRoleRepository = pmRoleRepository;
_pmUserRepository = pmUserRepository;
_pmRoleQueryService = pmRoleQueryService; _pmRoleQueryService = pmRoleQueryService;
_pmRoleCommandService = pmRoleCommandService; _pmRoleCommandService = pmRoleCommandService;
} }
@@ -179,28 +188,22 @@ public class RoleApplication : IRoleApplication
//این نقش را سمت پروگرام منیجر بساز //این نقش را سمت پروگرام منیجر بساز
if (pmPermissions.Any()) if (pmPermissions.Any())
{ {
var pmRole = new CreatePmRoleDto { RoleName = command.Name, Permissions = pmPermissions, GozareshgirRoleId = role.id };
var res = await _pmRoleCommandService.Create(pmRole);
if (!res.Item1) try
{
var pmPermissionsData = pmPermissions.Where(x => x > 0).Select(x => new PmPermission(x)).ToList();
var pmRole = new PmRole(command.Name, command.Id, pmPermissionsData);
await _pmRoleRepository.CreateAsync(pmRole);
await _pmRoleRepository.SaveChangesAsync();
}
catch (System.Exception)
{ {
_unitOfWork.RollbackAccountContext(); _unitOfWork.RollbackAccountContext();
return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر"); return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر");
} }
//try
//{
// var pmPermissionsData = pmPermissions.Where(x => x > 0).Select(x => new PmPermission(x)).ToList();
// var pmRole = new PmRole(command.Name, command.Id, pmPermissionsData);
// await _pmRoleRepository.CreateAsync(pmRole);
// await _pmRoleRepository.SaveChangesAsync();
//}
//catch (System.Exception)
//{
// _unitOfWork.RollbackAccountContext();
// return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر");
//}
//var parameters = new CreateProgramManagerRole //var parameters = new CreateProgramManagerRole
//{ //{
// RoleName = command.Name, // RoleName = command.Name,

View File

@@ -5,11 +5,14 @@ using AccountManagement.Domain.AccountAgg;
using AccountManagement.Domain.CameraAccountAgg; using AccountManagement.Domain.CameraAccountAgg;
using AccountManagement.Domain.SubAccountAgg; using AccountManagement.Domain.SubAccountAgg;
using AccountManagement.Domain.SubAccountRoleAgg; using AccountManagement.Domain.SubAccountRoleAgg;
using Company.Domain.WorkshopAccountAgg;
using Company.Domain.WorkshopSubAccountAgg; using Company.Domain.WorkshopSubAccountAgg;
using CompanyManagment.App.Contracts.Workshop;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
namespace AccountManagement.Application namespace AccountManagement.Application

View File

@@ -1,7 +1,9 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using _0_Framework.Application; using _0_Framework.Application;
using AccountManagement.Application.Contracts.TaskSubject; using AccountManagement.Application.Contracts.TaskSubject;
using AccountManagement.Domain.TaskSubjectAgg; using AccountManagement.Domain.TaskSubjectAgg;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
namespace AccountManagement.Application; namespace AccountManagement.Application;

View File

@@ -0,0 +1,18 @@
using AccountManagement.Domain.PmDomains.PmRoleAgg;
using AccountManagement.Domain.PmDomains.PmUserAgg;
using AccountMangement.Infrastructure.EFCore.PmDbConetxt;
using AccountMangement.Infrastructure.EFCore.Repository.PmRepositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace AccountManagement.Configuration;
public class PmDbBootstrapper
{
public static void Configure(IServiceCollection services, string connectionString)
{
services.AddTransient<IPmRoleRepository, PmRoleRepository>();
services.AddTransient<IPmUserRepository, PmUserRepository>();
services.AddDbContext<PmDbContext>(x => x.UseSqlServer(connectionString));
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AccountManagement.Domain.PmDomains.PmRoleAgg;
namespace AccountManagement.Domain.PmDomains.PmPermissionAgg;
public class PmPermission
{
public long Id { get; private set; }
public int Code { get; private set; }
public PmRole Role { get; private set; }
public PmPermission(int code)
{
Code = code;
}
}

View File

@@ -0,0 +1,15 @@
using _0_Framework.Domain;
using System.Collections.Generic;
using System.Threading.Tasks;
using AccountManagement.Application.Contracts.ProgramManager;
namespace AccountManagement.Domain.PmDomains.PmRoleAgg;
public interface IPmRoleRepository :IRepository<long, PmRole>
{
Task<List<GetPmRolesDto>> GetPmRoleList(long? gozareshgirRoleId);
Task<PmRole?> GetPmRoleToEdit(long gozareshgirRoleId);
}

View File

@@ -0,0 +1,46 @@
using System.Collections.Generic;
using _0_Framework.Domain;
using AccountManagement.Domain.PmDomains.PmPermissionAgg;
namespace AccountManagement.Domain.PmDomains.PmRoleAgg;
public class PmRole : EntityBase
{
/// <summary>
/// نام نقش
/// </summary>
public string RoleName { get; private set; }
/// <summary>
/// لیست پرمیشن کد ها
/// </summary>
public List<PmPermission> PmPermission { get; private set; }
/// <summary>
/// ای دی نقش در گزارشگیر
/// </summary>
public long? GozareshgirRoleId { get; private set; }
protected PmRole()
{
}
public PmRole(string roleName,long? gozareshgirRolId, List<PmPermission> permissions)
{
RoleName = roleName;
PmPermission = permissions;
GozareshgirRoleId = gozareshgirRolId;
}
public void Edit(string roleName, List<PmPermission> permissions)
{
RoleName = roleName;
PmPermission = permissions;
}
}

View File

@@ -0,0 +1,19 @@
using AccountManagement.Domain.PmDomains.PmUserAgg;
namespace AccountManagement.Domain.PmDomains.PmRoleUserAgg;
public class PmRoleUser
{
public PmRoleUser(long roleId)
{
RoleId = roleId;
}
public long Id { get; private set; }
public long RoleId { get; private set; }
public PmUser User { get; set; }
}

View File

@@ -0,0 +1,21 @@
using _0_Framework.Domain;
using AccountManagement.Application.Contracts.ProgramManager;
using System.Threading.Tasks;
namespace AccountManagement.Domain.PmDomains.PmUserAgg;
public interface IPmUserRepository : IRepository<long, PmUser>
{
/// <summary>
/// دریافت کاربر پروگرام منیجر جهتد ویرایش
/// </summary>
/// <param name="accountId"></param>
/// <returns></returns>
Task<PmUser?> GetByPmUsertoEditbyAccountId(long accountId);
/// <summary>
/// دریافت کرابر پروگرام منیجر با اکانت آی دی در گزارشگیر
/// </summary>
/// <param name="accountId"></param>
/// <returns></returns>
Task<GetPmUserDto> GetPmUserByAccountId(long accountId);
}

View File

@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using _0_Framework.Domain;
using AccountManagement.Domain.PmDomains.PmRoleUserAgg;
namespace AccountManagement.Domain.PmDomains.PmUserAgg;
/// <summary>
/// کاربر
/// </summary>
public class PmUser : EntityBase
{
/// <summary>
/// ایجاد
/// </summary>
/// <param name="fullName"></param>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="mobile"></param>
/// <param name="email"></param>
/// <param name="accountId"></param>
/// <param name="roles"></param>
public PmUser(string fullName, string userName, string password, string mobile, string email, long? accountId, List<PmRoleUser> roles)
{
FullName = fullName;
UserName = userName;
Password = password;
Mobile = mobile;
Email = email;
IsActive = true;
AccountId = accountId;
RoleUser = roles;
}
protected PmUser()
{
}
/// <summary>
/// نام و نام خانوادگی
/// </summary>
public string FullName { get; private set; }
/// <summary>
/// نام کاربری
/// </summary>
public string UserName { get; private set; }
/// <summary>
/// گذرواژه
/// </summary>
public string Password { get; private set; }
/// <summary>
/// مسیر عکس پروفایل
/// </summary>
public string ProfilePhotoPath { get; private set; }
/// <summary>
/// شماره موبایل
/// </summary>
public string Mobile { get; set; }
/// <summary>
/// ایمیل
/// </summary>
public string Email { get; private set; }
/// <summary>
/// فعال/غیر فعال بودن یوزر
/// </summary>
public bool IsActive { get; private set; }
/// <summary>
/// کد یکبارمصرف ورود
/// </summary>
public string VerifyCode { get; private set; }
/// <summary>
/// آی دی کاربر در گزارشگیر
/// </summary>
public long? AccountId { get; private set; }
/// <summary>
/// لیست پرمیشن کد ها
/// </summary>
public List<PmRoleUser> RoleUser { get; private set; }
/// <summary>
/// آپدیت کاربر
/// </summary>
/// <param name="fullName"></param>
/// <param name="userName"></param>
/// <param name="mobile"></param>
/// <param name="roles"></param>
/// <param name="isActive"></param>
public void Edit(string fullName, string userName, string mobile, List<PmRoleUser> roles, bool isActive)
{
FullName = fullName;
UserName = userName;
Mobile = mobile;
RoleUser = roles;
IsActive = isActive;
}
/// <summary>
/// غیرفعال سازی
/// </summary>
public void DeActive()
{
IsActive = false;
}
/// <summary>
/// فعال سازی
/// </summary>
public void ReActive()
{
IsActive = true;
}
}

View File

@@ -0,0 +1,24 @@
using AccountManagement.Domain.PmDomains.PmRoleAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace AccountMangement.Infrastructure.EFCore.Mappings.PmMappings;
public class PmRoleMapping : IEntityTypeConfiguration<PmRole>
{
public void Configure(EntityTypeBuilder<PmRole> builder)
{
builder.ToTable("PmRoles", t => t.ExcludeFromMigrations());
builder.HasKey(x => x.id);
builder.Property(x => x.RoleName).HasMaxLength(100).IsRequired();
builder.OwnsMany(x => x.PmPermission, navigationBuilder =>
{
navigationBuilder.HasKey(x => x.Id);
navigationBuilder.ToTable("PmRolePermissions", t => t.ExcludeFromMigrations());
navigationBuilder.WithOwner(x => x.Role);
});
}
}

View File

@@ -0,0 +1,30 @@
using AccountManagement.Domain.PmDomains.PmUserAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace AccountMangement.Infrastructure.EFCore.Mappings.PmMappings;
public class PmUserMapping :IEntityTypeConfiguration<PmUser>
{
public void Configure(EntityTypeBuilder<PmUser> builder)
{
builder.ToTable("Users");
builder.HasKey(x => x.id);
builder.Property(x => x.FullName).HasMaxLength(100).IsRequired();
builder.Property(x => x.UserName).HasMaxLength(100).IsRequired();
builder.Property(x => x.Password).HasMaxLength(1000).IsRequired();
builder.Property(x => x.ProfilePhotoPath).HasMaxLength(500).IsRequired(false);
builder.Property(x => x.Mobile).HasMaxLength(20).IsRequired();
builder.Property(x => x.Email).HasMaxLength(150).IsRequired(false); ;
builder.Property(x => x.VerifyCode).HasMaxLength(10).IsRequired(false);
builder.OwnsMany(x => x.RoleUser, navigationBuilder =>
{
navigationBuilder.HasKey(x => x.Id);
navigationBuilder.ToTable("RoleUsers");
navigationBuilder.WithOwner(x => x.User);
});
}
}

View File

@@ -0,0 +1,32 @@
using AccountManagement.Domain.PmDomains.PmRoleAgg;
using AccountManagement.Domain.PmDomains.PmUserAgg;
using AccountMangement.Infrastructure.EFCore.Mappings;
using AccountMangement.Infrastructure.EFCore.Mappings.PmMappings;
using Microsoft.EntityFrameworkCore;
namespace AccountMangement.Infrastructure.EFCore.PmDbConetxt;
public class PmDbContext : DbContext
{
public PmDbContext(DbContextOptions<PmDbContext> options) : base(options)
{
}
public DbSet<PmUser> Users { get; set; } = null!;
public DbSet<PmRole> PmRoles { get; set; } = null!;
public PmDbContext()
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
var assembly = typeof(PmUserMapping).Assembly;
modelBuilder.ApplyConfigurationsFromAssembly(assembly);
//SubAccountPermissionSeeder.Seed(modelBuilder);
base.OnModelCreating(modelBuilder);
}
}

View File

@@ -0,0 +1,49 @@
using _0_Framework.InfraStructure;
using AccountManagement.Application.Contracts.ProgramManager;
using AccountManagement.Domain.PmDomains.PmRoleAgg;
using AccountMangement.Infrastructure.EFCore.PmDbConetxt;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace AccountMangement.Infrastructure.EFCore.Repository.PmRepositories;
public class PmRoleRepository : RepositoryBase<long, PmRole>, IPmRoleRepository
{
private readonly PmDbContext _pmDbContext;
public PmRoleRepository(PmDbContext context) : base(context)
{
_pmDbContext = context;
}
public async Task<List<GetPmRolesDto>> GetPmRoleList(long? gozareshgirRoleId)
{
var query = _pmDbContext.PmRoles.AsQueryable();
if (gozareshgirRoleId != null && gozareshgirRoleId > 0)
query = query.Where(x => x.GozareshgirRoleId == gozareshgirRoleId);
var res = await query
.Select(p => new GetPmRolesDto()
{
Id = p.id,
RoleName = p.RoleName,
GozareshgirRoleId = p.GozareshgirRoleId,
Permissions = p.PmPermission.Select(x => x.Code).ToList()
})
.ToListAsync();
return res;
}
public async Task<PmRole?> GetPmRoleToEdit(long gozareshgirRoleId)
{
return await _pmDbContext.PmRoles.FirstOrDefaultAsync(x => x.GozareshgirRoleId == gozareshgirRoleId);
}
}

View File

@@ -0,0 +1,47 @@
using _0_Framework.InfraStructure;
using AccountManagement.Application.Contracts.ProgramManager;
using AccountManagement.Domain.PmDomains.PmUserAgg;
using AccountMangement.Infrastructure.EFCore.PmDbConetxt;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace AccountMangement.Infrastructure.EFCore.Repository.PmRepositories;
public class PmUserRepository :RepositoryBase<long, PmUser>, IPmUserRepository
{
private readonly PmDbContext _pmDbContext;
public PmUserRepository(PmDbContext context, PmDbContext pmDbContext) : base(context)
{
_pmDbContext = pmDbContext;
}
public async Task<PmUser?> GetByPmUsertoEditbyAccountId(long accountId)
{
return await _pmDbContext.Users.FirstOrDefaultAsync(x => x.AccountId == accountId);
}
public async Task<GetPmUserDto> GetPmUserByAccountId(long accountId)
{
var query = await _pmDbContext.Users.FirstOrDefaultAsync(x => x.AccountId == accountId);
if (query == null)
return new GetPmUserDto();
List<long> roles = query.RoleUser.Select(x => x.RoleId).ToList();
return new GetPmUserDto()
{
FullName = query.FullName,
UserName = query.UserName,
ProfilePhotoPath = query.ProfilePhotoPath,
Mobile = query.Mobile,
IsActive = query.IsActive,
AccountId = query.AccountId,
Roles = roles,
RoleListDto = await _pmDbContext.PmRoles.Where(x => roles.Contains(x.id)).Select(x => new RoleListDto()
{
RoleName = x.RoleName,
RoleId = x.id,
Permissions = x.PmPermission.Select(x => x.Code).ToList()
}).ToListAsync(),
};
}
}

View File

@@ -12,7 +12,6 @@
<ProjectReference Include="..\..\0_Framework\0_Framework.csproj" /> <ProjectReference Include="..\..\0_Framework\0_Framework.csproj" />
<ProjectReference Include="..\..\AccountManagement.Configuration\AccountManagement.Configuration.csproj" /> <ProjectReference Include="..\..\AccountManagement.Configuration\AccountManagement.Configuration.csproj" />
<ProjectReference Include="..\..\PersonalContractingParty.Config\PersonalContractingParty.Config.csproj" /> <ProjectReference Include="..\..\PersonalContractingParty.Config\PersonalContractingParty.Config.csproj" />
<ProjectReference Include="..\..\ProgramManager\src\Infrastructure\GozareshgirProgramManager.Infrastructure\GozareshgirProgramManager.Infrastructure.csproj" />
<ProjectReference Include="..\..\Query.Bootstrapper\Query.Bootstrapper.csproj" /> <ProjectReference Include="..\..\Query.Bootstrapper\Query.Bootstrapper.csproj" />
<ProjectReference Include="..\..\WorkFlow\Infrastructure\WorkFlow.Infrastructure.Config\WorkFlow.Infrastructure.Config.csproj" /> <ProjectReference Include="..\..\WorkFlow\Infrastructure\WorkFlow.Infrastructure.Config\WorkFlow.Infrastructure.Config.csproj" />
</ItemGroup> </ItemGroup>

View File

@@ -1,6 +1,5 @@
using _0_Framework.Application; using _0_Framework.Application;
using _0_Framework.Application.Sms;
using Company.Domain.ContarctingPartyAgg; using Company.Domain.ContarctingPartyAgg;
using Company.Domain.InstitutionContractAgg; using Company.Domain.InstitutionContractAgg;
using Hangfire; using Hangfire;
@@ -14,15 +13,13 @@ public class JobSchedulerRegistrator
private readonly IInstitutionContractRepository _institutionContractRepository; private readonly IInstitutionContractRepository _institutionContractRepository;
private static DateTime? _lastRunCreateTransaction; private static DateTime? _lastRunCreateTransaction;
private static DateTime? _lastRunSendMonthlySms; private static DateTime? _lastRunSendMonthlySms;
private readonly ISmsService _smsService;
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository, ISmsService smsService) public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository)
{ {
_smsReminder = smsReminder; _smsReminder = smsReminder;
_backgroundJobClient = backgroundJobClient; _backgroundJobClient = backgroundJobClient;
_institutionContractRepository = institutionContractRepository; _institutionContractRepository = institutionContractRepository;
_smsService = smsService;
} }
public void Register() public void Register()
@@ -50,11 +47,6 @@ public class JobSchedulerRegistrator
() => SendBlockSms(), () => SendBlockSms(),
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن "*/1 * * * *" // هر 1 دقیقه یکبار چک کن
); );
RecurringJob.AddOrUpdate(
"InstitutionContract.SendInstitutionContractConfirmSms",
() => SendInstitutionContractConfirmSms(),
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن
);
} }
@@ -94,8 +86,8 @@ public class JobSchedulerRegistrator
} }
catch (Exception e) catch (Exception e)
{ {
await _smsService.Alarm("09114221321", "خطا-ایجاد سند مالی"); //_smsService.Alarm("09114221321", "خطا-ایجاد سند مالی");
} }
} }
@@ -154,15 +146,4 @@ public class JobSchedulerRegistrator
await _institutionContractRepository.SendBlockSmsForBackgroundTask(); await _institutionContractRepository.SendBlockSmsForBackgroundTask();
} }
/// <summary>
/// ارسال پیامک یادآور تایید قراداد مالی
/// </summary>
/// <returns></returns>
[DisableConcurrentExecution(timeoutInSeconds: 100)]
public async System.Threading.Tasks.Task SendInstitutionContractConfirmSms()
{
await _institutionContractRepository.SendInstitutionContractConfirmSmsTask();
}
} }

View File

@@ -1,10 +0,0 @@
using GozareshgirProgramManager.Application.Interfaces;
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
public class NullBoardNotificationPublisher:IBoardNotificationPublisher
{
public Task SendProjectStatusChanged(long userId, TaskSectionStatus oldStatus, TaskSectionStatus newStatus, Guid sectionId)
{
throw new NotImplementedException();
}
}

View File

@@ -7,17 +7,11 @@ using BackgroundInstitutionContract.Task;
using BackgroundInstitutionContract.Task.Jobs; using BackgroundInstitutionContract.Task.Jobs;
using CompanyManagment.App.Contracts.Hubs; using CompanyManagment.App.Contracts.Hubs;
using CompanyManagment.EFCore.Services; using CompanyManagment.EFCore.Services;
using GozareshgirProgramManager.Application._Bootstrapper;
using GozareshgirProgramManager.Application.Interfaces;
using GozareshgirProgramManager.Application.Modules.Users.Commands.CreateUser;
using GozareshgirProgramManager.Infrastructure;
using GozareshgirProgramManager.Infrastructure.Persistence.Seed;
using Hangfire; using Hangfire;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using MongoDB.Driver; using MongoDB.Driver;
using PersonalContractingParty.Config; using PersonalContractingParty.Config;
using Query.Bootstrapper; using Query.Bootstrapper;
using Shared.Contracts.PmUser.Queries;
using WorkFlow.Infrastructure.Config; using WorkFlow.Infrastructure.Config;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@@ -32,7 +26,7 @@ builder.Services.AddTransient<ISmsService, SmsService>();
builder.Services.AddTransient<IUidService, UidService>(); builder.Services.AddTransient<IUidService, UidService>();
builder.Services.AddTransient<IFileUploader, FileUploader>(); builder.Services.AddTransient<IFileUploader, FileUploader>();
builder.Services.Configure<AppSettingConfiguration>(builder.Configuration); builder.Services.Configure<AppSettingConfiguration>(builder.Configuration);
builder.Services.AddScoped<IBoardNotificationPublisher, NullBoardNotificationPublisher>();
#region MongoDb #region MongoDb
var mongoConnectionSection = builder.Configuration.GetSection("MongoDb"); var mongoConnectionSection = builder.Configuration.GetSection("MongoDb");
@@ -44,15 +38,10 @@ builder.Services.AddSingleton<IMongoDatabase>(mongoDatabase);
#endregion #endregion
builder.Services.AddProgramManagerApplication();
builder.Services.AddProgramManagerInfrastructure(builder.Configuration);
PersonalBootstrapper.Configure(builder.Services, connectionString); PersonalBootstrapper.Configure(builder.Services, connectionString);
TestDbBootStrapper.Configure(builder.Services, connectionStringTestDb); TestDbBootStrapper.Configure(builder.Services, connectionStringTestDb);
AccountManagementBootstrapper.Configure(builder.Services, connectionString); AccountManagementBootstrapper.Configure(builder.Services, connectionString);
WorkFlowBootstrapper.Configure(builder.Services, connectionString); WorkFlowBootstrapper.Configure(builder.Services, connectionString);
QueryBootstrapper.Configure(builder.Services); QueryBootstrapper.Configure(builder.Services);
JobsBootstrapper.Configure(builder.Services); JobsBootstrapper.Configure(builder.Services);
builder.Services.AddHttpClient(); builder.Services.AddHttpClient();

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Domain; using _0_Framework.Domain;
using Company.Domain.EmployeeInsuranceRecordAgg; using Company.Domain.EmployeeInsuranceRecordAgg;
using CompanyManagment.App.Contracts.Employee; using CompanyManagment.App.Contracts.Employee;
@@ -77,6 +78,7 @@ public interface IEmployeeRepository : IRepository<long, Employee>
Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id); Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id);
Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel); Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel);
#endregion #endregion
Task<List<GetEmployeeClientListViewModel>> GetEmployeeClientList(GetEmployeeClientListSearchModel searchModel,
long workshopId);
} }

View File

@@ -56,7 +56,7 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
void UpdateStatusIfNeeded(long institutionContractId); void UpdateStatusIfNeeded(long institutionContractId);
Task<GetInstitutionVerificationDetailsViewModel> GetVerificationDetails(Guid id); Task<GetInstitutionVerificationDetailsViewModel> GetVerificationDetails(Guid id);
Task<InstitutionContract> GetByPublicIdAsync(Guid id); Task<InstitutionContract> GetByPublicIdAsync(Guid id);
InstitutionContractDiscountResponse CalculateDiscount(InstitutionContractSetDiscountRequest request,string contractStart = null); InstitutionContractDiscountResponse CalculateDiscount(InstitutionContractSetDiscountRequest request);
InstitutionContractDiscountResponse ResetDiscountCreate(InstitutionContractResetDiscountForCreateRequest request); InstitutionContractDiscountResponse ResetDiscountCreate(InstitutionContractResetDiscountForCreateRequest request);
@@ -140,11 +140,6 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
/// <returns></returns> /// <returns></returns>
Task SendReminderSmsToContractingParties(List<SmsListData> smsListData, string typeOfSms, string sendMessStart, string sendMessEnd); Task SendReminderSmsToContractingParties(List<SmsListData> smsListData, string typeOfSms, string sendMessStart, string sendMessEnd);
/// <summary>
/// ارسال پیامک یادآور تایید قراداد مالی
/// </summary>
/// <returns></returns>
Task SendInstitutionContractConfirmSmsTask();
#endregion #endregion
#region CreateMontlyTransaction #region CreateMontlyTransaction

View File

@@ -98,11 +98,6 @@ public class InstitutionContract : EntityBase
// مبلغ قرارداد // مبلغ قرارداد
public double ContractAmount { get; private set; } public double ContractAmount { get; private set; }
public double ContractAmountWithTax => !IsOldContract ? ContractAmount + ContractAmountTax
: ContractAmount;
public double ContractAmountTax => ContractAmount*0.10;
//خسارت روزانه //خسارت روزانه
public double DailyCompenseation { get; private set; } public double DailyCompenseation { get; private set; }
@@ -164,10 +159,6 @@ public class InstitutionContract : EntityBase
public List<InstitutionContractAmendment> Amendments { get; private set; } public List<InstitutionContractAmendment> Amendments { get; private set; }
public InstitutionContractSigningType? SigningType { get; private set; }
public bool IsOldContract => LawId== 0;
public InstitutionContract() public InstitutionContract()
{ {
ContactInfoList = []; ContactInfoList = [];
@@ -271,10 +262,6 @@ public class InstitutionContract : EntityBase
{ {
WorkshopGroup = null; WorkshopGroup = null;
} }
public void SetSigningType(InstitutionContractSigningType signingType)
{
SigningType = signingType;
}
} }
public class InstitutionContractAmendment : EntityBase public class InstitutionContractAmendment : EntityBase

View File

@@ -10,15 +10,13 @@ public class InstitutionContractWorkshopCurrent:InstitutionContractWorkshopBase
public InstitutionContractWorkshopCurrent(string workshopName, bool hasRollCallPlan, public InstitutionContractWorkshopCurrent(string workshopName, bool hasRollCallPlan,
bool hasRollCallPlanInPerson, bool hasCustomizeCheckoutPlan, bool hasContractPlan, bool hasRollCallPlanInPerson, bool hasCustomizeCheckoutPlan, bool hasContractPlan,
bool hasContractPlanInPerson, bool hasInsurancePlan, bool hasInsurancePlanInPerson, bool hasContractPlanInPerson, bool hasInsurancePlan, bool hasInsurancePlanInPerson,
int personnelCount, double price,long institutionContractWorkshopGroupId, int personnelCount, double price,long institutionContractWorkshopGroupId,InstitutionContractWorkshopGroup workshopGroup,long workshopId) : base(workshopName, hasRollCallPlan,
InstitutionContractWorkshopGroup workshopGroup,long workshopId,long initialWorkshopId) : base(workshopName, hasRollCallPlan,
hasRollCallPlanInPerson, hasCustomizeCheckoutPlan, hasContractPlan, hasRollCallPlanInPerson, hasCustomizeCheckoutPlan, hasContractPlan,
hasContractPlanInPerson, hasInsurancePlan, hasInsurancePlanInPerson, personnelCount, price) hasContractPlanInPerson, hasInsurancePlan, hasInsurancePlanInPerson, personnelCount, price)
{ {
InstitutionContractWorkshopGroupId = institutionContractWorkshopGroupId; InstitutionContractWorkshopGroupId = institutionContractWorkshopGroupId;
WorkshopGroup = workshopGroup; WorkshopGroup = workshopGroup;
WorkshopId = workshopId; WorkshopId = workshopId;
InitialWorkshopId = initialWorkshopId;
} }
public long InstitutionContractWorkshopGroupId { get; private set; } public long InstitutionContractWorkshopGroupId { get; private set; }
public InstitutionContractWorkshopGroup WorkshopGroup { get; private set; } public InstitutionContractWorkshopGroup WorkshopGroup { get; private set; }

View File

@@ -37,10 +37,4 @@ public class InstitutionContractWorkshopGroup : EntityBase
CurrentWorkshops = updatedDetails.ToList(); CurrentWorkshops = updatedDetails.ToList();
LastModifiedDate = DateTime.Now; LastModifiedDate = DateTime.Now;
} }
public void AddCurrentWorkshop(InstitutionContractWorkshopCurrent currentWorkshop)
{
CurrentWorkshops.Add(currentWorkshop);
LastModifiedDate = DateTime.Now;
}
} }

View File

@@ -31,7 +31,7 @@ public class InstitutionContractWorkshopInitial:InstitutionContractWorkshopBase
WorkshopCreated = true; WorkshopCreated = true;
WorkshopCurrent = new InstitutionContractWorkshopCurrent(WorkshopName,Services.RollCall,Services.RollCallInPerson, WorkshopCurrent = new InstitutionContractWorkshopCurrent(WorkshopName,Services.RollCall,Services.RollCallInPerson,
Services.CustomizeCheckout,Services.Contract,Services.ContractInPerson,Services.Insurance, Services.CustomizeCheckout,Services.Contract,Services.ContractInPerson,Services.Insurance,
Services.InsuranceInPerson,PersonnelCount,Price,InstitutionContractWorkshopGroupId,WorkshopGroup,workshopId,id); Services.InsuranceInPerson,PersonnelCount,Price,InstitutionContractWorkshopGroupId,WorkshopGroup,workshopId);
WorkshopCurrent.SetEmployers(Employers.Select(x=>x.EmployerId).ToList()); WorkshopCurrent.SetEmployers(Employers.Select(x=>x.EmployerId).ToList());
} }

View File

@@ -1,9 +1,7 @@
using _0_Framework.Application; using _0_Framework.Domain;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.InstitutionPlan; using CompanyManagment.App.Contracts.InstitutionPlan;
using CompanyManagment.App.Contracts.TemporaryClientRegistration; using CompanyManagment.App.Contracts.TemporaryClientRegistration;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
namespace Company.Domain.InstitutionPlanAgg; namespace Company.Domain.InstitutionPlanAgg;
@@ -28,18 +26,4 @@ public interface IPlanPercentageRepository : IRepository<long, PlanPercentage>
/// <param name="command"></param> /// <param name="command"></param>
/// <returns></returns> /// <returns></returns>
InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command); InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command);
/// <summary>
/// دریافت دیتای مودال ایجاد
/// </summary>
/// <returns></returns>
Task<CreateServiceAmountDto> GetCreateModalData();
/// <summary>
/// دریافت لیست مبالغ سرویس ها
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<PagedResult<InstitutionPlanListDto>> GetList(
InstitutionPlanSearchModel searchModel);
} }

View File

@@ -73,7 +73,6 @@ public interface IInsuranceListRepository:IRepository<long, InsuranceList>
Task<InsuranceListConfirmOperation> GetInsuranceOperationDetails(long id); Task<InsuranceListConfirmOperation> GetInsuranceOperationDetails(long id);
Task<InsuranceListTabsCountViewModel> GetTabCounts(InsuranceListSearchModel searchModel); Task<InsuranceListTabsCountViewModel> GetTabCounts(InsuranceListSearchModel searchModel);
Task<PagedResult<InsuranceClientListViewModel>> GetInsuranceClientList(InsuranceClientSearchModel searchModel);
#endregion #endregion

View File

@@ -1,10 +1,8 @@
using _0_Framework.Application; using System;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.InstitutionPlan;
using CompanyManagment.App.Contracts.Leave;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using _0_Framework.Application;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.Leave;
namespace Company.Domain.LeaveAgg; namespace Company.Domain.LeaveAgg;
@@ -29,8 +27,6 @@ public interface ILeaveRepository : IRepository<long, Leave>
List<LeaveMainViewModel> searchClient(LeaveSearchModel searchModel); List<LeaveMainViewModel> searchClient(LeaveSearchModel searchModel);
LeavePrintViewModel PrintOne(long id); LeavePrintViewModel PrintOne(long id);
List<LeavePrintViewModel> PrintAll(List<long> id); List<LeavePrintViewModel> PrintAll(List<long> id);
Task<List<LeavePrintResponseViewModel>> PrintAllAsync(List<long> ids, long workshopId);
#region Vafa #region Vafa
@@ -38,20 +34,4 @@ public interface ILeaveRepository : IRepository<long, Leave>
#endregion #endregion
bool CheckIfValidToEdit(long id); bool CheckIfValidToEdit(long id);
/// <summary>
/// دریافت لیست مرخصی ها در کلاینت
/// Api
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<PagedResult<leaveListDto>> GetList(
LeaveListSearchModel searchModel);
/// <summary>
/// دریافت لیست گروه بندی شده
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<List<GroupLeaveListDto>> GetGroupList(LeaveListSearchModel searchModel);
} }

View File

@@ -316,10 +316,7 @@ public class Workshop : EntityBase
IsStaticCheckout = isStaticCheckout; IsStaticCheckout = isStaticCheckout;
} }
public void AddContractingPartyId(long contractingPartyId)
{
ContractingPartyId = contractingPartyId;
}
public void Active(string archiveCode) public void Active(string archiveCode)
{ {
this.IsActive = true; this.IsActive = true;

View File

@@ -26,7 +26,7 @@ public class CustomizeWorkshopGroupSettingExcelGenerator
{ {
public static byte[] Generate(List<CustomizeWorkshopGroupExcelViewModel> groups) public static byte[] Generate(List<CustomizeWorkshopGroupExcelViewModel> groups)
{ {
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using (var package = new ExcelPackage()) using (var package = new ExcelPackage())
{ {
var worksheet = package.Workbook.Worksheets.Add("GroupsAndEmployees"); var worksheet = package.Workbook.Worksheets.Add("GroupsAndEmployees");

View File

@@ -24,7 +24,7 @@ public class CaseManagementExcelGenerator
}; };
public static byte[] GenerateCheckoutTempExcelInfo(List<FileExcelViewModel> data) public static byte[] GenerateCheckoutTempExcelInfo(List<FileExcelViewModel> data)
{ {
OfficeOpenXml.ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); OfficeOpenXml.ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new ExcelPackage(); using var package = new ExcelPackage();
CreateSheet(data, package,"همه"); CreateSheet(data, package,"همه");
CreateSheet(data.Where(x=>x.Status ==2).ToList(), package,"فعال"); CreateSheet(data.Where(x=>x.Status ==2).ToList(), package,"فعال");

View File

@@ -46,7 +46,7 @@ public class CustomizeCheckoutExcelGenerator
}; };
public static byte[] GenerateCheckoutTempExcelInfo(List<CustomizeCheckoutTempExcelViewModel> data, List<string> selectedParameters) public static byte[] GenerateCheckoutTempExcelInfo(List<CustomizeCheckoutTempExcelViewModel> data, List<string> selectedParameters)
{ {
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); OfficeOpenXml.ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new ExcelPackage(); using var package = new ExcelPackage();
var worksheet = package.Workbook.Worksheets.Add("Sheet1"); var worksheet = package.Workbook.Worksheets.Add("Sheet1");

View File

@@ -7,7 +7,7 @@ public class EmployeeBankInfoExcelGenerator
{ {
public static byte[] Generate(List<EmployeeBankInfoExcelViewModel> list) public static byte[] Generate(List<EmployeeBankInfoExcelViewModel> list)
{ {
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new ExcelPackage(); using var package = new ExcelPackage();
var worksheet = package.Workbook.Worksheets.Add("EmployeeBankInfo"); var worksheet = package.Workbook.Worksheets.Add("EmployeeBankInfo");
@@ -166,7 +166,7 @@ public class EmployeeBankInfoExcelGenerator
public static byte[] Generate2(List<EmployeeBankInfoExcelViewModel> list) public static byte[] Generate2(List<EmployeeBankInfoExcelViewModel> list)
{ {
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new ExcelPackage(); using var package = new ExcelPackage();
foreach (var employee in list) foreach (var employee in list)
{ {
@@ -220,4 +220,4 @@ public class EmployeeBankInfoExcelGenerator
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Center; cell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
cell.Style.Fill.PatternType = ExcelFillStyle.Solid; cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
} }
} }

View File

@@ -13,7 +13,7 @@ public class InstitutionContractExcelGenerator
public static byte[] GenerateExcel(List<InstitutionContractViewModel> institutionContractViewModels) public static byte[] GenerateExcel(List<InstitutionContractViewModel> institutionContractViewModels)
{ {
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new ExcelPackage(); using var package = new ExcelPackage();
var allWorksheet = package.Workbook.Worksheets.Add("همه"); var allWorksheet = package.Workbook.Worksheets.Add("همه");

View File

@@ -8,7 +8,7 @@ public class RollCallExcelGenerator : ExcelGenerator
{ {
public static byte[] CaseHistoryExcelForEmployee(CaseHistoryRollCallExcelForEmployeeViewModel data) public static byte[] CaseHistoryExcelForEmployee(CaseHistoryRollCallExcelForEmployeeViewModel data)
{ {
OfficeOpenXml.ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); OfficeOpenXml.ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new OfficeOpenXml.ExcelPackage(); using var package = new OfficeOpenXml.ExcelPackage();
var worksheet = package.Workbook.Worksheets.Add("Sheet1"); var worksheet = package.Workbook.Worksheets.Add("Sheet1");
var rollCalls = data.RollCalls; var rollCalls = data.RollCalls;
@@ -181,7 +181,7 @@ public class RollCallExcelGenerator : ExcelGenerator
public static byte[] CaseHistoryExcelForOneDay(CaseHistoryRollCallForOneDayViewModel data) public static byte[] CaseHistoryExcelForOneDay(CaseHistoryRollCallForOneDayViewModel data)
{ {
OfficeOpenXml.ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); OfficeOpenXml.ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new OfficeOpenXml.ExcelPackage(); using var package = new OfficeOpenXml.ExcelPackage();
var worksheet = package.Workbook.Worksheets.Add("Sheet1"); var worksheet = package.Workbook.Worksheets.Add("Sheet1");
var rollCalls = data.RollCalls; var rollCalls = data.RollCalls;

View File

@@ -43,7 +43,7 @@ public class SalaryAidImportExcel
ValidData = [] ValidData = []
}; };
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
if (file == null || file.Length == 0) if (file == null || file.Length == 0)
{ {

View File

@@ -9,7 +9,7 @@ public class WorkshopRollCallExcelExporter
{ {
public static byte[] Export(List<WorkshopRollCallExcelViewModel> workshops) public static byte[] Export(List<WorkshopRollCallExcelViewModel> workshops)
{ {
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization"); ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using (var package = new ExcelPackage()) using (var package = new ExcelPackage())
{ {
var ws = package.Workbook.Worksheets.Add("Workshops"); var ws = package.Workbook.Worksheets.Add("Workshops");

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using _0_Framework.Application; using _0_Framework.Application;
using CompanyManagment.App.Contracts.Employee.DTO; using CompanyManagment.App.Contracts.Employee.DTO;
@@ -60,7 +61,7 @@ public interface IEmployeeApplication
/// <returns></returns> /// <returns></returns>
Task<OperationResult<EmployeeByNationalCodeInWorkshopViewModel>> Task<OperationResult<EmployeeByNationalCodeInWorkshopViewModel>>
ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode, ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode,
string birthDate,bool authorizedCanceled, long workshopId); string birthDate, long workshopId);
/// <summary> /// <summary>
/// پرسنل هایی که در کارگاهی از سمت ادمین شروع به کار کرده اند /// پرسنل هایی که در کارگاهی از سمت ادمین شروع به کار کرده اند
@@ -95,6 +96,41 @@ public interface IEmployeeApplication
/// <returns></returns> /// <returns></returns>
Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel); Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel);
Task<List<GetEmployeeClientListViewModel>> GetEmployeeClientList(GetEmployeeClientListSearchModel searchModel,
long workshopId);
#endregion #endregion
}
public class GetEmployeeClientListSearchModel
{
public string NationalCode { get; set; }
public string FullName { get; set; }
}
public class GetEmployeeClientListViewModel
{
public long WorkshopId { get; set; }
public long EmployeeId { get; set; }
public string FullName { get; set; }
public long PersonnelCode { get; set; }
public bool HasInsurance { get; set; }
public bool HasContract { get; set; }
public bool InsuranceLeft { get; set; }
public bool ContractLeft { get; set; }
public DateTime StartWork { get; set; }
public DateTime LeftWork { get; set; }
public string LastStartInsuranceWork { get; set; }
public string LastLeftInsuranceWork { get; set; }
public string LastStartContractWork { get; set; }
public string LastLeftContractWork { get; set; }
public string NationalCode { get; set; }
public string IdNumber { get; set; }
public string MaritalStatus { get; set; }
public string DateOfBirthFa { get; set; }
public string FatherName { get; set; }
public bool PendingCreate { get; set; }
public bool PendingLefWork { get; set; }
public int ChildrenCount { get; set; }
} }

View File

@@ -13,6 +13,5 @@ namespace CompanyManagment.App.Contracts.EmployeeDocuments
public string EmployerName { get; set; } public string EmployerName { get; set; }
public List<EmployeeDocumentItemViewModel> SubmittedItems { get; set; } public List<EmployeeDocumentItemViewModel> SubmittedItems { get; set; }
public int EmployeesWithoutDocumentCount { get; set; } public int EmployeesWithoutDocumentCount { get; set; }
public long EmployeeId { get; set; }
} }
} }

View File

@@ -1,17 +0,0 @@
namespace CompanyManagment.App.Contracts.InstitutionContract;
public enum InstitutionContractSigningType
{
/// <summary>
/// قدیمی
/// </summary>
Legacy = 0,
/// <summary>
/// الکترونیکی با کد یکبار مصرف
/// </summary>
OtpBased = 1,
/// <summary>
/// به صورت فیزیکی
/// </summary>
Physical = 2
}

View File

@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using _0_Framework.Application; using _0_Framework.Application;
using _0_Framework.Application.Sms; using _0_Framework.Application.Sms;
using CompanyManagment.App.Contracts.Checkout; using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Law;
using CompanyManagment.App.Contracts.TemporaryClientRegistration; using CompanyManagment.App.Contracts.TemporaryClientRegistration;
using CompanyManagment.App.Contracts.Workshop; using CompanyManagment.App.Contracts.Workshop;
using CompanyManagment.App.Contracts.WorkshopPlan; using CompanyManagment.App.Contracts.WorkshopPlan;
@@ -259,13 +260,154 @@ public interface IInstitutionContractApplication
/// <returns></returns> /// <returns></returns>
Task<InstitutionContractPrintViewModel> PrintOneAsync(long id); Task<InstitutionContractPrintViewModel> PrintOneAsync(long id);
Task<OperationResult> SetPendingWorkflow(long entityId,InstitutionContractSigningType signingType); Task<OperationResult> SetPendingWorkflow(long entityId);
Task<long> GetIdByInstallmentId(long installmentId); Task<long> GetIdByInstallmentId(long installmentId);
/// <summary>
/// تایید قرارداد مالی به صورت دستی
/// </summary>
/// <param name="institutionContractId"></param>
/// <returns></returns>
Task<OperationResult> VerifyInstitutionContractManually(long institutionContractId);
}
public class InstitutionContractDiscountResponse
{
public InstitutionContractDiscountOneTimeViewModel OneTime { get; set; }
public InstitutionContractDiscountMonthlyViewModel Monthly { get; set; }
}
public class InstitutionContractDiscountMonthlyViewModel:InstitutionContractDiscountOneTimeViewModel
{
public List<MonthlyInstallment> Installments { get; set; }
}
public class InstitutionContractDiscountOneTimeViewModel
{
/// <summary>
/// مجموع مبالغ
/// </summary>
public string TotalAmount { get; set; }
/// <summary>
/// ارزش افزوده
/// </summary>
public string Tax { get; set; }
/// <summary>
/// مبلغ قابل پرداخت
/// </summary>
public string PaymentAmount { get; set; }
public string DiscountedAmount { get; set; }
public int DiscountPercetage { get; set; }
public string Obligation { get; set; }
public string OneMonthAmount { get; set; }
}
public class InstitutionContractResetDiscountForCreateRequest
{
public int DiscountPercentage { get; set; }
public double TotalAmount { get; set; }
public bool IsInstallment { get; set; }
public InstitutionContractDuration Duration { get; set; }
public double OneMonthAmount { get; set; }
}
public class InstitutionContractSetDiscountForExtensionRequest
{
public Guid TempId { get; set; }
public int DiscountPercentage { get; set; }
public double TotalAmount { get; set; }
public bool IsInstallment { get; set; }
}
public class InstitutionContractResetDiscountForExtensionRequest
{
public Guid TempId { get; set; }
public bool IsInstallment { get; set; }
}
public class InstitutionContractSetDiscountRequest
{
public int DiscountPercentage { get; set; }
public double TotalAmount { get; set; }
public InstitutionContractDuration Duration { get; set; }
public double OneMonthAmount { get; set; }
public bool IsInstallment { get; set; }
}
public class InstitutionContractPrintViewModel
{
public InstitutionContratVerificationParty FirstParty { get; set; }
public InstitutionContratVerificationParty SecondParty { get; set; }
public string ContractNo { get; set; }
public string CreationDate { get; set; }
public string ContractStart { get; set; }
public string ContractEnd { get; set; }
public List<GetInstitutionVerificationDetailsWorkshopsViewModel> Workshops { get; set; }
public string TotalPrice { get; set; }
public string TaxPrice { get; set; }
public string PaymentPrice { get; set; }
public string VerifyCode { get; set; }
public string VerifyDate { get; set; }
public string VerifyTime { get; set; }
public string VerifierFullName { get; set; }
public string VerifierPhoneNumber { get; set; }
public LawViewModel LawViewModel { get; set; }
public string Obligation { get; set; }
}
public class InsertAmendmentTempWorkshopResponse
{
public Guid WorkshopTempId { get; set; }
public string Amount { get; set; }
}
public class InstitutionContractAmendmentWorkshopsResponse
{
/// <summary>
///
/// </summary>
public List<InstitutionContractAmendmentTempWorkshopViewModel> Workshops { get; set; }
public Guid TempId { get; set; }
}
public class InstitutionContractSelectListViewModel : SelectListViewModel;
public class InstitutionContractExtensionInquiryResponse
{
public long Id { get; set; }
public string FName { get; set; }
public string LName { get; set; }
public string DateOfBirthFa { get; set; }
public string FatherName { get; set; }
public string IdNumberSerial { get; set; }
public string IdNumber { get; set; }
public string Address { get; set; }
public string Phone { get; set; }
public string City { get; set; }
public string State { get; set; }
public long RepresentativeId { get; set; }
public string NationalCode { get; set; }
}
public class InstitutionContractExtensionPaymentMonthly:InstitutionContractExtensionPaymentOneTime
{
public List<MonthlyInstallment> Installments { get; set; }
}
public class InstitutionContractExtensionPaymentOneTime
{
/// <summary>
/// مجموع مبالغ
/// </summary>
public string TotalAmount { get; set; }
/// <summary>
/// ارزش افزوده
/// </summary>
public string Tax { get; set; }
/// <summary>
/// مبلغ قابل پرداخت
/// </summary>
public string PaymentAmount { get; set; }
} }

View File

@@ -1,9 +0,0 @@
using System;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InsertAmendmentTempWorkshopResponse
{
public Guid WorkshopTempId { get; set; }
public string Amount { get; set; }
}

View File

@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractAmendmentWorkshopsResponse
{
/// <summary>
///
/// </summary>
public List<InstitutionContractAmendmentTempWorkshopViewModel> Workshops { get; set; }
public Guid TempId { get; set; }
}

View File

@@ -1,38 +0,0 @@
using System.Collections.Generic;
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractDiscountResponse
{
public InstitutionContractDiscountOneTimeViewModel OneTime { get; set; }
public InstitutionContractDiscountMonthlyViewModel Monthly { get; set; }
}
public class InstitutionContractDiscountMonthlyViewModel:InstitutionContractDiscountOneTimeViewModel
{
public List<MonthlyInstallment> Installments { get; set; }
}
public class InstitutionContractDiscountOneTimeViewModel
{
/// <summary>
/// مجموع مبالغ
/// </summary>
public string TotalAmount { get; set; }
/// <summary>
/// ارزش افزوده
/// </summary>
public string Tax { get; set; }
/// <summary>
/// مبلغ قابل پرداخت
/// </summary>
public string PaymentAmount { get; set; }
public string DiscountedAmount { get; set; }
public int DiscountPercetage { get; set; }
public string Obligation { get; set; }
public string OneMonthAmount { get; set; }
}

View File

@@ -1,18 +0,0 @@
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractExtensionInquiryResponse
{
public long Id { get; set; }
public string FName { get; set; }
public string LName { get; set; }
public string DateOfBirthFa { get; set; }
public string FatherName { get; set; }
public string IdNumberSerial { get; set; }
public string IdNumber { get; set; }
public string Address { get; set; }
public string Phone { get; set; }
public string City { get; set; }
public string State { get; set; }
public long RepresentativeId { get; set; }
public string NationalCode { get; set; }
}

View File

@@ -1,24 +0,0 @@
using System.Collections.Generic;
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractExtensionPaymentMonthly:InstitutionContractExtensionPaymentOneTime
{
public List<MonthlyInstallment> Installments { get; set; }
}
public class InstitutionContractExtensionPaymentOneTime
{
/// <summary>
/// مجموع مبالغ
/// </summary>
public string TotalAmount { get; set; }
/// <summary>
/// ارزش افزوده
/// </summary>
public string Tax { get; set; }
/// <summary>
/// مبلغ قابل پرداخت
/// </summary>
public string PaymentAmount { get; set; }
}

View File

@@ -1,28 +0,0 @@
using System.Collections.Generic;
using CompanyManagment.App.Contracts.Law;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractPrintViewModel
{
public InstitutionContratVerificationParty FirstParty { get; set; }
public InstitutionContratVerificationParty SecondParty { get; set; }
public string ContractNo { get; set; }
public string CreationDate { get; set; }
public string ContractStart { get; set; }
public string ContractEnd { get; set; }
public List<GetInstitutionVerificationDetailsWorkshopsViewModel> Workshops { get; set; }
public string TotalPrice { get; set; }
public string TaxPrice { get; set; }
public string PaymentPrice { get; set; }
public string OneMonthPrice { get; set; }
public string VerifyCode { get; set; }
public string VerifyDate { get; set; }
public string VerifyTime { get; set; }
public string VerifierFullName { get; set; }
public string VerifierPhoneNumber { get; set; }
public LawViewModel LawViewModel { get; set; }
public string Obligation { get; set; }
public string OneMonthWithoutTax { get; set; }
public string OneMonthTax { get; set; }
}

View File

@@ -1,10 +0,0 @@
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractResetDiscountForCreateRequest
{
public int DiscountPercentage { get; set; }
public double TotalAmount { get; set; }
public bool IsInstallment { get; set; }
public InstitutionContractDuration Duration { get; set; }
public double OneMonthAmount { get; set; }
}

View File

@@ -1,9 +0,0 @@
using System;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractResetDiscountForExtensionRequest
{
public Guid TempId { get; set; }
public bool IsInstallment { get; set; }
}

View File

@@ -1,5 +0,0 @@
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractSelectListViewModel : SelectListViewModel;

View File

@@ -1,11 +0,0 @@
using System;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractSetDiscountForExtensionRequest
{
public Guid TempId { get; set; }
public int DiscountPercentage { get; set; }
public double TotalAmount { get; set; }
public bool IsInstallment { get; set; }
}

View File

@@ -1,10 +0,0 @@
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractSetDiscountRequest
{
public int DiscountPercentage { get; set; }
public double TotalAmount { get; set; }
public InstitutionContractDuration Duration { get; set; }
public double OneMonthAmount { get; set; }
public bool IsInstallment { get; set; }
}

View File

@@ -76,7 +76,5 @@ public class InstitutionContractViewModel
public bool IsInstallment { get; set; } public bool IsInstallment { get; set; }
public InstitutionContractVerificationStatus VerificationStatus { get; set; } public InstitutionContractVerificationStatus VerificationStatus { get; set; }
public InstitutionContractSigningType? SigningType { get; set; }
public List<InstitutionContractInstallmentViewModel> InstallmentList { get; set; } public List<InstitutionContractInstallmentViewModel> InstallmentList { get; set; }
} }

View File

@@ -1,12 +0,0 @@
using System;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public record InstitutionCreationVerificationSmsDto
{
public string Number{ get; set; }
public string FullName { get; set; }
public Guid InstitutionId { get; set; }
public long ContractingPartyId { get; set; }
public long InstitutionContractId { get; set; }
};

View File

@@ -1,51 +0,0 @@
namespace CompanyManagment.App.Contracts.InstitutionPlan;
public class CreateServiceAmountDto
{
/// <summary>
/// آی دی
/// </summary>
public long Id { get; set; }
/// <summary>
/// قرارداد و تصفیه
/// درصد از مزد روزانه
/// string
/// </summary>
public string ContractAndCheckoutPercentStr { get; set; }
/// <summary>
/// بیمه
/// درصد از مزد روزانه
/// string
/// </summary>
public string InsurancePercentStr { get; set; }
/// <summary>
/// حضورغباب
/// درصد از مزد روزانه
/// string
/// </summary>
public string RollCallPercentStr { get; set; }
/// <summary>
/// فیش غیر رسمی
/// درصد از مزد روزانه
/// string
/// </summary>
public string CustomizeCheckoutPercentStr { get; set; }
/// <summary>
/// خدمات حضوری قرداد و تصفیه
/// درصد از مزد روزانه
/// string
/// </summary>
public string ContractAndCheckoutInPersonPercentStr { get; set; }
/// <summary>
/// خدمات حضوری بیمه
/// درصد از مزد روزانه
/// string
/// </summary>
public string InsuranceInPersonPercentStr { get; set; }
}

View File

@@ -1,7 +1,6 @@
using _0_Framework.Application; using System.Collections.Generic;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.TemporaryClientRegistration; using CompanyManagment.App.Contracts.TemporaryClientRegistration;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace CompanyManagment.App.Contracts.InstitutionPlan; namespace CompanyManagment.App.Contracts.InstitutionPlan;
@@ -35,27 +34,4 @@ public interface IInstitutionPlanApplication
/// <param name="command"></param> /// <param name="command"></param>
/// <returns></returns> /// <returns></returns>
InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command); InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command);
/// <summary>
/// دریافت دیتای درصد سرویس برای مودال ایجاد
/// </summary>
/// <returns></returns>
Task<CreateServiceAmountDto> GetCreateModalData();
/// <summary>
/// ایجاد درصد سرویس
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> CreateInstitutionPlanPercentage(CreateServiceAmountDto command);
/// <summary>
/// دریافت لیست مبالغ سرویس ها
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<PagedResult<InstitutionPlanListDto>> GetList(
InstitutionPlanSearchModel searchModel);
} }

View File

@@ -1,84 +0,0 @@
namespace CompanyManagment.App.Contracts.InstitutionPlan;
public class InstitutionPlanListDto
{
/// <summary>
/// تعداد پرسنل
/// </summary>
public int CountPerson { get; set; }
/// <summary>
/// مبلغ قرارداد و تصفیه
/// </summary>
public string ContractAndCheckout { get; set; }
/// <summary>
/// مبلغ بیمه
/// </summary>
public string Insurance { get; set; }
/// <summary>
/// مبلغ حضورغباب
/// </summary>
public string RollCall { get; set; }
/// <summary>
/// مبلغ فیش غیر رسمی
/// </summary>
public string CustomizeCheckout { get; set; }
/// <summary>
/// مبلغ خدمات حضوری قرداد و تصفیه
/// </summary>
public string ContractAndCheckoutInPerson { get; set; }
/// <summary>
/// مبلغ خدمات حضوری بیمه
/// </summary>
public string InsuranceInPerson { get; set; }
#region Total
/// <summary>
/// مبلغ کل خدمات حضوری
/// </summary>
public string InPersonSumAmountStr { get; set; }
/// <summary>
/// مبلغ کل خدمات آنلاین
/// </summary>
public string OnlineOnlySumAmountStr { get; set; }
/// <summary>
/// مبلغ کل خدمات حضوری و آنلاین
/// </summary>
public string OnlineAndInPersonSumAmountStr { get; set; }
/// <summary>
/// مبلغ کل خدمات حضوری و آنلاین
/// double
/// </summary>
public double OnlineAndInPersonSumAmountDouble { get; set; }
/// <summary>
/// مبلغ کل خدمات حضوری
/// double
/// </summary>
public double InPersonSumAmountDouble { get; set; }
/// <summary>
/// مبلغ کل خدمات آنلاین
/// double
/// </summary>
public double OnlineOnlySumAmountDouble { get; set; }
#endregion
}

View File

@@ -1,11 +0,0 @@
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.InstitutionPlan;
public class InstitutionPlanSearchModel : PaginationRequest
{
/// <summary>
/// تعداد پرسنل برای جستجو
/// </summary>
public int CountPerson { get; set; }
}

View File

@@ -90,27 +90,8 @@ public interface IInsuranceListApplication
Task<InsuranceListConfirmOperation> GetInsuranceOperationDetails(long id); Task<InsuranceListConfirmOperation> GetInsuranceOperationDetails(long id);
Task<InsuranceListTabsCountViewModel> GetTabCounts(InsuranceListSearchModel searchModel); Task<InsuranceListTabsCountViewModel> GetTabCounts(InsuranceListSearchModel searchModel);
Task<PagedResult<InsuranceClientListViewModel>> GetInsuranceClientList(InsuranceClientSearchModel searchModel);
#endregion #endregion
Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel); Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel);
}
public class InsuranceClientSearchModel:PaginationRequest
{
public int Year { get; set; }
public int Month { get; set; }
public string Sorting { get; set; }
}
public class InsuranceClientListViewModel
{
public long Id { get; set; }
public string Year { get; set; }
public string Month { get; set; }
public long WorkShopId { get; set; }
public int YearInt { get; set; }
public string MonthName { get; set; }
public int MonthInt { get; set; }
} }

View File

@@ -1,88 +0,0 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.Leave;
public class GroupLeaveListDto
{
/// <summary>
/// سال مرخصی
/// </summary>
public string YearStr { get; set; }
/// <summary>
/// ماه مرخصی
/// </summary>
public string MonthStr { get; set; }
/// <summary>
/// آیتم های هر گروه
/// </summary>
public List<LeaveListItemsDto> LeaveListItemsDto { get; set; }
}
/// <summary>
/// آیتم های هر گروه
/// </summary>
public class LeaveListItemsDto
{
/// <summary>
/// نوع مرخصی، استحقاقی/استعلاجی
/// </summary>
public string LeaveType { get; set; }
/// <summary>
/// تاریخ شروع مرخصی
/// </summary>
public string StartLeave { get; set; }
/// <summary>
/// تاریخ پایان مرخصی
/// </summary>
public string EndLeave { get; set; }
/// <summary>
/// زمان مرخصی
/// بازه مرخصی ساعتی
/// </summary>
public string HourlyInterval { get; set; }
/// <summary>
/// مدت مرخصی
/// </summary>
public string LeaveDuration { get; set; }
/// <summary>
/// موافقت/عدم موافقت کارفرما
/// </summary>
public bool IsAccepted { get; set; }
/// <summary>
/// آی دی
/// </summary>
public long Id { get; set; }
/// <summary>
/// آی دی گارگاه
/// </summary>
public long WorkshopId { get; set; }
/// <summary>
/// آی دی پرسنل
/// </summary>
public long EmployeeId { get; set; }
/// <summary>
///آیا فاقد اعتبار است. فاقد اعتبار ها فقط برای فیش های غیررسمی مورد استفاده قرار میگیرند
/// </summary>
public bool IsInvalid { get; set; }
}

View File

@@ -36,67 +36,5 @@ public interface ILeaveApplication
TimeSpan GetEmployeeLeaveTimeSpanInDates(long workshopId, long employeeId, string startFa, string endFa, TimeSpan GetEmployeeLeaveTimeSpanInDates(long workshopId, long employeeId, string startFa, string endFa,
string type); string type);
#endregion #endregion
/// <summary>
/// دریافت لیست مرخصی ها در کلاینت
/// Api
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<PagedResult<leaveListDto>> GetList(
LeaveListSearchModel searchModel);
/// <summary>
/// دریافت لیست گروه بندی شده
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<List<GroupLeaveListDto>> GetGroupList(LeaveListSearchModel searchModel);
/// <summary>
/// دریافت مجکوع مرخصی پرسنل
/// اگر آی دی پرسنل، سال و ماه خالی نباشد
/// </summary>
/// <param name="workshopId"></param>
/// <param name="employeeId"></param>
/// <param name="yearStr"></param>
/// <param name="monthStr"></param>
/// <param name="leaveType"></param>
/// <returns></returns>
TimeSpan SumOfEmployeeLeaveTimeSpanInDates(long workshopId, long employeeId, string yearStr, string monthStr,
LeaveType leaveType);
Task<List<LeavePrintResponseViewModel>> PrintAllAsync(List<long> ids, long workshopId);
Task<LeavePrintResponseViewModel> PrintOneAsync(long id, long workshopId);
}
public class LeavePrintResponseViewModel
{
public string FullName { get; set; }
public string NationalCode { get; set; }
public string WorkshopName { get; set; }
public List<string> EmployerNames { get; set; }
public string PaidLeaveType { get; set; }
public string ContractNo { get; set; }
public LeavePrintHourlyResponseViewModel HourlyLeave { get; set; }
public LeavePrintDailyResponseViewModel DailyLeave { get; set; }
}
public class LeavePrintDailyResponseViewModel
{
public string StartLeave { get; set; }
public string EndLeave { get; set; }
public string TotalDay { get; set; }
}
public class LeavePrintHourlyResponseViewModel
{
public string LeaveDate { get; set; }
public string StartHour { get; set; }
public string EndHour { get; set; }
public string TotalHour { get; set; }
} }

View File

@@ -1,24 +0,0 @@
using _0_Framework.Application;
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.Leave;
public class LeaveListMultipleDto
{
/// <summary>
/// لیست گروهبندی شده بر اساس سال و ماه
/// اگر در جستجو پرسنل انتخاب شود
/// </summary>
public List<GroupLeaveListDto>? GroupLeaveListDto { get; set; }
/// <summary>
/// لیست نرمال PageResult
/// </summary>
public PagedResult<leaveListDto>? leaveListDto { get; set; }
/// <summary>
/// مجموع مرخصی پرسنل
/// اگر پرسنل انتخاب شده باشد
/// </summary>
public string? SumOfEmployeeleaves { get; set; }
}

View File

@@ -1,45 +0,0 @@
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.Leave;
public class LeaveListSearchModel : PaginationRequest
{
/// <summary>
/// آی دی کارگاه
/// </summary>
public long WorkshopId { get; set; }
/// <summary>
/// نوع مرخصی، استحقاقی/استعلاجی
/// </summary>
public LeaveType LeaveType { get; set; }
/// <summary>
/// سال مرخصی
/// </summary>
public string YearStr { get; set; }
/// <summary>
/// ماه مرخصی
/// </summary>
public string MonthStr { get; set; }
/// <summary>
///آیا فاقد اعتبار است. فاقد اعتبار ها فقط برای فیش های غیررسمی مورد استفاده قرار میگیرند
/// </summary>
public bool IsInvalid { get; private set; }
/// <summary>
/// تاریخ شروع مرخصی
/// </summary>
public string StartLeave { get; set; }
/// <summary>
/// تاریخ پایان مرخصی
/// </summary>
public string EndLeave { get; set; }
/// <summary>
/// آی دی پرسنل
/// </summary>
public long EmployeeId { get; set; }
}

View File

@@ -1,18 +0,0 @@
namespace CompanyManagment.App.Contracts.Leave;
public enum LeaveType
{
/// <summary>
/// هر دو
/// </summary>
Both,
/// <summary>
/// مرخصی استعلاجی
/// </summary>
SickLeave,
/// <summary>
/// مرخصی استحقاقی
/// </summary>
PaidLeave
}

View File

@@ -1,84 +0,0 @@
namespace CompanyManagment.App.Contracts.Leave;
public class leaveListDto
{
/// <summary>
/// نام کامل پرسنل
/// </summary>
public string EmployeeFullName { get; set; }
/// <summary>
/// سال مرخصی
/// </summary>
public string YearStr { get; set; }
/// <summary>
/// ماه مرخصی
/// </summary>
public string MonthStr { get; set; }
/// <summary>
/// نوع مرخصی، استحقاقی/استعلاجی
/// </summary>
public string LeaveType { get; set; }
/// <summary>
/// تاریخ شروع مرخصی
/// </summary>
public string StartLeave { get; set; }
/// <summary>
/// تاریخ پایان مرخصی
/// </summary>
public string EndLeave { get; set; }
/// <summary>
/// زمان مرخصی
/// بازه مرخصی ساعتی
/// </summary>
public string HourlyInterval { get; set; }
/// <summary>
/// مدت مرخصی
/// </summary>
public string LeaveDuration { get; set; }
/// <summary>
/// موافقت/عدم موافقت کارفرما
/// </summary>
public bool IsAccepted { get; set; }
/// <summary>
/// آی دی
/// </summary>
public long Id { get; set; }
/// <summary>
/// آی دی گارگاه
/// </summary>
public long WorkshopId { get; set; }
/// <summary>
/// آی دی پرسنل
/// </summary>
public long EmployeeId { get; set; }
/// <summary>
///آیا فاقد اعتبار است. فاقد اعتبار ها فقط برای فیش های غیررسمی مورد استفاده قرار میگیرند
/// </summary>
public bool IsInvalid { get; set; }
}

View File

@@ -1,7 +1,6 @@
using _0_Framework.Application; using _0_Framework.Application;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
namespace CompanyManagment.App.Contracts.RollCallEmployee; namespace CompanyManagment.App.Contracts.RollCallEmployee;

View File

@@ -64,33 +64,49 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository; private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository;
private readonly IFaceEmbeddingService _faceEmbeddingService; private readonly IFaceEmbeddingService _faceEmbeddingService;
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context, IWorkshopRepository workShopRepository, IWebHostEnvironment webHostEnvironment, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallEmployeeRepository rollCallEmployeeRepository, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IEmployeeDocumentsApplication employeeDocumentsApplication, IEmployeeDocumentsRepository employeeDocumentsRepository, IEmployeeBankInformationApplication employeeBankInformationApplication, ILeftWorkTempRepository leftWorkTempRepository, IUidService uidService, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, IEmployeeClientTempRepository employeeClientTempRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository, ILeftWorkRepository leftWorkRepository, IEmployeeAuthorizeTempRepository employeeAuthorizeTempRepository, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IFaceEmbeddingService faceEmbeddingService) : base(context) public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context,
{ IWorkshopRepository workShopRepository, IWebHostEnvironment webHostEnvironment,
_context = context; IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication,
_WorkShopRepository = workShopRepository; IRollCallEmployeeRepository rollCallEmployeeRepository,
_webHostEnvironment = webHostEnvironment; ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication,
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication; IEmployeeDocumentsApplication employeeDocumentsApplication,
_rollCallEmployeeRepository = rollCallEmployeeRepository; IEmployeeDocumentsRepository employeeDocumentsRepository,
_customizeWorkshopSettingsApplication = customizeWorkshopSettingsApplication; IEmployeeBankInformationApplication employeeBankInformationApplication,
_employeeDocumentsApplication = employeeDocumentsApplication; ILeftWorkTempRepository leftWorkTempRepository, IUidService uidService,
_employeeBankInformationApplication = employeeBankInformationApplication; ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository,
_leftWorkTempRepository = leftWorkTempRepository; IPersonnelCodeRepository personnelCodeRepository, IEmployeeClientTempRepository employeeClientTempRepository,
_uidService = uidService; ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository,
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository; ILeftWorkRepository leftWorkRepository, IEmployeeAuthorizeTempRepository employeeAuthorizeTempRepository,
_personnelCodeRepository = personnelCodeRepository; ILeftWorkInsuranceRepository leftWorkInsuranceRepository,
_employeeClientTempRepository = employeeClientTempRepository; IFaceEmbeddingService faceEmbeddingService) : base(context)
_leftWorkRepository = leftWorkRepository; {
_employeeAuthorizeTempRepository = employeeAuthorizeTempRepository; _context = context;
_leftWorkInsuranceRepository = leftWorkInsuranceRepository; _WorkShopRepository = workShopRepository;
_EmployeeRepository = employeeRepository; _webHostEnvironment = webHostEnvironment;
_faceEmbeddingService = faceEmbeddingService; _rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
} _rollCallEmployeeRepository = rollCallEmployeeRepository;
_customizeWorkshopSettingsApplication = customizeWorkshopSettingsApplication;
_employeeDocumentsApplication = employeeDocumentsApplication;
_employeeBankInformationApplication = employeeBankInformationApplication;
_leftWorkTempRepository = leftWorkTempRepository;
_uidService = uidService;
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
_personnelCodeRepository = personnelCodeRepository;
_employeeClientTempRepository = employeeClientTempRepository;
_leftWorkRepository = leftWorkRepository;
_employeeAuthorizeTempRepository = employeeAuthorizeTempRepository;
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
_EmployeeRepository = employeeRepository;
_faceEmbeddingService = faceEmbeddingService;
}
public OperationResult Create(CreateEmployee command) public OperationResult Create(CreateEmployee command)
{ {
var opration = new OperationResult(); var opration = new OperationResult();
if (_EmployeeRepository.Exists(x => if (_EmployeeRepository.Exists(x =>
x.LName == command.LName && x.NationalCode == command.NationalCode && !string.IsNullOrWhiteSpace(command.NationalCode) && x.NationalCode != null && x.IsActiveString == "true")) x.LName == command.LName && x.NationalCode == command.NationalCode &&
!string.IsNullOrWhiteSpace(command.NationalCode) && x.NationalCode != null &&
x.IsActiveString == "true"))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد"); return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
//if (_EmployeeRepository.Exists(x => x.IdNumber == command.IdNumber && x.IdNumber !=null)) //if (_EmployeeRepository.Exists(x => x.IdNumber == command.IdNumber && x.IdNumber !=null))
@@ -182,13 +198,13 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
else else
{ {
nationalCodValid = false; nationalCodValid = false;
return opration.Failed("کد ملی وارد شده نا معتبر است"); return opration.Failed("کد ملی وارد شده نا معتبر است");
} }
} }
catch (Exception) catch (Exception)
@@ -198,6 +214,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Failed("لطفا کد ملی 10 رقمی وارد کنید"); return opration.Failed("لطفا کد ملی 10 رقمی وارد کنید");
} }
if (_EmployeeRepository.Exists(x => x.NationalCode == command.NationalCode)) if (_EmployeeRepository.Exists(x => x.NationalCode == command.NationalCode))
{ {
nationalcodeIsOk = false; nationalcodeIsOk = false;
@@ -210,24 +227,31 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
string initial = "1300/10/11"; string initial = "1300/10/11";
var dateOfBirth = command.DateOfBirth != null ? command.DateOfBirth.ToGeorgianDateTime() : initial.ToGeorgianDateTime(); var dateOfBirth = command.DateOfBirth != null
var dateOfIssue = command.DateOfIssue != null ? command.DateOfIssue.ToGeorgianDateTime() : initial.ToGeorgianDateTime(); ? command.DateOfBirth.ToGeorgianDateTime()
: initial.ToGeorgianDateTime();
var dateOfIssue = command.DateOfIssue != null
? command.DateOfIssue.ToGeorgianDateTime()
: initial.ToGeorgianDateTime();
var employeeData = new Employee(command.FName, command.LName, command.FatherName, dateOfBirth, var employeeData = new Employee(command.FName, command.LName, command.FatherName, dateOfBirth,
dateOfIssue, dateOfIssue,
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality, command.IdNumberSerial, command.IdNumberSeri, command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality,
command.IdNumberSerial, command.IdNumberSeri,
command.Phone, command.Address, command.Phone, command.Address,
command.State, command.City, command.MaritalStatus, command.MilitaryService, command.LevelOfEducation, command.State, command.City, command.MaritalStatus, command.MilitaryService, command.LevelOfEducation,
command.FieldOfStudy, command.BankCardNumber, command.FieldOfStudy, command.BankCardNumber,
command.BankBranch, command.InsuranceCode, command.InsuranceHistoryByYear, command.BankBranch, command.InsuranceCode, command.InsuranceHistoryByYear,
command.InsuranceHistoryByMonth, command.NumberOfChildren, command.OfficePhone, command.MclsUserName, command.MclsPassword, command.EserviceUserName, command.EservicePassword, command.InsuranceHistoryByMonth, command.NumberOfChildren, command.OfficePhone, command.MclsUserName,
command.MclsPassword, command.EserviceUserName, command.EservicePassword,
command.TaxOfficeUserName, command.TaxOfficepassword, command.SanaUserName, command.SanaPassword); command.TaxOfficeUserName, command.TaxOfficepassword, command.SanaUserName, command.SanaPassword);
if (command.IsAuthorized) if (command.IsAuthorized)
{ {
employeeData.Authorized(); employeeData.Authorized();
} }
_EmployeeRepository.Create(employeeData); _EmployeeRepository.Create(employeeData);
_EmployeeRepository.SaveChanges(); _EmployeeRepository.SaveChanges();
@@ -244,7 +268,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Failed("رکورد مورد نظر یافت نشد"); return opration.Failed("رکورد مورد نظر یافت نشد");
if (_EmployeeRepository.Exists(x => if (_EmployeeRepository.Exists(x =>
x.LName == command.LName && x.NationalCode == command.NationalCode && !string.IsNullOrWhiteSpace(command.NationalCode) && x.id != command.Id && x.IsActiveString == "true")) x.LName == command.LName && x.NationalCode == command.NationalCode &&
!string.IsNullOrWhiteSpace(command.NationalCode) && x.id != command.Id && x.IsActiveString == "true"))
return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد"); return opration.Failed("امکان ثبت رکورد تکراری وجود ندارد");
//if (_EmployeeRepository.Exists(x => x.IdNumber == command.IdNumber && x.IdNumber != null && x.id != command.Id)) //if (_EmployeeRepository.Exists(x => x.IdNumber == command.IdNumber && x.IdNumber != null && x.id != command.Id))
// return opration.Failed("شماره شناسنامه وارد شده تکراری است"); // return opration.Failed("شماره شناسنامه وارد شده تکراری است");
@@ -339,6 +364,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Failed("لطفا کد ملی 10 رقمی وارد کنید"); return opration.Failed("لطفا کد ملی 10 رقمی وارد کنید");
} }
if (_EmployeeRepository.Exists(x => x.NationalCode == command.NationalCode && x.id != command.Id)) if (_EmployeeRepository.Exists(x => x.NationalCode == command.NationalCode && x.id != command.Id))
{ {
nationalcodeIsOk = false; nationalcodeIsOk = false;
@@ -349,8 +375,12 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
string initial = "1300/10/11"; string initial = "1300/10/11";
var dateOfBirth = command.DateOfBirth != null ? command.DateOfBirth.ToGeorgianDateTime() : initial.ToGeorgianDateTime(); var dateOfBirth = command.DateOfBirth != null
var dateOfIssue = command.DateOfIssue != null ? command.DateOfIssue.ToGeorgianDateTime() : initial.ToGeorgianDateTime(); ? command.DateOfBirth.ToGeorgianDateTime()
: initial.ToGeorgianDateTime();
var dateOfIssue = command.DateOfIssue != null
? command.DateOfIssue.ToGeorgianDateTime()
: initial.ToGeorgianDateTime();
employee.Edit(command.FName, command.LName, command.FatherName, dateOfBirth, employee.Edit(command.FName, command.LName, command.FatherName, dateOfBirth,
dateOfIssue, dateOfIssue,
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality, command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality,
@@ -435,7 +465,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
var opration = new OperationResult(); var opration = new OperationResult();
var employeeData = new EmployeeInsuranceRecord(command.EmployeeId, command.WorkShopId, command.DateOfStart, command.DateOfEnd); var employeeData = new EmployeeInsuranceRecord(command.EmployeeId, command.WorkShopId, command.DateOfStart,
command.DateOfEnd);
_EmployeeRepository.CreateEmployeeInsuranceRecord(employeeData); _EmployeeRepository.CreateEmployeeInsuranceRecord(employeeData);
_EmployeeRepository.SaveChanges(); _EmployeeRepository.SaveChanges();
@@ -444,6 +475,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
} }
public OperationResult EditEmployeeInsuranceRecord(EditEmployeeInsuranceRecord command) public OperationResult EditEmployeeInsuranceRecord(EditEmployeeInsuranceRecord command)
{ {
var opration = new OperationResult(); var opration = new OperationResult();
@@ -455,6 +487,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
} }
public void RemoveEmployeeInsuranceRecord(long Id) public void RemoveEmployeeInsuranceRecord(long Id)
{ {
_EmployeeRepository.RemoveEmployeeInsuranceRecord(Id); _EmployeeRepository.RemoveEmployeeInsuranceRecord(Id);
@@ -468,12 +501,14 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Failed("خطا در انتخاب کارگاه"); return opration.Failed("خطا در انتخاب کارگاه");
} }
var ws = _WorkShopRepository.GetDetails(eir.WorkShopId); var ws = _WorkShopRepository.GetDetails(eir.WorkShopId);
if (string.IsNullOrWhiteSpace(eir.DateOfStart)) if (string.IsNullOrWhiteSpace(eir.DateOfStart))
{ {
return opration.Failed("تاریخ شروع نمی تواند خالی باشد - " + ws.WorkshopFullName); return opration.Failed("تاریخ شروع نمی تواند خالی باشد - " + ws.WorkshopFullName);
} }
if (!string.IsNullOrWhiteSpace(eir.DateOfEnd)) if (!string.IsNullOrWhiteSpace(eir.DateOfEnd))
{ {
if (eir.DateOfEnd.ToGeorgianDateTime() < eir.DateOfStart.ToGeorgianDateTime()) if (eir.DateOfEnd.ToGeorgianDateTime() < eir.DateOfStart.ToGeorgianDateTime())
@@ -490,6 +525,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Succcedded(); return opration.Succcedded();
} }
public OperationResult ValidationEmployeeInsuranceRecord(List<CreateEmployeeInsuranceRecord> eir_lst) public OperationResult ValidationEmployeeInsuranceRecord(List<CreateEmployeeInsuranceRecord> eir_lst)
{ {
var opration = new OperationResult(); var opration = new OperationResult();
@@ -509,16 +545,19 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
return opration.Failed("خطا در تداخل تاریخ - " + wshop.WorkshopFullName); return opration.Failed("خطا در تداخل تاریخ - " + wshop.WorkshopFullName);
} }
if (string.IsNullOrEmpty(q[i].DateOfEnd.ToString())) if (string.IsNullOrEmpty(q[i].DateOfEnd.ToString()))
{ {
count++; count++;
} }
} }
if (count > 1) if (count > 1)
{ {
return opration.Failed("تاریخ ترک کار را وارد نمایید "); return opration.Failed("تاریخ ترک کار را وارد نمایید ");
} }
} }
return opration.Succcedded(); return opration.Succcedded();
@@ -532,11 +571,13 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
return opration.Failed("خطا در انتخاب پرسنل"); return opration.Failed("خطا در انتخاب پرسنل");
} }
var employee = _EmployeeRepository.GetDetails(employeeId); var employee = _EmployeeRepository.GetDetails(employeeId);
if (string.IsNullOrWhiteSpace(employee.FName)) if (string.IsNullOrWhiteSpace(employee.FName))
{ {
error += "(نام)" + Environment.NewLine; error += "(نام)" + Environment.NewLine;
} }
if (string.IsNullOrWhiteSpace(employee.LName)) if (string.IsNullOrWhiteSpace(employee.LName))
{ {
error += "(نام خانوادگی)" + Environment.NewLine; error += "(نام خانوادگی)" + Environment.NewLine;
@@ -546,22 +587,27 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
error += "(کد ملی)" + Environment.NewLine; error += "(کد ملی)" + Environment.NewLine;
} }
if (string.IsNullOrWhiteSpace(employee.PlaceOfIssue)) if (string.IsNullOrWhiteSpace(employee.PlaceOfIssue))
{ {
error += "(شهر محل تولد)" + Environment.NewLine; error += "(شهر محل تولد)" + Environment.NewLine;
} }
if (string.IsNullOrWhiteSpace(employee.DateOfBirth)) if (string.IsNullOrWhiteSpace(employee.DateOfBirth))
{ {
error += "(تاریخ تولد)" + Environment.NewLine; error += "(تاریخ تولد)" + Environment.NewLine;
} }
if (string.IsNullOrWhiteSpace(employee.IdNumber)) if (string.IsNullOrWhiteSpace(employee.IdNumber))
{ {
error += "(شماره شناسنامه)" + Environment.NewLine; error += "(شماره شناسنامه)" + Environment.NewLine;
} }
if (string.IsNullOrWhiteSpace(employee.InsuranceCode)) if (string.IsNullOrWhiteSpace(employee.InsuranceCode))
{ {
error += "(شماره بیمه)" + Environment.NewLine; error += "(شماره بیمه)" + Environment.NewLine;
} }
if (!string.IsNullOrWhiteSpace(error)) if (!string.IsNullOrWhiteSpace(error))
{ {
var note = "آیتم های زیر برای ثبت سابقه الزامی می باشد" + Environment.NewLine + error; var note = "آیتم های زیر برای ثبت سابقه الزامی می باشد" + Environment.NewLine + error;
@@ -610,7 +656,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
InsuranceCode = x.InsuranceCode, InsuranceCode = x.InsuranceCode,
IsActiveString = x.IsActiveString, IsActiveString = x.IsActiveString,
IsActive = x.IsActive, IsActive = x.IsActive,
PersonnelCode = _context.PersonnelCodeSet.FirstOrDefault(p => p.EmployeeId == x.Id && p.WorkshopId == searchModel.WorkshopId)?.PersonnelCode PersonnelCode = _context.PersonnelCodeSet
.FirstOrDefault(p => p.EmployeeId == x.Id && p.WorkshopId == searchModel.WorkshopId)?.PersonnelCode
}).ToList(); }).ToList();
//w2.Stop(); //w2.Stop();
//Console.WriteLine("efore :" + w2.ElapsedMilliseconds); //Console.WriteLine("efore :" + w2.ElapsedMilliseconds);
@@ -619,6 +666,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
} }
return res; return res;
} }
@@ -663,6 +711,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
if (_EmployeeRepository.ExistsEmployeeWorkshopNationalCode(command.NationalCode, command.WorkshopId)) if (_EmployeeRepository.ExistsEmployeeWorkshopNationalCode(command.NationalCode, command.WorkshopId))
return opration.Failed("کد ملی وارد شده تکراری است"); return opration.Failed("کد ملی وارد شده تکراری است");
} }
if (_EmployeeRepository.Exists(x => x.InsuranceCode == command.InsuranceCode && x.InsuranceCode != null)) if (_EmployeeRepository.Exists(x => x.InsuranceCode == command.InsuranceCode && x.InsuranceCode != null))
{ {
if (_EmployeeRepository.ExistsEmployeeWorkshoppInsuranceCode(command.InsuranceCode, command.WorkshopId)) if (_EmployeeRepository.ExistsEmployeeWorkshoppInsuranceCode(command.InsuranceCode, command.WorkshopId))
@@ -789,13 +838,17 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
if (_EmployeeRepository.Exists(x => x.NationalCode == command.NationalCode && x.id != command.Id)) if (_EmployeeRepository.Exists(x => x.NationalCode == command.NationalCode && x.id != command.Id))
{ {
nationalcodeIsOk = false; nationalcodeIsOk = false;
if (_EmployeeRepository.ExistsEmployeeWorkshopNationalCodeEmployeeId(command.NationalCode, command.WorkshopId, command.Id)) if (_EmployeeRepository.ExistsEmployeeWorkshopNationalCodeEmployeeId(command.NationalCode,
command.WorkshopId, command.Id))
return opration.Failed("کد ملی وارد شده تکراری است"); return opration.Failed("کد ملی وارد شده تکراری است");
} }
if (!string.IsNullOrEmpty(command.InsuranceCode) && _EmployeeRepository.Exists(x => x.InsuranceCode == command.InsuranceCode && x.id != command.Id))
if (!string.IsNullOrEmpty(command.InsuranceCode) &&
_EmployeeRepository.Exists(x => x.InsuranceCode == command.InsuranceCode && x.id != command.Id))
{ {
nationalcodeIsOk = false; nationalcodeIsOk = false;
if (_EmployeeRepository.ExistsEmployeeWorkshopInsuranceCodeEmployeeId(command.InsuranceCode, command.WorkshopId, command.Id)) if (_EmployeeRepository.ExistsEmployeeWorkshopInsuranceCodeEmployeeId(command.InsuranceCode,
command.WorkshopId, command.Id))
return opration.Failed("کد بیمه وارد شده تکراری است"); return opration.Failed("کد بیمه وارد شده تکراری است");
} }
@@ -877,8 +930,12 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
string initial = "1300/10/11"; string initial = "1300/10/11";
var dateOfBirth = command.DateOfBirth != null ? command.DateOfBirth.ToGeorgianDateTime() : initial.ToGeorgianDateTime(); var dateOfBirth = command.DateOfBirth != null
var dateOfIssue = command.DateOfIssue != null ? command.DateOfIssue.ToGeorgianDateTime() : initial.ToGeorgianDateTime(); ? command.DateOfBirth.ToGeorgianDateTime()
: initial.ToGeorgianDateTime();
var dateOfIssue = command.DateOfIssue != null
? command.DateOfIssue.ToGeorgianDateTime()
: initial.ToGeorgianDateTime();
employee.Edit(command.FName, command.LName, command.FatherName, dateOfBirth, employee.Edit(command.FName, command.LName, command.FatherName, dateOfBirth,
dateOfIssue, dateOfIssue,
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality, command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality,
@@ -898,14 +955,17 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
} }
public EditEmployee GetDetailsForClient(long id, long workshopId) public EditEmployee GetDetailsForClient(long id, long workshopId)
{ {
var employee = _EmployeeRepository.GetDetails(id); var employee = _EmployeeRepository.GetDetails(id);
employee.PersonelCode = _context.PersonnelCodeSet.FirstOrDefault(p => p.EmployeeId == id && p.WorkshopId == workshopId)?.PersonnelCode; employee.PersonelCode = _context.PersonnelCodeSet
.FirstOrDefault(p => p.EmployeeId == id && p.WorkshopId == workshopId)?.PersonnelCode;
return employee; return employee;
} }
#region NewByHeydari #region NewByHeydari
public List<EmployeeViewModel> SearchForMain(EmployeeSearchModel searchModel) public List<EmployeeViewModel> SearchForMain(EmployeeSearchModel searchModel)
{ {
var res = _EmployeeRepository.SearchForMain(searchModel); var res = _EmployeeRepository.SearchForMain(searchModel);
@@ -917,6 +977,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return res; return res;
} }
#endregion #endregion
@@ -926,7 +987,9 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
if (nationalCode.NationalCodeValid() != "valid") if (nationalCode.NationalCodeValid() != "valid")
return new(); return new();
var workshopEmployeesWithLeftWork = _EmployeeRepository.GetWorkingEmployeesByWorkshopIdsAndNationalCodeAndDate(workshopIds, nationalCode, DateTime.Now.Date); var workshopEmployeesWithLeftWork =
_EmployeeRepository.GetWorkingEmployeesByWorkshopIdsAndNationalCodeAndDate(workshopIds, nationalCode,
DateTime.Now.Date);
return workshopEmployeesWithLeftWork.FirstOrDefault(); return workshopEmployeesWithLeftWork.FirstOrDefault();
} }
@@ -934,9 +997,12 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
if (nationalCode.NationalCodeValid() != "valid") if (nationalCode.NationalCodeValid() != "valid")
return new(); return new();
var workshopEmployeesWithLeftWork = _EmployeeRepository.GetWorkedEmployeesByWorkshopIdsAndNationalCodeAndDate(workshopIds, nationalCode, DateTime.Now.Date); var workshopEmployeesWithLeftWork =
_EmployeeRepository.GetWorkedEmployeesByWorkshopIdsAndNationalCodeAndDate(workshopIds, nationalCode,
DateTime.Now.Date);
return workshopEmployeesWithLeftWork.FirstOrDefault(); return workshopEmployeesWithLeftWork.FirstOrDefault();
} }
public List<EmployeeViewModel> GetWorkingEmployeesByWorkshopId(long workshopId) public List<EmployeeViewModel> GetWorkingEmployeesByWorkshopId(long workshopId)
{ {
return _EmployeeRepository.GetWorkingEmployeesByWorkshopId(workshopId); return _EmployeeRepository.GetWorkingEmployeesByWorkshopId(workshopId);
@@ -980,6 +1046,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
#endregion #endregion
#region Mahan #region Mahan
public OperationResult CreateEmployeeByClient(CreateEmployeeByClient command) public OperationResult CreateEmployeeByClient(CreateEmployeeByClient command)
{ {
OperationResult op = new(); OperationResult op = new();
@@ -1028,20 +1095,23 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
_EmployeeRepository.SaveChanges(); _EmployeeRepository.SaveChanges();
} }
if (employee == null) if (employee == null)
{ {
return op.Failed("خطای سیستمی. لطفا دوباره تلاش کنید . درصورت تکرار این مشکل با تیم پشتیبان تماس بگیرید"); return op.Failed("خطای سیستمی. لطفا دوباره تلاش کنید . درصورت تکرار این مشکل با تیم پشتیبان تماس بگیرید");
} }
if (_leftWorkTempRepository.Exists(x => if (_leftWorkTempRepository.Exists(x =>
x.EmployeeId == employee.id && x.WorkshopId == command.WorkshopId && x.LeftWorkType == LeftWorkTempType.StartWork)) x.EmployeeId == employee.id && x.WorkshopId == command.WorkshopId &&
x.LeftWorkType == LeftWorkTempType.StartWork))
{ {
return op.Failed("این پرسنل در کارگاه شما قبلا افزوده شده است و در انتظار تایید میباشد"); return op.Failed("این پرسنل در کارگاه شما قبلا افزوده شده است و در انتظار تایید میباشد");
} }
var startLeftWork = command.StartLeftWork.ToGeorgianDateTime(); var startLeftWork = command.StartLeftWork.ToGeorgianDateTime();
var leftWorkViewModel = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(command.WorkshopId, employee.id); var leftWorkViewModel =
_leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(command.WorkshopId, employee.id);
PersonnelCodeDomain personnelCode = null; PersonnelCodeDomain personnelCode = null;
@@ -1125,8 +1195,10 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
rollCallEmployee.HasImage(); rollCallEmployee.HasImage();
_rollCallEmployeeRepository.Create(rollCallEmployee); _rollCallEmployeeRepository.Create(rollCallEmployee);
_rollCallEmployeeRepository.SaveChanges(); _rollCallEmployeeRepository.SaveChanges();
string employeeFullName = employee.FName + " " + employee.LName; string employeeFullName = employee.FName + " " + employee.LName;
var res = _faceEmbeddingService.GenerateEmbeddingsAsync(employee.id,command.WorkshopId,employeeFullName, filePath1,filePath2).GetAwaiter().GetResult(); var res = _faceEmbeddingService
.GenerateEmbeddingsAsync(employee.id, command.WorkshopId, employeeFullName, filePath1, filePath2)
.GetAwaiter().GetResult();
if (!res.IsSuccedded) if (!res.IsSuccedded)
{ {
return op.Failed(res.Message); return op.Failed(res.Message);
@@ -1212,7 +1284,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
command.EmployeeDocumentItems = command.EmployeeDocumentItems ?? []; command.EmployeeDocumentItems = command.EmployeeDocumentItems ?? [];
var employeeDocumentResult = _employeeDocumentsApplication.AddRangeEmployeeDocumentItemsByClient(command.WorkshopId, var employeeDocumentResult = _employeeDocumentsApplication.AddRangeEmployeeDocumentItemsByClient(
command.WorkshopId,
employee.id, command.EmployeeDocumentItems); employee.id, command.EmployeeDocumentItems);
if (employeeDocumentResult.IsSuccedded == false) if (employeeDocumentResult.IsSuccedded == false)
@@ -1262,8 +1335,9 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
byte[] bytes = Convert.FromBase64String(subBase64); byte[] bytes = Convert.FromBase64String(subBase64);
System.IO.File.WriteAllBytes(filePath, bytes); System.IO.File.WriteAllBytes(filePath, bytes);
} }
public async Task<OperationResult<EmployeeByNationalCodeInWorkshopViewModel>> public async Task<OperationResult<EmployeeByNationalCodeInWorkshopViewModel>>
ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode, string birthDate,bool authorizedCanceled, long workshopId) ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode, string birthDate, long workshopId)
{ {
var op = new OperationResult<EmployeeByNationalCodeInWorkshopViewModel>(); var op = new OperationResult<EmployeeByNationalCodeInWorkshopViewModel>();
@@ -1279,25 +1353,71 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
var employee = _EmployeeRepository.GetByNationalCodeIgnoreQueryFilter(nationalCode); var employee = _EmployeeRepository.GetByNationalCodeIgnoreQueryFilter(nationalCode);
if (employee == null && !authorizedCanceled) if (employee == null)
{ {
var personalInfo = await _uidService.GetPersonalInfo(nationalCode, birthDate); var personalInfo = await _uidService.GetPersonalInfo(nationalCode, birthDate);
if (personalInfo != null)
if (personalInfo.ResponseContext.Status.Code == 14)
{ {
if (personalInfo.ResponseContext.Status.Code == 14) return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید",
{ new EmployeeByNationalCodeInWorkshopViewModel() { AuthorizedCanceled = true });
return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeByNationalCodeInWorkshopViewModel() { AuthorizedCanceled = true }); }
}
if (personalInfo.ResponseContext.Status.Code != 0)
{
return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");
}
var basicInfo = personalInfo.BasicInformation; if (personalInfo.ResponseContext.Status.Code != 0)
var identityInfo = personalInfo.IdentificationInformation; {
DateTime apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime(); return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");
}
var dateOfIssue = new DateTime(1922, 1, 1); var basicInfo = personalInfo.BasicInformation;
var identityInfo = personalInfo.IdentificationInformation;
DateTime apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime();
var dateOfIssue = new DateTime(1922, 1, 1);
var gender = basicInfo.GenderEnum switch
{
Gender.Female => "زن",
Gender.Male => "مرد",
_ => throw new AggregateException()
};
var idNumber = identityInfo.ShenasnamehNumber == "0"
? identityInfo.NationalId
: identityInfo.ShenasnamehNumber;
var newEmployee = new Employee(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, apiBirthDate,
dateOfIssue, null, identityInfo.NationalId, idNumber, gender, "ایرانی", identityInfo.ShenasnameSerial,
identityInfo.ShenasnameSeri);
newEmployee.Authorized();
await _EmployeeRepository.CreateAsync(newEmployee);
await _EmployeeRepository.SaveChangesAsync();
return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel()
{
EmployeeId = newEmployee.id,
EmployeeFName = newEmployee.FName,
Gender = newEmployee.Gender,
Nationality = newEmployee.Nationality,
EmployeeLName = newEmployee.LName
});
}
if (_leftWorkTempRepository.ExistsIgnoreQueryFilter(x =>
x.EmployeeId == employee.id && x.WorkshopId == workshopId &&
x.LeftWorkType == LeftWorkTempType.StartWork))
{
return op.Failed("این پرسنل در کارگاه شما قبلا افزوده شده است و در انتظار تایید میباشد");
}
if (employee.IsAuthorized == false)
{
var personalInfoResponse = await _uidService.GetPersonalInfo(nationalCode, birthDate);
if (personalInfoResponse.ResponseContext.Status.Code == 0)
{
var basicInfo = personalInfoResponse.BasicInformation;
var identityInfo = personalInfoResponse.IdentificationInformation;
var apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime();
var gender = basicInfo.GenderEnum switch var gender = basicInfo.GenderEnum switch
{ {
@@ -1306,92 +1426,36 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
_ => throw new AggregateException() _ => throw new AggregateException()
}; };
var idNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber; var idNumber = identityInfo.ShenasnamehNumber == "0"
? identityInfo.NationalId
: identityInfo.ShenasnamehNumber;
employee.Edit(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, apiBirthDate,
employee.DateOfIssue, employee.PlaceOfIssue, identityInfo.NationalId, idNumber,
gender, "ایرانی", employee.Phone, employee.Address, employee.State, employee.City,
employee.MaritalStatus, employee.MilitaryService, employee.LevelOfEducation,
employee.FieldOfStudy, employee.BankCardNumber, employee.BankBranch, employee.InsuranceCode,
employee.InsuranceHistoryByYear,
employee.InsuranceHistoryByMonth, employee.NumberOfChildren,
employee.OfficePhone, employee.MclsUserName, employee.MclsPassword,
employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName,
employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword);
employee.Authorized();
var newEmployee = new Employee(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, apiBirthDate,
dateOfIssue, null, identityInfo.NationalId, idNumber, gender, "ایرانی", identityInfo.ShenasnameSerial, identityInfo.ShenasnameSeri);
newEmployee.Authorized();
await _EmployeeRepository.CreateAsync(newEmployee);
await _EmployeeRepository.SaveChangesAsync(); await _EmployeeRepository.SaveChangesAsync();
return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel()
{
EmployeeId = newEmployee.id,
EmployeeFName = newEmployee.FName,
Gender = newEmployee.Gender,
Nationality = newEmployee.Nationality,
EmployeeLName = newEmployee.LName
});
} }
else else
{
return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeByNationalCodeInWorkshopViewModel() { AuthorizedCanceled = true });
}
}
else if (employee == null && authorizedCanceled)
{
return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel());
}
if (_leftWorkTempRepository.ExistsIgnoreQueryFilter(x =>
x.EmployeeId == employee.id && x.WorkshopId == workshopId && x.LeftWorkType == LeftWorkTempType.StartWork))
{
return op.Failed("این پرسنل در کارگاه شما قبلا افزوده شده است و در انتظار تایید میباشد");
}
var personalInfoResponse = await _uidService.GetPersonalInfo(nationalCode, birthDate);
if (personalInfoResponse != null)
{
if (employee.IsAuthorized == false)
{
if (personalInfoResponse.ResponseContext.Status.Code == 0)
{
var basicInfo = personalInfoResponse.BasicInformation;
var identityInfo = personalInfoResponse.IdentificationInformation;
var apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime();
var gender = basicInfo.GenderEnum switch
{
Gender.Female => "زن",
Gender.Male => "مرد",
_ => throw new AggregateException()
};
var idNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber;
employee.Edit(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, apiBirthDate,
employee.DateOfIssue, employee.PlaceOfIssue, identityInfo.NationalId, idNumber,
gender, "ایرانی", employee.Phone, employee.Address, employee.State, employee.City,
employee.MaritalStatus, employee.MilitaryService, employee.LevelOfEducation,
employee.FieldOfStudy, employee.BankCardNumber, employee.BankBranch, employee.InsuranceCode, employee.InsuranceHistoryByYear,
employee.InsuranceHistoryByMonth, employee.NumberOfChildren,
employee.OfficePhone, employee.MclsUserName, employee.MclsPassword,
employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName,
employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword);
employee.Authorized();
await _EmployeeRepository.SaveChangesAsync();
}
else
{
return op.Failed("کد ملی با تاریخ تولد وارد شده مطابقت ندارد");
}
}
else if (employee.DateOfBirth.ToFarsi() != birthDate || employee.NationalCode != nationalCode)
{ {
return op.Failed("کد ملی با تاریخ تولد وارد شده مطابقت ندارد"); return op.Failed("کد ملی با تاریخ تولد وارد شده مطابقت ندارد");
} }
} }
else if (employee.DateOfBirth.ToFarsi() != birthDate || employee.NationalCode != nationalCode)
{
return op.Failed("کد ملی با تاریخ تولد وارد شده مطابقت ندارد");
}
var leftWorkViewModel = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(workshopId, employee.id); var leftWorkViewModel = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(workshopId, employee.id);
if (leftWorkViewModel == null) if (leftWorkViewModel == null)
@@ -1403,7 +1467,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
Gender = employee.Gender, Gender = employee.Gender,
Nationality = employee.Nationality, Nationality = employee.Nationality,
EmployeeLName = employee.LName EmployeeLName = employee.LName
}); ; });
;
} }
if (leftWorkViewModel.LeftWorkDate >= DateTime.Now || !leftWorkViewModel.HasLeft) if (leftWorkViewModel.LeftWorkDate >= DateTime.Now || !leftWorkViewModel.HasLeft)
@@ -1455,17 +1520,18 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
Picture1 = picture1, Picture1 = picture1,
Picture2 = picture2, Picture2 = picture2,
PersonnelCode = personnelCode, PersonnelCode = personnelCode,
EmployeeBankInfos = bankInformationViewModel.BankInformation.Select(x => new EmployeeByNationalCodeEmployeeBankInfoViewModel EmployeeBankInfos = bankInformationViewModel.BankInformation.Select(x =>
{ new EmployeeByNationalCodeEmployeeBankInfoViewModel
ShebaNumber = x.ShebaNumber, {
IsDefault = x.IsDefault, ShebaNumber = x.ShebaNumber,
CardNumber = x.CardNumber, IsDefault = x.IsDefault,
BankAccountNumber = x.BankAccountNumber, CardNumber = x.CardNumber,
BankId = x.BankId, BankAccountNumber = x.BankAccountNumber,
BankLogoMediaId = x.BankLogoMediaId, BankId = x.BankId,
BankLogoPath = x.BankLogoPath, BankLogoMediaId = x.BankLogoMediaId,
BankName = x.BankName BankLogoPath = x.BankLogoPath,
}).ToList(), BankName = x.BankName
}).ToList(),
EmployeeDocument = new EmployeeByNationalCodeEmployeeDocumentViewModel EmployeeDocument = new EmployeeByNationalCodeEmployeeDocumentViewModel
{ {
EducationalDegree = employeeDocumentsViewModel.EducationalDegree, EducationalDegree = employeeDocumentsViewModel.EducationalDegree,
@@ -1519,6 +1585,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
return op.Failed("جنسیت وارد شده نامعتبر است"); return op.Failed("جنسیت وارد شده نامعتبر است");
} }
if (command.BirthDate.TryToGeorgianDateTime(out var birthDateGr) == false) if (command.BirthDate.TryToGeorgianDateTime(out var birthDateGr) == false)
{ {
return op.Failed("تاریخ تولد وارد شده نامعتبر است"); return op.Failed("تاریخ تولد وارد شده نامعتبر است");
@@ -1555,7 +1622,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
} }
} }
var employeeClientTemp = _employeeClientTempRepository.GetByEmployeeIdAndWorkshopId(command.EmployeeId, command.WorkshopId); var employeeClientTemp =
_employeeClientTempRepository.GetByEmployeeIdAndWorkshopId(command.EmployeeId, command.WorkshopId);
employeeClientTemp?.Edit(command.MaritalStatus); employeeClientTemp?.Edit(command.MaritalStatus);
@@ -1582,6 +1650,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName, employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName,
employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword); employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword);
} }
await _EmployeeRepository.SaveChangesAsync(); await _EmployeeRepository.SaveChangesAsync();
return op.Succcedded(); return op.Succcedded();
@@ -1592,7 +1661,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return await _EmployeeRepository.WorkedEmployeesInWorkshopSelectList(workshopId); return await _EmployeeRepository.WorkedEmployeesInWorkshopSelectList(workshopId);
} }
public async Task<OperationResult<EmployeeDataFromApiViewModel>> GetEmployeeDataFromApi(string nationalCode, string birthDate) public async Task<OperationResult<EmployeeDataFromApiViewModel>> GetEmployeeDataFromApi(string nationalCode,
string birthDate)
{ {
var op = new OperationResult<EmployeeDataFromApiViewModel>(); var op = new OperationResult<EmployeeDataFromApiViewModel>();
var birthDateGr = birthDate.ToGeorgianDateTime(); var birthDateGr = birthDate.ToGeorgianDateTime();
@@ -1604,20 +1674,23 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
if (employee.IsAuthorized == false) if (employee.IsAuthorized == false)
{ {
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate); var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
if (apiResult == null) if (apiResult == null)
{ {
return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد"); return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد");
} }
if (apiResult.ResponseContext.Status.Code is 14 or 3) if (apiResult.ResponseContext.Status.Code is 14 or 3)
{ {
return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد"); return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد");
} }
if (apiResult.ResponseContext.Status.Code != 0) if (apiResult.ResponseContext.Status.Code != 0)
{ {
return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند"); return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");
} }
var basicInfo = apiResult.BasicInformation; var basicInfo = apiResult.BasicInformation;
var identityInfo = apiResult.IdentificationInformation; var identityInfo = apiResult.IdentificationInformation;
@@ -1628,12 +1701,15 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
_ => throw new AggregateException() _ => throw new AggregateException()
}; };
var idNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber; var idNumber = identityInfo.ShenasnamehNumber == "0"
? identityInfo.NationalId
: identityInfo.ShenasnamehNumber;
employee.Edit(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, birthDateGr, employee.Edit(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, birthDateGr,
employee.DateOfIssue, employee.PlaceOfIssue, identityInfo.NationalId, idNumber, employee.DateOfIssue, employee.PlaceOfIssue, identityInfo.NationalId, idNumber,
gender, "ایرانی", employee.Phone, employee.Address, employee.State, employee.City, gender, "ایرانی", employee.Phone, employee.Address, employee.State, employee.City,
employee.MaritalStatus, employee.MilitaryService, employee.LevelOfEducation, employee.MaritalStatus, employee.MilitaryService, employee.LevelOfEducation,
employee.FieldOfStudy, employee.BankCardNumber, employee.BankBranch, employee.InsuranceCode, employee.InsuranceHistoryByYear, employee.FieldOfStudy, employee.BankCardNumber, employee.BankBranch, employee.InsuranceCode,
employee.InsuranceHistoryByYear,
employee.InsuranceHistoryByMonth, employee.NumberOfChildren, employee.InsuranceHistoryByMonth, employee.NumberOfChildren,
employee.OfficePhone, employee.MclsUserName, employee.MclsPassword, employee.OfficePhone, employee.MclsUserName, employee.MclsPassword,
employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName, employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName,
@@ -1668,15 +1744,18 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
}; };
return op.Succcedded(data); return op.Succcedded(data);
} }
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate); var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
if (apiResult == null) if (apiResult == null)
{ {
return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true }); return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید",
new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true });
} }
if (apiResult.ResponseContext.Status.Code is 14 or 3) if (apiResult.ResponseContext.Status.Code is 14 or 3)
{ {
return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true }); return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید",
new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true });
} }
@@ -1684,10 +1763,12 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند"); return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");
} }
if (apiResult.ResponseContext.Status.Code != 0) if (apiResult.ResponseContext.Status.Code != 0)
{ {
return op.Failed("اطلاعات وارد شده نامعتبر میباشد"); return op.Failed("اطلاعات وارد شده نامعتبر میباشد");
} }
var basicInfo = apiResult.BasicInformation; var basicInfo = apiResult.BasicInformation;
var identityInfo = apiResult.IdentificationInformation; var identityInfo = apiResult.IdentificationInformation;
@@ -1695,7 +1776,9 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
{ {
BirthDate = identityInfo.BirthDate, BirthDate = identityInfo.BirthDate,
NationalCode = identityInfo.NationalId, NationalCode = identityInfo.NationalId,
IdNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber, IdNumber = identityInfo.ShenasnamehNumber == "0"
? identityInfo.NationalId
: identityInfo.ShenasnamehNumber,
FatherName = basicInfo.FatherName, FatherName = basicInfo.FatherName,
FName = basicInfo.FirstName, FName = basicInfo.FirstName,
Gender = basicInfo.GenderEnum, Gender = basicInfo.GenderEnum,
@@ -1704,7 +1787,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
IdNumberSerial = identityInfo.ShenasnameSerial IdNumberSerial = identityInfo.ShenasnameSerial
}; };
var newAuthorizeTemp = new EmployeeAuthorizeTemp(data.Gender, data.FName, data.LName, data.FatherName, birthDateGr, data.NationalCode, data.IdNumber, data.IdNumberSerial, data.IdNumberSeri); var newAuthorizeTemp = new EmployeeAuthorizeTemp(data.Gender, data.FName, data.LName, data.FatherName,
birthDateGr, data.NationalCode, data.IdNumber, data.IdNumberSerial, data.IdNumberSeri);
await _employeeAuthorizeTempRepository.CreateAsync(newAuthorizeTemp); await _employeeAuthorizeTempRepository.CreateAsync(newAuthorizeTemp);
await _employeeAuthorizeTempRepository.SaveChangesAsync(); await _employeeAuthorizeTempRepository.SaveChangesAsync();
@@ -1719,9 +1803,9 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
#region Api #region Api
public async Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id) public async Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText, long id)
{ {
return await _EmployeeRepository.GetSelectList(searchText,id ); return await _EmployeeRepository.GetSelectList(searchText, id);
} }
public async Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel) public async Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel)
@@ -1729,5 +1813,10 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return await _EmployeeRepository.GetList(searchModel); return await _EmployeeRepository.GetList(searchModel);
} }
#endregion public Task<List<GetEmployeeClientListViewModel>> GetEmployeeClientList(GetEmployeeClientListSearchModel searchModel,long workshopId)
{
return _EmployeeRepository.GetEmployeeClientList(searchModel, workshopId);
}
#endregion
} }

View File

@@ -22,7 +22,6 @@ using Company.Domain.InstitutionContractAgg;
using Company.Domain.LeftWorkAgg; using Company.Domain.LeftWorkAgg;
using Company.Domain.PaymentTransactionAgg; using Company.Domain.PaymentTransactionAgg;
using Company.Domain.RepresentativeAgg; using Company.Domain.RepresentativeAgg;
using Company.Domain.RollCallServiceAgg;
using Company.Domain.TemporaryClientRegistrationAgg; using Company.Domain.TemporaryClientRegistrationAgg;
using Company.Domain.WorkshopAgg; using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.FinancialInvoice; using CompanyManagment.App.Contracts.FinancialInvoice;
@@ -60,7 +59,6 @@ public class InstitutionContractApplication : IInstitutionContractApplication
private readonly IFinancialInvoiceRepository _financialInvoiceRepository; private readonly IFinancialInvoiceRepository _financialInvoiceRepository;
private readonly IPaymentGateway _paymentGateway; private readonly IPaymentGateway _paymentGateway;
private readonly IPaymentTransactionRepository _paymentTransactionRepository; private readonly IPaymentTransactionRepository _paymentTransactionRepository;
private readonly IRollCallServiceRepository _rollCallServiceRepository;
public InstitutionContractApplication(IInstitutionContractRepository institutionContractRepository, public InstitutionContractApplication(IInstitutionContractRepository institutionContractRepository,
@@ -72,7 +70,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
IFinancialStatmentRepository financialStatmentRepository, IContactInfoApplication contactInfoApplication, IFinancialStatmentRepository financialStatmentRepository, IContactInfoApplication contactInfoApplication,
IAccountApplication accountApplication, ISmsService smsService, IUidService uidService, IAccountApplication accountApplication, ISmsService smsService, IUidService uidService,
IFinancialInvoiceRepository financialInvoiceRepository, IHttpClientFactory httpClientFactory, IFinancialInvoiceRepository financialInvoiceRepository, IHttpClientFactory httpClientFactory,
IPaymentTransactionRepository paymentTransactionRepository, IRollCallServiceRepository rollCallServiceRepository) IPaymentTransactionRepository paymentTransactionRepository)
{ {
_institutionContractRepository = institutionContractRepository; _institutionContractRepository = institutionContractRepository;
_contractingPartyRepository = contractingPartyRepository; _contractingPartyRepository = contractingPartyRepository;
@@ -90,7 +88,6 @@ public class InstitutionContractApplication : IInstitutionContractApplication
_uidService = uidService; _uidService = uidService;
_financialInvoiceRepository = financialInvoiceRepository; _financialInvoiceRepository = financialInvoiceRepository;
_paymentTransactionRepository = paymentTransactionRepository; _paymentTransactionRepository = paymentTransactionRepository;
_rollCallServiceRepository = rollCallServiceRepository;
_paymentGateway = new SepehrPaymentGateway(httpClientFactory); _paymentGateway = new SepehrPaymentGateway(httpClientFactory);
} }
@@ -1540,7 +1537,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return (await _institutionContractRepository.PrintAllAsync([id])).FirstOrDefault(); return (await _institutionContractRepository.PrintAllAsync([id])).FirstOrDefault();
} }
public async Task<OperationResult> SetPendingWorkflow(long entityId,InstitutionContractSigningType signingType) public async Task<OperationResult> SetPendingWorkflow(long entityId)
{ {
var op = new OperationResult(); var op = new OperationResult();
var institutionContract = await _institutionContractRepository.GetIncludeWorkshopDetailsAsync(entityId); var institutionContract = await _institutionContractRepository.GetIncludeWorkshopDetailsAsync(entityId);
@@ -1554,61 +1551,15 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return op.Failed("وضعیت قرارداد مالی برای این عملیات مناسب نمی باشد"); return op.Failed("وضعیت قرارداد مالی برای این عملیات مناسب نمی باشد");
} }
var initialCreatedWorkshops = institutionContract.WorkshopGroup.InitialWorkshops
.Where(x => x.WorkshopCreated && x.WorkshopId is > 0).ToList();
var currentWorkshops = institutionContract.WorkshopGroup.CurrentWorkshops.ToList();
var accountId = _contractingPartyRepository
.GetAccountByPersonalContractingParty(institutionContract.ContractingPartyId).Id;
foreach (var createdWorkshop in initialCreatedWorkshops)
{
if (currentWorkshops.Any(x => x.WorkshopId == createdWorkshop.WorkshopId))
{
//rollcall serviecs
if (createdWorkshop.Services.RollCall)
{
var ActiveService = _rollCallServiceRepository.GetActiveServiceByWorkshopId(createdWorkshop.WorkshopId!.Value);
var startTime = institutionContract.ContractStartGr;
var endTime = institutionContract.ContractEndGr;
if (ActiveService != null)
{
if (ActiveService.EndService> startTime)
{
startTime = ActiveService.EndService;
}
}
var rollCallService = new RollCallService("BasedOnIC",
startTime, endTime, createdWorkshop.WorkshopId.Value,accountId,createdWorkshop.PersonnelCount,
0,"12");
await _rollCallServiceRepository.CreateAsync(rollCallService);
}
}
else
{
var currentWorkshop = new InstitutionContractWorkshopCurrent(createdWorkshop.WorkshopName,
createdWorkshop.Services.RollCall, createdWorkshop.Services.RollCallInPerson,
createdWorkshop.Services.CustomizeCheckout, createdWorkshop.Services.Contract,
createdWorkshop.Services.ContractInPerson, createdWorkshop.Services.Insurance,
createdWorkshop.Services.InsuranceInPerson,createdWorkshop.PersonnelCount, createdWorkshop.Price,
createdWorkshop.InstitutionContractWorkshopGroupId,createdWorkshop.WorkshopGroup,
createdWorkshop.WorkshopId!.Value, createdWorkshop.id);
institutionContract.WorkshopGroup.AddCurrentWorkshop(currentWorkshop);
}
}
if (institutionContract.WorkshopGroup.InitialWorkshops.All(x => x.WorkshopCreated && x.WorkshopId is > 0)) if (institutionContract.WorkshopGroup.InitialWorkshops.All(x => x.WorkshopCreated && x.WorkshopId is > 0))
{ {
institutionContract.Verified(); institutionContract.Verified();
} }
else else
{ {
institutionContract.SetPendingWorkflow(); institutionContract.SetPendingWorkflow();
} }
institutionContract.SetSigningType(signingType);
await _institutionContractRepository.SaveChangesAsync(); await _institutionContractRepository.SaveChangesAsync();
return op.Succcedded(); return op.Succcedded();
} }
@@ -1618,42 +1569,6 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return await _institutionContractRepository.GetIdByInstallmentId(installmentId); return await _institutionContractRepository.GetIdByInstallmentId(installmentId);
} }
public async Task<OperationResult> VerifyInstitutionContractManually(long institutionContractId)
{
var op = new OperationResult();
var institutionContract =await _institutionContractRepository
.GetIncludeWorkshopDetailsAsync(institutionContractId);
if (institutionContract == null)
return op.Failed("قرارداد مالی یافت نشد");
if (institutionContract.VerificationStatus == InstitutionContractVerificationStatus.Verified)
return op.Failed("قرارداد مالی قبلا تایید شده است");
var transaction = await _institutionContractRepository.BeginTransactionAsync();
await SetPendingWorkflow(institutionContractId,InstitutionContractSigningType.Physical);
var financialStatement = await _financialStatmentRepository
.GetByContractingPartyId(institutionContract.ContractingPartyId);
DateTime today = DateTime.Today;
var description = institutionContract.IsInstallment
? "قسط اول سرویس"
: "پرداخت کل سرویس";
var debtorAmount = institutionContract.IsInstallment
? institutionContract.Installments.First().Amount
: institutionContract.TotalAmount;
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
description, "debt", "بابت خدمات", debtorAmount, 0, 0);
financialStatement.AddFinancialTransaction(financialTransaction);
await _institutionContractRepository.SaveChangesAsync();
await transaction.CommitAsync();
return op.Succcedded();
}
private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity( private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity(
CreateInstitutionContractLegalPartyRequest request, long representativeId, string address, string city, CreateInstitutionContractLegalPartyRequest request, long representativeId, string address, string city,
string state) string state)

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Application; using _0_Framework.Application;
using Company.Domain.InstitutionPlanAgg; using Company.Domain.InstitutionPlanAgg;
using CompanyManagment.App.Contracts.InstitutionPlan; using CompanyManagment.App.Contracts.InstitutionPlan;
@@ -85,73 +84,4 @@ public class InstitutionPlanApplication : IInstitutionPlanApplication
{ {
return _planPercentageRepository.GetInstitutionPlanForWorkshop(command); return _planPercentageRepository.GetInstitutionPlanForWorkshop(command);
} }
#region ForApi
public async Task<CreateServiceAmountDto> GetCreateModalData()
{
return await _planPercentageRepository.GetCreateModalData();
}
public async Task<OperationResult> CreateInstitutionPlanPercentage(CreateServiceAmountDto command)
{
var op = new OperationResult();
if (string.IsNullOrWhiteSpace(command.ContractAndCheckoutInPersonPercentStr) || command.ContractAndCheckoutInPersonPercentStr == "0" ||
string.IsNullOrWhiteSpace(command.ContractAndCheckoutPercentStr) || (command.ContractAndCheckoutPercentStr == "0" ||
string.IsNullOrWhiteSpace(command.CustomizeCheckoutPercentStr) || command.CustomizeCheckoutPercentStr == "0" ||
string.IsNullOrWhiteSpace(command.InsuranceInPersonPercentStr) || command.InsuranceInPersonPercentStr == "0" ||
string.IsNullOrWhiteSpace(command.InsurancePercentStr) || command.InsurancePercentStr == "0" ||
string.IsNullOrWhiteSpace(command.RollCallPercentStr) || command.RollCallPercentStr == "0"))
return op.Failed("هیچ یک از فیلدها نمیتوانند صفر باشند");
int contractAndCheckoutInPersonPercent = 0;
int contractAndCheckoutPercent = 0;
int customizeCheckoutPercent = 0;
int insuranceInPersonPercent = 0;
int insurancePercent = 0;
int rollCallPercent = 0;
try
{
contractAndCheckoutInPersonPercent = Convert.ToInt32(command.ContractAndCheckoutInPersonPercentStr);
contractAndCheckoutPercent = Convert.ToInt32(command.ContractAndCheckoutPercentStr);
customizeCheckoutPercent = Convert.ToInt32(command.CustomizeCheckoutPercentStr);
insuranceInPersonPercent = Convert.ToInt32(command.InsuranceInPersonPercentStr);
insurancePercent = Convert.ToInt32(command.InsurancePercentStr);
rollCallPercent = Convert.ToInt32(command.RollCallPercentStr);
}
catch (Exception e)
{
return op.Failed("لطفا عدد معتبر وارد کنید");
}
var firstPlan =await _planPercentageRepository.GetCreateModalData();
if (firstPlan != null)
{
var planPercentage = _planPercentageRepository.Get(firstPlan.Id);
planPercentage.Edit(contractAndCheckoutPercent, insurancePercent, rollCallPercent, customizeCheckoutPercent, contractAndCheckoutInPersonPercent, insuranceInPersonPercent);
_planPercentageRepository.SaveChanges();
}
else
{
var create = new PlanPercentage(contractAndCheckoutPercent, insurancePercent, rollCallPercent,
customizeCheckoutPercent, contractAndCheckoutInPersonPercent, insuranceInPersonPercent);
await _planPercentageRepository.CreateAsync(create);
await _planPercentageRepository.SaveChangesAsync();
}
return op.Succcedded();
}
public async Task<PagedResult<InstitutionPlanListDto>> GetList(InstitutionPlanSearchModel searchModel)
{
return await _planPercentageRepository.GetList(searchModel);
}
#endregion
} }

View File

@@ -2371,11 +2371,6 @@ public class InsuranceListApplication : IInsuranceListApplication
return _insuranceListRepositpry.GetTabCounts(searchModel); return _insuranceListRepositpry.GetTabCounts(searchModel);
} }
public async Task<PagedResult<InsuranceClientListViewModel>> GetInsuranceClientList(InsuranceClientSearchModel searchModel)
{
return await _insuranceListRepositpry.GetInsuranceClientList(searchModel);
}
public async Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel) public async Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel)
{ {
return await _insuranceListRepositpry.GetNotCreatedWorkshop(searchModel); return await _insuranceListRepositpry.GetNotCreatedWorkshop(searchModel);

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks;
using _0_Framework.Application; using _0_Framework.Application;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums; using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg; using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
@@ -591,86 +590,11 @@ public class LeaveApplication : ILeaveApplication
return leaveTotalTimeSpan; return leaveTotalTimeSpan;
} }
private TimeSpan CalculateTotalLeaveTimeSpan(List<LeavePrintViewModel> leaves)
private TimeSpan CalculateTotalLeaveTimeSpan(List<LeavePrintViewModel> leaves)
{ {
var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType != "روزانه").Sum(x => (x.EndLeaveGr - x.StartLeaveGr).Ticks)); var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType != "روزانه").Sum(x => (x.EndLeaveGr - x.StartLeaveGr).Ticks));
var dailyLeaveCount = leaves.Count(x => x.PaidLeaveType == "روزانه") * new TimeSpan(1, 0, 0, 0); var dailyLeaveCount = leaves.Count(x => x.PaidLeaveType == "روزانه") * new TimeSpan(1, 0, 0, 0);
return timeSpanHourlyLeave + dailyLeaveCount; return timeSpanHourlyLeave + dailyLeaveCount;
} }
#endregion #endregion
#region ForApi
public async Task<PagedResult<leaveListDto>> GetList(LeaveListSearchModel searchModel)
{
return await _leaveRepository.GetList(searchModel);
}
public async Task<List<GroupLeaveListDto>> GetGroupList(LeaveListSearchModel searchModel)
{
return await _leaveRepository.GetGroupList(searchModel);
}
public TimeSpan SumOfEmployeeLeaveTimeSpanInDates(long workshopId, long employeeId, string yearStr, string monthStr, LeaveType leaveType)
{
var startFa = $"{yearStr}/{monthStr:00}/01";
var endFa = startFa.FindeEndOfMonth();
if (startFa.TryToGeorgianDateTime(out var start) == false || endFa.TryToGeorgianDateTime(out var end) == false)
return TimeSpan.Zero;
var leaveTotalTimeSpan = TimeSpan.Zero;
var leaves = _leaveRepository.GetByWorkshopIdEmployeeIdInDates(workshopId, employeeId, start, end);
//var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType != "روزانه").Sum(x => (x.EndLeaveGr - x.StartLeaveGr).Ticks));
//var dailyLeaveCount = leaves.Count(x => x.PaidLeaveType == "روزانه") * new TimeSpan(1, 0, 0, 0);
if (leaveType == LeaveType.PaidLeave)
{
var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType == "ساعتی" && x.LeaveType == "استحقاقی")
.Sum(x => TimeOnly.Parse(x.LeaveHourses).Ticks));
var dailyLeaveTime = leaves.Where(x => x.PaidLeaveType == "روزانه" && x.LeaveType == "استحقاقی")
.Sum(x => Convert.ToInt32(x.LeaveHourses)) * TimeSpan.FromDays(1);
leaveTotalTimeSpan = timeSpanHourlyLeave + dailyLeaveTime;
}
else if (leaveType == LeaveType.SickLeave)
{
var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType == "ساعتی" && x.LeaveType == "استعلاجی")
.Sum(x => TimeOnly.Parse(x.LeaveHourses).Ticks));
var dailyLeaveTime = leaves.Where(x => x.PaidLeaveType == "روزانه" && x.LeaveType == "استعلاجی")
.Sum(x => Convert.ToInt32(x.LeaveHourses)) * TimeSpan.FromDays(1);
leaveTotalTimeSpan = timeSpanHourlyLeave + dailyLeaveTime;
}
else
{
var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType == "ساعتی").Sum(x => TimeOnly.Parse(x.LeaveHourses).Ticks));
var dailyLeaveTime = leaves.Where(x => x.PaidLeaveType == "روزانه").Sum(x => Convert.ToInt32(x.LeaveHourses)) * TimeSpan.FromDays(1);
leaveTotalTimeSpan = timeSpanHourlyLeave + dailyLeaveTime;
}
return leaveTotalTimeSpan;
}
public async Task<List<LeavePrintResponseViewModel>> PrintAllAsync(List<long> ids,long workshopId)
{
return await _leaveRepository.PrintAllAsync(ids,workshopId);
}
public async Task<LeavePrintResponseViewModel> PrintOneAsync(long id, long workshopId)
{
return (await _leaveRepository.PrintAllAsync([id],workshopId)).FirstOrDefault();
}
#endregion
} }

View File

@@ -384,7 +384,6 @@ public class RollCallApplication : IRollCallApplication
var workshopSettings = _customizeWorkshopSettingsRepository.GetBy(command.WorkshopId); var workshopSettings = _customizeWorkshopSettingsRepository.GetBy(command.WorkshopId);
var employeeSettings = var employeeSettings =
_customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings( _customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(
command.WorkshopId, command.EmployeeId)?.WorkshopShiftStatus; command.WorkshopId, command.EmployeeId)?.WorkshopShiftStatus;

View File

@@ -11,7 +11,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Transactions; using System.Transactions;
using _0_Framework.Application.FaceEmbedding;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
namespace CompanyManagment.Application; namespace CompanyManagment.Application;
@@ -24,9 +23,7 @@ public class RollCallEmployeeApplication : IRollCallEmployeeApplication
private readonly ILeftWorkRepository _leftWorkRepository; private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository; private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository;
private readonly IWebHostEnvironment _webHostEnvironment; private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IFaceEmbeddingService _faceEmbeddingService; public RollCallEmployeeApplication(IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, ILeftWorkRepository leftWorkRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, IWebHostEnvironment webHostEnvironment)
public RollCallEmployeeApplication(IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, ILeftWorkRepository leftWorkRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, IWebHostEnvironment webHostEnvironment, IFaceEmbeddingService faceEmbeddingService)
{ {
_rollCallEmployeeRepository = rollCallEmployeeRepository; _rollCallEmployeeRepository = rollCallEmployeeRepository;
_employeeRepository = employeeRepository; _employeeRepository = employeeRepository;
@@ -34,7 +31,6 @@ public class RollCallEmployeeApplication : IRollCallEmployeeApplication
_leftWorkRepository = leftWorkRepository; _leftWorkRepository = leftWorkRepository;
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository; _rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
_webHostEnvironment = webHostEnvironment; _webHostEnvironment = webHostEnvironment;
_faceEmbeddingService = faceEmbeddingService;
} }
public OperationResult Create(CreateRollCallEmployee command) public OperationResult Create(CreateRollCallEmployee command)
@@ -217,18 +213,9 @@ public class RollCallEmployeeApplication : IRollCallEmployeeApplication
if (entity.IsActiveString != "true") if (entity.IsActiveString != "true")
return result.Failed("امکان تغییر نام برای کارمند غیر فعال وجود ندارد"); return result.Failed("امکان تغییر نام برای کارمند غیر فعال وجود ندارد");
var transaction = _rollCallEmployeeRepository.BeginTransactionAsync().GetAwaiter().GetResult();
entity.ChangeName(fName, lName); entity.ChangeName(fName, lName);
_rollCallEmployeeRepository.SaveChanges(); _rollCallEmployeeRepository.SaveChanges();
var embeddingRes =_faceEmbeddingService
.UpdateEmbeddingFullNameAsync(entity.EmployeeId, entity.WorkshopId, fullName)
.GetAwaiter().GetResult();
if (!embeddingRes.IsSuccedded)
return result.Failed("خطا در به روز رسانی نام در سیستم تشخیص چهره: " + embeddingRes.Message);
transaction.Commit();
return result.Succcedded(); return result.Succcedded();
} }
#endregion #endregion

View File

@@ -1092,9 +1092,7 @@ public class WorkshopAppliction : IWorkshopApplication
Amount = 1000, Amount = 1000,
MaxPersonValid = 500, MaxPersonValid = 500,
Duration = "12", Duration = "12",
HasCustomizeCheckoutService = command.HasCustomizeCheckoutService, HasCustomizeCheckoutService = command.HasCustomizeCheckoutService
StartService = institutionContract.ContractStartGr,
}; };
_rollCallServiceApplication.Create(commandSave); _rollCallServiceApplication.Create(commandSave);
} }

View File

@@ -34,10 +34,6 @@ public class InstitutionContractMapping : IEntityTypeConfiguration<InstitutionCo
builder.Property(x => x.VerifierPhoneNumber).HasMaxLength(20); builder.Property(x => x.VerifierPhoneNumber).HasMaxLength(20);
builder.Property(x => x.VerificationStatus).HasConversion<string>().HasMaxLength(122); builder.Property(x => x.VerificationStatus).HasConversion<string>().HasMaxLength(122);
builder.Property(x=>x.SigningType).HasConversion<string>()
.HasMaxLength(25)
.IsRequired(false);
builder.HasMany(x => x.Installments) builder.HasMany(x => x.Installments)
.WithOne(x => x.InstitutionContract) .WithOne(x => x.InstitutionContract)
@@ -49,10 +45,5 @@ public class InstitutionContractMapping : IEntityTypeConfiguration<InstitutionCo
builder.HasMany(x => x.Amendments).WithOne(x => x.InstitutionContract) builder.HasMany(x => x.Amendments).WithOne(x => x.InstitutionContract)
.HasForeignKey(x => x.InstitutionContractId); .HasForeignKey(x => x.InstitutionContractId);
builder.Ignore(x => x.ContractAmountWithTax);
builder.Ignore(x => x.ContractAmountTax);
builder.Ignore(x => x.ContractAmountTax);
} }
} }

View File

@@ -1,29 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addsigningTypeforinstitutioncontract : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "SigningType",
table: "InstitutionContracts",
type: "nvarchar(25)",
maxLength: 25,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "SigningType",
table: "InstitutionContracts");
}
}
}

View File

@@ -3462,10 +3462,6 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(1) .HasMaxLength(1)
.HasColumnType("nvarchar(1)"); .HasColumnType("nvarchar(1)");
b.Property<string>("SigningType")
.HasMaxLength(25)
.HasColumnType("nvarchar(25)");
b.Property<string>("State") b.Property<string>("State")
.HasMaxLength(20) .HasMaxLength(20)
.HasColumnType("nvarchar(20)"); .HasColumnType("nvarchar(20)");

View File

@@ -64,7 +64,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
} }
/// <summary> /// <summary>
/// چک میکند که آیا پرسنل در سال و ماه درخواستی در این کارگاه فیش حقوقی دارد یا خیر /// چیک میکند که آیا پرسنل در سال و ماه درخواستی در این کارگاه فیش حقوقی دارد یا خیر
/// </summary> /// </summary>
/// <param name="workshopId"></param> /// <param name="workshopId"></param>
/// <param name="employeId"></param> /// <param name="employeId"></param>
@@ -74,21 +74,12 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
public (bool hasChekout, double FamilyAlloance, double OverTimePay, double RotatingShift, double Nightwork, double Fridaywork, double YraesPay) HasCheckout(long workshopId, long employeId, string year, string month) public (bool hasChekout, double FamilyAlloance, double OverTimePay, double RotatingShift, double Nightwork, double Fridaywork, double YraesPay) HasCheckout(long workshopId, long employeId, string year, string month)
{ {
var farisMonthName = Tools.ToFarsiMonthByNumber(month); var farisMonthName = Tools.ToFarsiMonthByNumber(month);
var res = _context.CheckoutSet.FirstOrDefault(x => var res = _context.CheckoutSet.FirstOrDefault(x =>
x.WorkshopId == workshopId && x.EmployeeId == employeId && x.Year == year && x.Month == farisMonthName && x.WorkshopId == workshopId && x.EmployeeId == employeId && x.Year == year && x.Month == farisMonthName &&
x.IsActiveString == "true"); x.IsActiveString == "true");
if (res == null) if (res == null)
{ return (false, 0, 0,0,0,0,0);
var checkLeftDate = ($"{year}/{month}/01").ToGeorgianDateTime();
var hasLeftwork = _context.LeftWorkList.Any(x =>
x.EmployeeId == employeId && x.WorkshopId == workshopId && x.LeftWorkDate == checkLeftDate);
if(hasLeftwork)
return (true, 0, 0, 0, 0, 0, 0);
return (false, 0, 0, 0, 0, 0, 0);
}
return (true, res.FamilyAllowance, res.OvertimePay, res.ShiftPay, res.NightworkPay, res.FridayPay,res.YearsPay); return (true, res.FamilyAllowance, res.OvertimePay, res.ShiftPay, res.NightworkPay, res.FridayPay,res.YearsPay);
} }

Some files were not shown because too many files have changed in this diff Show More