diff --git a/0_Framework/Application/AuthHelper.cs b/0_Framework/Application/AuthHelper.cs index 9a4997a5..7bbc80e1 100644 --- a/0_Framework/Application/AuthHelper.cs +++ b/0_Framework/Application/AuthHelper.cs @@ -181,7 +181,9 @@ public class AuthHelper : IAuthHelper var authProperties = new AuthenticationProperties { - ExpiresUtc = DateTimeOffset.UtcNow.AddDays(1) + + //ExpiresUtc = DateTimeOffset.UtcNow.AddDays(30) + ExpiresUtc = new DateTimeOffset(year: 2100, month: 1, day: 1, hour: 0, minute: 0, second: 0, offset: TimeSpan.Zero) }; _contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, diff --git a/0_Framework/Application/Version.cs b/0_Framework/Application/Version.cs index 04a09de3..004dc2f5 100644 --- a/0_Framework/Application/Version.cs +++ b/0_Framework/Application/Version.cs @@ -10,9 +10,9 @@ public static class Version { static Version() { - StyleVersion = "2.12.17"; - AdminVersion = "2.5.37"; - CameraVersion = "1.0.7"; + StyleVersion = "2.12.19"; + AdminVersion = "2.5.39"; + CameraVersion = "1.0.9"; } public static string StyleVersion { get; set; } diff --git a/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs b/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs index 4251e7eb..ab3e5884 100644 --- a/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs +++ b/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs @@ -29,5 +29,7 @@ public interface ITicketApplication OperationResult CloseTicket(long ticketId); TypesCountOfTicketViewModel GetTypesCountOfTicketForAdmin(); TypesCountOfTicketViewModel GetTypesCountOfTicketForClient(long workshopId); - + #region Vafa + int GetAdminTicketsCount(); + #endregion } \ No newline at end of file diff --git a/AccountManagement.Application/TicketApplication.cs b/AccountManagement.Application/TicketApplication.cs index fedf373c..79a2b83d 100644 --- a/AccountManagement.Application/TicketApplication.cs +++ b/AccountManagement.Application/TicketApplication.cs @@ -616,4 +616,12 @@ public class TicketApplication : ITicketApplication { return _ticketRepository.GetTypesCountOfTicketForClient(workshopId); } + #region Vafa + + public int GetAdminTicketsCount() + { + return _ticketRepository.GetAdminTicketsCount(); + } + + #endregion } \ No newline at end of file diff --git a/AccountManagement.Domain/TicketAgg/ITicketRepository.cs b/AccountManagement.Domain/TicketAgg/ITicketRepository.cs index 6e4caf7c..60998bfb 100644 --- a/AccountManagement.Domain/TicketAgg/ITicketRepository.cs +++ b/AccountManagement.Domain/TicketAgg/ITicketRepository.cs @@ -22,6 +22,7 @@ public interface ITicketRepository:IRepository TypesCountOfTicketViewModel GetTypesCountOfTicketForAdmin(); TypesCountOfTicketViewModel GetTypesCountOfTicketForClient(long workshopId); - - + #region Vafa + int GetAdminTicketsCount(); + #endregion } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs index df4cf20a..85eb09a2 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs @@ -394,8 +394,15 @@ public class TicketRepository : RepositoryBase, ITicketRepository }; } + #region Vafa + public int GetAdminTicketsCount() + { + return _accountContext.Tickets.Count(x => x.Status == "باز"); + } + #endregion - public List MergeResponses(List clientResponseList, List adminResponseList) + + public List MergeResponses(List clientResponseList, List adminResponseList) { var list = new List(); var adminList = adminResponseList.Select(x => new Response() diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 54bfac89..14bee357 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -966,7 +966,6 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll foreach (var day in groupedRollCall) { - foreach (var shift in shiftSettings) { DateTime start = DateTime.Parse(shift.StartTime); @@ -1017,14 +1016,74 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll TypeOfSapn = "EarlyExist" }); } + else if (singleHasRollCall != null && singleHasRollCall.Start > startShift && + singleHasRollCall.End < endShift) + { + lateToWorkEarlyExistSpannig.Add(new LateToWorkEarlyExistSpannig() + { + StartSpan = startShift, + EndSpan = singleHasRollCall.Start, + Spanning = (singleHasRollCall.Start - startShift), + TypeOfSapn = "LateToWork" + }); + + lateToWorkEarlyExistSpannig.Add(new LateToWorkEarlyExistSpannig() + { + StartSpan = singleHasRollCall.End, + EndSpan = endShift, + Spanning = (endShift - singleHasRollCall.End), + TypeOfSapn = "EarlyExist" + }); + } } else if (hasRollCall.Count() > 1) { - + var multiHasRollCall = hasRollCall.OrderBy(x => x.Start); + var firstRollcall = multiHasRollCall.First(); + var lastRollCall = multiHasRollCall.Last(); + + if (firstRollcall.Start > startShift && + firstRollcall.End >= endShift) + { + lateToWorkEarlyExistSpannig.Add(new LateToWorkEarlyExistSpannig() + { + StartSpan = startShift, + EndSpan = firstRollcall.Start, + Spanning = (firstRollcall.Start - startShift), + TypeOfSapn = "LateToWork" + }); + } + + if (lastRollCall.Start <= startShift && + lastRollCall.End < endShift) + { + lateToWorkEarlyExistSpannig.Add(new LateToWorkEarlyExistSpannig() + { + StartSpan = lastRollCall.End, + EndSpan = endShift, + Spanning = (endShift - lastRollCall.End), + TypeOfSapn = "EarlyExist" + }); + } } } } + // اگر تاخیر یا تعجیل به دلیل مرخصی ساعتی بود حساب نشود + if (leavList.Count > 0 && lateToWorkEarlyExistSpannig.Count > 0) + { + foreach (var el in lateToWorkEarlyExistSpannig.ToList()) + { + var hasLeve = leavList.Any(x => + (x.StartLeaveGr <= el.StartSpan && x.EndLeaveGr > el.StartSpan) || + (x.StartLeaveGr >= el.StartSpan && x.EndLeaveGr <= el.EndSpan) || + (x.StartLeaveGr > el.StartSpan && x.EndLeaveGr > el.EndSpan)); + if (hasLeve) + lateToWorkEarlyExistSpannig.Remove(el); + } + + } + return (0, 0); } } diff --git a/CompanyManagment.EFCore/Repository/RollCallRepository.cs b/CompanyManagment.EFCore/Repository/RollCallRepository.cs index 7083106c..ebe87160 100644 --- a/CompanyManagment.EFCore/Repository/RollCallRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallRepository.cs @@ -375,11 +375,14 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos var date = DateTime.Now.Date; - //get active leaves for workshop which are active today and accepted and are either روزانه and استحقاقی or استعلاجی - var leaves = _context.LeaveList.Where(x => x.WorkshopId == workshopId && x.EndLeave.Date >= date && x.StartLeave.Date <= date && - x.IsAccepted && (x.LeaveType == "استعلاجی" || (x.LeaveType == "استحقاقی" && x.PaidLeaveType == "روزانه"))); + //get active leaves for workshop which are active today and accepted and are either روزانه and استحقاقی or استعلاجی + var leaves = _context.LeaveList + .Where(x => + (x.WorkshopId == workshopId && x.EndLeave.Date >= date && x.StartLeave.Date <= date && x.IsAccepted) && + ((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).ToList(); //get currently working employees with leftWork table //var workingEmployees = diff --git a/ServiceHost/Areas/Admin/Pages/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Index.cshtml index 210804fd..fefe13bf 100644 --- a/ServiceHost/Areas/Admin/Pages/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Index.cshtml @@ -1,232 +1,561 @@ @page +@using _0_Framework.Application +@using AccountManagement.Application.Contracts.TicketAccessAccount +@using Microsoft.AspNetCore.Mvc.TagHelpers @model ServiceHost.Areas.Admin.Pages.IndexModel +@inject ITicketAccessAccountApplication TicketAccessAccount; +@inject IAuthHelper authHelper; + @{ - - + + // + // + }
-
- - - @Model.today +
+ + + @Model.today - - @Model.day + + @Model.day - @Model.month - - @Model.year - - - - - - - - -
+ @Model.month + @Model.year +
+ + + + +
-
-

دادمهرگستر


-

DadmehrGostar

+@*
+

دادمهرگستر


+

DadmehrGostar

+ + -@*backups*@ -
-
-
- بکاپ خودکار - -
- -

لیست بکاپ های دیتابیس

-
- - @foreach (var item in Model.DbBackupList) - { - -

- @item.FileName - - - - - -

-
- } -
+@* @if(authHelper.GetPermissions().Any(x => x == 306)){ -
- -
- -

لیست بکاپ های بیمه

-
- - @foreach (var item in Model.InsuranceBackupList) - { - -

- @item.FileName - - - - - -

-
- } -
+
+
+
خلاصه گزارش
+ جزئیات بیشتر +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
-
+ +
+ +
+ +
+ +
+ +
+ +
+ +
-
\ No newline at end of file +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+} *@ + +@*backups*@ +@*
+
+
+ بکاپ خودکار + +
+ +

لیست بکاپ های دیتابیس

+
+ + @foreach (var item in @Model.DbBackupList) + { + +

@item.FileName + + + +

+
+ } +
+ +
+ +
+ +

لیست بکاپ های بیمه

+
+ + @foreach (var item in @Model.InsuranceBackupList) + { + +

@item.FileName + + + +

+
+ } +
+ +
+
+
+
*@ + +@section Script +{ +@* *@ +@* *@ +@* *@ + +} \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs index 99102cbb..80af10ac 100644 --- a/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs @@ -1,167 +1,203 @@ -using _0_Framework.Application; -using backService; +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using _0_Framework.Application; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using PersianTools.Core; +using System.IO; +using System.Linq; +using backService; +using CompanyManagment.EFCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using CompanyContext = CompanyManagment.EFCore.CompanyContext; +using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.Task; +using AccountManagement.Application.Contracts.Ticket; +using CompanyManagment.App.Contracts.Report; +using CompanyManagment.App.Contracts.Workshop; +using CompanyManagment.App.Contracts.YearlySalary; +using CompanyManagment.Application; -namespace ServiceHost.Areas.Admin.Pages; - -[Authorize] -public class IndexModel : PageModel +namespace ServiceHost.Areas.Admin.Pages { - private readonly IConfiguration _configuration; - private readonly IWebHostEnvironment _webHostEnvironment; - public string day; - public string filedirectory = string.Empty; - public string month; + [Authorize] + public class IndexModel : PageModel + { + private readonly IReportApplication _reportApplication; + private readonly IYearlySalaryApplication _yearlySalaryApplication; + private readonly IWorkshopApplication _workshopApplication; + private readonly IAccountApplication _accountApplication; + private readonly ITaskApplication _taskApplication; + private readonly ITicketApplication _ticketApplication; + private readonly IWebHostEnvironment _webHostEnvironment; + private readonly IConfiguration _configuration; - public string today; - public string year; + public string today; + public string month; + public string day; + public string year; + public string filedirectory = string.Empty; + public string FolderPath; + public int TaskRequestCount; + public int TicketCount; - public IndexModel(IWebHostEnvironment webHostEnvironment, IConfiguration configuration) - { - _webHostEnvironment = webHostEnvironment; - _configuration = configuration; - } + public IndexModel(IWebHostEnvironment webHostEnvironment, IConfiguration configuration, IAuthHelper authHelper, IReportApplication reportApplication, IYearlySalaryApplication yearlySalaryApplication, IWorkshopApplication workshopApplication, IAccountApplication accountApplication, ITaskApplication taskApplication, ITicketApplication ticketApplication) + { + _webHostEnvironment = webHostEnvironment; + _configuration = configuration; + _reportApplication = reportApplication; + _yearlySalaryApplication = yearlySalaryApplication; + _workshopApplication = workshopApplication; + _accountApplication = accountApplication; + _taskApplication = taskApplication; + _ticketApplication = ticketApplication; + } - public List DbBackupList { get; set; } - public List InsuranceBackupList { get; set; } - public string FolderPath { get; set; } + public void OnGet() + { + var todayGr = DateTime.Now; + var todayFa = todayGr.ToFarsi(); + var syear = Convert.ToInt32(todayFa.Substring(0, 4)); + var smonth = Convert.ToInt32(todayFa.Substring(5, 2)); + var sday = Convert.ToInt32(todayFa.Substring(8, 2)); + var d1 = new PersianDateTime(syear, smonth, sday); + - public void OnGet() - { - var todayGr = DateTime.Now; - var todayFa = todayGr.ToFarsi(); - var syear = Convert.ToInt32(todayFa.Substring(0, 4)); - var smonth = Convert.ToInt32(todayFa.Substring(5, 2)); - var sday = Convert.ToInt32(todayFa.Substring(8, 2)); - var d1 = new PersianDateTime(syear, smonth, sday); + today = d1.DayOfWeek; + month = d1.MonthOfYear; + day = todayFa.Substring(8, 2); + year = todayFa.Substring(0, 4); + + TaskRequestCount = _taskApplication.GetRequestedTasksCount(); + TicketCount = _ticketApplication.GetAdminTicketsCount(); + + //foreach (string fileEntry in fileEntries) + //{ + // Console.WriteLine(Path.GetFileName(fileEntry)); + //} + } + + public IActionResult OnGetReportDataAjax() + { + var allReports = _reportApplication.GetAllReports(null, null); + var now = new PersianDateTime(Convert.ToInt32(allReports.Year), Convert.ToInt32(allReports.Month), 1); + var before = now.AddMonths(1); + + return new JsonResult(new + { + success = true, + AllPercent = allReports.AllPercent, + ContractPercent = allReports.ContractPercent, + ContractSignaturePercent = allReports.ContractSignaturePercent, + CheckoutPercent = allReports.CheckoutPercent, + CheckoutSignaturePercent = allReports.CheckoutSignaturePercent, + ReportYear = allReports.Year, + ReportMonth = allReports.Month, + ReportCurrentMonth = allReports.Month.ToFarsiMonthByNumber(), + ReportNextMonth = before.Month.ToFarsiMonthByIntNumber(), + AllContract = allReports.AllContract, + ContractNotDone = allReports.ContractNotDone, + ContrcatDone = allReports.ContrcatDone, + ContractSignNotDone = allReports.ContractSignNotDone, + ContractSignDone = allReports.ContractSignDone, + AllCheckout = allReports.AllCheckout, + CheckoutDone = allReports.CheckoutDone, + CheckoutNotDone = allReports.CheckoutNotDone, + CheckoutSignNotDone = allReports.CheckoutSignNotDone, + CheckoutSignDone = allReports.CheckoutSignDone, + }); + } + + //public IActionResult OnGetCreateDatabaseBackup() + //{ + // ServerConnection serverConnection = new ServerConnection("46.4.37.226\\MSSQLSERVER2019,51019", "mesbah_db", "fD!4vm64"); + // Server server = new Server(serverConnection); + // Database database = server.Databases["mesbah_db"]; + // Backup backup = new Backup(); + // backup.Action = BackupActionType.Database; + + // backup.Database = "mesbah_db"; + + // BackupDeviceItem deviceItem = new BackupDeviceItem("mesbah_db.bak", DeviceType.File); + // backup.Devices.Add(deviceItem); + // backup.Incremental = false; + + // backup.SqlBackup(server); + + // return RedirectToPage("./Index"); + //} + + //public IActionResult OnGetCreateBackup() + //{ + // var directoryPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL15.MSNEW\\MSSQL\\Backup"; + // ServerConnection connection = new ServerConnection("46.4.37.226\\MSSQLSERVER2019,51019", "mesbah_db", "fD!4vm64"); + // Server server = new Server(connection); + // Backup backup = new Backup(); + // backup.Action = BackupActionType.Database; + // backup.Database = "mesbah_db"; + // backup.Devices.AddDevice(Path.Combine(directoryPath, "mesbah_db" + "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".bak"), DeviceType.File); + // backup.Initialize = true; + // backup.SqlBackup(server); + // return RedirectToPage("./Index"); + + //} + + //public IActionResult OnGetBackup() + //{ + // FolderPath = $"{_webHostEnvironment.WebRootPath}"; + + // SaveBackupFile(); + + // return Page(); - today = d1.DayOfWeek; - month = d1.MonthOfYear; - day = todayFa.Substring(8, 2); - year = todayFa.Substring(0, 4); - - #region DbBackupLoad - - var dbZipPath = _configuration["BackupOptions:DbBackupZipPath"]; - var dbBackups = Directory.GetFiles(dbZipPath); - DbBackupList = dbBackups.Select(x => new BackupViewModel - { - FileName = Path.GetFileName(x), - FullPath = x, - CreationDate = Path.GetFileName(x).ExtractTimeFromDbbackup() - }).OrderByDescending(x => x.CreationDate).ToList(); - - #endregion - - #region InsurancBackupLoad - - var insuranceZipPath = _configuration["BackupOptions:InsuranceListZipPath"]; - var insuranceBackups = Directory.GetFiles(insuranceZipPath); - InsuranceBackupList = insuranceBackups.Select(x => new BackupViewModel - { - FileName = Path.GetFileName(x), - FullPath = x, - CreationDate = Path.GetFileName(x).ExtractTimeFromInsurancebackup() - }).OrderByDescending(x => x.CreationDate).ToList(); - - #endregion - - //foreach (string fileEntry in fileEntries) - //{ - // Console.WriteLine(Path.GetFileName(fileEntry)); - //} - } - - public IActionResult OnGetDownloadFile(string path, string fileName) - { - var fileContent = System.IO.File.ReadAllBytes(path); - return File(fileContent, "application/zip", fileName); - } - //public IActionResult OnGetCreateDatabaseBackup() - //{ - // ServerConnection serverConnection = new ServerConnection("46.4.37.226\\MSSQLSERVER2019,51019", "mesbah_db", "fD!4vm64"); - // Server server = new Server(serverConnection); - // Database database = server.Databases["mesbah_db"]; - // Backup backup = new Backup(); - // backup.Action = BackupActionType.Database; - - // backup.Database = "mesbah_db"; - - // BackupDeviceItem deviceItem = new BackupDeviceItem("mesbah_db.bak", DeviceType.File); - // backup.Devices.Add(deviceItem); - // backup.Incremental = false; - - // backup.SqlBackup(server); - - // return RedirectToPage("./Index"); - //} - - //public IActionResult OnGetCreateBackup() - //{ - // var directoryPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL15.MSNEW\\MSSQL\\Backup"; - // ServerConnection connection = new ServerConnection("46.4.37.226\\MSSQLSERVER2019,51019", "mesbah_db", "fD!4vm64"); - // Server server = new Server(connection); - // Backup backup = new Backup(); - // backup.Action = BackupActionType.Database; - // backup.Database = "mesbah_db"; - // backup.Devices.AddDevice(Path.Combine(directoryPath, "mesbah_db" + "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".bak"), DeviceType.File); - // backup.Initialize = true; - // backup.SqlBackup(server); - // return RedirectToPage("./Index"); - - //} - - //public IActionResult OnGetBackup() - //{ - // FolderPath = $"{_webHostEnvironment.WebRootPath}"; - - // SaveBackupFile(); - - // return Page(); + //} - //} + //private void SaveBackupFile() + //{ - //private void SaveBackupFile() - //{ + + // var backupPath = "C:\\Dell"; + // var databaseName = "Mesbah_db"; + // var connectionString = + // "Data Source=DESKTOP-NUE119G\\MSNEW;Initial Catalog=Mesbah_db;Integrated Security=True"; + // // Connect to SQL Server database + // SqlConnection connection = new SqlConnection(connectionString); + + // // Open database connection + // connection.Open(); + + // // Create backup command + // string backupQuery = $"BACKUP DATABASE {databaseName} TO DISK='{backupPath}\\Mesbah_db.bak'"; + // SqlCommand command = new SqlCommand(backupQuery, connection); + + // // Execute backup command + // command.ExecuteNonQuery(); - // var backupPath = "C:\\Dell"; - // var databaseName = "Mesbah_db"; - // var connectionString = - // "Data Source=DESKTOP-NUE119G\\MSNEW;Initial Catalog=Mesbah_db;Integrated Security=True"; - // // Connect to SQL Server database - // SqlConnection connection = new SqlConnection(connectionString); - - // // Open database connection - // connection.Open(); - - // // Create backup command - // string backupQuery = $"BACKUP DATABASE {databaseName} TO DISK='{backupPath}\\Mesbah_db.bak'"; - // SqlCommand command = new SqlCommand(backupQuery, connection); - - // // Execute backup command - // command.ExecuteNonQuery(); - // //// create backup command - // //var backupCommand = $"BACKUP DATABASE {databaseName} TO DISK = '{backupPath}\\Mesbah_db.bak'"; - // // // execute backup command - // // _context.Database.ExecuteSqlRaw(backupCommand); + // //// create backup command + // //var backupCommand = $"BACKUP DATABASE {databaseName} TO DISK = '{backupPath}\\Mesbah_db.bak'"; - // // // save backup file to disk - // // var fileStream = new FileStream($"{backupPath}\\Mesbah_db.bak", FileMode.Create); - // // using (var binaryWriter = new BinaryWriter(fileStream)) - // // { - // // binaryWriter.Write(_context.Database.GetDbConnection().Database); - // // } + // // // execute backup command + // // _context.Database.ExecuteSqlRaw(backupCommand); + + // // // save backup file to disk + // // var fileStream = new FileStream($"{backupPath}\\Mesbah_db.bak", FileMode.Create); + // // using (var binaryWriter = new BinaryWriter(fileStream)) + // // { + // // binaryWriter.Write(_context.Database.GetDbConnection().Database); + // // } - //} -} \ No newline at end of file + + //} + } +} diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/FileBackup/Index.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/FileBackup/Index.cshtml new file mode 100644 index 00000000..c2690912 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/FileBackup/Index.cshtml @@ -0,0 +1,193 @@ +@page +@model ServiceHost.Areas.AdminNew.Pages.Company.FileBackup.IndexModel +@inject _0_Framework.Application.IAuthHelper AuthHelper; + +@{ + string versionAdmin = _0_Framework.Application.Version.AdminVersion; + ViewData["Title"] = " - " + "گروهبندی"; + int indexDb = 1; + int indexInsurance = 1; +} + +@section Styles { + + + + +} + + + +
+
+
+ + +

بکاپ گیری

+
+ +
+
+ + +
+
+
+
+ +
+
ردیف
+
عنوان
+
عملیات
+
+ + @foreach (var item in Model.DbBackupList) + { + +
+
+
+ ردیف +
+
+ + @(indexDb++) + +
+
+ +
+
+ عنوان +
+
+

+ @item.FileName +

+
+
+ +
+
+ عنوان +
+
+ +
+
+
+ } + +
+
+
+
+
+
+ +
+
ردیف
+
عنوان
+
عملیات
+
+ + @foreach (var item in Model.InsuranceBackupList) + { +
+
+
+ ردیف +
+
+ + @(indexInsurance++) + +
+
+ +
+
+ عنوان +
+
+

+ @item.FileName +

+
+
+ +
+
+ عنوان +
+
+ +
+
+
+ } + +
+
+
+ +
+ + + + + +@section Script { + + + + + +} \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/FileBackup/Index.cshtml.cs b/ServiceHost/Areas/AdminNew/Pages/Company/FileBackup/Index.cshtml.cs new file mode 100644 index 00000000..22bbfef0 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/FileBackup/Index.cshtml.cs @@ -0,0 +1,76 @@ +using _0_Framework.Application; +using _0_Framework.Infrastructure; +using _0_Framework.InfraStructure; +using backService; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Configuration.UserSecrets; + +namespace ServiceHost.Areas.AdminNew.Pages.Company.FileBackup +{ + [Authorize] + public class IndexModel : PageModel + { + private readonly IConfiguration _configuration; + private readonly IAuthHelper _authHelper; + + public List DbBackupList { get; set; } + public List InsuranceBackupList { get; set; } + + public IndexModel(IConfiguration configuration, IAuthHelper authHelper) + { + _configuration = configuration; + _authHelper = authHelper; + } + + + public IActionResult OnGet() + { + + if (_authHelper.GetPermissions().Any(x => x == 2)) + { + #region DbBackupLoad + + string? dbZipPath = _configuration["BackupOptions:DbBackupZipPath"]; + string[] dbBackups = Directory.GetFiles(dbZipPath); + DbBackupList = dbBackups.Select(x => new BackupViewModel() + { + FileName = Path.GetFileName(x), + FullPath = x, + CreationDate = Path.GetFileName(x).ExtractTimeFromDbbackup(), + }).OrderByDescending(x => x.CreationDate).ToList(); + + #endregion + + #region InsurancBackupLoad + + string? insuranceZipPath = _configuration["BackupOptions:InsuranceListZipPath"]; + string[] insuranceBackups = Directory.GetFiles(insuranceZipPath); + InsuranceBackupList = insuranceBackups.Select(x => new BackupViewModel() + { + FileName = Path.GetFileName(x), + FullPath = x, + CreationDate = Path.GetFileName(x).ExtractTimeFromInsurancebackup(), + }).OrderByDescending(x => x.CreationDate).ToList(); + + + #endregion + + return Page(); + } + else + { + return Forbid(); + } + + + } + + public IActionResult OnGetDownloadFile(string path, string fileName) + { + byte[] fileContent = System.IO.File.ReadAllBytes(path); + return File(fileContent, "application/zip", fileName); + } + } +} diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateModal.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateModal.cshtml index eae58f2c..16a672e6 100644 --- a/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateModal.cshtml +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateModal.cshtml @@ -333,4 +333,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/DetailsModal.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/DetailsModal.cshtml index 25fe81b4..02ba8890 100644 --- a/ServiceHost/Areas/AdminNew/Pages/Company/Task/DetailsModal.cshtml +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/DetailsModal.cshtml @@ -321,5 +321,5 @@ } else { - + } diff --git a/ServiceHost/Areas/Camera/Pages/ErrorMessage.cshtml b/ServiceHost/Areas/Camera/Pages/ErrorMessage.cshtml index ea47577a..9c6824ad 100644 --- a/ServiceHost/Areas/Camera/Pages/ErrorMessage.cshtml +++ b/ServiceHost/Areas/Camera/Pages/ErrorMessage.cshtml @@ -1,15 +1,16 @@ @page @model ServiceHost.Areas.Camera.Pages.ErrorMessageModel -@using Version = _0_Framework.Application.Version + @{ Layout = "Shared/_Layout"; - ViewData["Title"] = " - " + "خطای سیستمی"; + ViewData["Title"] = " - " + "خطای سیستمی"; + string cameraVersion = _0_Framework.Application.Version.CameraVersion; } @section Styles { - + }
diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs index 87bd3be9..078b1dc4 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs @@ -193,46 +193,61 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall public IActionResult OnGetModalTakeImages(long employeeId) { - var workshopHash = User.FindFirstValue("WorkshopSlug"); - var workshopId = _passwordHasher.SlugDecrypt(workshopHash); - if (workshopId > 0) - { + var workshopHash = User.FindFirstValue("WorkshopSlug"); + var workshopId = _passwordHasher.SlugDecrypt(workshopHash); + if (workshopId > 0) + { - var employeeWorkshopInfo = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, workshopId); + var employeeWorkshopInfo = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, workshopId); - bool hasPicture = false; - if (employeeWorkshopInfo != null && !string.IsNullOrEmpty(employeeWorkshopInfo.HasUploadedImage)) - hasPicture = bool.Parse(employeeWorkshopInfo.HasUploadedImage); + bool hasPicture = false; + if (employeeWorkshopInfo != null && !string.IsNullOrEmpty(employeeWorkshopInfo.HasUploadedImage)) + hasPicture = bool.Parse(employeeWorkshopInfo.HasUploadedImage); - var employeeDetails = _employeeApplication.GetDetails(employeeId); + var employeeDetails = _employeeApplication.GetDetails(employeeId); - string employeeName = string.Empty; - if (employeeDetails != null) - employeeName = employeeDetails.EmployeeFullName; + string employeeName = string.Empty; + if (employeeDetails != null) + employeeName = employeeDetails.EmployeeFullName; - string pic1 = ""; - string pic2 = ""; - if (hasPicture) - { - byte[] fileContent1 = System.IO.File.ReadAllBytes($"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\{1}.jpg"); - pic1 = Convert.ToBase64String(fileContent1); - byte[] fileContent2 = System.IO.File.ReadAllBytes($"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\{2}.jpg"); - pic2 = Convert.ToBase64String(fileContent2); - } + string pic1 = ""; + string pic2 = ""; + if (hasPicture) + { + string path1 = $"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\{1}.jpg"; + string path2 = $"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\{2}.jpg"; - var res = new TakePictureModel() - { - HasPicture = hasPicture, - EmployeeId = employeeId, - WorkshopId = workshopId, - Name = employeeName, - Pic1 = pic1, - Pic2 = pic2, - }; - + if (System.IO.File.Exists(path1)) + { + byte[] fileContent1 = System.IO.File.ReadAllBytes(path1); + pic1 = Convert.ToBase64String(fileContent1); + } - return Partial("ModalTakeImages", res); - } + if (System.IO.File.Exists(path2)) + { + byte[] fileContent2 = System.IO.File.ReadAllBytes(path2); + pic2 = Convert.ToBase64String(fileContent2); + } + + //byte[] fileContent1 = System.IO.File.ReadAllBytes($"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\{1}.jpg"); + //pic1 = Convert.ToBase64String(fileContent1); + //byte[] fileContent2 = System.IO.File.ReadAllBytes($"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\{2}.jpg"); + //pic2 = Convert.ToBase64String(fileContent2); + } + + var res = new TakePictureModel() + { + HasPicture = hasPicture, + EmployeeId = employeeId, + WorkshopId = workshopId, + Name = employeeName, + Pic1 = pic1, + Pic2 = pic2, + }; + + + return Partial("ModalTakeImages", res); + } else { var resultError = new ErrorViewModel() diff --git a/ServiceHost/Faces/11/1/1.jpg b/ServiceHost/Faces/11/1/1.jpg index e16ba277..ab15e686 100644 Binary files a/ServiceHost/Faces/11/1/1.jpg and b/ServiceHost/Faces/11/1/1.jpg differ diff --git a/ServiceHost/Faces/11/1/2.jpg b/ServiceHost/Faces/11/1/2.jpg index 69de22e2..9c72df8f 100644 Binary files a/ServiceHost/Faces/11/1/2.jpg and b/ServiceHost/Faces/11/1/2.jpg differ diff --git a/ServiceHost/Pages/Shared/_Layout.cshtml b/ServiceHost/Pages/Shared/_Layout.cshtml index f0267e61..3ca1a04e 100644 --- a/ServiceHost/Pages/Shared/_Layout.cshtml +++ b/ServiceHost/Pages/Shared/_Layout.cshtml @@ -1,5 +1,10 @@ @using Microsoft.AspNetCore.Razor.Language.Intermediate -@using Version = _0_Framework.Application.Version + +@{ + string styleVersion = _0_Framework.Application.Version.StyleVersion; + + +} @@ -13,10 +18,10 @@ @RenderSection("head", false) - - - - + + + + @@ -45,7 +50,7 @@ - +