Extract
This commit is contained in:
@ -9,6 +9,7 @@ namespace SystemX.Product.CP.TRA.Extract
|
||||
public class Config
|
||||
{
|
||||
public string CPXV2Server { get; set; }
|
||||
public string CPXV2Database { get; set; }
|
||||
public string Server { get; set; }
|
||||
public string DataBase { get; set; }
|
||||
public string SummaryTable { get; set; }
|
||||
|
||||
@ -36,7 +36,7 @@ namespace SystemX.Product.CP.TRA.Extract
|
||||
,[SpecMin]
|
||||
,[SpecMax]
|
||||
,[Dim]
|
||||
FROM [CPXV2].[dbo].[VRFY_TestListFileRelease] WITH(NOLOCK) where StepDesc = '{config.MO}'";
|
||||
FROM [{config.CPXV2Database}].[dbo].[VRFY_TestListFileRelease] WITH(NOLOCK) where StepDesc = '{config.MO}'";
|
||||
|
||||
SqlCommand cmd = new SqlCommand(sql, conn);
|
||||
// 타임아웃 설정 (600만 건은 시간이 걸릴 수 있으므로 0(무제한) 또는 넉넉하게 설정)
|
||||
@ -79,10 +79,6 @@ namespace SystemX.Product.CP.TRA.Extract
|
||||
int fileNo = 0;
|
||||
string fileName = $"";
|
||||
|
||||
foreach (var tl in testList)
|
||||
{
|
||||
Console.WriteLine($"진행중 테스트리스트(MO:{config.MO}): TestListFileNo:{tl.TestListFileNo}, StepVersion:{tl.StepVersion}");
|
||||
|
||||
// 1. 연결 생성
|
||||
using (SqlConnection conn = new SqlConnection(ConnectionString))
|
||||
{
|
||||
@ -95,30 +91,29 @@ namespace SystemX.Product.CP.TRA.Extract
|
||||
|
||||
string sql = $@"SELECT
|
||||
Summary.*,
|
||||
Result.*,
|
||||
Result.LogData,
|
||||
TL.StepVersion AS Matched_StepVersion
|
||||
FROM [{config.DataBase}].[dbo].[{config.SummaryTable}] AS Summary WITH(NOLOCK)
|
||||
JOIN [{config.DataBase}].[dbo].[{config.ResultTable}] AS Result WITH(NOLOCK)
|
||||
ON Summary.No = Result.No
|
||||
OUTER APPLY (
|
||||
SELECT TOP 1 *
|
||||
FROM [CPXV2].[dbo].[VRFY_TestListFileRelease]
|
||||
WHERE StepVersion <= Summary.StepVersion and TestListFileNo = {tl.TestListFileNo} and StepDesc = '{config.MO}'
|
||||
FROM [{config.CPXV2Database}].[dbo].[VRFY_TestListFileRelease]
|
||||
WHERE StepVersion <= Summary.StepVersion and StepDesc = '{config.MO}'
|
||||
ORDER BY StepVersion DESC
|
||||
) AS TL
|
||||
WHERE Summary.TestListFileNo = {tl.TestListFileNo} and StepVersion=TL.StepVersion";
|
||||
|
||||
//test code
|
||||
if(string.IsNullOrEmpty(config.TestCode) == false)
|
||||
sql += $" and TestCode = '{config.TestCode}'";
|
||||
|
||||
//productNo
|
||||
if(string.IsNullOrEmpty(config.ProductNo) == false)
|
||||
sql += $" and ProdNo_C = '{config.ProductNo}'";
|
||||
) AS TL";
|
||||
|
||||
//TestDT
|
||||
DateTime endDate = Convert.ToDateTime(config.EndDate).AddDays(1);
|
||||
sql += $" and '{config.StartDate}' <= Summary.TestDT and Summary.TestDT < '{endDate.ToString("yyyy-MM-dd")}'";
|
||||
sql += $" where '{config.StartDate}' <= Summary.TestDT and Summary.TestDT < '{endDate.ToString("yyyy-MM-dd")}'";
|
||||
|
||||
//test code
|
||||
if (string.IsNullOrEmpty(config.TestCode) == false)
|
||||
sql += $" and TestCode = '{config.TestCode}'";
|
||||
|
||||
//productNo
|
||||
if (string.IsNullOrEmpty(config.ProductNo) == false)
|
||||
sql += $" and ProdNo_C = '{config.ProductNo}'";
|
||||
|
||||
SqlCommand cmd = new SqlCommand(sql, conn);
|
||||
// 타임아웃 설정 (600만 건은 시간이 걸릴 수 있으므로 0(무제한) 또는 넉넉하게 설정)
|
||||
@ -144,6 +139,10 @@ namespace SystemX.Product.CP.TRA.Extract
|
||||
// 예: 데이터 처리 로직
|
||||
var val = Decompression(reader["LogData"].ToString());
|
||||
var date = Convert.ToDateTime(reader["TestDT"]);
|
||||
var testListFileNo = Convert.ToInt32(reader["TestListFileNo"]);
|
||||
var stepVersion = Convert.ToInt32(reader["Matched_StepVersion"]);
|
||||
|
||||
var no = Convert.ToInt32(reader["No"]);
|
||||
|
||||
var productNo = reader["ProdNo_C"].ToString();
|
||||
var testCode = reader["TestCode"].ToString();
|
||||
@ -151,6 +150,11 @@ namespace SystemX.Product.CP.TRA.Extract
|
||||
var productID = reader["ProductID"].ToString();
|
||||
|
||||
var r = JsonConvert.DeserializeObject<List<TestResult>>(val);
|
||||
var tl = testList.Find(x => x.TestListFileNo == testListFileNo && x.StepVersion == stepVersion);
|
||||
|
||||
if(tl != null)
|
||||
{
|
||||
//Console.WriteLine($"Current No:{no}");
|
||||
var findStep = r.Find(x => x.StepID == tl.StepID);
|
||||
|
||||
if (rowCount % config.RowCount == 0)
|
||||
@ -164,7 +168,7 @@ namespace SystemX.Product.CP.TRA.Extract
|
||||
if (string.IsNullOrEmpty(config.TestCode) == false)
|
||||
fileName += $"_{testCode}";
|
||||
|
||||
if(string.IsNullOrEmpty(config.ProductNo) == false)
|
||||
if (string.IsNullOrEmpty(config.ProductNo) == false)
|
||||
fileName += $"_{productNo}";
|
||||
|
||||
fileName += $"_{config.StartDate}_{config.EndDate}";
|
||||
@ -179,6 +183,8 @@ namespace SystemX.Product.CP.TRA.Extract
|
||||
rowCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SqlException ex)
|
||||
@ -187,7 +193,6 @@ namespace SystemX.Product.CP.TRA.Extract
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string Decompression(string compressedDataStr)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user