From 098233fd1b2c8debe02f49cca81cd2da861b9716 Mon Sep 17 00:00:00 2001 From: Mahan Chamani <109232147+mahanch@users.noreply.github.com> Date: Mon, 29 Dec 2025 12:42:26 +0330 Subject: [PATCH 1/9] Refactor deployment script to use environment variables --- .github/workflows/dotnet-developPublish.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet-developPublish.yml b/.github/workflows/dotnet-developPublish.yml index 4b5a1e48..79c2e5bd 100644 --- a/.github/workflows/dotnet-developPublish.yml +++ b/.github/workflows/dotnet-developPublish.yml @@ -33,14 +33,18 @@ jobs: shell: powershell run: | $publishFolder = Resolve-Path ./publish + $server = $env:SERVER_HOST + $user = $env:DEPLOY_USER + $pass = $env:DEPLOY_PASSWORD + & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` -verb:sync ` -source:contentPath="$publishFolder" ` - -dest:contentPath="dadmehrg",computerName="https://$env:SERVER_HOST:8172/msdeploy.axd?site=gozareshgir",userName="$env:DEPLOY_USER",password="$env:DEPLOY_PASSWORD",authType="Basic" ` + -dest:contentPath="dadmehrg",computerName="https://${server}:8172/msdeploy.axd?site=gozareshgir",userName="$user",password="$pass",authType="Basic" ` -allowUntrusted ` -enableRule:AppOffline - env: + env: SERVER_HOST: 171.22.24.15 DEPLOY_USER: ${{ secrets.DEPLOY_USER }} DEPLOY_PASSWORD: ${{ secrets.DEPLOY_PASSWORD }} From fe4e81a60ce4ce9ac42d82e470fc54b7b95fb9e1 Mon Sep 17 00:00:00 2001 From: sadegh Farokhi <47900503+syntax24@users.noreply.github.com> Date: Mon, 29 Dec 2025 12:56:16 +0330 Subject: [PATCH 2/9] Update dotnet-developPublish.yml --- .github/workflows/dotnet-developPublish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet-developPublish.yml b/.github/workflows/dotnet-developPublish.yml index 79c2e5bd..2a09e131 100644 --- a/.github/workflows/dotnet-developPublish.yml +++ b/.github/workflows/dotnet-developPublish.yml @@ -45,6 +45,6 @@ jobs: -enableRule:AppOffline env: - SERVER_HOST: 171.22.24.15 - DEPLOY_USER: ${{ secrets.DEPLOY_USER }} - DEPLOY_PASSWORD: ${{ secrets.DEPLOY_PASSWORD }} + SERVER_HOST: ${{ secrets.DEV_HOST }} + DEPLOY_USER: ${{ secrets.DEV_USER }} + DEPLOY_PASSWORD: ${{ secrets.DEV_PASS }} From 8e6defb29eeea22753e78de69616f6163836127e Mon Sep 17 00:00:00 2001 From: sadegh Farokhi <47900503+syntax24@users.noreply.github.com> Date: Mon, 29 Dec 2025 13:00:43 +0330 Subject: [PATCH 3/9] Update dotnet-developPublish.yml --- .github/workflows/dotnet-developPublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-developPublish.yml b/.github/workflows/dotnet-developPublish.yml index 2a09e131..d99d345e 100644 --- a/.github/workflows/dotnet-developPublish.yml +++ b/.github/workflows/dotnet-developPublish.yml @@ -40,7 +40,7 @@ jobs: & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` -verb:sync ` -source:contentPath="$publishFolder" ` - -dest:contentPath="dadmehrg",computerName="https://${server}:8172/msdeploy.axd?site=gozareshgir",userName="$user",password="$pass",authType="Basic" ` + -dest:contentPath="dadmehrg",computerName="https://${server}:8172/msdeploy.axd?site=dadmehrg",userName="$user",password="$pass",authType="Basic" ` -allowUntrusted ` -enableRule:AppOffline From 313955221737131d35b9fa831a193da6f2c148a1 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 29 Dec 2025 13:41:23 +0330 Subject: [PATCH 4/9] Change Method name --- Company.Domain/EmployeeAgg/IEmployeeRepository.cs | 2 +- .../Employee/IEmployeeApplication.cs | 2 +- CompanyManagment.Application/EmployeeAplication.cs | 4 ++-- CompanyManagment.EFCore/Repository/EmployeeRepository .cs | 2 +- ServiceHost/Areas/Client/Controllers/EmployeeController.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Company.Domain/EmployeeAgg/IEmployeeRepository.cs b/Company.Domain/EmployeeAgg/IEmployeeRepository.cs index e18463a0..7ab427d8 100644 --- a/Company.Domain/EmployeeAgg/IEmployeeRepository.cs +++ b/Company.Domain/EmployeeAgg/IEmployeeRepository.cs @@ -85,7 +85,7 @@ public interface IEmployeeRepository : IRepository /// /// /// - Task> ListOfAllEmployees(EmployeeSearchModelDto searchModel, long workshopId); + Task> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId); #endregion diff --git a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs index 6547c132..58a5190a 100644 --- a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs +++ b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs @@ -111,7 +111,7 @@ public interface IEmployeeApplication /// /// /// - Task> ListOfAllEmployees(EmployeeSearchModelDto searchModel, long workshopId); + Task> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId); #endregion } diff --git a/CompanyManagment.Application/EmployeeAplication.cs b/CompanyManagment.Application/EmployeeAplication.cs index ce465140..288bdf4c 100644 --- a/CompanyManagment.Application/EmployeeAplication.cs +++ b/CompanyManagment.Application/EmployeeAplication.cs @@ -1734,9 +1734,9 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli return await _EmployeeRepository.GetClientEmployeeList(searchModel, workshopId); } - public async Task> ListOfAllEmployees(EmployeeSearchModelDto searchModel, long workshopId) + public async Task> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId) { - return await _EmployeeRepository.ListOfAllEmployees(searchModel, workshopId); + return await _EmployeeRepository.ListOfAllEmployeesClient(searchModel, workshopId); } #endregion diff --git a/CompanyManagment.EFCore/Repository/EmployeeRepository .cs b/CompanyManagment.EFCore/Repository/EmployeeRepository .cs index d7b362c7..05db2554 100644 --- a/CompanyManagment.EFCore/Repository/EmployeeRepository .cs +++ b/CompanyManagment.EFCore/Repository/EmployeeRepository .cs @@ -1175,7 +1175,7 @@ public class EmployeeRepository : RepositoryBase, IEmployeeRepos } - public async Task> ListOfAllEmployees(EmployeeSearchModelDto searchModel, long workshopId) + public async Task> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId) { var hasNotStoppedWorkingYet = Tools.GetUndefinedDateTime(); diff --git a/ServiceHost/Areas/Client/Controllers/EmployeeController.cs b/ServiceHost/Areas/Client/Controllers/EmployeeController.cs index 140009e6..c506d9cb 100644 --- a/ServiceHost/Areas/Client/Controllers/EmployeeController.cs +++ b/ServiceHost/Areas/Client/Controllers/EmployeeController.cs @@ -33,7 +33,7 @@ public class EmployeeController:ClientBaseController [HttpGet] public async Task>> GetList(EmployeeSearchModelDto searchModel) { - var result = await _employeeApplication.ListOfAllEmployees(searchModel, _workshopId); + var result = await _employeeApplication.ListOfAllEmployeesClient(searchModel, _workshopId); return result; } } \ No newline at end of file From d2acf59eba54bbdd6ac1e86a58db2d279cea123c Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 29 Dec 2025 16:14:25 +0330 Subject: [PATCH 5/9] PrintAllEmployeesInfoClient api --- .../EmployeeAgg/IEmployeeRepository.cs | 8 ++ .../DTO/PrintAllEmployeesInfoDtoClient.cs | 96 +++++++++++++++++++ .../Employee/IEmployeeApplication.cs | 8 ++ .../EmployeeAplication.cs | 5 + .../Repository/EmployeeRepository .cs | 11 +++ .../Client/Controllers/EmployeeController.cs | 13 +++ 6 files changed, 141 insertions(+) create mode 100644 CompanyManagment.App.Contracts/Employee/DTO/PrintAllEmployeesInfoDtoClient.cs diff --git a/Company.Domain/EmployeeAgg/IEmployeeRepository.cs b/Company.Domain/EmployeeAgg/IEmployeeRepository.cs index 7ab427d8..b61bf8f4 100644 --- a/Company.Domain/EmployeeAgg/IEmployeeRepository.cs +++ b/Company.Domain/EmployeeAgg/IEmployeeRepository.cs @@ -87,6 +87,14 @@ public interface IEmployeeRepository : IRepository /// Task> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId); + /// + /// پرینت تجمیعی پرسنل کلاینت + /// api + /// + /// + /// + Task> PrintAllEmployeesInfoClient(long workshopId); + #endregion diff --git a/CompanyManagment.App.Contracts/Employee/DTO/PrintAllEmployeesInfoDtoClient.cs b/CompanyManagment.App.Contracts/Employee/DTO/PrintAllEmployeesInfoDtoClient.cs new file mode 100644 index 00000000..d9781377 --- /dev/null +++ b/CompanyManagment.App.Contracts/Employee/DTO/PrintAllEmployeesInfoDtoClient.cs @@ -0,0 +1,96 @@ +namespace CompanyManagment.App.Contracts.Employee.DTO; + +/// +/// پرینت تجمیعی پرسنل +/// +public class PrintAllEmployeesInfoDtoClient +{ + public PrintAllEmployeesInfoDtoClient(EmployeeListDto source) + { + Id = source.Id; + EmployeeFullName = source.EmployeeFullName; + PersonnelCode = source.PersonnelCode; + MaritalStatus = source.MaritalStatus; + NationalCode = source.NationalCode; + IdNumber = source.IdNumber; + DateOfBirth = source.DateOfBirth; + FatherName = source.FatherName; + NumberOfChildren = source.NumberOfChildren; + LatestContractStartDate = source.LatestContractStartDate; + ContractLeftDate = source.ContractLeftDate; + LatestInsuranceStartDate = source.LatestInsuranceStartDate; + InsuranceLeftDate = source.InsuranceLeftDate; + EmployeeStatusInWorkshop = source.EmployeeStatusInWorkshop; + } + /// + /// آی دی پرسنل + /// + public long Id { get; set; } + + /// + /// نام کامل پرسنل + /// + public string EmployeeFullName { get; set; } + + /// + /// کد پرسنلی + /// + public int PersonnelCode { get; set; } + + /// + /// وضعیت تاهل + /// + public string MaritalStatus { get; set; } + + /// + ///کد ملی + /// + public string NationalCode { get; set; } + + /// + /// شماره شناسنامه + /// + public string IdNumber { get; set; } + + /// + /// تاریخ تولد + /// + public string DateOfBirth { get; set; } + + /// + /// نام پدر + /// + public string FatherName { get; set; } + + /// + /// تعداد فرزندان + /// + public string NumberOfChildren { get; set; } + + /// + /// آخرین تاریخ شروع بکار قرارداد + /// + public string LatestContractStartDate { get; set; } + + /// + /// تاریخ ترک کار قرارداد + /// + public string ContractLeftDate { get; set; } + + + /// + /// آخرین تاریخ شروع بکار بیمه + /// + public string LatestInsuranceStartDate { get; set; } + + /// + /// تاریخ ترک کار بیمه + /// + public string InsuranceLeftDate { get; set; } + + + /// + /// وضعیت پرسنل در کارگاه + /// + public EmployeeStatusInWorkshop EmployeeStatusInWorkshop { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs index 58a5190a..aaba14db 100644 --- a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs +++ b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs @@ -112,6 +112,14 @@ public interface IEmployeeApplication /// /// Task> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId); + + /// + /// پرینت تجمیعی پرسنل کلاینت + /// api + /// + /// + /// + Task> PrintAllEmployeesInfoClient(long workshopId); #endregion } diff --git a/CompanyManagment.Application/EmployeeAplication.cs b/CompanyManagment.Application/EmployeeAplication.cs index 288bdf4c..9d8aa4f4 100644 --- a/CompanyManagment.Application/EmployeeAplication.cs +++ b/CompanyManagment.Application/EmployeeAplication.cs @@ -1739,5 +1739,10 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli return await _EmployeeRepository.ListOfAllEmployeesClient(searchModel, workshopId); } + public async Task> PrintAllEmployeesInfoClient(long workshopId) + { + return await _EmployeeRepository.PrintAllEmployeesInfoClient(workshopId); + } + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/EmployeeRepository .cs b/CompanyManagment.EFCore/Repository/EmployeeRepository .cs index 05db2554..5d82f0ca 100644 --- a/CompanyManagment.EFCore/Repository/EmployeeRepository .cs +++ b/CompanyManagment.EFCore/Repository/EmployeeRepository .cs @@ -1275,5 +1275,16 @@ public class EmployeeRepository : RepositoryBase, IEmployeeRepos return result; } + + + public async Task> PrintAllEmployeesInfoClient(long workshopId) + { + var res = await ListOfAllEmployeesClient(new EmployeeSearchModelDto(), workshopId); + + return res + .Where(x=>x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.CreatedByClient + && x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.LefWorkTemp) + .Select(x => new PrintAllEmployeesInfoDtoClient(x)).ToList(); + } #endregion } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Controllers/EmployeeController.cs b/ServiceHost/Areas/Client/Controllers/EmployeeController.cs index c506d9cb..d3136348 100644 --- a/ServiceHost/Areas/Client/Controllers/EmployeeController.cs +++ b/ServiceHost/Areas/Client/Controllers/EmployeeController.cs @@ -36,4 +36,17 @@ public class EmployeeController:ClientBaseController var result = await _employeeApplication.ListOfAllEmployeesClient(searchModel, _workshopId); return result; } + + /// + /// پرینت تجمیعی پرسنل + /// + /// + [HttpGet("PrintAllEmployeesInfo")] + public async Task>> PrintAllEmployeesInfo() + { + var result = await _employeeApplication.PrintAllEmployeesInfoClient(_workshopId); + return result; + } + + } \ No newline at end of file From efcf40eea80bf63c02d6b1ceefd143060f9af1d9 Mon Sep 17 00:00:00 2001 From: mahan Date: Mon, 29 Dec 2025 16:24:36 +0330 Subject: [PATCH 6/9] feat: add method to retrieve working employees select list by workshop ID --- .../Repository/EmployeeRepository .cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CompanyManagment.EFCore/Repository/EmployeeRepository .cs b/CompanyManagment.EFCore/Repository/EmployeeRepository .cs index 5d82f0ca..0f708422 100644 --- a/CompanyManagment.EFCore/Repository/EmployeeRepository .cs +++ b/CompanyManagment.EFCore/Repository/EmployeeRepository .cs @@ -1286,5 +1286,30 @@ public class EmployeeRepository : RepositoryBase, IEmployeeRepos && x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.LefWorkTemp) .Select(x => new PrintAllEmployeesInfoDtoClient(x)).ToList(); } + + public async Task> GetWorkingEmployeesSelectList(long workshopId) + { + var dateNow = DateTime.Now.Date; + + + var workshopActiveLeftWorksQuery = _context.LeftWorkList.Where(x => x.WorkshopId == workshopId && + x.StartWorkDate <= dateNow && x.LeftWorkDate > dateNow); + + + var workshopActiveInsuranceLeftWorksQuery = _context.LeftWorkInsuranceList.Where(x => x.WorkshopId == workshopId && + x.StartWorkDate <= dateNow && (x.LeftWorkDate > dateNow || x.LeftWorkDate == null)); + + + var employeesQuery = _context.Employees.Where(x => workshopActiveLeftWorksQuery.Any(y => y.EmployeeId == x.id) || + workshopActiveInsuranceLeftWorksQuery.Any(y => y.EmployeeId == x.id)); + + + return await employeesQuery.Select(x => new EmployeeSelectListViewModel() + { + Id = x.id, + EmployeeFullName = x.FullName + }).ToListAsync(); + } + #endregion } \ No newline at end of file From 4ed1907075a35d76fb4e7b07d9213f9224028080 Mon Sep 17 00:00:00 2001 From: mahan Date: Mon, 29 Dec 2025 16:42:44 +0330 Subject: [PATCH 7/9] feat: add GetWorkingEmployeesSelectList method and update controller to use it --- Company.Domain/EmployeeAgg/IEmployeeRepository.cs | 8 ++++++++ .../Employee/IEmployeeApplication.cs | 6 +++++- CompanyManagment.Application/EmployeeAplication.cs | 5 +++++ .../Areas/Client/Controllers/EmployeeController.cs | 4 +++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Company.Domain/EmployeeAgg/IEmployeeRepository.cs b/Company.Domain/EmployeeAgg/IEmployeeRepository.cs index b61bf8f4..5bf23937 100644 --- a/Company.Domain/EmployeeAgg/IEmployeeRepository.cs +++ b/Company.Domain/EmployeeAgg/IEmployeeRepository.cs @@ -54,6 +54,7 @@ public interface IEmployeeRepository : IRepository Employee GetIgnoreQueryFilter(long id); + [Obsolete("این متد منسوخ شده است و از متد WorkedEmployeesInWorkshopSelectList استفاده کنید")] Task> WorkedEmployeesInWorkshopSelectList(long workshopId); @@ -95,6 +96,13 @@ public interface IEmployeeRepository : IRepository /// Task> PrintAllEmployeesInfoClient(long workshopId); + /// + /// سلکت لیست پرسنل های کارگاه کلاینت + /// + /// + /// + Task> GetWorkingEmployeesSelectList(long workshopId); + #endregion diff --git a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs index aaba14db..5ea7e80e 100644 --- a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs +++ b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs @@ -1,8 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Threading.Tasks; using _0_Framework.Application; using CompanyManagment.App.Contracts.Employee.DTO; using CompanyManagment.App.Contracts.EmployeeInsuranceRecord; +using Microsoft.AspNetCore.Mvc; namespace CompanyManagment.App.Contracts.Employee; @@ -73,6 +75,7 @@ public interface IEmployeeApplication long workshopId); Task EditEmployeeInEmployeeDocumentWorkFlow(EditEmployeeInEmployeeDocument command); + [Obsolete("این متد منسوخ شده است و از متد WorkedEmployeesInWorkshopSelectList استفاده کنید")] Task> WorkedEmployeesInWorkshopSelectList(long workshopId); Task> GetEmployeeDataFromApi(string nationalCode, string birthDate); @@ -122,6 +125,7 @@ public interface IEmployeeApplication Task> PrintAllEmployeesInfoClient(long workshopId); #endregion + Task> GetWorkingEmployeesSelectList(long workshopId); } public class GetClientEmployeeListSearchModel diff --git a/CompanyManagment.Application/EmployeeAplication.cs b/CompanyManagment.Application/EmployeeAplication.cs index 9d8aa4f4..fdf7e950 100644 --- a/CompanyManagment.Application/EmployeeAplication.cs +++ b/CompanyManagment.Application/EmployeeAplication.cs @@ -1744,5 +1744,10 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli return await _EmployeeRepository.PrintAllEmployeesInfoClient(workshopId); } + public async Task> GetWorkingEmployeesSelectList(long workshopId) + { + return await _EmployeeRepository.GetWorkingEmployeesSelectList(workshopId); + } + #endregion } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Controllers/EmployeeController.cs b/ServiceHost/Areas/Client/Controllers/EmployeeController.cs index d3136348..5218a7a8 100644 --- a/ServiceHost/Areas/Client/Controllers/EmployeeController.cs +++ b/ServiceHost/Areas/Client/Controllers/EmployeeController.cs @@ -17,14 +17,16 @@ public class EmployeeController:ClientBaseController _workshopId = authHelper.GetWorkshopId(); } + [HttpGet("select-list")] public async Task>> GetEmployeeSelectList() { - var result = await _employeeApplication.WorkedEmployeesInWorkshopSelectList(_workshopId); + var result = await _employeeApplication.GetWorkingEmployeesSelectList(_workshopId); return result; } + /// /// دریافت لیست پرسنل /// From d5b70d15453696787381dc40bbc631f287faa12e Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 29 Dec 2025 16:52:54 +0330 Subject: [PATCH 8/9] refactor selectList and PrintAllEmployee Client --- .../DTO/PrintAllEmployeesInfoDtoClient.cs | 4 +- .../Employee/IEmployeeApplication.cs | 9 ++- .../Repository/EmployeeRepository .cs | 71 +++++++++++++++---- .../Client/Controllers/EmployeeController.cs | 7 +- 4 files changed, 72 insertions(+), 19 deletions(-) diff --git a/CompanyManagment.App.Contracts/Employee/DTO/PrintAllEmployeesInfoDtoClient.cs b/CompanyManagment.App.Contracts/Employee/DTO/PrintAllEmployeesInfoDtoClient.cs index d9781377..67d640d1 100644 --- a/CompanyManagment.App.Contracts/Employee/DTO/PrintAllEmployeesInfoDtoClient.cs +++ b/CompanyManagment.App.Contracts/Employee/DTO/PrintAllEmployeesInfoDtoClient.cs @@ -20,7 +20,7 @@ public class PrintAllEmployeesInfoDtoClient ContractLeftDate = source.ContractLeftDate; LatestInsuranceStartDate = source.LatestInsuranceStartDate; InsuranceLeftDate = source.InsuranceLeftDate; - EmployeeStatusInWorkshop = source.EmployeeStatusInWorkshop; + Black = source.EmployeeStatusInWorkshop == EmployeeStatusInWorkshop.HasLeft; } /// /// آی دی پرسنل @@ -92,5 +92,5 @@ public class PrintAllEmployeesInfoDtoClient /// /// وضعیت پرسنل در کارگاه /// - public EmployeeStatusInWorkshop EmployeeStatusInWorkshop { get; set; } + public bool Black { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs index 5ea7e80e..9347332f 100644 --- a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs +++ b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs @@ -123,9 +123,16 @@ public interface IEmployeeApplication /// /// Task> PrintAllEmployeesInfoClient(long workshopId); + + /// + /// سلکت لیست پرسنل های کارگاه کلاینت + /// + /// + /// + Task> GetWorkingEmployeesSelectList(long workshopId); #endregion - Task> GetWorkingEmployeesSelectList(long workshopId); + } public class GetClientEmployeeListSearchModel diff --git a/CompanyManagment.EFCore/Repository/EmployeeRepository .cs b/CompanyManagment.EFCore/Repository/EmployeeRepository .cs index 0f708422..fc08b209 100644 --- a/CompanyManagment.EFCore/Repository/EmployeeRepository .cs +++ b/CompanyManagment.EFCore/Repository/EmployeeRepository .cs @@ -7,6 +7,7 @@ using Company.Domain.EmployeeAccountAgg; using Company.Domain.EmployeeAgg; using Company.Domain.EmployeeInsuranceRecordAgg; using Company.Domain.InsuranceListAgg; +using Company.Domain.LeftWorkTempAgg; using CompanyManagment.App.Contracts.Employee; using CompanyManagment.App.Contracts.Employee.DTO; using CompanyManagment.App.Contracts.EmployeeInsuranceRecord; @@ -1289,26 +1290,68 @@ public class EmployeeRepository : RepositoryBase, IEmployeeRepos public async Task> GetWorkingEmployeesSelectList(long workshopId) { - var dateNow = DateTime.Now.Date; + var hasNotStoppedWorkingYet = Tools.GetUndefinedDateTime(); + var baseQuery = await + ( + from personnelCode in _context.PersonnelCodeSet + join employee in _context.Employees + on personnelCode.EmployeeId equals employee.id + where personnelCode.WorkshopId == workshopId + select new + { + Employee = employee, + PersonnelCode = personnelCode + } + ).ToListAsync(); - var workshopActiveLeftWorksQuery = _context.LeftWorkList.Where(x => x.WorkshopId == workshopId && - x.StartWorkDate <= dateNow && x.LeftWorkDate > dateNow); + var employeeIds = baseQuery.Select(x => x.Employee.id).ToList(); + var leftWorks = await _context.LeftWorkList + .Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId)) + .ToListAsync(); - var workshopActiveInsuranceLeftWorksQuery = _context.LeftWorkInsuranceList.Where(x => x.WorkshopId == workshopId && - x.StartWorkDate <= dateNow && (x.LeftWorkDate > dateNow || x.LeftWorkDate == null)); + var insuranceLeftWorks = await _context.LeftWorkInsuranceList + .Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId)) + .ToListAsync(); - - var employeesQuery = _context.Employees.Where(x => workshopActiveLeftWorksQuery.Any(y => y.EmployeeId == x.id) || - workshopActiveInsuranceLeftWorksQuery.Any(y => y.EmployeeId == x.id)); - - - return await employeesQuery.Select(x => new EmployeeSelectListViewModel() + var result = baseQuery.Select(x => { - Id = x.id, - EmployeeFullName = x.FullName - }).ToListAsync(); + var left = leftWorks + .Where(l => l.EmployeeId == x.Employee.id) + .MaxBy(l => l.StartWorkDate); + + var insuranceLeftWork = insuranceLeftWorks + .Where(l => l.EmployeeId == x.Employee.id).MaxBy(l => l.StartWorkDate); + + + + + var contractLeft = left != null + ? left.LeftWorkDate != hasNotStoppedWorkingYet ? left.LeftWorkDate.ToFarsi() : "" + : ""; + var insuranceLeft = insuranceLeftWork != null + ? insuranceLeftWork.LeftWorkDate != null ? insuranceLeftWork.LeftWorkDate.ToFarsi() : "" + : ""; + + + + + bool employeeHasLeft = + (!string.IsNullOrWhiteSpace(insuranceLeft) && !string.IsNullOrWhiteSpace(contractLeft)) + || (left == null && !string.IsNullOrWhiteSpace(insuranceLeft)) + || (insuranceLeftWork == null && !string.IsNullOrWhiteSpace(contractLeft)); + + return new EmployeeSelectListViewModel + { + Id = x.Employee.id, + EmployeeFullName = x.Employee.FullName, + Black = employeeHasLeft, + }; + }).OrderBy(x => x.Black ? 1 : 0).ToList(); + + return result; + } #endregion diff --git a/ServiceHost/Areas/Client/Controllers/EmployeeController.cs b/ServiceHost/Areas/Client/Controllers/EmployeeController.cs index 5218a7a8..1ed78e45 100644 --- a/ServiceHost/Areas/Client/Controllers/EmployeeController.cs +++ b/ServiceHost/Areas/Client/Controllers/EmployeeController.cs @@ -16,8 +16,11 @@ public class EmployeeController:ClientBaseController _employeeApplication = employeeApplication; _workshopId = authHelper.GetWorkshopId(); } - - + + /// + /// سلکت لیست پرسنل + /// + /// [HttpGet("select-list")] public async Task>> GetEmployeeSelectList() { From 6154c2c7f5ed0b40f032879a2c251e0b33145fd9 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 29 Dec 2025 17:01:06 +0330 Subject: [PATCH 9/9] selectlist employee refactor --- Company.Domain/EmployeeAgg/IEmployeeRepository.cs | 1 - .../Employee/IEmployeeApplication.cs | 2 +- CompanyManagment.Application/EmployeeAplication.cs | 4 ---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Company.Domain/EmployeeAgg/IEmployeeRepository.cs b/Company.Domain/EmployeeAgg/IEmployeeRepository.cs index 5db29343..5bf23937 100644 --- a/Company.Domain/EmployeeAgg/IEmployeeRepository.cs +++ b/Company.Domain/EmployeeAgg/IEmployeeRepository.cs @@ -106,5 +106,4 @@ public interface IEmployeeRepository : IRepository #endregion - Task> GetWorkingEmployeesSelectList(long workshopId); } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs index 51bf620b..f1bd0180 100644 --- a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs +++ b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs @@ -79,7 +79,7 @@ public interface IEmployeeApplication Task> WorkedEmployeesInWorkshopSelectList(long workshopId); Task> GetEmployeeDataFromApi(string nationalCode, string birthDate); - Task> GetWorkingEmployeesSelectList(long workshopId); + #endregion diff --git a/CompanyManagment.Application/EmployeeAplication.cs b/CompanyManagment.Application/EmployeeAplication.cs index 2e8f836c..fdf7e950 100644 --- a/CompanyManagment.Application/EmployeeAplication.cs +++ b/CompanyManagment.Application/EmployeeAplication.cs @@ -1714,10 +1714,6 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli } - public async Task> GetWorkingEmployeesSelectList(long workshopId) - { - return await _EmployeeRepository.GetWorkingEmployeesSelectList(workshopId); - } #endregion