แก้สมัครสอบ
This commit is contained in:
parent
afc0cd830c
commit
07903d3b67
30 changed files with 3471 additions and 771 deletions
|
|
@ -185,32 +185,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
throw;
|
||||
}
|
||||
}
|
||||
private List<Guid?> GetAllIdByRoot(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ret = new List<Guid?>();
|
||||
|
||||
var oc = _contextMetadata.Organizations.FirstOrDefault(x => x.Id == id && x.IsActive);
|
||||
if (oc != null)
|
||||
ret.Add(oc.Id);
|
||||
|
||||
var child = _contextMetadata.Organizations.AsQueryable().Where(x => x.ParentId == id && x.IsActive).ToList();
|
||||
if (child.Any())
|
||||
{
|
||||
foreach (var item in child)
|
||||
{
|
||||
ret.AddRange(GetAllIdByRoot(item.Id));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -717,45 +691,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
x.CreatedUserId,
|
||||
})
|
||||
.ToListAsync();
|
||||
var profileOrganizations = await _contextMetadata.ProfileOrganizations.AsQueryable()
|
||||
.ToListAsync();
|
||||
var _periodExams = (from x in data
|
||||
join po in profileOrganizations on Guid.Parse(x.CreatedUserId) equals po?.UserId into poGroup
|
||||
from po in poGroup.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
x.Id,
|
||||
x.Year,
|
||||
x.Name,
|
||||
x.Round,
|
||||
x.ImportDate,
|
||||
x.ExamCount,
|
||||
x.Score,
|
||||
x.CreatedUserId,
|
||||
OcId = po == null ? null : po.OrganizationId,
|
||||
}).AsQueryable()
|
||||
.ToList();
|
||||
|
||||
var roles = _httpContextAccessor?.HttpContext?.User?.FindAll(ClaimTypes.Role)?.Select(c => c.Value).ToList();
|
||||
// if (!roles.Contains("head"))
|
||||
// {
|
||||
// var criteria = new List<Guid?>();
|
||||
// var profileOrganization = await _contextMetadata.ProfileOrganizations.AsQueryable()
|
||||
// .FirstOrDefaultAsync(x => x.UserId == Guid.Parse(UserId));
|
||||
|
||||
// if (profileOrganization == null)
|
||||
// return Success(new List<dynamic>());
|
||||
|
||||
// var ocId = _contextMetadata.Organizations.AsQueryable()
|
||||
// .FirstOrDefault(x => x.Id == profileOrganization.OrganizationId);
|
||||
// if (ocId == null)
|
||||
// return Success(new List<dynamic>());
|
||||
// criteria = GetAllIdByRoot(ocId.Id);
|
||||
// if (criteria.Any())
|
||||
// _periodExams = _periodExams.Where(x => x.CreatedUserId == UserId || criteria.Contains(x.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OcId)).ToList();
|
||||
// }
|
||||
|
||||
return Success(_periodExams);
|
||||
return Success(data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -867,6 +806,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
r.CitizenCardExpireDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalCardExpireDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"));
|
||||
r.ApplyDate = (DateTime)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ApplyDate)]?.GetValue<DateTime>();
|
||||
r.PositionName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PositionName)]?.GetValue<string>().IsNull("");
|
||||
r.PositionType = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PositionType)]?.GetValue<string>().IsNull("");
|
||||
r.PositionLevel = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PositionLevel)]?.GetValue<string>().IsNull("");
|
||||
|
||||
|
||||
// address
|
||||
|
|
@ -1229,6 +1170,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
r.CitizenCardExpireDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalCardExpireDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"));
|
||||
r.ApplyDate = (DateTime)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ApplyDate)]?.GetValue<DateTime>();
|
||||
r.PositionName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PositionName)]?.GetValue<string>().IsNull("");
|
||||
r.PositionType = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PositionType)]?.GetValue<string>().IsNull("");
|
||||
r.PositionLevel = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PositionLevel)]?.GetValue<string>().IsNull("");
|
||||
|
||||
// address
|
||||
r.Addresses.Add(new DisableAddress()
|
||||
|
|
@ -1626,6 +1569,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
applyDate = dr["applydate"] == null ? "" : Convert.ToDateTime(dr["applydate"]).ToThaiShortDate(),
|
||||
university = dr["university"].ToString(),
|
||||
position_name = dr["position_name"].ToString(),
|
||||
position_level = dr["position_level"].ToString(),
|
||||
position_type = dr["position_type"].ToString(),
|
||||
exam_name = dr["exam_name"].ToString(),
|
||||
exam_order = dr["exam_order"].ToString(),
|
||||
score_year = Convert.ToInt32(dr["score_year"]).ToThaiYear().ToString(),
|
||||
|
|
@ -1722,6 +1667,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
Remark = p.Remark,
|
||||
University = p.Educations.First().University,
|
||||
PositionName = p.PositionName,
|
||||
PositionType = p.PositionType,
|
||||
PositionLevel = p.PositionLevel,
|
||||
ExamName = p.PeriodExam.Name,
|
||||
ExamOrder = p.PeriodExam.Round,
|
||||
ExamYear = p.PeriodExam.Year == null ? 0 : p.PeriodExam.Year.Value.ToThaiYear(),
|
||||
|
|
@ -1820,7 +1767,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
ExamId = x.ExamId,
|
||||
CitizenId = x.CitizenId,
|
||||
Fullname = $"{x.Prefix}{x.FirstName} {x.LastName}",
|
||||
PositionName = x.PositionName
|
||||
PositionName = x.PositionName,
|
||||
PositionType = x.PositionType,
|
||||
PositionLevel = x.PositionLevel
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
|
@ -1835,69 +1784,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
};
|
||||
return Success(_data);
|
||||
//var template_dir = Path.Combine(_webHostEnvironment.ContentRootPath, "Templates");
|
||||
|
||||
//var template_file = Path.Combine(template_dir, "ExamList.xlsx");
|
||||
|
||||
//var tmpDir = Path.Combine(_webHostEnvironment.ContentRootPath, "tmp");
|
||||
//if (!Directory.Exists(tmpDir))
|
||||
// Directory.CreateDirectory(tmpDir);
|
||||
|
||||
//var exportFile = Path.Combine(tmpDir, $"ExamList_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
|
||||
//try
|
||||
//{
|
||||
// // copy template
|
||||
// System.IO.File.Copy(template_file, exportFile);
|
||||
|
||||
// using (var excel = new ExcelPackage(new FileInfo(exportFile)))
|
||||
// {
|
||||
// var workSheet = excel.Workbook.Worksheets[0];
|
||||
|
||||
|
||||
// workSheet.Cells[1, 2].Value = header;
|
||||
// var disables = data.Disables.OrderBy(x => x.ExamId).ToList();
|
||||
|
||||
// var row = 4; // start at row 4
|
||||
// foreach (var item in disables)
|
||||
// {
|
||||
// workSheet.Cells[row, 1].Value = item.ExamId;
|
||||
// workSheet.Cells[row, 2].Value = item.CitizenId;
|
||||
// workSheet.Cells[row, 3].Value = $"{item.Prefix}{item.FirstName} {item.LastName}";
|
||||
// workSheet.Cells[row, 4].Value = item.PositionName;
|
||||
|
||||
// row++;
|
||||
// }
|
||||
|
||||
// excel.Save();
|
||||
|
||||
// using (FileStream fs = new FileStream(exportFile, FileMode.Open, FileAccess.Read))
|
||||
// {
|
||||
// byte[] bytes = System.IO.File.ReadAllBytes(exportFile);
|
||||
// fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length));
|
||||
// fs.Close();
|
||||
|
||||
// var fname = Path.GetFileName(exportFile);
|
||||
|
||||
// Response.Headers["Content-Disposition"] = $"inline; filename={fname}";
|
||||
|
||||
// var ret = new FileContentResult(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
// {
|
||||
// FileDownloadName = fname
|
||||
// };
|
||||
|
||||
// return ret;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// return Error(ex, "ไม่สามารถส่งออกรายชื่อผู้มีสิทธิ์สอบได้!!");
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// if (System.IO.File.Exists(exportFile))
|
||||
// System.IO.File.Delete(exportFile);
|
||||
//}
|
||||
}
|
||||
|
||||
[HttpGet("export/pass-exam/{id:length(36)}")]
|
||||
|
|
@ -1928,9 +1814,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
{
|
||||
r.ExamId,
|
||||
r.CitizenId,
|
||||
r.Prefix,
|
||||
r.FirstName,
|
||||
r.LastName,
|
||||
Fullname = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
s.FullA,
|
||||
s.SumA,
|
||||
s.AStatus,
|
||||
|
|
@ -1946,87 +1830,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
};
|
||||
return Success(_data);
|
||||
//var template_dir = Path.Combine(_webHostEnvironment.ContentRootPath, "Templates");
|
||||
|
||||
//var template_file = Path.Combine(template_dir, "PassAExamList.xlsx");
|
||||
|
||||
//var tmpDir = Path.Combine(_webHostEnvironment.ContentRootPath, "tmp");
|
||||
//if (!Directory.Exists(tmpDir))
|
||||
// Directory.CreateDirectory(tmpDir);
|
||||
|
||||
//var exportFile = Path.Combine(tmpDir, $"PassExamList_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
|
||||
|
||||
//try
|
||||
//{
|
||||
// var result = (from r in data.Disables.ToList()
|
||||
// join s in data_pass.ScoreImport.Scores.Where(x => x.AStatus == "ผ่าน").ToList() on r.ExamId equals s.ExamId
|
||||
// select new
|
||||
// {
|
||||
// r.ExamId,
|
||||
// r.CitizenId,
|
||||
// r.Prefix,
|
||||
// r.FirstName,
|
||||
// r.LastName,
|
||||
// s.FullA,
|
||||
// s.SumA,
|
||||
// s.AStatus,
|
||||
|
||||
// }).ToList();
|
||||
|
||||
// // copy template
|
||||
// System.IO.File.Copy(template_file, exportFile);
|
||||
|
||||
// using (var excel = new ExcelPackage(new FileInfo(exportFile)))
|
||||
// {
|
||||
// var workSheet = excel.Workbook.Worksheets[0];
|
||||
|
||||
|
||||
// workSheet.Cells[1, 2].Value = header;
|
||||
// var disables = data.Disables.OrderBy(x => x.ExamId).ToList();
|
||||
|
||||
// var row = 4; // start at row 4
|
||||
// foreach (var item in result)
|
||||
// {
|
||||
// workSheet.Cells[row, 1].Value = item.ExamId;
|
||||
// workSheet.Cells[row, 2].Value = item.CitizenId;
|
||||
// workSheet.Cells[row, 3].Value = $"{item.Prefix}{item.FirstName} {item.LastName}";
|
||||
// workSheet.Cells[row, 4].Value = item.FullA;
|
||||
// workSheet.Cells[row, 5].Value = item.SumA;
|
||||
// workSheet.Cells[row, 6].Value = item.AStatus;
|
||||
|
||||
// row++;
|
||||
// }
|
||||
|
||||
// excel.Save();
|
||||
|
||||
// using (FileStream fs = new FileStream(exportFile, FileMode.Open, FileAccess.Read))
|
||||
// {
|
||||
// byte[] bytes = System.IO.File.ReadAllBytes(exportFile);
|
||||
// fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length));
|
||||
// fs.Close();
|
||||
|
||||
// var fname = Path.GetFileName(exportFile);
|
||||
|
||||
// Response.Headers["Content-Disposition"] = $"inline; filename={fname}";
|
||||
|
||||
// var ret = new FileContentResult(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
// {
|
||||
// FileDownloadName = fname
|
||||
// };
|
||||
|
||||
// return ret;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// return Error(ex, "ไม่สามารถส่งออกรายชื่อผู้สอบผ่านได้!!");
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// if (System.IO.File.Exists(exportFile))
|
||||
// System.IO.File.Delete(exportFile);
|
||||
//}
|
||||
}
|
||||
|
||||
[HttpGet("export/pass/{id:length(36)}")]
|
||||
|
|
@ -2060,8 +1863,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
Full = s.FullA + s.FullB + s.FullC,
|
||||
Sum = s.SumA + s.SumB + s.SumC,
|
||||
Status = s.ExamStatus,
|
||||
Number = s.Number,
|
||||
PositionName = r.PositionName,
|
||||
s.Number,
|
||||
r.PositionName,
|
||||
r.PositionType,
|
||||
r.PositionLevel,
|
||||
}).ToList()
|
||||
.OrderBy(x => x.ExamId)
|
||||
.ThenBy(x => x.PositionName)
|
||||
|
|
@ -2078,90 +1883,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
};
|
||||
return Success(_data);
|
||||
//var template_dir = Path.Combine(_webHostEnvironment.ContentRootPath, "Templates");
|
||||
|
||||
//var template_file = Path.Combine(template_dir, "PassExamList.xlsx");
|
||||
|
||||
//var tmpDir = Path.Combine(_webHostEnvironment.ContentRootPath, "tmp");
|
||||
//if (!Directory.Exists(tmpDir))
|
||||
// Directory.CreateDirectory(tmpDir);
|
||||
|
||||
//var exportFile = Path.Combine(tmpDir, $"PassExamList_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
|
||||
|
||||
//try
|
||||
//{
|
||||
// var result = (from r in data.Disables.ToList()
|
||||
// join s in data_pass.ScoreImport.Scores.Where(x => x.ExamStatus == "ผ่าน").ToList() on r.ExamId equals s.ExamId
|
||||
// select new
|
||||
// {
|
||||
// r.ExamId,
|
||||
// r.CitizenId,
|
||||
// r.Prefix,
|
||||
// r.FirstName,
|
||||
// r.LastName,
|
||||
// Full = s.FullA + s.FullB + s.FullC,
|
||||
// Sum = s.SumA + s.SumB + s.SumC,
|
||||
// Status = s.ExamStatus,
|
||||
// r.PositionName,
|
||||
// s.Number
|
||||
// }).ToList();
|
||||
|
||||
// // copy template
|
||||
// System.IO.File.Copy(template_file, exportFile);
|
||||
|
||||
// using (var excel = new ExcelPackage(new FileInfo(exportFile)))
|
||||
// {
|
||||
// var workSheet = excel.Workbook.Worksheets[0];
|
||||
|
||||
|
||||
// workSheet.Cells[1, 2].Value = header;
|
||||
// var disables = data.Disables.OrderBy(x => x.ExamId).ToList();
|
||||
|
||||
// var row = 4; // start at row 4
|
||||
// foreach (var item in result)
|
||||
// {
|
||||
// workSheet.Cells[row, 1].Value = item.ExamId;
|
||||
// workSheet.Cells[row, 2].Value = item.CitizenId;
|
||||
// workSheet.Cells[row, 3].Value = $"{item.Prefix}{item.FirstName} {item.LastName}";
|
||||
// workSheet.Cells[row, 4].Value = item.Full;
|
||||
// workSheet.Cells[row, 5].Value = item.Sum;
|
||||
// workSheet.Cells[row, 6].Value = item.Status;
|
||||
// workSheet.Cells[row, 7].Value = item.Number;
|
||||
// workSheet.Cells[row, 8].Value = item.PositionName;
|
||||
|
||||
// row++;
|
||||
// }
|
||||
|
||||
// excel.Save();
|
||||
|
||||
// using (FileStream fs = new FileStream(exportFile, FileMode.Open, FileAccess.Read))
|
||||
// {
|
||||
// byte[] bytes = System.IO.File.ReadAllBytes(exportFile);
|
||||
// fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length));
|
||||
// fs.Close();
|
||||
|
||||
// var fname = Path.GetFileName(exportFile);
|
||||
|
||||
// Response.Headers["Content-Disposition"] = $"inline; filename={fname}";
|
||||
|
||||
// var ret = new FileContentResult(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
// {
|
||||
// FileDownloadName = fname
|
||||
// };
|
||||
|
||||
// return ret;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// return Error(ex, "ไม่สามารถส่งออกรายชื่อผู้สอบผ่านได้!!");
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// if (System.IO.File.Exists(exportFile))
|
||||
// System.IO.File.Delete(exportFile);
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -179,6 +179,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||
University = p.Educations.First().University,
|
||||
PositionName = p.PositionName,
|
||||
PositionType = p.PositionType,
|
||||
PositionLevel = p.PositionLevel,
|
||||
ExamName = $"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}",
|
||||
Number = sr == null ? "" : sr.Number,
|
||||
// ExamCount = 10,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue