[성현모] 테스트리스트 조회 기능 추가
This commit is contained in:
@ -210,15 +210,12 @@ namespace Web.Tra.Services
|
||||
return testHistory.ToList();
|
||||
}
|
||||
|
||||
public async Task<TestResult> GetTestResult(IDataModel row, int stepVersion)
|
||||
public async Task<TestList> GetTestList(string productNo, string testCode, int stepVersion)
|
||||
{
|
||||
TestResult result = new TestResult();
|
||||
|
||||
var selectRow = row as TestHistory;
|
||||
if(selectRow is not null)
|
||||
{
|
||||
TestList testList = new TestList();
|
||||
TestList testList = new TestList();
|
||||
|
||||
if (TryParseTestCode(testCode, out var outTestCode) == true)
|
||||
{
|
||||
//cpxv2
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
@ -227,9 +224,7 @@ namespace Web.Tra.Services
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
int testCode = (int)context.STAT_TestCodes.Where(x => x.TestCode == selectRow.TestCode)?.First()?.No;
|
||||
|
||||
var prodRelease = context.PROD_Releases.Where(x => x.ProdNo_C == selectRow.ProductNo && x.TestCodeNo == testCode)?.FirstOrDefault();
|
||||
var prodRelease = context.PROD_Releases.Where(x => x.ProdNo_C == productNo && x.TestCodeNo == outTestCode)?.FirstOrDefault();
|
||||
var prodVariant = context.PROD_Variants.Where(x => x.No == prodRelease.VariantNo)?.FirstOrDefault();
|
||||
var prodGroup = context.PROD_Groups.Where(x => x.No == prodVariant.GroupNo)?.FirstOrDefault();
|
||||
var statTestCode = context.STAT_TestCodes.Where(x => x.No == prodRelease.TestCodeNo)?.FirstOrDefault();
|
||||
@ -241,7 +236,7 @@ namespace Web.Tra.Services
|
||||
{
|
||||
stepVersion = maxStepVersion.LatestStepVersion;
|
||||
}
|
||||
else if(stepVersion < 0)
|
||||
else if (stepVersion < 0)
|
||||
{
|
||||
stepVersion = 0;
|
||||
}
|
||||
@ -249,9 +244,9 @@ namespace Web.Tra.Services
|
||||
var findTestList = context.VRFY_TestListFileReleases
|
||||
.Where(x => x.TestListFileNo == prodVariant.TestListFileNo && x.StepVersion <= stepVersion)
|
||||
.OrderBy(x => x.StepID)
|
||||
.ThenByDescending(x=>x.StepVersion)
|
||||
.ThenByDescending(x => x.StepVersion)
|
||||
.AsEnumerable()
|
||||
.DistinctBy(x=>x.StepID)
|
||||
.DistinctBy(x => x.StepID)
|
||||
.ToList();
|
||||
|
||||
testList.ProdRelease = prodRelease;
|
||||
@ -263,22 +258,44 @@ namespace Web.Tra.Services
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//log
|
||||
if (Int32.TryParse(selectRow.TestDateTime?.Year.ToString(), out var year) == true)
|
||||
{
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
return testList;
|
||||
}
|
||||
|
||||
public async Task<TestResult> GetTestResult(IDataModel row, int stepVersion)
|
||||
{
|
||||
TestResult result = new TestResult();
|
||||
|
||||
var selectRow = row as TestHistory;
|
||||
if(selectRow is not null)
|
||||
{
|
||||
TestList testList = new TestList();
|
||||
|
||||
//if (TryParseTestCode(selectRow.TestCode, out var testCode) == true)
|
||||
{
|
||||
//testlist info
|
||||
var testListInfo = await GetTestList(selectRow.ProductNo, selectRow.TestCode, stepVersion);
|
||||
|
||||
//log
|
||||
if(testListInfo?.TestListFile is not null)
|
||||
{
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
using (var context = GetDBContext<CPXV2Log>(provider, year))
|
||||
if (Int32.TryParse(selectRow.TestDateTime?.Year.ToString(), out var year) == true)
|
||||
{
|
||||
if (context is not null)
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
var testResult = context.HIST_TestResults.Where(x => x.No == selectRow.No)?.First();
|
||||
result = testResult.ToTestResult(testList);
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
using (var context = GetDBContext<CPXV2Log>(provider, year))
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
var testResult = context.HIST_TestResults.Where(x => x.No == selectRow.No)?.First();
|
||||
result = testResult.ToTestResult(testListInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,6 +303,32 @@ namespace Web.Tra.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool TryParseTestCode(string testCode, out int outValue)
|
||||
{
|
||||
bool result = false;
|
||||
outValue = -1;
|
||||
|
||||
//search testlist
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
using (var context = GetDBContext<CPXV2>(provider, 1))
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
var selectTestCode = context.STAT_TestCodes.Where(x => x.TestCode == testCode)?.FirstOrDefault();
|
||||
if(selectTestCode is not null)
|
||||
{
|
||||
outValue = selectTestCode.No;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//Get DBContext
|
||||
private T? GetDBContext<T>(DbContextProvider provider, int dbID) where T : DbContext
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user