From db79e8ecf1519b9b969a2c16899863b0547d2480 Mon Sep 17 00:00:00 2001 From: SamSys Date: Tue, 7 Jan 2025 18:51:13 +0330 Subject: [PATCH] AsSpliterQuery adde on AdminWorkflow metods - update new changes admin workflow --- .../Repository/CheckoutRepository.cs | 2 +- .../RollCallEmployeeStatusRepository.cs | 2 +- .../Repository/RollCallRepository.cs | 14 +- .../Repository/RollCallServiceRepository.cs | 3 +- .../GetWorkshopWithRollCallHandler.cs | 14 +- .../Pages/Company/RollCall/Index.cshtml | 140 +++++++++++++++--- .../Pages/Company/RollCall/Index.cshtml.cs | 10 +- .../RollCallConfirmedAbsenceRepository.cs | 3 +- 8 files changed, 139 insertions(+), 49 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index 685fba58..de84fb74 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -1429,7 +1429,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos - return _context.CheckoutSet.Where(x => x.ContractEnd.Date >= start && x.ContractStart.Date <= end && x.WorkshopId == workshopId).Select(x => new + return _context.CheckoutSet.AsSplitQuery().Where(x => x.ContractEnd.Date >= start && x.ContractStart.Date <= end && x.WorkshopId == workshopId).Select(x => new { EmployeeId = x.EmployeeId, CheckoutEnd = x.ContractEnd, diff --git a/CompanyManagment.EFCore/Repository/RollCallEmployeeStatusRepository.cs b/CompanyManagment.EFCore/Repository/RollCallEmployeeStatusRepository.cs index 4d4f1f4f..d098debf 100644 --- a/CompanyManagment.EFCore/Repository/RollCallEmployeeStatusRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallEmployeeStatusRepository.cs @@ -68,7 +68,7 @@ namespace CompanyManagment.EFCore.Repository public List GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr) { - return _context.RollCallEmployeesStatus.Include(x => x.RollCallEmployee).Where(x => x.RollCallEmployee.WorkshopId == workshopId && + return _context.RollCallEmployeesStatus.AsSplitQuery().Include(x => x.RollCallEmployee).Where(x => x.RollCallEmployee.WorkshopId == workshopId && x.StartDate.Date <= endDateGr.Date && x.EndDate.Date >= startDateGr.Date).Select(x => new RollCallEmployeeStatusViewModel() { EndDateGr = x.EndDate, diff --git a/CompanyManagment.EFCore/Repository/RollCallRepository.cs b/CompanyManagment.EFCore/Repository/RollCallRepository.cs index 123d3065..3207dd94 100644 --- a/CompanyManagment.EFCore/Repository/RollCallRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallRepository.cs @@ -803,28 +803,28 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos if (endSearch.Date == DateTime.Now.Date) endSearch = endSearch.AddDays(-1); //get leaves for workshop that have been activated in dateIndex date - var leavesQuery = _context.LeaveList.Where(x => x.WorkshopId == workshopId && - x.IsAccepted && (x.LeaveType == "استعلاجی" || (x.LeaveType == "استحقاقی" && x.PaidLeaveType == "روزانه")) && - x.EndLeave.Date >= startSearch.Date && x.StartLeave.Date <= endSearch.Date); + var leavesQuery = _context.LeaveList.AsSplitQuery().Where(x => x.WorkshopId == workshopId && + x.IsAccepted && (x.LeaveType == "استعلاجی" || (x.LeaveType == "استحقاقی" && x.PaidLeaveType == "روزانه")) && + x.EndLeave.Date >= startSearch.Date && x.StartLeave.Date <= endSearch.Date); //roll calls for current workshop where shift start is in dateIndex date (filters today's shifts) - var rollCallsQuery = _context.RollCalls + var rollCallsQuery = _context.RollCalls.AsSplitQuery() .Where(x => x.WorkshopId == workshopId && x.StartDate.HasValue && x.StartDate.Value.Date >= startSearch.Date && x.StartDate.Value.Date <= endSearch.Date && x.RollCallModifyType != RollCallModifyType.Undefined); - var withPersonnelCode = _context.PersonnelCodeSet.Where(x => x.WorkshopId == workshopId); + var withPersonnelCode = _context.PersonnelCodeSet.AsSplitQuery().Where(x => x.WorkshopId == workshopId); //get active employees of workshop in dateIndex date var activeEmployeesQuery = - _context.RollCallEmployees.Include(x => x.EmployeesStatus) + _context.RollCallEmployees.AsSplitQuery().Include(x => x.EmployeesStatus) .Where(x => x.WorkshopId == workshopId && x.EmployeesStatus.Any(y => y.EndDate.Date >= startSearch && y.StartDate.Date <= endSearch) && withPersonnelCode.Any(y => y.EmployeeId == x.EmployeeId)); var employeeSettingsList = - _context.CustomizeWorkshopEmployeeSettings.Where(x => x.WorkshopId == workshopId).ToList(); + _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery().Where(x => x.WorkshopId == workshopId).ToList(); var rollCallsList = rollCallsQuery.ToList(); var activatedEmployeesList = activeEmployeesQuery.ToList(); var leavesList = leavesQuery.ToList(); diff --git a/CompanyManagment.EFCore/Repository/RollCallServiceRepository.cs b/CompanyManagment.EFCore/Repository/RollCallServiceRepository.cs index a600f33d..a9d5a430 100644 --- a/CompanyManagment.EFCore/Repository/RollCallServiceRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallServiceRepository.cs @@ -4,6 +4,7 @@ using _0_Framework.Application; using _0_Framework.InfraStructure; using Company.Domain.RollCallServiceAgg; using CompanyManagment.App.Contracts.RollCallService; +using Microsoft.EntityFrameworkCore; namespace CompanyManagment.EFCore.Repository; @@ -38,7 +39,7 @@ public class RollCallServiceRepository : RepositoryBase, public RollCallServiceViewModel GetActiveServiceByWorkshopId(long workshopId) { - return _context.RollCallServices.Select(x => new RollCallServiceViewModel() + return _context.RollCallServices.AsSplitQuery().Select(x => new RollCallServiceViewModel() { Id = x.id, ServiceType = x.ServiceType, diff --git a/Query/AdminReports/Handlers/GetWorkshopWithRollCallHandler.cs b/Query/AdminReports/Handlers/GetWorkshopWithRollCallHandler.cs index 2da1ea4c..df269fee 100644 --- a/Query/AdminReports/Handlers/GetWorkshopWithRollCallHandler.cs +++ b/Query/AdminReports/Handlers/GetWorkshopWithRollCallHandler.cs @@ -32,9 +32,9 @@ namespace Query.AdminReports.Handlers //workshop filter by parameters - var rollCallServiceQuery = _companyContext.RollCallServices.AsQueryable(); + var rollCallServiceQuery = _companyContext.RollCallServices.AsSplitQuery(); - var allWorkshops = _companyContext.Workshops.Select(x => new { x.id, x.WorkshopFullName }); + var allWorkshops = _companyContext.Workshops.AsSplitQuery().Select(x => new { x.id, x.WorkshopFullName }); if (parameters.WorkshopId != 0) allWorkshops = allWorkshops.Where(x => x.id == parameters.WorkshopId); @@ -64,7 +64,7 @@ namespace Query.AdminReports.Handlers //workshop population - var workshopLeftWorks = _companyContext.Workshops.Where(x => workshopsWithService.Any(y => y.WorkshopId == x.id)).Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances) + var workshopLeftWorks = _companyContext.Workshops.AsSplitQuery().Where(x => workshopsWithService.Any(y => y.WorkshopId == x.id)).Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances) .Select(x => new { WorkshopId = x.id, @@ -77,15 +77,15 @@ namespace Query.AdminReports.Handlers - var activeEmployees = _companyContext.RollCallEmployees.Include(x => x.EmployeesStatus).Where(x => x.EmployeesStatus.Any(y => + var activeEmployees = _companyContext.RollCallEmployees.AsSplitQuery().Include(x => x.EmployeesStatus).Where(x => x.EmployeesStatus.Any(y => y.EndDate.Date >= now) && workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).Select(x => new { x.WorkshopId, x.EmployeeId }); - var lastWeekRollCalls = _companyContext.RollCalls.Where(x => x.StartDate.HasValue && x.StartDate.Value >= lastWeek + var lastWeekRollCalls = _companyContext.RollCalls.AsSplitQuery().Where(x => x.StartDate.HasValue && x.StartDate.Value >= lastWeek && workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).GroupBy(x => x.EmployeeId).Select(x => x.Key); - var leaves = _companyContext.LeaveList.Where(x => x.StartLeave <= lastWeek && x.EndLeave >= now && (x.LeaveType == "استعلاجی" || x.PaidLeaveType == "روزانه") - && workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).Select(x => x.EmployeeId); + var leaves = _companyContext.LeaveList.AsSplitQuery().Where(x => x.StartLeave <= lastWeek && x.EndLeave >= now && (x.LeaveType == "استعلاجی" || x.PaidLeaveType == "روزانه") + && workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).Select(x => x.EmployeeId); var activeEmployeesList = activeEmployees.ToList(); diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/RollCall/Index.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/RollCall/Index.cshtml index 8c346497..c39f9e8a 100644 --- a/ServiceHost/Areas/AdminNew/Pages/Company/RollCall/Index.cshtml +++ b/ServiceHost/Areas/AdminNew/Pages/Company/RollCall/Index.cshtml @@ -65,17 +65,17 @@ var index = 1; -
-
- + +
@@ -265,24 +282,103 @@ var index = 1; + + @section Script {