From 8c3a0cbd45620db80e83de21fc2060bcedae771e Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 23 Dec 2024 06:03:23 +0330 Subject: [PATCH] som change to new backup database --- 0_Framework/Application/Tools.cs | 38 ++++++++++++++----- .../Repository/RollCallEmployeeRepository.cs | 15 +++++--- .../Repository/RollCallRepository.cs | 2 +- ServiceHost/Properties/launchSettings.json | 4 +- ServiceHost/appsettings.Development.json | 2 +- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/0_Framework/Application/Tools.cs b/0_Framework/Application/Tools.cs index 09d1ffcc..d5a5a74b 100644 --- a/0_Framework/Application/Tools.cs +++ b/0_Framework/Application/Tools.cs @@ -15,6 +15,8 @@ using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; using Image = System.Drawing.Image; using Newtonsoft.Json; using Newtonsoft.Json.Bson; +using Microsoft.Extensions.Logging; +using System.IO.Compression; namespace _0_Framework.Application; @@ -1029,16 +1031,34 @@ public static class Tools public static DateTime ExtractTimeFromDbbackup(this string value) { - var year = value.Substring(10, 4); - var month = value.Substring(15, 2); - var day = value.Substring(18, 2); - var persianDate = year + "/" + month + "/" + day; - var georgianDate = persianDate.ToGeorgianDateTime(); - var hourString = value.Substring(21, 2); - int hour = hourString.ExtractIntNumbers(); + DateTime dateTime = new DateTime(); + var parts = value.Split('-'); + if (parts.Length >= 4 && parts[1].Length == 4 && parts[2].Length == 2 && parts[3].Length == 2 && parts[4].Length == 2 && parts[5].Length == 2) + { - var result = new DateTime(georgianDate.Year, georgianDate.Month, georgianDate.Day, hour, 1, 1); - return result; + try + { + PersianCalendar pc = new PersianCalendar(); + dateTime = pc.ToDateTime(int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3]), int.Parse(parts[4]), int.Parse(parts[5]), 0, 0, 0); + + } + catch (Exception e) + { + + + } + + } + //var year = value.Substring(10, 4); + //var month = value.Substring(15, 2); + //var day = value.Substring(18, 2); + //var persianDate = year + "/" + month + "/" + day; + //var georgianDate = persianDate.ToGeorgianDateTime(); + //var hourString = value.Substring(21, 2); + //int hour = hourString.ExtractIntNumbers(); + + //var result = new DateTime(georgianDate.Year, georgianDate.Month, georgianDate.Day, hour, 1, 1); + return dateTime; } public static DateTime ExtractTimeFromInsurancebackup(this string value) diff --git a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs index 12becbdf..eb736e7d 100644 --- a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs @@ -197,7 +197,10 @@ public class RollCallEmployeeRepository : RepositoryBase public List GetRollCallEmployeesByWorkshopId(long workshopId) { - return _context.RollCallEmployees.Where(x => x.WorkshopId == workshopId) + var dateNow = DateTime.Now.Date; + var personnelCodes = _context.PersonnelCodeSet.Where(x => x.WorkshopId == workshopId); + return _context.RollCallEmployees.Include(x => x.EmployeesStatus).Where(x => x.WorkshopId == workshopId && + personnelCodes.Any(y => y.EmployeeId == x.EmployeeId)) .Select(x => new RollCallEmployeeViewModel() { @@ -205,7 +208,7 @@ public class RollCallEmployeeRepository : RepositoryBase EmployeeFullName = x.EmployeeFullName, Id = x.id, WorkshopId = x.WorkshopId, - IsActiveString = x.IsActiveString, + IsActiveString = x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) ? "true" : "false", HasUploadedImage = x.HasUploadedImage, Statuses = x.EmployeesStatus.Select(y => new RollCallEmployeeStatusViewModel() { @@ -283,10 +286,12 @@ public class RollCallEmployeeRepository : RepositoryBase public List GetEmployeeRollCalls(long workshopId) { - var f = _context.RollCallEmployees.Include(x=>x.EmployeesStatus) - .Where(x => x.WorkshopId == workshopId && x.EmployeesStatus.Any()); + var personnelCodes = _context.PersonnelCodeSet.Where(x => x.WorkshopId == workshopId); - var res = f.Select(x => new RollCallEmployeeViewModel + var rollCallEmployeesQuery = _context.RollCallEmployees.Include(x=>x.EmployeesStatus) + .Where(x => x.WorkshopId == workshopId && x.EmployeesStatus.Any() && personnelCodes.Any(y=>y.EmployeeId == x.EmployeeId)); + + var res = rollCallEmployeesQuery.Select(x => new RollCallEmployeeViewModel { RollCallEmployeeId = x.id, EmployeeId = x.EmployeeId, diff --git a/CompanyManagment.EFCore/Repository/RollCallRepository.cs b/CompanyManagment.EFCore/Repository/RollCallRepository.cs index 9798bbca..2141b28b 100644 --- a/CompanyManagment.EFCore/Repository/RollCallRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallRepository.cs @@ -608,7 +608,7 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos ((x.LeaveType == "استعلاجی" || (x.LeaveType == "استحقاقی" && x.PaidLeaveType == "روزانه")) || (x.LeaveType == "استحقاقی" && x.PaidLeaveType == "ساعتی" && x.StartLeave <= DateTime.Now && x.EndLeave >= DateTime.Now)) ); - var personnelCodes = _context.PersonnelCodeSet.Where(x => x.WorkshopId == workshopId).ToList(); + var personnelCodes = _context.PersonnelCodeSet.Where(x => x.WorkshopId == workshopId); //get currently working employees with leftWork table //var workingEmployees = diff --git a/ServiceHost/Properties/launchSettings.json b/ServiceHost/Properties/launchSettings.json index d504dfb7..ccd45753 100644 --- a/ServiceHost/Properties/launchSettings.json +++ b/ServiceHost/Properties/launchSettings.json @@ -19,8 +19,8 @@ "sqlDebugging": true, "dotnetRunMessages": "true", "nativeDebugging": true, - //"applicationUrl": "https://localhost:5004;http://localhost:5003;", - "applicationUrl": "https://localhost:5004;http://localhost:5003;http://192.168.0.117:82;https://192.168.0.117:83;", + "applicationUrl": "https://localhost:5004;http://localhost:5003;", + //"applicationUrl": "https://localhost:5004;http://localhost:5003;http://192.168.0.117:82;https://192.168.0.117:83;", "jsWebView2Debugging": false, "hotReloadEnabled": true }, diff --git a/ServiceHost/appsettings.Development.json b/ServiceHost/appsettings.Development.json index e892ad48..809f0d97 100644 --- a/ServiceHost/appsettings.Development.json +++ b/ServiceHost/appsettings.Development.json @@ -15,7 +15,7 @@ //"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]is[3019]#@ATt;TrustServerCertificate=true;" //local - "MesbahDb": "Data Source=.;Initial Catalog=Mesbah_db;Integrated Security=True;TrustServerCertificate=true;" + "MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;" }, "GoogleRecaptchaV3": { "SiteKey": "6Lfhp_AnAAAAAB79WkrMoHd1k8ir4m8VvfjE7FTH",