LV1_006 - เช็คเวลาต้องลงเวลาเข้าหรือออกงาน (USER)
This commit is contained in:
parent
c9f68b045b
commit
065314fd6c
20 changed files with 967 additions and 258 deletions
|
|
@ -1,7 +1,7 @@
|
|||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.Commands;
|
||||
using BMA.EHR.Application.Repositories.Leaves;
|
||||
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Repositories.Reports;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -36,6 +36,7 @@ namespace BMA.EHR.Application
|
|||
services.AddTransient<MinIOExamService>();
|
||||
|
||||
services.AddTransient<DutyTimeRepository>();
|
||||
services.AddTransient<UserTimeStampRepository>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Domain.Models.Leave;
|
||||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Leaves
|
||||
namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||
{
|
||||
public class DutyTimeRepository : GenericRepository<Guid, DutyTime>
|
||||
{
|
||||
|
|
@ -61,6 +61,11 @@ namespace BMA.EHR.Application.Repositories.Leaves
|
|||
return await _dbContext.Set<DutyTime>().Where(x => x.IsActive).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<DutyTime?> GetDefaultAsync()
|
||||
{
|
||||
return await _dbContext.Set<DutyTime>().Where(x => x.IsDefault).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||
{
|
||||
public class UserTimeStampRepository : GenericRepository<Guid, UserTimeStamp>
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBContext _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 UserTimeStampRepository(IApplicationDBContext 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
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<UserTimeStamp?> GetLastRecord(Guid keycloakId)
|
||||
{
|
||||
var data = await _dbContext.Set<UserTimeStamp>()
|
||||
.Where(u => u.KeycloakUserId == keycloakId)
|
||||
.OrderByDescending(u => u.CheckIn)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -315,6 +315,40 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task UploadFileAsync(string fileName, string subFolder)
|
||||
{
|
||||
try
|
||||
{
|
||||
var fileContents = File.ReadAllBytes(fileName);
|
||||
System.IO.MemoryStream filestream = new System.IO.MemoryStream(fileContents);
|
||||
//var fileNameWithoutExt = Path.GetFileNameWithoutExtension(fileName);
|
||||
var fileExt = Path.GetExtension(fileName);
|
||||
var fileType = MimeTypeMap.GetMimeType(fileExt);
|
||||
var file_name = Path.GetFileName(fileName);
|
||||
Console.WriteLine($"{_bucketName}{subFolder}");
|
||||
Console.WriteLine(fileName);
|
||||
Console.WriteLine(file_name);
|
||||
Console.WriteLine(filestream);
|
||||
Console.WriteLine(fileType);
|
||||
|
||||
var request = new PutObjectRequest
|
||||
{
|
||||
//BucketName = $"{_bucketName}",
|
||||
BucketName = $"{_bucketName}{subFolder}",
|
||||
Key = file_name,
|
||||
InputStream = filestream,
|
||||
ContentType = fileType,
|
||||
CannedACL = S3CannedACL.PublicRead
|
||||
};
|
||||
|
||||
await _s3Client.PutObjectAsync(request);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GenerateJsonFile(string json, string path, string fileName)
|
||||
{
|
||||
var tmpDir = Path.Combine("tmp");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue