cronjob + ลงเวลากรณีพิเดศษ
This commit is contained in:
parent
72f64728bb
commit
e76d994098
16 changed files with 1518 additions and 9 deletions
|
|
@ -47,6 +47,7 @@ namespace BMA.EHR.Application
|
|||
services.AddTransient<UserTimeStampRepository>();
|
||||
services.AddTransient<ProcessUserTimeStampRepository>();
|
||||
services.AddTransient<UserDutyTimeRepository>();
|
||||
services.AddTransient<AdditionalCheckRequestRepository>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||
{
|
||||
public class AdditionalCheckRequestRepository : GenericLeaveRepository<Guid, AdditionalCheckRequest>
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ILeaveDbContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly OrganizationCommonRepository _organizationCommonRepository;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly EmailSenderService _emailSenderService;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destuctor "
|
||||
|
||||
public AdditionalCheckRequestRepository(ILeaveDbContext dbContext,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
OrganizationCommonRepository organizationCommonRepository,
|
||||
UserProfileRepository userProfileRepository,
|
||||
IConfiguration configuration,
|
||||
EmailSenderService emailSenderService) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_organizationCommonRepository = organizationCommonRepository;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_configuration = configuration;
|
||||
_emailSenderService = emailSenderService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Properties "
|
||||
|
||||
protected Guid UserOrganizationId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +56,26 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
|
||||
#region " Methods "
|
||||
|
||||
public void UpdateUserDutyTime()
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _dbContext.Set<UserDutyTime>()
|
||||
.Where(u => !u.IsProcess)
|
||||
.Where(u => u.EffectiveDate.Value.Date <= DateTime.Now.Date)
|
||||
.ToList();
|
||||
|
||||
foreach (var d in data)
|
||||
{
|
||||
var result = _userProfileRepository.UpdateDutyTimeAsync(d.ProfileId, d.DutyTimeId, d.EffectiveDate.Value.Date).Result;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<UserDutyTime>> GetListByProfileIdAsync(Guid profileId)
|
||||
{
|
||||
var data = await _dbContext.Set<UserDutyTime>().AsQueryable()
|
||||
|
|
|
|||
|
|
@ -28,12 +28,37 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<bool> UpdateDutyTimeAsync(Guid profileId, Guid roundId, DateTime effectiveDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
var profile = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.Id == profileId);
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile.DutyTimeId = roundId;
|
||||
profile.DutyTimeEffectiveDate = effectiveDate;
|
||||
|
||||
await UpdateAsync(profile);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<Profile>> SearchProfile(string? citizenId, string? firstName, string? lastName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _dbContext.Set<Profile>().AsQueryable();
|
||||
|
||||
|
||||
|
||||
if (citizenId != null)
|
||||
data = data.Where(x => x.CitizenId!.Contains(citizenId));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue