From 080131c14df10cbba5c5bd038445d12c07cb02fc Mon Sep 17 00:00:00 2001 From: samsys Date: Tue, 9 Jul 2024 19:06:41 +0330 Subject: [PATCH] workingHoursTemp ReModify --- 0_Framework/Application/Sms/SmsService.cs | 4 +- .../Task/CompleteTaskViewModel.cs | 3 +- .../Task/CreateTask.cs | 3 +- .../IWorkingHoursItemsRepository.cs | 2 +- .../IWorkingHoursTempRepository.cs | 2 +- .../CreateWorkingHoursTemp.cs | 4 -- .../IWorkingHoursTempApplication.cs | 3 -- .../RotatingShiftViewModel.cs | 4 -- .../Repository/WorkingHoursItemsRepository.cs | 5 +- .../Repository/WorkingHoursTempRepository.cs | 51 ++++++++----------- _0_Framework/Application/Tools.cs | 1 - 11 files changed, 30 insertions(+), 52 deletions(-) diff --git a/0_Framework/Application/Sms/SmsService.cs b/0_Framework/Application/Sms/SmsService.cs index 1b41b073..e6947ebb 100644 --- a/0_Framework/Application/Sms/SmsService.cs +++ b/0_Framework/Application/Sms/SmsService.cs @@ -168,8 +168,8 @@ public class SmsService : ISmsService var res = new List(); Int32 unixTimestamp = (int)st.Subtract(new DateTime(1970,1,1)).TotalSeconds; Int32 unixTimestamp2 = (int)ed.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; - int? fromDateUnixTime = null; // unix time - for instance: 1700598600 - int? toDateUnixTime = null; // unix time - for instance: 1703190600 + // int? fromDateUnixTime = null; // unix time - for instance: 1700598600 + //int? toDateUnixTime = null; // unix time - for instance: 1703190600 int pageNumber = 2; int pageSize = 100; // max: 100 SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa"); diff --git a/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs b/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs index 73389d6e..bb4d4bac 100644 --- a/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs +++ b/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs @@ -1,4 +1,5 @@ -namespace AccountManagement.Application.Contracts.Task; +#nullable enable +namespace AccountManagement.Application.Contracts.Task; public class CompleteTaskViewModel { diff --git a/AccountManagement.Application.Contracts/Task/CreateTask.cs b/AccountManagement.Application.Contracts/Task/CreateTask.cs index a88b849f..f0bed283 100644 --- a/AccountManagement.Application.Contracts/Task/CreateTask.cs +++ b/AccountManagement.Application.Contracts/Task/CreateTask.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; + +using System.Collections.Generic; using Microsoft.AspNetCore.Http; namespace AccountManagement.Application.Contracts.Task; diff --git a/Company.Domain/WorkingHoursItemsAgg/IWorkingHoursItemsRepository.cs b/Company.Domain/WorkingHoursItemsAgg/IWorkingHoursItemsRepository.cs index e0ab54a4..5c27e2f5 100644 --- a/Company.Domain/WorkingHoursItemsAgg/IWorkingHoursItemsRepository.cs +++ b/Company.Domain/WorkingHoursItemsAgg/IWorkingHoursItemsRepository.cs @@ -12,5 +12,5 @@ public interface IWorkingHoursItemsRepository : IRepository GetWorkingHoursItems(); List GetWorkingHoursItemListByHoursId(long id); WorkingHoursItemsViewModel GetByWorkingHoursId(long id); - ComputingViewModel GetWorkingHourSByRollCall(long workshopId, long employeeId, DateTime start, DateTime end); + } \ No newline at end of file diff --git a/Company.Domain/WorkingHoursTempAgg/IWorkingHoursTempRepository.cs b/Company.Domain/WorkingHoursTempAgg/IWorkingHoursTempRepository.cs index 5f9c1ee9..b229b447 100644 --- a/Company.Domain/WorkingHoursTempAgg/IWorkingHoursTempRepository.cs +++ b/Company.Domain/WorkingHoursTempAgg/IWorkingHoursTempRepository.cs @@ -20,5 +20,5 @@ public interface IWorkingHoursTempRepository : IRepository> Correct(); void RemoveWorkingHoursTempAndItems(long workshopId, long employeeId); - ComputingViewModel GetWorkingHourSByRollCall(long workshopId, long employeeId, DateTime start, DateTime end); + } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/WorkingHoursTemp/CreateWorkingHoursTemp.cs b/CompanyManagment.App.Contracts/WorkingHoursTemp/CreateWorkingHoursTemp.cs index 808877cb..a3ec46ad 100644 --- a/CompanyManagment.App.Contracts/WorkingHoursTemp/CreateWorkingHoursTemp.cs +++ b/CompanyManagment.App.Contracts/WorkingHoursTemp/CreateWorkingHoursTemp.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace CompanyManagment.App.Contracts.WorkingHoursTemp; diff --git a/CompanyManagment.App.Contracts/WorkingHoursTemp/IWorkingHoursTempApplication.cs b/CompanyManagment.App.Contracts/WorkingHoursTemp/IWorkingHoursTempApplication.cs index 8abf3a26..54313b2f 100644 --- a/CompanyManagment.App.Contracts/WorkingHoursTemp/IWorkingHoursTempApplication.cs +++ b/CompanyManagment.App.Contracts/WorkingHoursTemp/IWorkingHoursTempApplication.cs @@ -1,11 +1,8 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; using _0_Framework.Application; using CompanyManagment.App.Contracts.Contract; -using System.Threading.Tasks; namespace CompanyManagment.App.Contracts.WorkingHoursTemp; diff --git a/CompanyManagment.App.Contracts/WorkingHoursTemp/RotatingShiftViewModel.cs b/CompanyManagment.App.Contracts/WorkingHoursTemp/RotatingShiftViewModel.cs index 35b47c37..3b3e9bb1 100644 --- a/CompanyManagment.App.Contracts/WorkingHoursTemp/RotatingShiftViewModel.cs +++ b/CompanyManagment.App.Contracts/WorkingHoursTemp/RotatingShiftViewModel.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace CompanyManagment.App.Contracts.WorkingHoursTemp; diff --git a/CompanyManagment.EFCore/Repository/WorkingHoursItemsRepository.cs b/CompanyManagment.EFCore/Repository/WorkingHoursItemsRepository.cs index 740ac81f..c49c89cd 100644 --- a/CompanyManagment.EFCore/Repository/WorkingHoursItemsRepository.cs +++ b/CompanyManagment.EFCore/Repository/WorkingHoursItemsRepository.cs @@ -112,8 +112,5 @@ public class WorkingHoursItemsRepository : RepositoryBase x.WorkingHoursId == id); } - public ComputingViewModel GetWorkingHourSByRollCall(long workshopId, long employeeId, DateTime start, DateTime end) - { - throw new NotImplementedException(); - } + } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/WorkingHoursTempRepository.cs b/CompanyManagment.EFCore/Repository/WorkingHoursTempRepository.cs index 84e759d0..06d924b9 100644 --- a/CompanyManagment.EFCore/Repository/WorkingHoursTempRepository.cs +++ b/CompanyManagment.EFCore/Repository/WorkingHoursTempRepository.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading.Tasks; using _0_Framework.Application; using _0_Framework.InfraStructure; +using Company.Domain.WorkingHoursAgg; using Company.Domain.WorkingHoursTempAgg; using CompanyManagment.App.Contracts.Contract; using CompanyManagment.App.Contracts.WorkingHours; @@ -15,33 +15,25 @@ using Microsoft.EntityFrameworkCore; namespace CompanyManagment.EFCore.Repository; public class WorkingHoursTempRepository : RepositoryBase, IWorkingHoursTempRepository - { private readonly CompanyContext _context; - private readonly IWorkingHoursApplication _workingHoursApplication; - private readonly IWorkingHoursItemsApplication _workingHoursItemsApplication; - - public WorkingHoursTempRepository(CompanyContext context, IWorkingHoursApplication workingHoursRepository, - IWorkingHoursItemsApplication workingHoursItemsRepository) : base(context) + public WorkingHoursTempRepository(CompanyContext context) : base(context) { _context = context; - _workingHoursApplication = workingHoursRepository; - _workingHoursItemsApplication = workingHoursItemsRepository; - + } public WorkingHoursTempViewModel GetDetails(long id) { - throw new NotImplementedException(); + throw new System.NotImplementedException(); } - [SuppressMessage("ReSharper.DPA", "DPA0009: High execution time of DB command", MessageId = "time: 1291ms")] public CreateWorkingHoursTemp GetByWorkshopIdAndEmployeeId(long workshopId, long employeeId) { var workingHoursAndItems = _context.WorkingHoursTemps - .Include(x => x.WorkingHoursTempItemList) - .FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId); + .Include(x => x.WorkingHoursTempItemList) + .FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId); if (workingHoursAndItems == null) @@ -2247,22 +2239,21 @@ public class WorkingHoursTempRepository : RepositoryBase ShiftWork = workingHoursAndItems.ShiftWork, StartComplex = items.FirstOrDefault()?.ComplexStart, EndComplex = items.FirstOrDefault()?.ComplexEnd, - + }; result.WorkshopAddress2 = workingHoursAndItems.WorkShopAddress2; return result; } } - } public CreateWorkingHoursTemp GetByContractId(long contractId) { var workingHours = _context.WorkingHoursSet - .Include(x => x.WorkingHoursItemsList) - .FirstOrDefault(x => x.ContractId == contractId); - + .Include(x => x.WorkingHoursItemsList) + .FirstOrDefault(x => x.ContractId == contractId); + if (workingHours != null) { var items = workingHours?.WorkingHoursItemsList; @@ -3038,7 +3029,7 @@ public class WorkingHoursTempRepository : RepositoryBase } #endregion - + return result; } else @@ -3050,7 +3041,7 @@ public class WorkingHoursTempRepository : RepositoryBase public CreateWorkingHoursTemp GetByContractIdConvertToShiftwork4(long contractId) { var workingHours = _context.WorkingHoursSet - .Include(x => x.WorkingHoursItemsList) + .Include(x => x.WorkingHoursItemsList) .FirstOrDefault(x => x.ContractId == contractId); if (workingHours != null) @@ -4157,8 +4148,8 @@ public class WorkingHoursTempRepository : RepositoryBase public CreateWorkingHoursTemp GetByWorkshopIdAndEmployeeIdToShiftwork4(long workshopId, long employeeId) { var contract = _context.Contracts.Where(x => x.EmployeeId == employeeId && x.WorkshopIds == workshopId) - .OrderByDescending(x => x.ContarctStart) - .FirstOrDefault(); + .OrderByDescending(x => x.ContarctStart) + .FirstOrDefault(); if (contract != null) { var workingHours = _context.WorkingHoursSet @@ -5268,7 +5259,6 @@ public class WorkingHoursTempRepository : RepositoryBase { return new CreateWorkingHoursTemp(); } - } public async Task> Correct() @@ -5278,7 +5268,7 @@ public class WorkingHoursTempRepository : RepositoryBase #region correctContractsAndChekouts - + var contracts = _context.Contracts.Where(x => x.WorkingHoursWeekly != "44" && x.WorkingHoursWeekly != "48 - 24" && x.WorkingHoursWeekly != "36 - 12" && @@ -5300,18 +5290,18 @@ public class WorkingHoursTempRepository : RepositoryBase ContractEnd = x.ContractEnd.ToFarsi(), GetWorkDate = x.GetWorkDate.ToFarsi(), GetWorkDateHide = x.GetWorkDate.ToFarsi() - + }); - return contracts.OrderBy(x=>x.Id).Take(100).ToList(); + return contracts.OrderBy(x => x.Id).Take(100).ToList(); + - #endregion - } + public void RemoveWorkingHoursTempAndItems(long workshopId, long employeeId) { var workingHoursAndItems = _context.WorkingHoursTemps @@ -5319,7 +5309,7 @@ public class WorkingHoursTempRepository : RepositoryBase .FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId); if (workingHoursAndItems != null) { - if (workingHoursAndItems.WorkingHoursTempItemList.Count > 0) + if (workingHoursAndItems.WorkingHoursTempItemList.Count > 0) { var items = workingHoursAndItems?.WorkingHoursTempItemList; _context.RemoveRange(items); @@ -5331,4 +5321,5 @@ public class WorkingHoursTempRepository : RepositoryBase } } + } \ No newline at end of file diff --git a/_0_Framework/Application/Tools.cs b/_0_Framework/Application/Tools.cs index 12bbed3d..2ca7c7b1 100644 --- a/_0_Framework/Application/Tools.cs +++ b/_0_Framework/Application/Tools.cs @@ -321,7 +321,6 @@ namespace _0_Framework_b.Application var persianStartDate = new MD.PersianDateTime.Standard.PersianDateTime(startDate); var persianEndDate = new MD.PersianDateTime.Standard.PersianDateTime(endDate); - var i = 0; while (persianEndDate - persianStartDate >= TimeSpan.FromDays(0)) {