Compare commits

..

2 Commits

Author SHA1 Message Date
ab604d3be5 change qr code to barcode 2025-06-17 13:46:13 +03:30
MahanCh
d713cbb1fe add qrCode 2025-05-31 20:30:36 +03:30
29 changed files with 4577 additions and 5055 deletions

View File

@@ -12,65 +12,65 @@ namespace _0_Framework.Application;
public class AuthHelper : IAuthHelper
{
private readonly IHttpContextAccessor _contextAccessor;
private readonly IHttpContextAccessor _contextAccessor;
public AuthHelper(IHttpContextAccessor contextAccessor)
{
_contextAccessor = contextAccessor;
}
public AuthHelper(IHttpContextAccessor contextAccessor)
{
_contextAccessor = contextAccessor;
}
public AuthViewModel CurrentAccountInfo()
{
var result = new AuthViewModel();
if (!IsAuthenticated())
return result;
public AuthViewModel CurrentAccountInfo()
{
var result = new AuthViewModel();
if (!IsAuthenticated())
return result;
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
result.Id = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId").Value);
result.Username = claims.FirstOrDefault(x => x.Type == "Username")?.Value;
result.ProfilePhoto = claims.FirstOrDefault(x => x.Type == "ProfilePhoto")?.Value;
result.RoleId = long.Parse(claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value);
result.Fullname = claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value;
result.Role = claims.FirstOrDefault(x => x.Type == "RoleName")?.Value;
result.ClientAriaPermission = claims.FirstOrDefault(x => x.Type == "ClientAriaPermission").Value;
result.AdminAreaPermission = claims.FirstOrDefault(x => x.Type == "AdminAreaPermission").Value;
result.PositionValue = !string.IsNullOrWhiteSpace(claims.FirstOrDefault(x => x.Type == "PositionValue")?.Value) ? int.Parse(claims.FirstOrDefault(x => x.Type == "PositionValue")?.Value) : 0;
result.WorkshopList = Tools.DeserializeFromBsonList<WorkshopClaim>(claims.FirstOrDefault(x => x is { Type: "workshopList" })?.Value);
result.WorkshopSlug = claims.FirstOrDefault(x => x is { Type: "WorkshopSlug" }).Value;
result.Mobile = claims.FirstOrDefault(x => x is { Type: "Mobile" }).Value;
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
result.Id = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId").Value);
result.Username = claims.FirstOrDefault(x => x.Type == "Username")?.Value;
result.ProfilePhoto = claims.FirstOrDefault(x => x.Type == "ProfilePhoto")?.Value;
result.RoleId = long.Parse(claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value);
result.Fullname = claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value;
result.Role = claims.FirstOrDefault(x => x.Type == "RoleName")?.Value;
result.ClientAriaPermission =claims.FirstOrDefault(x => x.Type == "ClientAriaPermission").Value;
result.AdminAreaPermission = claims.FirstOrDefault(x => x.Type == "AdminAreaPermission").Value;
result.PositionValue = !string.IsNullOrWhiteSpace(claims.FirstOrDefault(x => x.Type == "PositionValue")?.Value) ? int.Parse(claims.FirstOrDefault(x => x.Type == "PositionValue")?.Value) : 0;
result.WorkshopList = Tools.DeserializeFromBsonList<WorkshopClaim>(claims.FirstOrDefault(x => x is { Type: "workshopList" })?.Value);
result.WorkshopSlug = claims.FirstOrDefault(x => x is { Type: "WorkshopSlug" }).Value;
result.Mobile = claims.FirstOrDefault(x => x is { Type: "Mobile" }).Value;
result.SubAccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "SubAccountId").Value);
result.WorkshopName = claims.FirstOrDefault(x => x is { Type: "WorkshopName" })?.Value;
return result;
}
}
public List<int> GetPermissions()
{
if (!IsAuthenticated())
return new List<int>();
public List<int> GetPermissions()
{
if (!IsAuthenticated())
return new List<int>();
var permissions = _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "permissions")
?.Value;
return Tools.DeserializeFromBsonList<int>(permissions); //Mahan
}
var permissions = _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "permissions")
?.Value;
return Tools.DeserializeFromBsonList<int>(permissions); //Mahan
}
public long CurrentAccountId()
{
return IsAuthenticated()
? long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "AccountId")?.Value)
: 0;
}
public long CurrentSubAccountId()
{
return IsAuthenticated()
? long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "SubAccountId")?.Value)
: 0;
}
public long CurrentAccountId()
{
return IsAuthenticated()
? long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "AccountId")?.Value)
: 0;
}
public long CurrentSubAccountId()
{
return IsAuthenticated()
? long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "SubAccountId")?.Value)
: 0;
}
public string CurrentAccountMobile()
{
return IsAuthenticated()
? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "Mobile")?.Value
: "";
}
{
return IsAuthenticated()
? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "Mobile")?.Value
: "";
}
#region Vafa
@@ -111,166 +111,160 @@ public class AuthHelper : IAuthHelper
}
public string GetWorkshopSlug()
{
return CurrentAccountInfo().ClientAriaPermission == "true"
? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopSlug")?.Value
: "";
}
public string GetWorkshopName()
{
var workshopName = _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "ClientAriaPermission")?.Value == "true";
if (workshopName)
{
return _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopName")?.Value;
}
{
return CurrentAccountInfo().ClientAriaPermission == "true"
? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopSlug")?.Value
: "";
}
public string GetWorkshopName()
{
var workshopName = _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "ClientAriaPermission")?.Value == "true";
if (workshopName)
{
return _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopName")?.Value;
}
return "";
}
return "";
}
#endregion
public string CurrentAccountRole()
{
if (IsAuthenticated())
return _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value;
return null;
}
{
if (IsAuthenticated())
return _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value;
return null;
}
public bool IsAuthenticated()
{
return _contextAccessor.HttpContext.User.Identity.IsAuthenticated;
//var claims = _contextAccessor.HttpContext.User.Claims.ToList();
//if (claims.Count > 0)
// return true;
//return false;
//return claims.Count > 0;
}
public bool IsAuthenticated()
{
return _contextAccessor.HttpContext.User.Identity.IsAuthenticated;
//var claims = _contextAccessor.HttpContext.User.Claims.ToList();
//if (claims.Count > 0)
// return true;
//return false;
//return claims.Count > 0;
}
public void Signin(AuthViewModel account)
{
#region MahanChanges
public void Signin(AuthViewModel account)
{
#region MahanChanges
if (account.Id == 322)
account.Permissions.AddRange([3060301, 30603, 30604, 30605]);
var permissions = account.Permissions is { Count: > 0 } ? Tools.SerializeToBson(account.Permissions) : "";
var workshopBson = account.WorkshopList is { Count: > 0 } ? Tools.SerializeToBson(account.WorkshopList) : "";
var slug = account.WorkshopSlug ?? "";
var permissions = account.Permissions is { Count: > 0 } ? Tools.SerializeToBson(account.Permissions) : "";
#endregion
var workshopBson = account.WorkshopList is { Count: > 0 } ? Tools.SerializeToBson(account.WorkshopList) : "";
var slug = account.WorkshopSlug ?? "";
#endregion
var claims = new List<Claim>
{
new Claim("AccountId", account.Id.ToString()),
new Claim(ClaimTypes.Name, account.Fullname),
new Claim(ClaimTypes.Role, account.RoleId.ToString()),
new Claim("Username", account.Username), // Or Use ClaimTypes.NameIdentifier
var claims = new List<Claim>
{
new Claim("AccountId", account.Id.ToString()),
new Claim(ClaimTypes.Name, account.Fullname),
new Claim(ClaimTypes.Role, account.RoleId.ToString()),
new Claim("Username", account.Username), // Or Use ClaimTypes.NameIdentifier
new Claim("permissions", permissions),
new Claim("Mobile", account.Mobile),
new Claim("ProfilePhoto", account.ProfilePhoto ),
new Claim("RoleName", account.RoleName),
new Claim("SubAccountId", account.SubAccountId.ToString()),
new Claim("Mobile", account.Mobile),
new Claim("ProfilePhoto", account.ProfilePhoto ),
new Claim("RoleName", account.RoleName),
new Claim("SubAccountId", account.SubAccountId.ToString()),
new Claim("AdminAreaPermission", account.AdminAreaPermission.ToString()),
new Claim("ClientAriaPermission", account.ClientAriaPermission.ToString()),
new Claim("IsCamera", "false"),
new Claim("PositionValue",account.PositionValue.ToString()),
new Claim("ClientAriaPermission", account.ClientAriaPermission.ToString()),
new Claim("IsCamera", "false"),
new Claim("PositionValue",account.PositionValue.ToString()),
//mahanChanges
new("workshopList",workshopBson),
new("WorkshopSlug",slug),
new("WorkshopName",account.WorkshopName??"")
new("WorkshopSlug",slug),
new("WorkshopName",account.WorkshopName??"")
};
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var authProperties = new AuthenticationProperties
{
ExpiresUtc = DateTimeOffset.UtcNow.AddDays(1)
};
var authProperties = new AuthenticationProperties
{
ExpiresUtc = DateTimeOffset.UtcNow.AddDays(1)
};
_contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
_contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
#region Camera
public void CameraSignIn(CameraAuthViewModel account)
{
var claims = new List<Claim>
{
new Claim("AccountId", account.Id.ToString()),
new Claim("Username", account.Username), // Or Use ClaimTypes.NameIdentifier
#region Camera
public void CameraSignIn(CameraAuthViewModel account)
{
var claims = new List<Claim>
{
new Claim("AccountId", account.Id.ToString()),
new Claim("Username", account.Username), // Or Use ClaimTypes.NameIdentifier
new Claim("WorkshopId", account.WorkshopId.ToString()),
new Claim("WorkshopName", account.WorkshopName),
new Claim("Mobile", account.Mobile),
new Claim("AccountId", account.AccountId.ToString()),
new Claim("IsActiveString", account.IsActiveString),
new Claim("IsCamera", "true"),
new Claim("WorkshopName", account.WorkshopName),
new Claim("Mobile", account.Mobile),
new Claim("AccountId", account.AccountId.ToString()),
new Claim("IsActiveString", account.IsActiveString),
new Claim("IsCamera", "true"),
};
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
};
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var authProperties = new AuthenticationProperties
{
var authProperties = new AuthenticationProperties
{
//ExpiresUtc = DateTimeOffset.UtcNow.AddDays(30)
ExpiresUtc = new DateTimeOffset(year: 2100, month: 1, day: 1, hour: 0, minute: 0, second: 0, offset: TimeSpan.Zero)
};
//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,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
_contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
public CameraAuthViewModel CameraAccountInfo()
{
var result = new CameraAuthViewModel();
if (!IsAuthenticated())
return result;
public CameraAuthViewModel CameraAccountInfo()
{
var result = new CameraAuthViewModel();
if (!IsAuthenticated())
return result;
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
result.Id = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId").Value);
result.Username = claims.FirstOrDefault(x => x.Type == "Username")?.Value;
result.WorkshopId = long.Parse(claims.FirstOrDefault(x => x.Type == "WorkshopId")?.Value);
result.WorkshopName = claims.FirstOrDefault(x => x.Type == "WorkshopName").Value;
result.Mobile = claims.FirstOrDefault(x => x.Type == "Mobile").Value;
result.AccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId")?.Value);
result.IsActiveString = claims.FirstOrDefault(x => x.Type == "IsActiveString").Value;
return result;
}
#endregion
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
result.Id = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId").Value);
result.Username = claims.FirstOrDefault(x => x.Type == "Username")?.Value;
result.WorkshopId = long.Parse(claims.FirstOrDefault(x => x.Type == "WorkshopId")?.Value);
result.WorkshopName = claims.FirstOrDefault(x => x.Type == "WorkshopName").Value;
result.Mobile = claims.FirstOrDefault(x => x.Type == "Mobile").Value;
result.AccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "AccountId")?.Value);
result.IsActiveString = claims.FirstOrDefault(x => x.Type == "IsActiveString").Value;
return result;
}
#endregion
public void SignOut()
{
_contextAccessor.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
}
public void SignOut()
{
_contextAccessor.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
}
#region Pooya
#region Pooya
public (long Id, UserType userType, long roleId) GetUserTypeWithId()
{
if (!IsAuthenticated())
return (0, UserType.Anonymous, 0);
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
public (long Id, UserType userType, long roleId) GetUserTypeWithId()
{
if (!IsAuthenticated())
return (0, UserType.Anonymous, 0);
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
var subAccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "SubAccountId")?.Value ?? "0");
if (subAccountId > 0)
return (subAccountId, UserType.SubAccount, 0);
var subAccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "SubAccountId")?.Value ?? "0");
if (subAccountId > 0)
return (subAccountId, UserType.SubAccount, 0);
var id = long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "AccountId")?.Value);
if (claims.FirstOrDefault(x => x.Type == "AdminAreaPermission")?.Value == "true")
{
var roleId = long.Parse(claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value ?? "0");
return (id, UserType.Admin, roleId);
}
var id = long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "AccountId")?.Value);
if (claims.FirstOrDefault(x => x.Type == "AdminAreaPermission")?.Value == "true")
{
var roleId = long.Parse(claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value ?? "0");
return (id, UserType.Admin, roleId);
}
return (id, UserType.Client, 0);
}
#endregion
return (id, UserType.Client, 0);
}
#endregion
}

View File

@@ -385,27 +385,11 @@
/// </summary>
public const int SetWorkshopWorkingHoursPermissionCode = 10606;
#region حساب کاربری دوربین
/// <summary>
/// تنظیمات حساب کاربری دوربین
/// </summary>
public const int CameraAccountSettingsPermissionCode = 10607;
/// <summary>
/// فعال/غیرفعال اکانت دوربین
/// </summary>
public const int CameraAccountActivationBtnPermissionCode = 1060701;
/// <summary>
/// ویرایش اکانت دوربین
/// </summary>
public const int CameraAccountEditPermissionCode = 1060702;
#endregion
#endregion
#region کارپوشه
@@ -760,22 +744,6 @@
Code = CameraAccountSettingsPermissionCode,
ParentId = RollCallOperationsPermissionCode
};
public static SubAccountPermissionDto CameraAccountActivationBtn { get; } = new()
{
Id = CameraAccountActivationBtnPermissionCode,
Name = "فعال/غیرفعال حساب کاربری دوربین",
Code = CameraAccountActivationBtnPermissionCode,
ParentId = CameraAccountSettingsPermissionCode
};
public static SubAccountPermissionDto CameraAccountEdit { get; } = new()
{
Id = CameraAccountEditPermissionCode,
Name = "ویراش حساب کاربری دوربین",
Code = CameraAccountEditPermissionCode,
ParentId = CameraAccountSettingsPermissionCode
};
#endregion
#region کارپوشه,ParentId = WorkFlowOperationsPermissionCode

View File

@@ -16,7 +16,7 @@ public class TaskSchedule:EntityBase
UnitType = unitType;
UnitNumber = unitNumber;
LastEndTaskDate = lastEndTaskDate;
IsActive = IsActive.True;
IsActive = IsActive.False;
}
public string Count { get; private set; }
public TaskScheduleType Type { get; private set; }

View File

@@ -52,8 +52,5 @@ public interface ILeftWorkInsuranceRepository : IRepository<long, LeftWorkInsura
/// <returns></returns>
List<LeftWorkViewModel> GetEmployeesWithContractExitOnly(long workshopId);
LeftWorkInsurance GetLastLeftWorkByEmployeeIdAndWorkshopId(long workshopId, long employeeId);
#endregion
}

View File

@@ -16,19 +16,7 @@ namespace Company.Domain.RollCallAgg;
public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
{
ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout);
/// <summary>
/// محاسبه ساعات کارکرد پرسنل در صورت داشتن حضور غیاب
/// </summary>
/// <param name="employeeId"></param>
/// <param name="workshopId"></param>
/// <param name="contractStart"></param>
/// <param name="contractEnd"></param>
/// <returns></returns>
(bool hasRollCall, TimeSpan sumOfSpan) GetRollCallWorkingSpan(long employeeId, long workshopId,
DateTime contractStart, DateTime contractEnd);
TimeSpan AfterSubtract(CreateWorkingHoursTemp command, TimeSpan sumOneDaySpan, DateTime creationDate);
TimeSpan AfterSubtract(CreateWorkingHoursTemp command, TimeSpan sumOneDaySpan, DateTime creationDate);
List<RotatingShiftViewModel> RotatingShiftCheck(List<GroupedRollCalls> rollCallList);

View File

@@ -38,5 +38,4 @@ public interface IRollCallEmployeeApplication
(int activeEmployees, int deActiveEmployees) GetActiveAndDeActiveRollCallEmployees(long workshopId);
bool HasEmployees(long workshopId);
#endregion
}

View File

@@ -17,7 +17,5 @@ namespace CompanyManagment.App.Contracts.RollCallEmployeeStatus
List<RollCallEmployeeStatusViewModel> GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr);
bool IsActiveInPeriod(long employeeId, long workshopId, DateTime startDate, DateTime endDate);
void SyncRollCallEmployeeWithLeftWork(long rollCallEmployeeId);
}
}
}

View File

@@ -30,7 +30,6 @@ using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
using Company.Domain.LeftWorkAgg;
using CompanyManagment.App.Contracts.Employee.DTO;
using Company.Domain.EmployeeAuthorizeTempAgg;
using Company.Domain.LeftWorkInsuranceAgg;
namespace CompanyManagment.Application;
@@ -60,9 +59,8 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
private readonly IEmployeeClientTempRepository _employeeClientTempRepository;
private readonly ICustomizeWorkshopGroupSettingsRepository _customizeWorkshopGroupSettingsRepository;
private readonly IEmployeeAuthorizeTempRepository _employeeAuthorizeTempRepository;
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository ;
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context, IWorkshopRepository workShopRepository, IWebHostEnvironment webHostEnvironment, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallEmployeeRepository rollCallEmployeeRepository, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IEmployeeDocumentsApplication employeeDocumentsApplication, IEmployeeDocumentsRepository employeeDocumentsRepository, IEmployeeBankInformationApplication employeeBankInformationApplication, ILeftWorkTempRepository leftWorkTempRepository, IUidService uidService, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, IEmployeeClientTempRepository employeeClientTempRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository, ILeftWorkRepository leftWorkRepository, IEmployeeAuthorizeTempRepository employeeAuthorizeTempRepository, ILeftWorkInsuranceRepository leftWorkInsuranceRepository) : base(context)
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context, IWorkshopRepository workShopRepository, IWebHostEnvironment webHostEnvironment, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallEmployeeRepository rollCallEmployeeRepository, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IEmployeeDocumentsApplication employeeDocumentsApplication, IEmployeeDocumentsRepository employeeDocumentsRepository, IEmployeeBankInformationApplication employeeBankInformationApplication, ILeftWorkTempRepository leftWorkTempRepository, IUidService uidService, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, IEmployeeClientTempRepository employeeClientTempRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository, ILeftWorkRepository leftWorkRepository, IEmployeeAuthorizeTempRepository employeeAuthorizeTempRepository) : base(context)
{
_context = context;
_WorkShopRepository = workShopRepository;
@@ -79,7 +77,6 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
_employeeClientTempRepository = employeeClientTempRepository;
_leftWorkRepository = leftWorkRepository;
_employeeAuthorizeTempRepository = employeeAuthorizeTempRepository;
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
_EmployeeRepository = employeeRepository;
}
@@ -1012,9 +1009,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
var startLeftWork = command.StartLeftWork.ToGeorgianDateTime();
var leftWorkViewModel = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(command.WorkshopId, employee.id);
PersonnelCodeDomain personnelCode = null;
PersonnelCodeDomain personnelCode = null;
if (leftWorkViewModel != null)
{
if (leftWorkViewModel.HasLeft == false && leftWorkViewModel.LeftWorkDate > DateTime.Now)
@@ -1029,16 +1024,10 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
}
else
{
var insuranceLeftWork =
_leftWorkInsuranceRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(command.WorkshopId, employee.id);
if (insuranceLeftWork == null)
{
var lastPersonnelCodeByWorkshop =
_personnelCodeRepository.GetLastPersonnelCodeByWorkshop(command.WorkshopId);
var lastPersonnelCodeByWorkshop = _personnelCodeRepository.GetLastPersonnelCodeByWorkshop(command.WorkshopId);
personnelCode = new PersonnelCodeDomain(command.WorkshopId,
employee.id, lastPersonnelCodeByWorkshop + 1);
}
personnelCode = new PersonnelCodeDomain(command.WorkshopId,
employee.id, lastPersonnelCodeByWorkshop + 1);
}
var leftWorkTemp = LeftWorkTemp.CreateStartWork(command.WorkshopId, employee.id, startLeftWork, command.JobId);

View File

@@ -17,206 +17,204 @@ namespace CompanyManagment.Application;
public class RollCallEmployeeApplication : IRollCallEmployeeApplication
{
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
private readonly IEmployeeRepository _employeeRepository;
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository;
private readonly IWebHostEnvironment _webHostEnvironment;
public RollCallEmployeeApplication(IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, ILeftWorkRepository leftWorkRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, IWebHostEnvironment webHostEnvironment)
{
_rollCallEmployeeRepository = rollCallEmployeeRepository;
_employeeRepository = employeeRepository;
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
_leftWorkRepository = leftWorkRepository;
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
_webHostEnvironment = webHostEnvironment;
}
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
private readonly IEmployeeRepository _employeeRepository;
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository;
private readonly IWebHostEnvironment _webHostEnvironment;
public RollCallEmployeeApplication(IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, ILeftWorkRepository leftWorkRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, IWebHostEnvironment webHostEnvironment)
{
_rollCallEmployeeRepository = rollCallEmployeeRepository;
_employeeRepository = employeeRepository;
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
_leftWorkRepository = leftWorkRepository;
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
_webHostEnvironment = webHostEnvironment;
}
public OperationResult Create(CreateRollCallEmployee command)
{
var opreation = new OperationResult();
public OperationResult Create(CreateRollCallEmployee command)
{
var opreation = new OperationResult();
if (_rollCallEmployeeRepository.Exists(x =>
x.EmployeeId == command.EmployeeId && x.WorkshopId == command.EmployeeId))
return opreation.Succcedded();
var fullname = _employeeRepository.GetDetails(command.EmployeeId);
if (fullname == null)
return opreation.Failed("پرسنل یافت نشد");
if (_rollCallEmployeeRepository.Exists(x =>
x.EmployeeId == command.EmployeeId && x.WorkshopId == command.EmployeeId))
return opreation.Succcedded();
var fullname = _employeeRepository.GetDetails(command.EmployeeId);
if (fullname == null)
return opreation.Failed("پرسنل یافت نشد");
var create = new RollCallEmployee(command.WorkshopId, command.EmployeeId, fullname.FName, fullname.LName);
_rollCallEmployeeRepository.Create(create);
if (command.HasUploadedImage == "true")
create.HasImage();
if (command.HasUploadedImage == "true")
create.HasImage();
_rollCallEmployeeRepository.SaveChanges();
return opreation.Succcedded(create.id);
_rollCallEmployeeRepository.SaveChanges();
return opreation.Succcedded(create.id);
}
}
public OperationResult Active(long id)
{
var opreation = new OperationResult();
public OperationResult Active(long id)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.Get(id);
var emp = _rollCallEmployeeRepository.Get(id);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
if (!_leftWorkRepository.Exists(x => x.EmployeeId == emp.EmployeeId && x.WorkshopId == emp.WorkshopId &&
x.StartWorkDate <= DateTime.Now && x.LeftWorkDate > DateTime.Now))
return opreation.Failed("کارمند شروع به کار ندارد");
if (!_leftWorkRepository.Exists(x => x.EmployeeId == emp.EmployeeId && x.WorkshopId == emp.WorkshopId &&
x.StartWorkDate <= DateTime.Now && x.LeftWorkDate > DateTime.Now))
return opreation.Failed("کارمند شروع به کار ندارد");
if (emp.HasUploadedImage == "false")
return opreation.Failed("لطفا ابتدا عکس پرسنل را آپلود کنید");
if (emp.HasUploadedImage == "false")
return opreation.Failed("لطفا ابتدا عکس پرسنل را آپلود کنید");
using var transaction = new TransactionScope();
using var transaction = new TransactionScope();
emp.Active();
var operation2 = _rollCallEmployeeStatusApplication.Create(new CreateRollCallEmployeeStatus() { RollCallEmployeeId = id });
if (operation2.IsSuccedded == false)
return operation2;
var operation2 = _rollCallEmployeeStatusApplication.Create(new CreateRollCallEmployeeStatus() { RollCallEmployeeId = id });
if (operation2.IsSuccedded == false)
return operation2;
_rollCallEmployeeRepository.SaveChanges();
transaction.Complete();
return operation2;
}
}
public OperationResult DeActive(long id)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.GetWithRollCallStatus(id);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
var lastStatus = emp.EmployeesStatus.MaxBy(x => x.StartDate);
emp.DeActive();
_rollCallEmployeeRepository.SaveChanges();
_rollCallEmployeeStatusApplication.Deactivate(lastStatus.id);
return opreation.Succcedded();
}
public OperationResult DeActive(long id)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.GetWithRollCallStatus(id);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
var lastStatus = emp.EmployeesStatus.MaxBy(x => x.StartDate);
emp.DeActive();
_rollCallEmployeeRepository.SaveChanges();
_rollCallEmployeeStatusApplication.Deactivate(lastStatus.id);
return opreation.Succcedded();
}
public OperationResult UploadedImage(long Employeeid, long WorkshopId)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(Employeeid, WorkshopId);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
public OperationResult UploadedImage(long Employeeid, long WorkshopId)
{
var opreation = new OperationResult();
var emp = _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(Employeeid, WorkshopId);
if (emp == null)
return opreation.Failed("پرسنل یافت نشد");
var rollCall = _rollCallEmployeeRepository.Get(emp.Id);
rollCall.HasImage();
_rollCallEmployeeRepository.SaveChanges();
var path = Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", WorkshopId.ToString(), Employeeid.ToString());
var thumbnailPath = Path.Combine(path, "Thumbnail.jpg");
try
{
var thumbnail = Tools.ResizeImage(Path.Combine(path, "1.jpg"), 150, 150);
System.IO.File.WriteAllBytes(thumbnailPath, Convert.FromBase64String(thumbnail));
}
catch
{
// ignored
}
var rollCall = _rollCallEmployeeRepository.Get(emp.Id);
rollCall.HasImage();
_rollCallEmployeeRepository.SaveChanges();
var path = Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", WorkshopId.ToString(), Employeeid.ToString());
var thumbnailPath = Path.Combine(path, "Thumbnail.jpg");
try
{
var thumbnail = Tools.ResizeImage(Path.Combine(path, "1.jpg"), 150, 150);
System.IO.File.WriteAllBytes(thumbnailPath, Convert.FromBase64String(thumbnail));
}
catch
{
// ignored
}
return opreation.Succcedded();
}
return opreation.Succcedded();
}
public List<RollCallEmployeeViewModel> GetByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetByWorkshopId(workshopId);
}
public List<RollCallEmployeeViewModel> GetByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetByWorkshopId(workshopId);
}
public EditRollCallEmployee GetDetails(long id)
{
return _rollCallEmployeeRepository.GetDetails(id);
}
public EditRollCallEmployee GetDetails(long id)
{
return _rollCallEmployeeRepository.GetDetails(id);
}
public RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId)
{
return _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
}
public RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId)
{
return _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
}
public List<RollCallEmployeeViewModel> GetPersonnelRollCallListPaginate(RollCallEmployeeSearchModel command)
{
public List<RollCallEmployeeViewModel> GetPersonnelRollCallListPaginate(RollCallEmployeeSearchModel command)
{
return _rollCallEmployeeRepository.GetPersonnelRollCallListPaginate(command);
}
public int activedPerson(long workshopId)
{
return _rollCallEmployeeRepository.activedPerson(workshopId);
}
public int activedPerson(long workshopId)
{
return _rollCallEmployeeRepository.activedPerson(workshopId);
}
#region Pooya
public List<RollCallEmployeeViewModel> GetRollCallEmployeesByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetRollCallEmployeesByWorkshopId(workshopId);
}
public List<RollCallEmployeeViewModel> GetActivePersonnelByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetActivePersonnelByWorkshopId(workshopId);
}
#region Pooya
public List<RollCallEmployeeViewModel> GetRollCallEmployeesByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetRollCallEmployeesByWorkshopId(workshopId);
}
public List<RollCallEmployeeViewModel> GetActivePersonnelByWorkshopId(long workshopId)
{
return _rollCallEmployeeRepository.GetActivePersonnelByWorkshopId(workshopId);
}
public bool IsEmployeeRollCallActive(long employeeId, long workshopId)
{
RollCallEmployeeViewModel rollCallEmployee = _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
if (rollCallEmployee == null || rollCallEmployee.IsActiveString != "true" || rollCallEmployee.HasUploadedImage != "true")
return false;
var now = DateTime.Now;
return _rollCallEmployeeStatusRepository.Exists(x => x.RollCallEmployeeId == rollCallEmployee.Id && x.StartDate < now && x.EndDate > now);
public bool IsEmployeeRollCallActive(long employeeId, long workshopId)
{
RollCallEmployeeViewModel rollCallEmployee = _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
if (rollCallEmployee == null || rollCallEmployee.IsActiveString != "true" || rollCallEmployee.HasUploadedImage != "true")
return false;
var now = DateTime.Now;
return _rollCallEmployeeStatusRepository.Exists(x => x.RollCallEmployeeId == rollCallEmployee.Id && x.StartDate < now && x.EndDate > now);
}
public List<RollCallEmployeeViewModel> GetEmployeeRollCalls(long workshopId)
{
return _rollCallEmployeeRepository.GetEmployeeRollCalls(workshopId);
}
public (int activeEmployees, int deActiveEmployees) GetActiveAndDeActiveRollCallEmployees(long workshopId)
{
return _rollCallEmployeeRepository.GetActiveAndDeActiveRollCallEmployees(workshopId);
}
public List<RollCallEmployeeViewModel> GetPersonnelRollCallListAll(long workshopId)
{
return _rollCallEmployeeRepository.GetPersonnelRollCallListAll(workshopId);
}
public bool HasEmployees(long workshopId)
{
return _rollCallEmployeeRepository.HasEmployees(workshopId);
}
public OperationResult ChangeEmployeeRollCallName(long rollCallEmployeeId, string fName, string lName)
{
OperationResult result = new();
if (string.IsNullOrWhiteSpace(lName) || string.IsNullOrWhiteSpace(fName))
return result.Failed("نام و نام خانوادگی نمی توانند خالی باشند");
fName = fName.Trim();
lName = lName.Trim();
var fullName = $"{fName} {lName}";
var entity = _rollCallEmployeeRepository.Get(rollCallEmployeeId);
if (entity == null)
return result.Failed(ApplicationMessages.RecordNotFound);
}
if (_rollCallEmployeeRepository.Exists(x => x.WorkshopId == entity.WorkshopId && x.EmployeeFullName == fullName && x.id != rollCallEmployeeId))
return result.Failed("نام و نام خانوادگی کارمند نمی تواند با نام و نام خانوادگی کارمند دیگری در آن کارگاه یکسان باشد");
public List<RollCallEmployeeViewModel> GetEmployeeRollCalls(long workshopId)
{
return _rollCallEmployeeRepository.GetEmployeeRollCalls(workshopId);
}
public (int activeEmployees, int deActiveEmployees) GetActiveAndDeActiveRollCallEmployees(long workshopId)
{
return _rollCallEmployeeRepository.GetActiveAndDeActiveRollCallEmployees(workshopId);
}
public List<RollCallEmployeeViewModel> GetPersonnelRollCallListAll(long workshopId)
{
return _rollCallEmployeeRepository.GetPersonnelRollCallListAll(workshopId);
}
public bool HasEmployees(long workshopId)
{
return _rollCallEmployeeRepository.HasEmployees(workshopId);
}
public OperationResult ChangeEmployeeRollCallName(long rollCallEmployeeId, string fName, string lName)
{
OperationResult result = new();
if (string.IsNullOrWhiteSpace(lName) || string.IsNullOrWhiteSpace(fName))
return result.Failed("نام و نام خانوادگی نمی توانند خالی باشند");
fName = fName.Trim();
lName = lName.Trim();
var fullName = $"{fName} {lName}";
var entity = _rollCallEmployeeRepository.Get(rollCallEmployeeId);
if (entity.IsActiveString != "true")
return result.Failed("امکان تغییر نام برای کارمند غیر فعال وجود ندارد");
if (entity == null)
return result.Failed(ApplicationMessages.RecordNotFound);
if (_rollCallEmployeeRepository.Exists(x => x.WorkshopId == entity.WorkshopId && x.EmployeeFullName == fullName && x.id != rollCallEmployeeId))
return result.Failed("نام و نام خانوادگی کارمند نمی تواند با نام و نام خانوادگی کارمند دیگری در آن کارگاه یکسان باشد");
if (entity.IsActiveString != "true")
return result.Failed("امکان تغییر نام برای کارمند غیر فعال وجود ندارد");
entity.ChangeName(fName, lName);
_rollCallEmployeeRepository.SaveChanges();
return result.Succcedded();
}
entity.ChangeName(fName, lName);
_rollCallEmployeeRepository.SaveChanges();
return result.Succcedded();
}
#endregion
}

View File

@@ -134,38 +134,5 @@ namespace CompanyManagment.Application
{
return _employeeRollCallStatusRepository.GetAll();
}
public void SyncRollCallEmployeeWithLeftWork(long rollCallEmployeeId)
{
var rollCallEmployee = _rollCallEmployeeRepository.GetWithRollCallStatus(rollCallEmployeeId);
if (rollCallEmployee == null)
return;
var rollCallStatus = rollCallEmployee.EmployeesStatus.MaxBy(x => x.StartDate);
if (rollCallStatus == null)
return;
var today = DateTime.Today;
var firstDayOfMonth = today.FindFirstDayOfMonthGr();
var employeeId = rollCallEmployee.EmployeeId;
var workshopId = rollCallEmployee.WorkshopId;
var leftWork = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(workshopId, employeeId);
if (leftWork == null)
return;
var startWork = leftWork.StartWorkDate;
rollCallStatus.Edit(startWork < firstDayOfMonth ? firstDayOfMonth : startWork, rollCallStatus.EndDate);
_employeeRollCallStatusRepository.SaveChanges();
}
}
}
}

View File

@@ -10,340 +10,329 @@ using AccountMangement.Infrastructure.EFCore;
using Company.Domain.AdminMonthlyOverviewAgg;
using CompanyManagment.App.Contracts.AdminMonthlyOverview;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.EntityFrameworkCore;
using Tools = _0_Framework_b.Application.Tools;
namespace CompanyManagment.EFCore.Repository;
public class AdminMonthlyOverviewRepository : RepositoryBase<long, AdminMonthlyOverview>, IAdminMonthlyOverviewRepository
{
private readonly CompanyContext _companyContext;
private readonly AccountContext _accountContext;
public AdminMonthlyOverviewRepository(CompanyContext companyContext, AccountContext accountContext) : base(companyContext)
{
_companyContext = companyContext;
_accountContext = accountContext;
}
private readonly CompanyContext _companyContext;
private readonly AccountContext _accountContext;
public AdminMonthlyOverviewRepository(CompanyContext companyContext, AccountContext accountContext) : base(companyContext)
{
_companyContext = companyContext;
_accountContext = accountContext;
}
public async Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopStatus(AdminMonthlyOverviewSearchModel searchModel)
{
public async Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopStatus(AdminMonthlyOverviewSearchModel searchModel)
{
var year = searchModel.Year;
var month = searchModel.Month;
var accountId = searchModel.AdminAccountId;
// اگر تبدیل تاریخ به میلادی موفق نبود، لیست خالی برگردان
if ($"{year:0000}/{month:00}/01".TryToGeorgianDateTime(out var targetStartDate) == false)
return [];
var targetEndDate = Tools.FindeEndOfMonth(targetStartDate.ToFarsi()).ToGeorgianDateTime();
var year = searchModel.Year;
var month = searchModel.Month;
var accountId = searchModel.AdminAccountId;
// اگر تبدیل تاریخ به میلادی موفق نبود، لیست خالی برگردان
if ($"{year:0000}/{month:00}/01".TryToGeorgianDateTime(out var targetDate) == false)
return [];
_ = $"{year:0000}/{month:00}/01".ToGeorgianDateTime().AddMonthsFa(1, out var nextMonth);
// دریافت اطلاعات ادمین
var adminAccount = await _accountContext.Accounts.FirstOrDefaultAsync(x => x.id == searchModel.AdminAccountId);
// اگر ادمین پیدا نشد، لیست خالی برگردان
if (adminAccount == null)
return [];
// دریافت طرف حساب های معتبر برای تاریخ مورد نظر
var contractingPartyIds = _companyContext.InstitutionContractSet.AsNoTracking()
.Where(c => c.ContractStartGr <= targetDate && c.ContractEndGr >= targetDate)
.Select(c => c.ContractingPartyId);
// دریافت کارگاه‌های مرتبط با اکانت
var workshopAccounts = _companyContext.WorkshopAccounts
.AsNoTracking()
.Where(w => w.AccountId == accountId)
.Select(w => w.WorkshopId).ToList();
_ = $"{year:0000}/{month:00}/01".ToGeorgianDateTime().AddMonthsFa(1, out var nextFirstMonth);
var nextEndMonth = Tools.FindeEndOfMonth(nextFirstMonth.ToFarsi()).ToGeorgianDateTime();
// دریافت اطلاعات ادمین
var adminAccount = await _accountContext.Accounts.FirstOrDefaultAsync(x => x.id == searchModel.AdminAccountId);
// اگر ادمین پیدا نشد، لیست خالی برگردان
if (adminAccount == null)
return [];
// دریافت طرف حساب های معتبر برای تاریخ مورد نظر
var contractingPartyIds = _companyContext.InstitutionContractSet.AsNoTracking()
.Where(c => c.ContractStartGr <= targetEndDate && c.ContractEndGr >= targetStartDate)
.Select(c => c.ContractingPartyId);
// دریافت کارگاه‌های مرتبط با اکانت
var workshopAccounts = _companyContext.WorkshopAccounts
.AsNoTracking()
.Where(w => w.AccountId == accountId)
.Select(w => w.WorkshopId).ToList();
var workshopsHasLeftWorkEmployees = _companyContext.LeftWorkList.Where(x =>
((x.StartWorkDate <= targetEndDate && x.LeftWorkDate.AddDays(-1) >= targetStartDate)
|| (x.StartWorkDate <= nextEndMonth && x.LeftWorkDate.AddDays(-1) >= nextFirstMonth)) && workshopAccounts.Contains(x.WorkshopId)).Select(x => x.WorkshopId);
var workshopsHasLeftWorkEmployees = _companyContext.LeftWorkList.Where(x =>
((x.StartWorkDate <= targetDate && x.LeftWorkDate.AddDays(-1) >= targetDate)
|| (x.StartWorkDate <= nextMonth && x.LeftWorkDate.AddDays(-1) >= nextMonth)) && workshopAccounts.Contains(x.WorkshopId)).Select(x => x.WorkshopId);
// دریافت کارگاه‌های مربوط به طرف حساب و اکانت
// Replace the selected code with the following to return a list of anonymous objects containing both workshop and contractingParty
var workshopsWithContractingParty = await _companyContext.Workshops
.AsNoTracking()
.Where(w => workshopsHasLeftWorkEmployees.Contains(w.id) && w.IsActive)
.Include(w => w.WorkshopEmployers)
.ThenInclude(we => we.Employer)
.ThenInclude(e => e.ContractingParty).AsSplitQuery().
Where(w => w.WorkshopEmployers.Any(we =>
we.Employer != null &&
contractingPartyIds.Contains(we.Employer.ContractingPartyId)))
.Select(w => new
{
Workshop = w,
ContractingParty = w.WorkshopEmployers
.Where(we => we.Employer != null && contractingPartyIds.Contains(we.Employer.ContractingPartyId))
.Select(we => we.Employer.ContractingParty)
.FirstOrDefault()
})
.ToListAsync();
// دریافت کارگاه‌های مربوط به طرف حساب و اکانت
// Replace the selected code with the following to return a list of anonymous objects containing both workshop and contractingParty
var workshopsWithContractingParty = await _companyContext.Workshops
.AsNoTracking()
.Where(w => workshopsHasLeftWorkEmployees.Contains(w.id) && w.IsActive)
.Include(w => w.WorkshopEmployers)
.ThenInclude(we => we.Employer)
.ThenInclude(e => e.ContractingParty).AsSplitQuery().
Where(w => w.WorkshopEmployers.Any(we =>
we.Employer != null &&
contractingPartyIds.Contains(we.Employer.ContractingPartyId)))
.Select(w => new
{
Workshop = w,
ContractingParty = w.WorkshopEmployers
.Where(we => we.Employer != null && contractingPartyIds.Contains(we.Employer.ContractingPartyId))
.Select(we => we.Employer.ContractingParty)
.FirstOrDefault()
})
.ToListAsync();
var workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
var workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
// پیدا کردن کارگاه‌هایی که قبلاً برای این ماه/سال AdminMonthlyOverview دارند
var adminMonthlyOverviewWorkshopIds = await _companyContext.AdminMonthlyOverviews
.AsNoTracking()
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year)
.Select(x => x.WorkshopId)
.ToListAsync();
// پیدا کردن کارگاه‌هایی که قبلاً برای این ماه/سال AdminMonthlyOverview دارند
var adminMonthlyOverviewWorkshopIds = await _companyContext.AdminMonthlyOverviews
.AsNoTracking()
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year)
.Select(x => x.WorkshopId)
.ToListAsync();
// پیدا کردن کارگاه‌هایی که نیاز به ایجاد AdminMonthlyOverview جدید دارند
var notExistAdminMonthlyReviewsWorkshopIds = workshopIds
.Except(adminMonthlyOverviewWorkshopIds)
.ToList();
// پیدا کردن کارگاه‌هایی که نیاز به ایجاد AdminMonthlyOverview جدید دارند
var notExistAdminMonthlyReviewsWorkshopIds = workshopIds
.Except(adminMonthlyOverviewWorkshopIds)
.ToList();
// ایجاد رکوردهای AdminMonthlyOverview که وجود ندارند
if (notExistAdminMonthlyReviewsWorkshopIds.Any())
await CreateRangeAdminMonthlyOverview(notExistAdminMonthlyReviewsWorkshopIds, month, year);
// ایجاد رکوردهای AdminMonthlyOverview که وجود ندارند
if (notExistAdminMonthlyReviewsWorkshopIds.Any())
await CreateRangeAdminMonthlyOverview(notExistAdminMonthlyReviewsWorkshopIds, month, year);
// به‌روزرسانی وضعیت‌ها
await UpdateAdminMonthlyOverviewStatus(year, month, workshopIds, targetStartDate,targetEndDate, nextFirstMonth,nextEndMonth);
// به‌روزرسانی وضعیت‌ها
await UpdateAdminMonthlyOverviewStatus(year, month, workshopIds, targetDate, nextMonth);
if (searchModel.ActivationStatus != IsActive.None)
{
var isBlock = searchModel.ActivationStatus == IsActive.True ? "false" : "true";
if (searchModel.ActivationStatus != IsActive.None)
{
var isBlock = searchModel.ActivationStatus == IsActive.True ? "false" : "true";
workshopsWithContractingParty = workshopsWithContractingParty
.Where(x => x.ContractingParty?.IsBlock == isBlock).ToList();
workshopsWithContractingParty = workshopsWithContractingParty
.Where(x => x.ContractingParty?.IsBlock == isBlock).ToList();
workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
}
workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
}
// دریافت همه AdminMonthlyOverview برای این کارگاه‌ها/ماه/سال
var adminMonthlyOverviewsQuery = _companyContext.AdminMonthlyOverviews
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year);
// دریافت همه AdminMonthlyOverview برای این کارگاه‌ها/ماه/سال
var adminMonthlyOverviewsQuery = _companyContext.AdminMonthlyOverviews
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year);
if (searchModel.WorkshopId > 0)
{
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => x.WorkshopId == searchModel.WorkshopId);
}
if (searchModel.WorkshopId > 0)
{
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => x.WorkshopId == searchModel.WorkshopId);
}
if (searchModel.EmployerId > 0)
{
var searchWorkshopId = workshopsWithContractingParty.Where(x => x.Workshop.WorkshopEmployers.Any(e => e.EmployerId == searchModel.EmployerId)).Select(x => x.Workshop.id).ToList();
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => searchWorkshopId.Contains(x.WorkshopId));
}
if (searchModel.EmployerId > 0)
{
var searchWorkshopId = workshopsWithContractingParty.Where(x => x.Workshop.WorkshopEmployers.Any(e => e.EmployerId == searchModel.EmployerId)).Select(x => x.Workshop.id).ToList();
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => searchWorkshopId.Contains(x.WorkshopId));
}
var employeeCheckoutCounts = _companyContext.LeftWorkList.Where(x =>
x.StartWorkDate <= targetStartDate && x.LeftWorkDate.AddDays(-1) >= targetStartDate && workshopIds.Contains(x.WorkshopId))
.GroupBy(x => x.WorkshopId).Select(x => new { EmployeeCounts = x.Count(), WorkshopId = x.Key }).ToList();
var employeeCheckoutCounts = _companyContext.LeftWorkList.Where(x =>
x.StartWorkDate <= targetDate && x.LeftWorkDate.AddDays(-1) >= targetDate && workshopIds.Contains(x.WorkshopId))
.GroupBy(x => x.WorkshopId).Select(x => new { EmployeeCounts = x.Count(), WorkshopId = x.Key }).ToList();
var employeeContractCounts = _companyContext.LeftWorkList.Where(x =>
x.StartWorkDate <= nextFirstMonth && x.LeftWorkDate.AddDays(-1) >= nextFirstMonth && workshopIds.Contains(x.WorkshopId))
.GroupBy(x => x.WorkshopId).Select(x => new { EmployeeCounts = x.Count(), WorkshopId = x.Key }).ToList();
var employeeContractCounts = _companyContext.LeftWorkList.Where(x =>
x.StartWorkDate <= nextMonth && x.LeftWorkDate.AddDays(-1) >= nextMonth && workshopIds.Contains(x.WorkshopId))
.GroupBy(x => x.WorkshopId).Select(x => new { EmployeeCounts = x.Count(), WorkshopId = x.Key }).ToList();
var adminMonthlyOverviewsList = await adminMonthlyOverviewsQuery.ToListAsync();
var adminMonthlyOverviewsList = await adminMonthlyOverviewsQuery.ToListAsync();
var now = DateTime.Today;
//پرسنل ادمین اجرایی
var operatorAdminAccounts = _accountContext.AccountLeftWorks
.Where(x => workshopIds.Contains(x.WorkshopId) && x.StartWorkGr <= now && x.LeftWorkGr >= now &&
x.RoleId == 5).Select(x => new { x.WorkshopId, x.AccountId })
.Join(_accountContext.Accounts,
x => x.AccountId,
account => account.id, (x, account) => new
{
x.WorkshopId,
account.Fullname
}).ToList();
var now = DateTime.Today;
//پرسنل ادمین اجرایی
var operatorAdminAccounts = _accountContext.AccountLeftWorks
.Where(x => workshopIds.Contains(x.WorkshopId) && x.StartWorkGr <= now && x.LeftWorkGr >= now &&
x.RoleId == 5).Select(x => new { x.WorkshopId, x.AccountId })
.Join(_accountContext.Accounts,
x =>x.AccountId,
account=>account.id,(x, account) => new
{
x.WorkshopId,
account.Fullname
}).ToList();
var adminMonthlyOverviewList = adminMonthlyOverviewsList.Select(x =>
{
var employeeCheckoutCount = employeeCheckoutCounts.FirstOrDefault(e => e.WorkshopId == x.WorkshopId);
var employeeContractCount = employeeContractCounts.FirstOrDefault(e => e.WorkshopId == x.WorkshopId);
var workshopWithContractingParty =
workshopsWithContractingParty.FirstOrDefault(w => w.Workshop.id == x.WorkshopId);
var adminMonthlyOverviewList = adminMonthlyOverviewsList.Select(x =>
{
var employeeCheckoutCount = employeeCheckoutCounts.FirstOrDefault(e => e.WorkshopId == x.WorkshopId);
var employeeContractCount = employeeContractCounts.FirstOrDefault(e => e.WorkshopId == x.WorkshopId);
var workshopWithContractingParty =
workshopsWithContractingParty.FirstOrDefault(w => w.Workshop.id == x.WorkshopId);
var operatorAccount = operatorAdminAccounts.FirstOrDefault(o => o.WorkshopId == x.WorkshopId);
var operatorAccount = operatorAdminAccounts.FirstOrDefault(o => o.WorkshopId == x.WorkshopId);
var workshop = workshopWithContractingParty?.Workshop;
var contractingParty = workshopWithContractingParty?.ContractingParty;
var employer = workshop?.WorkshopEmployers.FirstOrDefault()?.Employer;
return new AdminMonthlyOverviewListViewModel
{
WorkshopId = x.WorkshopId,
Status = x.Status,
Id = x.id,
WorkshopName = workshop?.WorkshopFullName ?? "",
WorkshopArchiveCode = workshop?.ArchiveCode ?? "",
WorkshopArchiveCodeInt = workshop?.ArchiveCode.ExtractIntNumbers() ?? 0,
Address = workshop?.Address ?? "",
City = workshop?.City ?? "",
Province = workshop?.State ?? "",
EmployerName = employer?.FullName ?? "",
EmployerPhoneNumber = employer?.Phone ?? "",
AdminFullName = operatorAccount?.Fullname ?? "",
CheckoutEmployeeCount = employeeCheckoutCount?.EmployeeCounts ?? 0,
ContractEmployeeCount = employeeContractCount?.EmployeeCounts ?? 0,
AgentPhoneNumber = "",
IsBlock = contractingParty?.IsBlock == "true"
};
}).OrderBy(x => x.IsBlock).ThenBy(x => x.WorkshopArchiveCodeInt).ToList();
var workshop = workshopWithContractingParty?.Workshop;
var contractingParty = workshopWithContractingParty?.ContractingParty;
var employer = workshop?.WorkshopEmployers.FirstOrDefault()?.Employer;
return new AdminMonthlyOverviewListViewModel
{
WorkshopId = x.WorkshopId,
Status = x.Status,
Id = x.id,
WorkshopName = workshop?.WorkshopFullName ?? "",
WorkshopArchiveCode = workshop?.ArchiveCode ?? "",
WorkshopArchiveCodeInt = workshop?.ArchiveCode.ExtractIntNumbers() ?? 0,
Address = workshop?.Address ?? "",
City = workshop?.City ?? "",
Province = workshop?.State ?? "",
EmployerName = employer?.FullName ?? "",
EmployerPhoneNumber = employer?.Phone ?? "",
AdminFullName = operatorAccount?.Fullname??"",
CheckoutEmployeeCount = employeeCheckoutCount?.EmployeeCounts ?? 0,
ContractEmployeeCount = employeeContractCount?.EmployeeCounts ?? 0,
AgentPhoneNumber = "",
IsBlock = contractingParty?.IsBlock == "true"
};
}).OrderBy(x => x.IsBlock).ThenBy(x => x.WorkshopArchiveCodeInt).ToList();
return adminMonthlyOverviewList;
}
return adminMonthlyOverviewList;
}
public async Task<AdminMonthlyOverViewCounterVm> GetCounter(int year, int month, long accountId)
{
var searchModel = new AdminMonthlyOverviewSearchModel()
{
AdminAccountId = accountId,
Month = month,
Year = year
};
var list = await GetWorkshopStatus(searchModel);
public async Task<AdminMonthlyOverViewCounterVm> GetCounter(int year, int month, long accountId)
{
var searchModel = new AdminMonthlyOverviewSearchModel()
{
AdminAccountId = accountId,
Month = month,
Year = year
};
var list = await GetWorkshopStatus(searchModel);
var allCount = list.Count;
var archivedCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.Archived);
var createDocCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.CreateDocuments);
var visitCompleteCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitCompleted);
var visitInProgressCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitInProgress);
var visitPendingCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitPending);
var allCount = list.Count;
var archivedCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.Archived);
var createDocCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.CreateDocuments);
var visitCompleteCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitCompleted);
var visitInProgressCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitInProgress);
var visitPendingCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitPending);
return new AdminMonthlyOverViewCounterVm
{
All = allCount,
Archived = archivedCount,
VisitPending = visitPendingCount,
VisitInProgress = visitInProgressCount,
VisitCompleted = visitCompleteCount,
CreateDocument = createDocCount
return new AdminMonthlyOverViewCounterVm
{
All = allCount,
Archived = archivedCount,
VisitPending = visitPendingCount,
VisitInProgress = visitInProgressCount,
VisitCompleted = visitCompleteCount,
CreateDocument = createDocCount
};
};
}
}
private async Task UpdateAdminMonthlyOverviewStatus(int year, int month, List<long> workshopIds, DateTime targetStartDate,DateTime targetEndDate, DateTime nextStartMonth,DateTime nextEndMonth)
{
var vipGroup = _companyContext.CustomizeWorkshopEmployeeSettings.Where(x => x.CustomizeWorkshopGroupSettingId == 117)
.Select(x => x.EmployeeId)
.Except([5976]).ToList();
private async Task UpdateAdminMonthlyOverviewStatus(int year, int month, List<long> workshopIds, DateTime targetDate, DateTime nextMonth)
{
var vipGroup = _companyContext.CustomizeWorkshopEmployeeSettings.Where(x => x.CustomizeWorkshopGroupSettingId == 117)
.Select(x => x.EmployeeId)
.Except([5976]).ToList();
var workingCheckoutEmployeeIds = _companyContext.LeftWorkList.AsNoTracking()
.Join(
_companyContext.Contracts.AsNoTracking(),
leftWork => new { leftWork.EmployeeId, WorkshopId = leftWork.WorkshopId },
contract => new { contract.EmployeeId, WorkshopId = contract.WorkshopIds },
(leftWork, contract) => new { leftWork, contract }
)
.Where(x =>
workshopIds.Contains(x.leftWork.WorkshopId) &&
x.leftWork.StartWorkDate <= targetEndDate &&
x.leftWork.LeftWorkDate.AddDays(-1) >= targetStartDate &&
x.contract.ContarctStart <= targetEndDate &&
x.contract.ContractEnd >= targetStartDate &&
!vipGroup.Contains(x.leftWork.EmployeeId) &&
!_companyContext.EmployeeClientTemps
.Any(temp => temp.EmployeeId == x.leftWork.EmployeeId && temp.WorkshopId == x.leftWork.WorkshopId)
)
.Select(x => new { x.leftWork.WorkshopId, x.leftWork.EmployeeId });
var workingCheckoutEmployeeIds = _companyContext.LeftWorkList.AsNoTracking()
.Join(
_companyContext.Contracts.AsNoTracking(),
leftWork => new { leftWork.EmployeeId, WorkshopId = leftWork.WorkshopId },
contract => new { contract.EmployeeId, WorkshopId = contract.WorkshopIds },
(leftWork, contract) => new { leftWork, contract }
)
.Where(x =>
workshopIds.Contains(x.leftWork.WorkshopId) &&
x.leftWork.StartWorkDate <= targetDate &&
x.leftWork.LeftWorkDate.AddDays(-1) >= targetDate &&
x.contract.ContarctStart <= targetDate &&
x.contract.ContractEnd >= targetDate
&& !vipGroup.Contains(x.leftWork.EmployeeId)
)
.Select(x => new { x.leftWork.WorkshopId, x.leftWork.EmployeeId });
var workingContractEmployeeIds = _companyContext.LeftWorkList.AsNoTracking()
.Where(x => workshopIds.Contains(x.WorkshopId) && x.StartWorkDate <= nextEndMonth && x.LeftWorkDate.AddDays(-1) >= nextStartMonth &&
!vipGroup.Contains(x.EmployeeId) &&
!_companyContext.EmployeeClientTemps
.Any(temp => temp.EmployeeId == x.EmployeeId && temp.WorkshopId == x.WorkshopId)
).Select(x => new { x.WorkshopId, x.EmployeeId });
.Where(x => workshopIds.Contains(x.WorkshopId) && x.StartWorkDate <= nextMonth && x.LeftWorkDate.AddDays(-1) >= nextMonth
&& !vipGroup.Contains(x.EmployeeId))
.Select(x => new { x.WorkshopId, x.EmployeeId });
var contractSet = (await _companyContext.Contracts.AsNoTracking()
.Where(x => x.ContarctStart <= nextEndMonth && x.ContractEnd >= nextStartMonth && workshopIds.Contains(x.WorkshopIds))
.Select(x => new { x.WorkshopIds, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopIds, x.EmployeeId))
.ToHashSet();
var contractSet = (await _companyContext.Contracts.AsNoTracking()
.Where(x => x.ContarctStart <= nextMonth && x.ContractEnd >= nextMonth && workshopIds.Contains(x.WorkshopIds))
.Select(x => new { x.WorkshopIds, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopIds, x.EmployeeId))
.ToHashSet();
var checkoutSet = (await _companyContext.CheckoutSet.AsNoTracking()
.Where(x => x.ContractStart <= targetEndDate && x.ContractEnd >= targetStartDate && workshopIds.Contains(x.WorkshopId))
.Select(x => new { x.WorkshopId, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopId, x.EmployeeId))
.ToHashSet();
var checkoutSet = (await _companyContext.CheckoutSet.AsNoTracking()
.Where(x => x.ContractStart <= targetDate && x.ContractEnd >= targetDate && workshopIds.Contains(x.WorkshopId))
.Select(x => new { x.WorkshopId, x.EmployeeId })
.ToListAsync())
.Select(x => (x.WorkshopId, x.EmployeeId))
.ToHashSet();
var workingCheckoutGrouping = workingCheckoutEmployeeIds.GroupBy(x => x.WorkshopId).ToList();
var workingCheckoutGrouping = workingCheckoutEmployeeIds.GroupBy(x => x.WorkshopId).ToList();
var workingContractGrouping = workingContractEmployeeIds.GroupBy(x => x.WorkshopId).Select(x => new
{
WorkshopId = x.Key,
Data = x.ToList()
}).ToList();
var workingContractGrouping = workingContractEmployeeIds.GroupBy(x => x.WorkshopId).Select(x => new
{
WorkshopId = x.Key,
Data = x.ToList()
}).ToList();
var workshopsWithFullContracts = workingContractGrouping
.Where(g => g.Data.All(emp => contractSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.WorkshopId)
.ToList();
var workshopsWithFullContracts = workingContractGrouping
.Where(g => g.Data.All(emp => contractSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.WorkshopId)
.ToList();
var list = workingContractEmployeeIds.ToList().Where(x=>!contractSet.Any(a=>a.EmployeeId== x.EmployeeId&&a.WorkshopIds == x.WorkshopId)).ToList();
var workshopsWithFullCheckout = workingCheckoutGrouping
.Where(g => g.All(emp => checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.Key)
.ToList();
var workshopsWithFullCheckout = workingCheckoutGrouping
.Where(g => g.All(emp => checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
.Select(g => g.Key)
.ToList();
var fullyCoveredWorkshops = workshopsWithFullContracts.Intersect(workshopsWithFullCheckout).ToList();
var fullyCoveredWorkshops = workshopsWithFullContracts.Intersect(workshopsWithFullCheckout).ToList();
//var notFullyCoveredWorkshops = groupedCheckout
// .Where(g => g.Any(emp =>
// !contractSet.Contains((emp.WorkshopId, emp.EmployeeId)) ||
// !checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
// .Select(g => g.Key)
// .ToList();
//var notFullyCoveredWorkshops = groupedCheckout
// .Where(g => g.Any(emp =>
// !contractSet.Contains((emp.WorkshopId, emp.EmployeeId)) ||
// !checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
// .Select(g => g.Key)
// .ToList();
var notFullyCoveredWorkshops = workshopIds.Except(fullyCoveredWorkshops);
var notFullyCoveredWorkshops = workshopIds.Except(fullyCoveredWorkshops);
var adminMonthlyOverviews = _companyContext.AdminMonthlyOverviews
.Where(x => x.Month == month && x.Year == year);
var adminMonthlyOverviews = _companyContext.AdminMonthlyOverviews
.Where(x => x.Month == month && x.Year == year);
var adminMonthlyOverviewsWithFullContracts = await adminMonthlyOverviews
.Where(x => fullyCoveredWorkshops.Contains(x.WorkshopId) && x.Status == AdminMonthlyOverviewStatus.CreateDocuments)
.ToListAsync();
var adminMonthlyOverviewsWithFullContracts = await adminMonthlyOverviews
.Where(x => fullyCoveredWorkshops.Contains(x.WorkshopId) && x.Status == AdminMonthlyOverviewStatus.CreateDocuments)
.ToListAsync();
var adminMonthlyOverviewsWithNotFullContracts = await adminMonthlyOverviews
.Where(x => notFullyCoveredWorkshops.Contains(x.WorkshopId) && x.Status != AdminMonthlyOverviewStatus.CreateDocuments)
.ToListAsync();
var adminMonthlyOverviewsWithNotFullContracts = await adminMonthlyOverviews
.Where(x => notFullyCoveredWorkshops.Contains(x.WorkshopId) && x.Status != AdminMonthlyOverviewStatus.CreateDocuments)
.ToListAsync();
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.VisitPending);
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.VisitPending);
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithNotFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.CreateDocuments);
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithNotFullContracts)
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.CreateDocuments);
await _companyContext.SaveChangesAsync();
}
await _companyContext.SaveChangesAsync();
}
private async Task CreateRangeAdminMonthlyOverview(List<long> workshopIds, int month, int year)
{
foreach (var workshopId in workshopIds)
{
var adminMonthlyOverview =
new AdminMonthlyOverview(workshopId, month, year, AdminMonthlyOverviewStatus.CreateDocuments);
await _companyContext.AddAsync(adminMonthlyOverview);
}
private async Task CreateRangeAdminMonthlyOverview(List<long> workshopIds, int month, int year)
{
foreach (var workshopId in workshopIds)
{
var adminMonthlyOverview =
new AdminMonthlyOverview(workshopId, month, year, AdminMonthlyOverviewStatus.CreateDocuments);
await _companyContext.AddAsync(adminMonthlyOverview);
}
await _companyContext.SaveChangesAsync();
}
await _companyContext.SaveChangesAsync();
}
}

View File

@@ -1173,17 +1173,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
//RequiredDocuments = requiredDocs
};
}).ToList();
result.ForEach(x =>
{
x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath);
x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath);
x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath);
x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath);
x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath);
x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath);
x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath);
x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath);
});
return result;
}
@@ -1204,7 +1194,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
.GroupBy(x => x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel()
{
WorkshopId = x.Key,
WorkshopFullName = x.FirstOrDefault().Workshop.WorkshopFullName,
WorkshopFullName = x.FirstOrDefault().Workshop.WorkshopName,
EmployeesWithoutDocumentCount = x.Count()
});
@@ -1311,19 +1301,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
};
}).ToList();
result.ForEach(x =>
{
x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath);
x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath);
x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath);
x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath);
x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath);
x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath);
x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath);
x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath);
});
return result;
return result;
}
public async Task<List<WorkshopWithEmployeeDocumentsViewModel>> GetClientRejectedDocumentWorkshopsForAdmin(List<long> workshops, long roleId)
@@ -1485,19 +1463,9 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
//RequiredDocuments = requiredDocs
};
}).ToList();
result.ForEach(x =>
{
x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath);
x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath);
x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath);
x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath);
x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath);
x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath);
x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath);
x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath);
});
return result;
return result;
}
public async Task<List<EmployeeDocumentsViewModel>> GetClientRejectedDocumentForClient(long workshopId, long accountId)
@@ -1600,18 +1568,8 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
//RequiredDocuments = requiredDocs
};
}).ToList();
result.ForEach(x =>
{
x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath);
x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath);
x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath);
x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath);
x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath);
x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath);
x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath);
x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath);
});
return result;
return result;
}
//ToDo آپلود مدارک و افزودن پرسنل
@@ -1688,12 +1646,8 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
};
}
private static string GetThumbnailPathFromFilePath(string filePath)
{
return string.IsNullOrWhiteSpace(filePath) ? string.Empty : Path.Combine(Path.GetDirectoryName(filePath)!, Path.GetFileNameWithoutExtension(filePath) + $"-thumbnail{Path.GetExtension(filePath)}");
}
private static EmployeeDocumentItemViewModel GetByLabelAndLoadMedia(List<EmployeeDocumentItemViewModel> items,
private static EmployeeDocumentItemViewModel GetByLabelAndLoadMedia(List<EmployeeDocumentItemViewModel> items,
List<MediaViewModel> medias, DocumentItemLabel label)
{
if (items == null || items.Count == 0)

View File

@@ -796,11 +796,5 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
return insuranceLeftWorkWithContractExitOnly.ToList();
}
public LeftWorkInsurance GetLastLeftWorkByEmployeeIdAndWorkshopId(long workshopId, long employeeId)
{
return _context.LeftWorkInsuranceList.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
.OrderByDescending(x => x.StartWorkDate).FirstOrDefault();
}
#endregion
}

View File

@@ -654,10 +654,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
var vipGroup = _context.CustomizeWorkshopEmployeeSettings.Where(x => x.CustomizeWorkshopGroupSettingId == 117)
.Select(x => x.EmployeeId)
.Except([5976]).ToList();
var clientTemps = _context.EmployeeClientTemps.Where(x => x.WorkshopId == searchModel.WorkshopId)
.Select(x => x.EmployeeId);
var query = _context.LeftWorkList.Select(x => new LeftWorkViewModel()
var query = _context.LeftWorkList.Select(x => new LeftWorkViewModel()
{
Id = x.id,
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
@@ -675,7 +672,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
JobName = _context.Jobs.FirstOrDefault(j => j.id == x.JobId).JobName
}).Where(x=> !vipGroup.Contains(x.EmployeeId) && !clientTemps.Contains(x.EmployeeId));
}).Where(x=> !vipGroup.Contains(x.EmployeeId));
if (searchModel.WorkshopId != 0 && searchModel.EmployeeId != 0)
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
if (searchModel.EmployeeId != 0 && searchModel.WorkshopId == 0)

View File

@@ -33,7 +33,6 @@ using CompanyManagment.App.Contracts.Reward.Enums;
using static System.Runtime.InteropServices.JavaScript.JSType;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
using Company.Domain.HolidayItemAgg;
using Company.Domain.RollCallEmployeeAgg;
using PersianTools.Core;
@@ -50,7 +49,6 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
private readonly TestDbContext _testDbContext;
public RollCallMandatoryRepository(CompanyContext context, IYearlySalaryRepository yearlySalaryRepository,
ILeftWorkRepository leftWorkRepository, ILeaveRepository leaveRepository, IHolidayItemRepository holidayItemRepository, TestDbContext testDbContext) : base(context)
{
@@ -60,7 +58,6 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
_leaveRepository = leaveRepository;
_holidayItemRepository = holidayItemRepository;
_testDbContext = testDbContext;
}
#region OfficialChckout
@@ -108,8 +105,8 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
.Include(x => x.CustomizeWorkshopGroupSettings).FirstOrDefault(x =>
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
//اگر ساعت استراحت پرسنل وجود نداشت صفر است
var breakTimeEntity = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime;
var endOfFarvardin = "1404/01/31".ToGeorgianDateTime();
var breakTime = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime;
#endregion
@@ -145,31 +142,16 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
BreakTimeSpan = x.BreakTimeSpan
}).ToList();
groupedRollCall = rollCallResult.GroupBy(x => x.CreationDate.Date).Select(x =>
groupedRollCall = rollCallResult.GroupBy(x => x.CreationDate.Date).Select(x => new GroupedRollCalls()
{
TimeSpan breakTime;
if (contractStart > endOfFarvardin)
{
breakTime = CalculateBreakTime(
x.First().BreakTimeSpan,
new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)));
}
else
{
breakTime = CalculateBreakTime(breakTimeEntity, new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)));
}
return new GroupedRollCalls()
{
CreationDate = x.Key,
ShiftList = x.Select(s => new ShiftList() { Start = s.StartDate!.Value, End = s.EndDate!.Value })
.ToList(),
HasFriday = x.Any(s =>
s.StartDate != null && s.EndDate != null && (s.StartDate.Value.DayOfWeek == DayOfWeek.Friday ||
s.EndDate.Value!.DayOfWeek == DayOfWeek.Friday)),
SumOneDaySpan = new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)) - breakTime,
CreationDate = x.Key,
ShiftList = x.Select(s => new ShiftList() { Start = s.StartDate!.Value, End = s.EndDate!.Value }).ToList(),
HasFriday = x.Any(s => s.StartDate != null && s.EndDate != null && (s.StartDate.Value.DayOfWeek == DayOfWeek.Friday || s.EndDate.Value!.DayOfWeek == DayOfWeek.Friday)),
SumOneDaySpan = new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)) - CalculateBreakTime(x.First().BreakTimeSpan,
new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))),
BreakTime = CalculateBreakTime(x.First().BreakTimeSpan, new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))),
BreakTime = breakTime,
};
}).OrderBy(x => x.CreationDate).ToList();
}
@@ -742,55 +724,6 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
return res;
}
/// <summary>
/// محاسبه ساعات کارکرد پرسنل در صورت داشتن حضور غیاب
/// </summary>
/// <param name="employeeId"></param>
/// <param name="workshopId"></param>
/// <param name="contractStart"></param>
/// <param name="contractEnd"></param>
/// <returns></returns>
public (bool hasRollCall, TimeSpan sumOfSpan) GetRollCallWorkingSpan(long employeeId, long workshopId,
DateTime contractStart, DateTime contractEnd)
{
//bool hasRollcall =
// _rollCallEmployeeRepository.HasRollCallRecord(employeeId, workshopId, contractStart, contractEnd);
//if (!hasRollcall)
// return (false, new TimeSpan());
List<RollCallViewModel> rollCallResult;
List<GroupedRollCalls> groupedRollCall;
rollCallResult = _context.RollCalls.Where(x =>
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date &&
x.StartDate.Value.Date <= contractEnd.Date && x.EndDate != null).Select(x => new RollCallViewModel()
{
StartDate = x.StartDate,
EndDate = x.EndDate,
ShiftSpan = (x.EndDate.Value - x.StartDate.Value),
CreationDate = x.ShiftDate,
BreakTimeSpan = x.BreakTimeSpan
}).ToList();
groupedRollCall = rollCallResult.GroupBy(x => x.CreationDate.Date).Select(x => new GroupedRollCalls()
{
CreationDate = x.Key,
ShiftList = x.Select(s => new ShiftList() { Start = s.StartDate!.Value, End = s.EndDate!.Value }).ToList(),
HasFriday = x.Any(s => s.StartDate != null && s.EndDate != null && (s.StartDate.Value.DayOfWeek == DayOfWeek.Friday || s.EndDate.Value!.DayOfWeek == DayOfWeek.Friday)),
SumOneDaySpan = new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)) - CalculateBreakTime(x.First().BreakTimeSpan,
new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))),
BreakTime = CalculateBreakTime(x.First().BreakTimeSpan, new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))),
}).OrderBy(x => x.CreationDate).ToList();
TimeSpan sumSpans = new TimeSpan(groupedRollCall.Sum(x => x.SumOneDaySpan.Ticks));
return (true, sumSpans);
}
public async Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart, DateTime contractEnd, string shiftwork, bool hasRollCall, CreateWorkingHoursTemp command, bool holidayWorking)
{
List<RollCallViewModel> rollCallResult = new List<RollCallViewModel>();
@@ -954,19 +887,19 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
public static TimeSpan CalculateBreakTime(BreakTime breakTime, TimeSpan sumOneDaySpan)
{
if (breakTime.BreakTimeType != BreakTimeType.WithTime)
return new TimeSpan();
//public static TimeSpan CalculateBreakTime(BreakTime breakTime, TimeSpan sumOneDaySpan)
//{
// if (breakTime.BreakTimeType != BreakTimeType.WithTime)
// return new TimeSpan();
var breakTimeSpan = breakTime.BreakTimeValue.ToTimeSpan();
// var breakTimeSpan = breakTime.BreakTimeValue.ToTimeSpan();
if (breakTimeSpan * 2 >= sumOneDaySpan)
return new TimeSpan();
// if (breakTimeSpan * 2 >= sumOneDaySpan)
// return new TimeSpan();
return breakTimeSpan; ;
// return breakTimeSpan; ;
}
//}
public static TimeSpan CalculateBreakTime(TimeSpan breakTimeSpan, TimeSpan sumOneDaySpan)
{
if (breakTimeSpan * 2 >= sumOneDaySpan)
@@ -2105,7 +2038,7 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
var starTimeSingel1 = Convert.ToDateTime(shift1Start);
var endTimeSingel2 = Convert.ToDateTime(shift1End);
bool hasRestTime = false;
bool hasRestTime = false;
shift1StartGr = new DateTime(cuurentDate.Year, cuurentDate.Month, cuurentDate.Day, starTimeSingel1.Hour, starTimeSingel1.Minute, 0);
@@ -2114,92 +2047,92 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
if (shift1EndGr.TimeOfDay < shift1StartGr.TimeOfDay)
shift1EndGr = shift1EndGr.AddDays(1);
var shiftEndWithoutRest = shift1EndGr;
var shiftEndWithoutRest = shift1EndGr;
var shiftSpan = (shift1EndGr - shift1StartGr);
if (restTime > TimeSpan.Zero && shiftSpan >= restTime)
{
hasRestTime = true;
shift1EndGr = shift1EndGr.Subtract(restTime);
shiftSpan = (shift1EndGr - shift1StartGr);
var shiftSpan = (shift1EndGr - shift1StartGr);
if (restTime > TimeSpan.Zero && shiftSpan >= restTime)
{
hasRestTime = true;
shift1EndGr = shift1EndGr.Subtract(restTime);
shiftSpan = (shift1EndGr - shift1StartGr);
}
}
if (!leaveSearchResult.Any(x => x.StartLeaveGr < shift1EndGr && x.EndLeaveGr > shift1StartGr && x.PaidLeaveType == "روزانه"))
{
var hourseLeaveTypeResult = leaveSearchResult.FirstOrDefault(x =>
x.StartLeaveGr < shift1EndGr && x.EndLeaveGr > shift1StartGr && x.PaidLeaveType == "ساعتی");
if (hourseLeaveTypeResult == null)
{
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = shift1StartGr,
EndDate = shift1EndGr,
ShiftSpan = shiftSpan,
ShiftDate = shift1StartGr,
if (!leaveSearchResult.Any(x => x.StartLeaveGr < shift1EndGr && x.EndLeaveGr > shift1StartGr && x.PaidLeaveType =="روزانه"))
{
var hourseLeaveTypeResult = leaveSearchResult.FirstOrDefault(x =>
x.StartLeaveGr < shift1EndGr && x.EndLeaveGr > shift1StartGr && x.PaidLeaveType == "ساعتی");
if (hourseLeaveTypeResult == null)
{
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = shift1StartGr,
EndDate = shift1EndGr,
ShiftSpan = shiftSpan,
ShiftDate = shift1StartGr,
ShiftEndWithoutRest = shiftEndWithoutRest
});
}
else
{
});
}
else
{
if (hourseLeaveTypeResult.StartLeaveGr <= shift1StartGr && hourseLeaveTypeResult.EndLeaveGr < shift1EndGr)
{
//leave <-------------------->
//shift <---------------------------------->
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = hourseLeaveTypeResult.EndLeaveGr,
EndDate = shift1EndGr,
ShiftSpan = (shift1EndGr - hourseLeaveTypeResult.EndLeaveGr),
ShiftDate = shift1StartGr,
ShiftEndWithoutRest = shiftEndWithoutRest
if (hourseLeaveTypeResult.StartLeaveGr <= shift1StartGr && hourseLeaveTypeResult.EndLeaveGr < shift1EndGr)
{
//leave <-------------------->
//shift <---------------------------------->
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = hourseLeaveTypeResult.EndLeaveGr,
EndDate = shift1EndGr,
ShiftSpan = (shift1EndGr - hourseLeaveTypeResult.EndLeaveGr),
ShiftDate = shift1StartGr,
ShiftEndWithoutRest = shiftEndWithoutRest
});
}
else if (hourseLeaveTypeResult.StartLeaveGr > shift1StartGr && hourseLeaveTypeResult.EndLeaveGr < shift1EndGr)
{
//leave <-------------------->
//shift <---------------------------------->
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = shift1StartGr,
EndDate = hourseLeaveTypeResult.StartLeaveGr,
ShiftSpan = (hourseLeaveTypeResult.StartLeaveGr - shift1StartGr),
ShiftDate = shift1StartGr,
ShiftEndWithoutRest = hourseLeaveTypeResult.StartLeaveGr
});
}
else if (hourseLeaveTypeResult.StartLeaveGr > shift1StartGr && hourseLeaveTypeResult.EndLeaveGr < shift1EndGr)
{
//leave <-------------------->
//shift <---------------------------------->
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = shift1StartGr,
EndDate = hourseLeaveTypeResult.StartLeaveGr,
ShiftSpan = (hourseLeaveTypeResult.StartLeaveGr - shift1StartGr),
ShiftDate = shift1StartGr,
ShiftEndWithoutRest = hourseLeaveTypeResult.StartLeaveGr
});
});
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = hourseLeaveTypeResult.EndLeaveGr,
EndDate = shift1EndGr,
ShiftSpan = (shift1EndGr - hourseLeaveTypeResult.EndLeaveGr),
ShiftDate = shift1StartGr,
ShiftEndWithoutRest = shiftEndWithoutRest
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = hourseLeaveTypeResult.EndLeaveGr,
EndDate = shift1EndGr,
ShiftSpan = (shift1EndGr - hourseLeaveTypeResult.EndLeaveGr),
ShiftDate = shift1StartGr,
ShiftEndWithoutRest = shiftEndWithoutRest
});
}
else if (hourseLeaveTypeResult.StartLeaveGr > shift1StartGr && hourseLeaveTypeResult.EndLeaveGr >= shift1EndGr)
{
//leave <-------------------->
//shift <---------------------------------->
});
}
else if (hourseLeaveTypeResult.StartLeaveGr > shift1StartGr && hourseLeaveTypeResult.EndLeaveGr >= shift1EndGr)
{
//leave <-------------------->
//shift <---------------------------------->
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = shift1StartGr,
EndDate = hourseLeaveTypeResult.StartLeaveGr,
ShiftSpan = (hourseLeaveTypeResult.StartLeaveGr - shift1StartGr),
ShiftDate = shift1StartGr,
ShiftEndWithoutRest = hourseLeaveTypeResult.StartLeaveGr
result.Add(new RollCallViewModel()
{
BreakTimeSpan = hasRestTime ? restTime : TimeSpan.Zero,
StartDate = shift1StartGr,
EndDate = hourseLeaveTypeResult.StartLeaveGr,
ShiftSpan = (hourseLeaveTypeResult.StartLeaveGr - shift1StartGr),
ShiftDate = shift1StartGr,
ShiftEndWithoutRest = hourseLeaveTypeResult.StartLeaveGr
});
});
}
@@ -2330,7 +2263,6 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
#endregion
#region CustomizeCheckout
/// <summary>
@@ -3036,13 +2968,13 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
var endFarvarding = new DateTime(2025, 4, 20);
if (contractStart > endFarvarding)
if (contractStart>endFarvarding)
{
customizeWorkshopEmployeeSettings = _context.CustomizeWorkshopEmployeeSettings
customizeWorkshopEmployeeSettings=_context.CustomizeWorkshopEmployeeSettings
.AsSplitQuery().AsNoTracking().FirstOrDefault(x =>
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
customizeWorkshopSettings = _context.CustomizeWorkshopSettings.AsNoTracking().FirstOrDefault(x => x.WorkshopId == workshopId);
customizeWorkshopSettings =_context.CustomizeWorkshopSettings.AsNoTracking().FirstOrDefault(x => x.WorkshopId == workshopId);
}
else
@@ -3997,40 +3929,40 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
}).ToList();
}
public List<LoanInstallmentViewModel> LoanInstallmentForCheckout(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
{
return _context.Loans
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId)
.SelectMany(x => x.LoanInstallments)
.Where(i => i.InstallmentDate >= contractStart && i.InstallmentDate <= contractEnd && i.IsActive == IsActive.True)
.Select(x => new LoanInstallmentViewModel()
{
Id = x.Id,
Month = x.Month,
IsActive = x.IsActive,
Amount = x.AmountForMonth.ToMoney(),
Year = x.Year,
AmountDouble = x.AmountForMonth,
RemainingAmount = _context.Loans.SelectMany(l => l.LoanInstallments).Where(i => i.LoanId == x.LoanId && i.IsActive == IsActive.True && i.InstallmentDate > x.InstallmentDate)
.Sum(i => i.AmountForMonth).ToMoney(),
LoanAmount = _context.Loans.FirstOrDefault(l => l.id == x.LoanId).Amount.ToMoney()
}).ToList();
}
public List<LoanInstallmentViewModel> LoanInstallmentForCheckout(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
{
return _context.Loans
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId)
.SelectMany(x => x.LoanInstallments)
.Where(i => i.InstallmentDate >= contractStart && i.InstallmentDate <= contractEnd && i.IsActive == IsActive.True)
.Select(x => new LoanInstallmentViewModel()
{
Id = x.Id,
Month = x.Month,
IsActive = x.IsActive,
Amount = x.AmountForMonth.ToMoney(),
Year = x.Year,
AmountDouble = x.AmountForMonth,
RemainingAmount = _context.Loans.SelectMany(l => l.LoanInstallments).Where(i => i.LoanId == x.LoanId && i.IsActive == IsActive.True && i.InstallmentDate > x.InstallmentDate)
.Sum(i => i.AmountForMonth).ToMoney(),
LoanAmount = _context.Loans.FirstOrDefault(l => l.id == x.LoanId).Amount.ToMoney()
}).ToList();
}
public List<SalaryAidViewModel> SalaryAidsForCheckout(long employeeId, long workshopId, DateTime checkoutStart, DateTime checkoutEnd)
{
return _context.SalaryAids
.Where(x => x.CalculationDate >= checkoutStart && x.CalculationDate <= checkoutEnd && x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new SalaryAidViewModel()
{
Amount = x.Amount.ToMoney(),
AmountDouble = x.Amount,
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
SalaryAidDateTimeGe = x.SalaryAidDateTime,
CalculationDateTimeGe = x.CalculationDate,
CalculationDateTimeFa = x.CalculationDate.ToFarsi(),
Id = x.id
}).ToList();
}
public List<SalaryAidViewModel> SalaryAidsForCheckout(long employeeId, long workshopId, DateTime checkoutStart, DateTime checkoutEnd)
{
return _context.SalaryAids
.Where(x => x.CalculationDate >= checkoutStart && x.CalculationDate <= checkoutEnd && x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new SalaryAidViewModel()
{
Amount = x.Amount.ToMoney(),
AmountDouble = x.Amount,
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
SalaryAidDateTimeGe = x.SalaryAidDateTime,
CalculationDateTimeGe = x.CalculationDate,
CalculationDateTimeFa = x.CalculationDate.ToFarsi(),
Id = x.id
}).ToList();
}
private void CreateRewardForBirthDay(long employeeId, long workshopId, double amount, int month, int year,
DateTime contractStart)

View File

@@ -152,16 +152,16 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
public List<CheckoutDailyRollCallViewModel> GetEmployeeRollCallsForMonth(long employeeId, long workshopId, DateTime startMonthDay, DateTime endMonthDay)
{
var firstDayOfMonth = $"{startMonthDay.ToFarsi().Substring(0,8)}01".ToGeorgianDateTime();
var endFarvardin = "1404/01/31".ToGeorgianDateTime();
//گرفتن ساعت استراحت پرسنل از تنظیمات
#region breakTime
BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery().FirstOrDefault(x =>
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
//اگر ساعت استراحت پرسنل وجود نداشت صفر است
var breakTime = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime;
//BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery().FirstOrDefault(x =>
// x.WorkshopId == workshopId && x.EmployeeId == employeeId);
////اگر ساعت استراحت پرسنل وجود نداشت صفر است
//var breakTime = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime;
#endregion
var rollCalls = _context.RollCalls.Where(x =>
var rollCalls = _context.RollCalls.Where(x =>
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate != null && x.EndDate != null && x.RollCallModifyType != RollCallModifyType.Undefined &&
x.ShiftDate.Date >= startMonthDay && x.ShiftDate.Date <= endMonthDay).ToList();
@@ -224,30 +224,26 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
var rollCallTimeSpanPerDay =
new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => (y.EndDate - y.StartDate)!.Value.Ticks));
TimeSpan breakTimePerDay ;
if(startMonthDay>endFarvardin)
breakTimePerDay= RollCallMandatoryRepository.CalculateBreakTime(x.First().BreakTimeSpan, rollCallTimeSpanPerDay);
else
breakTimePerDay = RollCallMandatoryRepository.CalculateBreakTime(breakTime, rollCallTimeSpanPerDay);
var breakTimePerDay = RollCallMandatoryRepository.CalculateBreakTime(x.First().BreakTimeSpan, rollCallTimeSpanPerDay);
return new CheckoutDailyRollCallViewModel()
{
StartDate1 = orderedRollcalls.FirstOrDefault().StartDate.Value.ToString("HH:mm"),
EndDate1 = orderedRollcalls.FirstOrDefault().EndDate.Value.ToString("HH:mm"),
{
StartDate1 = orderedRollcalls.FirstOrDefault().StartDate.Value.ToString("HH:mm"),
EndDate1 = orderedRollcalls.FirstOrDefault().EndDate.Value.ToString("HH:mm"),
StartDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.StartDate?.ToString("HH:mm") ?? "",
EndDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.EndDate?.ToString("HH:mm") ?? "",
StartDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.StartDate?.ToString("HH:mm") ?? "",
EndDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.EndDate?.ToString("HH:mm") ?? "",
TotalhourseSpan = rollCallTimeSpanPerDay - breakTimePerDay,
TotalhourseSpan = rollCallTimeSpanPerDay - breakTimePerDay,
BreakTimeTimeSpan = breakTimePerDay,
BreakTimeTimeSpan = breakTimePerDay,
DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(),
RollCallDateFa = x.Key.Date.ToFarsi(),
DateTimeGr = x.Key.Date,
IsSliced = x.Count() > 2,
IsAbsent = false
};
DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(),
RollCallDateFa = x.Key.Date.ToFarsi(),
DateTimeGr = x.Key.Date,
IsSliced = x.Count() > 2,
IsAbsent = false
};
});

File diff suppressed because it is too large Load Diff

View File

@@ -18,10 +18,6 @@
margin-right: 80px;
}
.level4 {
margin-right: 120px;
}
.parent {
border-radius: 10px 0px 0px 10px;
min-width: 220px;
@@ -46,16 +42,6 @@
border: 1px solid #666666 !important;
margin-right: -4px;
}
.parentLevel3 {
border-radius: 10px 0px 0px 10px;
min-width: 220px !important;
text-align: start;
background-color: #666666 !important;
border: 1px solid #666666 !important;
margin-right: -4px;
}
.ion-plus {
position: relative !important;
top: 4px !important;
@@ -550,45 +536,15 @@
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn"/>
</label>
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="306" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> مدیریت کاربران </span> </label>
@*لیست کاربران کلاینت*@
<div class="child-check level3">
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn"/>
</label>
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel3"><input type="checkbox" disabled="disabled" value="30603" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> لیست کاربران کلاینت </span> </label>
<div class="child-check level4">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="3060301" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> ورود به کلاینت </span> </label>
</div>
<div class="child-check level4">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="3060302" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> تغییر رمز </span> </label>
</div>
<div class="child-check level4">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="3060303" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> ویرایش </span> </label>
</div>
<div class="child-check level4">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="3060304" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> حذف </span> </label>
</div>
</div>
<div class="child-check level3">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="30601" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> ایجادکاربر جدید </span> </label>
</div>
<div class="child-check level3">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="30602" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> ایجاد نقش جدید </span> </label>
</div>
<div class="child-check level3">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="30604" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> لیست کاربران ادمین </span> </label>
</div>
<div class="child-check level3">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="30605" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> نقش ها </span> </label>
</div>
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="306" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> مدیریت کاربران </span> </label>
</div>
@* تشخیص چهره *@
<div class="child-check level2">
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn"/>
</label>
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="308" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> تشخیص چهره </span> </label>
</div>
@* گزارشات *@
<div class="child-check level2">
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">

View File

@@ -18,11 +18,6 @@
margin-right: 80px;
}
.level4 {
margin-right: 120px;
}
.parent {
border-radius: 10px 0px 0px 10px;
min-width: 220px;
@@ -47,15 +42,6 @@
margin-right: -4px;
}
.parentLevel3 {
border-radius: 10px 0px 0px 10px;
min-width: 220px !important;
text-align: start;
background-color: #666666 !important;
border: 1px solid #666666 !important;
margin-right: -4px;
}
.ion-plus {
position: relative !important;
top: 4px !important;
@@ -492,15 +478,7 @@
</div>
</div>
@*حضورغیاب*@
<div class="child-check level2">
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn"/>
</label>
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="308" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> حضورغیاب </span> </label>
</div>
@*ایجاد عناوین مقادیر سالانه*@
@*ایجاد عناوین مقادیر سالانه*@
<div class="child-check level2">
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn"/>
@@ -561,45 +539,15 @@
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn"/>
</label>
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="306" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> مدیریت کاربران </span> </label>
@*لیست کاربران کلاینت*@
<div class="child-check level3">
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn"/>
</label>
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel3"><input type="checkbox" disabled="disabled" value="30603" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> لیست کاربران کلاینت </span> </label>
<div class="child-check level4">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="3060301" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> ورود به کلاینت </span> </label>
</div>
<div class="child-check level4">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="3060302" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> تغییر رمز </span> </label>
</div>
<div class="child-check level4">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="3060303" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> ویرایش </span> </label>
</div>
<div class="child-check level4">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="3060304" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> حذف </span> </label>
</div>
</div>
<div class="child-check level3">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="30601" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> ایجادکاربر جدید </span> </label>
</div>
<div class="child-check level3">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="30602" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> ایجاد نقش جدید </span> </label>
</div>
<div class="child-check level3">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="30604" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> لیست کاربران ادمین </span> </label>
</div>
<div class="child-check level3">
<label class="btn btn-inverse waves-effect waves-light m-b-5 children "><input type="checkbox" disabled="disabled" value="30605" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> نقش ها </span> </label>
</div>
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="306" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> مدیریت کاربران </span> </label>
</div>
@* تشخیص چهره *@
<div class="child-check level2">
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">
<i class="ion-plus"></i> <i class="ion-minus" style="display: none;"></i><input type="checkbox" style="display: none" class="open-btn"/>
</label>
<label class="btn btn-inverse waves-effect waves-light m-b-5 parentLevel2"> <input type="checkbox" disabled="disabled" value="308" class="check-btn"> &nbsp;<span style="bottom: 2px;position: relative"> تشخیص چهره </span> </label>
</div>
@* گزارشات *@
<div class="child-check level2">
<label class="btn btn-icon waves-effect btn-default m-b-5 open-close">

View File

@@ -3,14 +3,12 @@
@using Microsoft.EntityFrameworkCore
@using _0_Framework.Application
@model ServiceHost.Areas.Admin.Pages.Accounts.Account.IndexModel
@inject IAuthHelper _AuthHelper;
@{
var i = 1;
var j = 1;
var r = 1;
var permissionList = _AuthHelper.GetPermissions();
//string colaps = "in";
//string act = "active";
}
@@ -66,11 +64,11 @@
<div class="row">
<div class="col-md-12">
<p class="pull-right" permission="30601">
<p class="pull-right">
<a href="#showmodal=@Url.Page("./Index", "Create")" class="btn btn-success btn-rounded waves-effect waves-light m-b-5" style=" background-color: #f5f5f5; border-color: #0f9500; font-family: 'Web_Yekan' !important; color: #0f9500 !important; border-top-left-radius: 0px; border-bottom-left-radius: 0px "> <i class="fa fa-user-plus" style="padding-left: 3px; font-size: 14px; color: #0f9500 !important "></i> ایجاد کاربر جدید</a>
</p>
<p class="pull-right" permission="30602">
<p class="pull-right">
<a href="#showmodal=@Url.Page("./Index", "CreateRole")" class="btn btn-success btn-rounded waves-effect waves-light m-b-5" style=" background-color: #f5f5f5; border-color: #605f5f; font-family: 'Web_Yekan' !important; color: #605f5f !important; border-top-right-radius: 0px; border-bottom-right-radius: 0px "> <i class="fa fa-group" style="padding-left: 3px; font-size: 14px; color: #605f5f !important "></i> ایجاد نقش جدید</a>
</p>
@@ -101,17 +99,17 @@
<ul class="nav nav-tabs tabs" id="myTab">
@* ============================================RolesTab=================*@
<li class="tab @(permissionList.All(x => x != 30604) && permissionList.All(x => x != 30603)? "active" : "") " permission="30605">
<li class="tab">
<a href="#profile-21" data-toggle="tab" aria-expanded="false" class=" ac">
<span class="visible-xs">
<i class="fa fa-group" style="display: block;padding: 20px 0 0 0;"></i>
<span class="visible-xs">
<i class="fa fa-group" style="display: block;padding: 20px 0 0 0;"></i>
<span class="textMenu">نقش ها</span>
</span>
</span>
<h3 class="hideInMobile" style="font-family: 'Web_Yekan' !important; font-size: 18px !important"><i class="fa fa-group fa-2x" style="padding-left: 3px;"></i> نقش ها</h3>
</a>
</li>
</li>
@* ===============================================AdminTab=================*@
<li class="tab active" permission="30604">
<li class="tab active">
<a href="#home-21" data-toggle="tab" aria-expanded="false" class="active ac">
<span class="visible-xs">
<i class="fa fa-user" style="display: block;padding: 20px 0 0 0;"></i>
@@ -121,21 +119,20 @@
</a>
</li>
@* ===============================================ClientTab=================*@
<li class="tab @(permissionList.All(x => x != 30604) ? "active" : "")" permission="30603">
<li class="tab">
<a href="#Client-21" data-toggle="tab" aria-expanded="false" class=" ac">
<span class="visible-xs" >
<i class="fa fa-group" style="display: block;padding: 20px 0 0 0;"></i>
<span class="textMenu">لیست کلاینت</span>
</span>
<h3 class="hideInMobile" style="font-family: 'Web_Yekan' !important; font-size: 18px !important"><i class="fa fa-group fa-2x" style="padding-left: 3px;"></i> لیست کاربران ( کلاینت) (@Model.ClientAccounts.Count) </h3>
<span class="visible-xs" >
<i class="fa fa-group" style="display: block;padding: 20px 0 0 0;"></i>
<span class="textMenu">لیست موازی</span>
</span>
<h3 class="hideInMobile" style="font-family: 'Web_Yekan' !important; font-size: 18px !important"><i class="fa fa-group fa-2x" style="padding-left: 3px;"></i> لیست کاربران ( موازی) (@Model.ClientAccounts.Count) </h3>
</a>
</li>
</ul>
<div class="tab-content">
@*==================================================================Adminusers=====*@
<div class="tab-pane active" id="home-21" permission="30604">
<div class="tab-pane active" id="home-21">
<div class="row">
<div class="col-md-12">
@@ -301,7 +298,7 @@
</div>
@*==================================================================roles=====*@
<div class="tab-pane @(permissionList.All(x => x != 30604) && permissionList.All(x => x != 30603)? "active" : "") " id="profile-21" permission="30605">
<div class="tab-pane" id="profile-21">
@@ -370,7 +367,7 @@
</div>
@*==================================================================Clientusers=====*@
<div class="tab-pane @(permissionList.All(x => x != 30604) ? "active" : "")" id="Client-21" permission="30603">
<div class="tab-pane" id="Client-21">
<div class="row">
<div class="col-md-12">
@@ -488,27 +485,27 @@
j++;
}
<td>
<a permission="3060301" class="btn btn-success pull-right m-rl-5 red" onclick="directLogin(@item.Id)">
<a class="btn btn-success pull-right m-rl-5 red" onclick="directLogin(@item.Id)">
<i class="fa fa-sign-in faSize"></i><span style="position: relative;bottom: 3px;">ورود به کلاینت</span>
</a>
<a permission="3060302" class="btn btn-info pull-right m-rl-5 red"
<a class="btn btn-info pull-right m-rl-5 red"
href="#showmodal=@Url.Page("./Index", "ChangePassword", new { item.Id })">
<i class="fa fa-key faSize"></i>
</a>
<a permission="3060303" class="btn btn-warning pull-right m-rl-5 red"
<a class="btn btn-warning pull-right m-rl-5 red"
href="#showmodal=@Url.Page("./Index", "Edit", new { item.Id })">
<i class="fa fa-edit faSize"></i>
</a>
@if (item.IsActiveString == "true" && item.Role != "مدیر سیستم")
{
<a permission="3060304" onclick="deActive(@item.Id, '@item.Fullname')" class="btn btn-danger pull-right m-rl-5 red">
<a onclick="deActive(@item.Id, '@item.Fullname')" class="btn btn-danger pull-right m-rl-5 red">
<i class="fa faSize fa-trash"></i>
</a>
}
else if (item.IsActiveString == "false")
{
<a permission="3060304" onclick="Active(@item.Id, '@item.Fullname')" class=" btn btn-success pull-right m-rl-5 red">
<a onclick="Active(@item.Id, '@item.Fullname')" class=" btn btn-success pull-right m-rl-5 red">
<i class="fa faSize fa-rotate-left"></i>
</a>
}

View File

@@ -25,12 +25,12 @@
height: 28cm;
margin: 3mm 5mm 0 5mm; ">
<div class="row" dir="rtl">
<div class="col-xs-3 d-inline-block"><fieldset style="border: 1px solid black; border-radius: 15px; padding: 1px 15px 1px 15px; margin-top: 5px; width: 70%; font-size: 12px; text-align: center;"> @Model.ContractNo</fieldset></div>
<div class="col-xs-3 d-inline-block"></div>
<div class="col-xs-6 d-inline-block text-center">
<p style="font-size: 18px; font-family: 'IranNastaliq' !important; margin-top:0 !important;">بسمه تعالی</p>
<p style="font-size: 15px; font-weight: bold; margin: 2px;">فیش حقوقی و رسید پرداخت حقوق</p>
</div>
<div class="col-xs-3 d-inline-block"></div>
<div class="col-xs-3 d-inline-block"><fieldset style="border: 1px solid black; border-radius: 15px; padding: 1px 15px 1px 15px; margin-top: 5px; width: 70%; font-size: 12px; text-align: center;"> @Model.ContractNo</fieldset></div>
</div>
@@ -165,6 +165,10 @@
</div>
</div>
<div style="padding-top: 10px" class="print-qrcode">
<img src="https://bwipjs-api.metafloor.com/?bcid=code128&text=Chkt_@Model.Id&includetext=false" alt="Barcode">
@* <img src="https://api.qrserver.com/v1/create-qr-code/?size=100x100&data=Chkt_@Model.Id" alt="QR Code"> *@
</div>
<div class="row m-t-20">
<fieldset style="border: 1px solid black !important;-webkit-print-color-adjust: exact;print-color-adjust: exact; border-radius: 10px 10px 10px 10px; margin: 0px 10px;overflow:hidden">

View File

@@ -15,7 +15,7 @@
<p style="font-size: 18px; font-family: 'IranNastaliq' !important; margin-top:0 !important;">بسمه تعالی</p>
<p style="font-size: 15px; font-weight: bold; margin: 2px;">فیش حقوقی و رسید پرداخت حقوق</p>
</div>
<div class="col-xs-3 d-inline-block"></div>
<div class="col-xs-3 d-inline-block"></div>
</div>
<div class="headerInfo">

View File

@@ -1483,8 +1483,8 @@ public class IndexModel : PageModel
return Partial("../Error/_ErrorModal", resultError);
}
//var clientTemps = _employeeClientTempApplication.GetByEmployeeId(employeeId).GetAwaiter().GetResult();
if (leftWorks.Any(x => x.LeftWorkType == LeftWorkTempType.StartWork) /*|| clientTemps.Any()*/)
var clientTemps = _employeeClientTempApplication.GetByEmployeeId(employeeId).GetAwaiter().GetResult();
if (leftWorks.Any(x => x.LeftWorkType == LeftWorkTempType.StartWork) || clientTemps.Any())
{
var resultError = new ErrorViewModel()
{

View File

@@ -23,8 +23,6 @@
}
</style>
var accountId = AuthHelper.CurrentAccountId();
}
<div class="left side-menu">
<div class="sidebar-inner slimscrollleft">
@@ -179,24 +177,19 @@
</svg>
حضورغیاب </a>
</li>
@if (accountId is 2 or 3)
{
<li permission="307">
<a class="clik3" href="/AdminNew/Company/Bank">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
</svg>
بانک ها </a>
</li>
<li permission="307">
<a class="clik3" asp-page="/Company/SmsResult/Index">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
</svg>
گزارش پیامک خودکار</a>
</li>
}
<li permission="306">
<a class="clik3" href="/AdminNew/Company/Bank">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
</svg>
بانک ها </a>
</li>
<li permission="306"><a class="clik3" asp-page="/Company/SmsResult/Index">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
</svg>
گزارش پیامک خودکار</a>
</li>
<li permission="301"><a class="clik3" asp-page="/Company/YearlySalaryTitles/Index">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>

View File

@@ -3,7 +3,7 @@
@inject ITicketAccessAccountRepository TicketAccessAccount;
@inject _0_Framework.Application.IAuthHelper AuthHelper;
@{
var accountId = AuthHelper.CurrentAccountId();
<style>
.showCount span {
background-color: #dd2a2a;
@@ -241,25 +241,21 @@
</svg>
حضورغیاب </a>
</li>
@if (accountId is 2 or 3)
{
<li permission="307">
<a class="clik3" href="/AdminNew/Company/Bank">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
</svg>
بانک ها </a>
</li>
<li permission="307">
<a class="clik3" asp-area="Admin" asp-page="/Company/SmsResult/Index">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white" />
</svg>
گزارش پیامک خودکار
</a>
</li>
}
<li permission="306">
<a class="clik3" href="/AdminNew/Company/Bank">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
</svg>
بانک ها </a>
</li>
<li permission="306">
<a class="clik3" asp-area="Admin" asp-page="/Company/SmsResult/Index">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white" />
</svg>
گزارش پیامک خودکار
</a>
</li>
<li permission="301">
<a class="clik3" asp-area="Admin" asp-page="/Company/YearlySalaryTitles/Index">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">

View File

@@ -1,8 +1,6 @@
@page
@using _0_Framework.Application
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model ServiceHost.Areas.Client.Pages.Company.RollCall.CameraAccounts.IndexModel
@inject _0_Framework.Application.IAuthHelper authHelper
@{
string clientVersion = _0_Framework.Application.Version.StyleVersion;
ViewData["Title"] = " - " + "تنظیمات حساب کاربری دوربین";
@@ -209,9 +207,6 @@
// check and show modal Camera Account And Workshop Setting
var statusCameraAccountAndWorkshopSettingUrl = `@Url.Page("./../Index", "StatusCameraAccountAndWorkshopSetting")`;
var modalCreateCameraAccountUrl = `@Url.Page("./Index", "CreateCameraAccount")`;
var hasActiveDeActvePersmission = @(authHelper.GetPermissions().Contains(SubAccountPermissionHelper.CameraAccountActivationBtnPermissionCode) ? "true" : "false");
var hasEditCameraAccountPermission = @(authHelper.GetPermissions().Contains(SubAccountPermissionHelper.CameraAccountEditPermissionCode) ? "true" : "false");
</script>
<script src="~/assetsclient/pages/RollCall/js/CameraAccounts.js?ver=@clientVersion"></script>
}

View File

@@ -360,10 +360,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
message = createRollCallEmployeeStatus.Message,
});
}
_rollCallEmployeeStatusApplication.SyncRollCallEmployeeWithLeftWork(result.SendId);
}
else
}
else
{
if ( rollCallEmployee.Statuses == null || rollCallEmployee.Statuses?.Any(x => x.StartDateGr <= DateTime.Now.Date && x.EndDateGr >= DateTime.Now.Date)== false)
{

View File

@@ -0,0 +1,31 @@
using _0_Framework.Application;
using CompanyManagment.App.Contracts.Checkout;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace ServiceHost.Controllers;
public record ApiSignCheckoutRequest(long Id);
[Route("api/[controller]")]
[ApiController]
public class CheckoutController : ControllerBase
{
private readonly ICheckoutApplication _checkoutApplication;
public CheckoutController(ICheckoutApplication checkoutApplication)
{
_checkoutApplication = checkoutApplication;
}
[HttpPost("Sign")]
public ActionResult<OperationResult> SignCheckout([FromBody] ApiSignCheckoutRequest data)
{
var result = _checkoutApplication.Sign(data.Id);
if (result.IsSuccedded)
{
return Ok(result);
}
return BadRequest(result);
}
}

View File

@@ -61,7 +61,7 @@ function loadDataCameraAccountAjax() {
<div class="Rtable-cell d-md-flex d-none justify-content-center width5">
<div class="Rtable-cell--content align-items-center d-flex d-md-flex text-end me-3">
<div class="d-flex align-items-center justify-content-center ${hasActiveDeActvePersmission ? `` : `disable`}">
<div class="d-flex align-items-center justify-content-center">
<span class="mx-1 df">فعال</span>
<label class="switch">
<input type="checkbox"
@@ -77,26 +77,14 @@ function loadDataCameraAccountAjax() {
<div class="Rtable-cell d-md-flex justify-content-end width6">
<div class="Rtable-cell--content align-items-center d-flex d-md-flex justify-content-end">
${hasEditCameraAccountPermission ?
`<button class="btn-pass ChangePassword d-none d-md-block" onclick="showModalCameraAccountChangePassword(${item.id})" id="CameraAccountChangePassword_${item.id}" type="button">
<button class="btn-pass ChangePassword d-none d-md-block" onclick="showModalCameraAccountChangePassword(${item.id})" id="CameraAccountChangePassword_${item.id}" type="button">
<span class="spanTxt d-none">تغییر گذرواژه</span>
<span class="spanSvg">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z" />
</svg>
</span>
</button>`
:
`<button class="btn-pass ChangePassword d-none d-md-block disable" type="button">
<span class="spanTxt d-none">تغییر گذرواژه</span>
<span class="spanSvg">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z" />
</svg>
</span>
</button>`
}
</button>
<button type="button" class="btn-more position-relative d-md-none d-flex" style="width: 36px;padding: 0;height: 36px;align-items: center;justify-content: center;position: relative !important;">
<span class="mx-1 align-items-center d-flex justify-content-center"></span>
@@ -121,7 +109,7 @@ function loadDataCameraAccountAjax() {
</div>
<div class="d-flex align-items-center justify-content-between my-1">
<span class="span1">وضعیت:</span>
<div class="d-flex align-items-center justify-content-center ${hasActiveDeActvePersmission ? `` : `disable`}">
<div class="d-flex align-items-center justify-content-center">
<span class="span1 mx-1 df">فعال</span>
<label class="switch">
<input type="checkbox"
@@ -145,25 +133,14 @@ function loadDataCameraAccountAjax() {
</span>
</button>
${hasEditCameraAccountPermission ?
`<button class="btn-pass ChangePassword w-100" onclick="showModalCameraAccountChangePassword(${item.id})" id="ChangePassword_${item.id}" type="button">
<span class="spanTxt">تغییر گذرواژه</span>
<span class="spanSvg">
<svg width="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z" />
</svg>
</span>
</button>`
:
`<button class="btn-pass ChangePassword w-100 disable" type="button">
<span class="spanTxt">تغییر گذرواژه</span>
<span class="spanSvg">
<svg width="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z" />
</svg>
</span>
</button>`
}
<button class="btn-pass ChangePassword w-100" onclick="showModalCameraAccountChangePassword(${item.id})" id="ChangePassword_${item.id}" type="button">
<span class="spanTxt">تغییر گذرواژه</span>
<span class="spanSvg">
<svg width="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z" />
</svg>
</span>
</button>
</div>
</div>