Compare commits

..

1 Commits

7 changed files with 37 additions and 186 deletions

View File

@@ -1,142 +0,0 @@
using _0_Framework.Application;
using OfficeOpenXml;
using OfficeOpenXml.Style;
namespace CompanyManagement.Infrastructure.Excel.Checkout;
public class YektaTejaratCheckout
{
private static readonly Dictionary<string, string> Header = new()
{
{ "FullName", "نام و نام خانوادگی" },
{ "NationalCode", "کد ملی" },
{ "StaticPayableAmount", "مبلغ قابل پرداخت استاتیک" },
{ "AttendancePayableAmount", "مبلغ قابل پرداخت حضور غیاب" }
};
public static byte[] GenerateYektaTejaratCheckoutExcel(List<YektaTejaratCheckoutViewModel> data)
{
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization");
using var package = new ExcelPackage();
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
// Add row index header
var indexCell = worksheet.Cells[1, 1];
indexCell.Value = "ردیف";
ApplyHeaderStyle(indexCell);
// Add headers to worksheet
for (int i = 0; i < Header.Count; i++)
{
worksheet.Cells[1, i + 2].Value = Header.ElementAt(i).Value;
ApplyHeaderStyle(worksheet.Cells[1, i + 2]);
}
// Add data rows
var dataRow = 2;
foreach (var item in data)
{
// Row number
var rowCounter = worksheet.Cells[dataRow, 1];
rowCounter.Value = dataRow - 1;
ApplyGeneralDataStyle(rowCounter);
ApplySpecificStyle(rowCounter, 1);
var column = 2;
foreach (var header in Header)
{
var property = item.GetType().GetProperty(header.Key);
var value = property?.GetValue(item, null)?.ToString();
// Check if the property requires MoneyToDouble()
if (RequiresMoneyToDouble(property?.Name))
{
worksheet.Cells[dataRow, column].Value = MoneyToDouble(value);
}
else
{
worksheet.Cells[dataRow, column].Value = value;
}
ApplyGeneralDataStyle(worksheet.Cells[dataRow, column]);
ApplySpecificStyle(worksheet.Cells[dataRow, column], column);
column++;
}
dataRow++;
}
// Auto-fit columns and set print settings
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
worksheet.PrinterSettings.PaperSize = ePaperSize.A4;
worksheet.PrinterSettings.Orientation = eOrientation.Portrait;
worksheet.PrinterSettings.FitToPage = true;
worksheet.PrinterSettings.FitToWidth = 1;
worksheet.PrinterSettings.FitToHeight = 0;
worksheet.View.RightToLeft = true;
return package.GetAsByteArray();
}
// Method to check if a property requires MoneyToDouble()
private static bool RequiresMoneyToDouble(string propertyName)
{
var propertiesRequiringConversion = new HashSet<string>
{
"StaticPayableAmount", "AttendancePayableAmount"
};
return propertiesRequiringConversion.Contains(propertyName);
}
// Convert money string to double
private static double MoneyToDouble(string value)
{
if (string.IsNullOrEmpty(value))
return 0;
var min = value.Length > 1 ? value.Substring(0, 2) : "";
var result = min == "\u200e\u2212" ? value.MoneyToDouble() * -1 : value.MoneyToDouble();
return result;
}
private static void ApplyHeaderStyle(ExcelRange cell)
{
cell.Style.Font.Bold = true;
cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
cell.Style.Border.BorderAround(ExcelBorderStyle.Thin);
}
private static void ApplyGeneralDataStyle(ExcelRange cell)
{
cell.Style.Border.BorderAround(ExcelBorderStyle.Thin);
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
}
private static void ApplySpecificStyle(ExcelRange cell, int columnIndex)
{
switch (columnIndex)
{
case 1: // ردیف
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
break;
case 2: // نام و نام خانوادگی
case 3: // کد ملی
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightYellow);
break;
case 4: // مبلغ قابل پرداخت استاتیک
cell.Style.Fill.BackgroundColor.SetColor(1, 208, 248, 208); // Light green
cell.Style.Numberformat.Format = "#,##0";
break;
case 5: // مبلغ قابل پرداخت حضور غیاب
cell.Style.Fill.BackgroundColor.SetColor(1, 168, 186, 254); // Light blue
cell.Style.Numberformat.Format = "#,##0";
break;
}
}
}

View File

@@ -1,10 +0,0 @@
namespace CompanyManagement.Infrastructure.Excel.Checkout;
public class YektaTejaratCheckoutViewModel
{
public required string FullName { get; set; }
public required string NationalCode { get; set; }
public required string StaticPayableAmount { get; set; }
public required string AttendancePayableAmount { get; set; }
}

View File

@@ -1425,7 +1425,7 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
public string CheckRepeat(long employeeId, long workshopId)
{
var validSpan = new TimeSpan(0, 0, 2, 0);
var validSpan = new TimeSpan(0, 0, 5, 0);
var checkDate = DateTime.Now.AddDays(-3);
var query = _context.RollCalls
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.CreationDate >= checkDate);

View File

@@ -34,7 +34,6 @@ using System.Net.Http;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Text.Json.Serialization;
using CompanyManagement.Infrastructure.Excel.Checkout;
using Microsoft.AspNetCore.Authentication;
using static ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk.IndexModel2;
@@ -153,14 +152,8 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
{
//await UpdateInstitutionContract();
//await UpdateFaceEmbeddingNames();
//await SetInstitutionContractSigningType();
var bytes= GetYektaCheckout();
return File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"YektaCheckout.xlsx");
await SetInstitutionContractSigningType();
ViewData["message"] = "تومام یک";
return Page();
}
@@ -1118,22 +1111,6 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
}
#endregion
private byte[] GetYektaCheckout()
{
var checkouts = _context.CheckoutSet
.Where(x => x.WorkshopId == 595
&& x.Month == "آذر" && x.Year == "1404").Select(x=>new YektaTejaratCheckoutViewModel()
{
AttendancePayableAmount = "0",
FullName = x.EmployeeFullName,
NationalCode = x.NationalCode,
StaticPayableAmount = x.TotalPayment.ToMoney()
}).ToList();
var bytes = YektaTejaratCheckout.GenerateYektaTejaratCheckoutExcel(checkouts);
return bytes;
}
}
public class IndexModel2 : PageModel

View File

@@ -145,10 +145,10 @@ public class CameraController : CameraBaseController
switch (repeatStatus)
{
case "IncomRegistred-InvalidOut":
throw new BadRequestException("شما به تازگی ثبت ورود نموده اید ,تا 2 دقیقه نمی توانید ثبت خروج نمایید");
throw new BadRequestException("شما به تازگی ثبت ورود نموده اید ,تا 5 دقیقه نمی توانید ثبت خروج نمایید");
case "outRegistred-InvalidIncom":
throw new BadRequestException("شما به تازگی ثبت خروج نموده اید تا 2 دقیقه نمی توانید ثبت ورود نمایید");
throw new BadRequestException("شما به تازگی ثبت خروج نموده اید تا 5 دقیقه نمی توانید ثبت ورود نمایید");
}
@@ -201,10 +201,10 @@ public class CameraController : CameraBaseController
switch (repeatStatus)
{
case "IncomRegistred-InvalidOut":
throw new BadRequestException("شما به تازگی ثبت ورود نموده اید ,تا 2 دقیقه نمی توانید ثبت خروج نمایید");
throw new BadRequestException("شما به تازگی ثبت ورود نموده اید ,تا 5 دقیقه نمی توانید ثبت خروج نمایید");
case "outRegistred-InvalidIncom":
throw new BadRequestException("شما به تازگی ثبت خروج نموده اید تا 2 دقیقه نمی توانید ثبت ورود نمایید");
throw new BadRequestException("شما به تازگی ثبت خروج نموده اید تا 5 دقیقه نمی توانید ثبت ورود نمایید");
}
@@ -302,13 +302,13 @@ public class CameraController : CameraBaseController
return new JsonResult(new
{
isSuccess = false,
message = "شما به تازگی ثبت ورود نموده اید ,تا 2 دقیقه نمی توانید ثبت خروج نمایید",
message = "شما به تازگی ثبت ورود نموده اید ,تا 5 دقیقه نمی توانید ثبت خروج نمایید",
});
case "outRegistred-InvalidIncom":
return new JsonResult(new
{
isSuccess = false,
message = "شما به تازگی ثبت خروج نموده اید تا 2 دقیقه نمی توانید ثبت ورود نمایید",
message = "شما به تازگی ثبت خروج نموده اید تا 5 دقیقه نمی توانید ثبت ورود نمایید",
});
}
@@ -412,6 +412,32 @@ public class CameraController : CameraBaseController
});
}
}
[HttpPost("check-password")]
public IActionResult OnPostCheckPassword([FromBody]string password)
{
var cameraAccount = _authHelper.CameraAccountInfo();
var cameraPassword = _cameraAccountApplication.GetDetails(cameraAccount.Id).Password;
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(cameraPassword, password);
if (result.Verified)
{
_accountApplication.Logout();
return new JsonResult(new
{
isSuccess = true,
});
}
return new JsonResult(new
{
isSuccess = false,
errorMessage = "گذرواژه اشتباه است",
});
}
}
public class RollCallExitRequest:RollCallEnterRequest

View File

@@ -139,13 +139,13 @@ public class IndexModel : PageModel
return new JsonResult(new
{
isSuccess = false,
message = "شما به تازگی ثبت ورود نموده اید ,تا 2 دقیقه نمی توانید ثبت خروج نمایید",
message = "شما به تازگی ثبت ورود نموده اید ,تا 5 دقیقه نمی توانید ثبت خروج نمایید",
});
case "outRegistred-InvalidIncom":
return new JsonResult(new
{
isSuccess = false,
message = "شما به تازگی ثبت خروج نموده اید تا 2 دقیقه نمی توانید ثبت ورود نمایید",
message = "شما به تازگی ثبت خروج نموده اید تا 5 دقیقه نمی توانید ثبت ورود نمایید",
});
}

View File

@@ -19,7 +19,7 @@
"sqlDebugging": true,
"dotnetRunMessages": "true",
"nativeDebugging": true,
"applicationUrl": "https://localhost:5004;http://localhost:5003;",
"applicationUrl": "https://localhost:5004;http://localhost:5003;https://192.168.0.117:5006",
"jsWebView2Debugging": false,
"hotReloadEnabled": true
},