ส่งวินัยไปออกคำสั่ง
This commit is contained in:
parent
e8a288b4b2
commit
f644654384
21 changed files with 24913 additions and 84 deletions
|
|
@ -158,6 +158,30 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
case "C-PM-24":
|
||||
result = await GetReceiver24Async(command);
|
||||
break;
|
||||
case "C-PM-25":
|
||||
result = await GetReceiver25Async(command, token);
|
||||
break;
|
||||
case "C-PM-26":
|
||||
result = await GetReceiver26Async(command, token);
|
||||
break;
|
||||
case "C-PM-27":
|
||||
result = await GetReceiver27Async(command, token);
|
||||
break;
|
||||
case "C-PM-28":
|
||||
result = await GetReceiver28Async(command, token);
|
||||
break;
|
||||
case "C-PM-29":
|
||||
result = await GetReceiver29Async(command, token);
|
||||
break;
|
||||
case "C-PM-30":
|
||||
result = await GetReceiver30Async(command, token);
|
||||
break;
|
||||
case "C-PM-31":
|
||||
result = await GetReceiver31Async(command, token);
|
||||
break;
|
||||
case "C-PM-32":
|
||||
result = await GetReceiver32Async(command, token);
|
||||
break;
|
||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||
}
|
||||
|
||||
|
|
@ -1659,6 +1683,497 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-25
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver25Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["API"];
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/stop";
|
||||
|
||||
var commandType = await _dbContext.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.CommandId)
|
||||
continue;
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id,
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-26
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver26Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["API"];
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/stop";
|
||||
|
||||
var commandType = await _dbContext.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.CommandId)
|
||||
continue;
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id,
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-27
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver27Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["API"];
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/up";
|
||||
|
||||
var commandType = await _dbContext.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.CommandId)
|
||||
continue;
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id,
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-28
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver28Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["API"];
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/up";
|
||||
|
||||
var commandType = await _dbContext.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.CommandId)
|
||||
continue;
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id,
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-29
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver29Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["API"];
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/up";
|
||||
|
||||
var commandType = await _dbContext.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.CommandId)
|
||||
continue;
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id,
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-30
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver30Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["API"];
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/down";
|
||||
|
||||
var commandType = await _dbContext.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.CommandId)
|
||||
continue;
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id,
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-31
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver31Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["API"];
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/down";
|
||||
|
||||
var commandType = await _dbContext.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.CommandId)
|
||||
continue;
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id,
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-32
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver32Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["API"];
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/reject";
|
||||
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id,
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Execute and Deploy "
|
||||
|
|
@ -1737,6 +2252,30 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
case "C-PM-24":
|
||||
await ExecuteCommand24Async(command);
|
||||
break;
|
||||
// case "C-PM-25":
|
||||
// await ExecuteCommand25Async(command);
|
||||
// break;
|
||||
// case "C-PM-26":
|
||||
// await ExecuteCommand26Async(command);
|
||||
// break;
|
||||
// case "C-PM-27":
|
||||
// await ExecuteCommand27Async(command);
|
||||
// break;
|
||||
// case "C-PM-28":
|
||||
// await ExecuteCommand28Async(command);
|
||||
// break;
|
||||
// case "C-PM-29":
|
||||
// await ExecuteCommand29Async(command);
|
||||
// break;
|
||||
// case "C-PM-30":
|
||||
// await ExecuteCommand30Async(command);
|
||||
// break;
|
||||
// case "C-PM-31":
|
||||
// await ExecuteCommand31Async(command);
|
||||
// break;
|
||||
// case "C-PM-32":
|
||||
// await ExecuteCommand32Async(command);
|
||||
// break;
|
||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||
}
|
||||
|
||||
|
|
|
|||
16
BMA.EHR.Application/Responses/PassDisciplineResponse.cs
Normal file
16
BMA.EHR.Application/Responses/PassDisciplineResponse.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
namespace BMA.EHR.Application.Responses
|
||||
{
|
||||
public class PassDisciplineResponse
|
||||
{
|
||||
// public bool successful { get; set; }
|
||||
|
||||
public List<DisciplineDataResponse> result { get; set; } = new();
|
||||
}
|
||||
|
||||
public class DisciplineDataResponse
|
||||
{
|
||||
public Guid id { get; set; } = Guid.Empty;
|
||||
|
||||
public Guid? CommandId { get; set; } = Guid.Empty;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue