[성현모] JsonConvertTool 추가, 서머리 수량 버그수정

This commit is contained in:
SHM
2024-10-25 13:40:03 +09:00
parent 3c8bece6b6
commit b76569d02f
52 changed files with 1148 additions and 547 deletions

View File

@ -353,7 +353,125 @@ namespace SystemX.Net.MiddlewareUI
nProcPos += 1;
}
private void RegisterCpLogData(ref int nProcPos, DataTable SetCpLogTable, DataSet dsVRFYInfo, DataRow dr, DataRow[] SetMakeLogRows)
private void RegisterCpLogShortData(ref int nProcPos, DataTable SetCpLogTable, DataSet dsVRFYInfo, DataRow dr, DataRow[] SetMakeLogRows)
{
string strGetMeasure = string.Empty;
//CpLog 한행의 정보 획득
ShortLogParamInfo.STEP = dr["STEP"].ToString().Trim();
ShortLogParamInfo.POSITION = dr["POSITION"].ToString().Trim();
ShortLogParamInfo.MO = dr["MO"].ToString().Trim();
ShortLogParamInfo.FNC_NAME = dr["FNC_NAME"].ToString().Trim();
ShortLogParamInfo.MIN = dr["MIN"].ToString().Trim();
ShortLogParamInfo.MEASURE = dr["MEASURE"].ToString().Trim();
ShortLogParamInfo.MAX = dr["MAX"].ToString().Trim();
ShortLogParamInfo.DIM = dr["DIM"].ToString().Trim();
ShortLogParamInfo.CHECK = dr["CHECK"].ToString().Trim();
ShortLogParamInfo.SPENT_TIME = dr["SPENT_TIME"].ToString().Trim();
ShortLogParamInfo.INFO = dr["INFO"].ToString().Trim();
ShortLogParamInfo.GLOBAL_SPEC = false;
ShortLogParamInfo.VRFY_MIN = "";
ShortLogParamInfo.VRFY_MAX = "";
//VRFY 키 지정 검색 > 현재의 STEP 이 VRFY 에 존재하면 해당 STEP 의 정보 VRFY 에서 가져옴
DataRow getDr = dsVRFYInfo.Tables[0].Rows.Find(ShortLogParamInfo.STEP);
if (getDr != null)
{
ShortLogParamInfo.GLOBAL_SPEC = Convert.ToBoolean(getDr["IsGlobal"]);
ShortLogParamInfo.VRFY_MIN = getDr["SpecMin"].ToString().Trim();
ShortLogParamInfo.VRFY_MAX = getDr["SpecMax"].ToString().Trim();
}
//DataRow 를 설정된 DataTable Format으로 한행 생성
SetMakeLogRows[nProcPos] = SetCpLogTable.NewRow();
//CpLog 의 정보와 VRFY 정보를 조건에 따라 생성한 DataRow에 업데이트
SetMakeLogRows[nProcPos]["StepID"] = ShortLogParamInfo.STEP;
SetMakeLogRows[nProcPos]["MeasVal"] = Convert.ToDecimal(0);
SetMakeLogRows[nProcPos]["MeasValStr"] = "";
SetMakeLogRows[nProcPos]["Message"] = "";
if (ShortLogParamInfo.FNC_NAME.IndexOf("PRINTOUT") >= 0)
{
if (ShortLogParamInfo.MEASURE.Length > ShortLogParamInfo.MessageLength)
{
strGetMeasure = ShortLogParamInfo.MEASURE;
strGetMeasure = strGetMeasure.Substring(0, ShortLogParamInfo.MessageLength);
SetMakeLogRows[nProcPos]["Message"] = strGetMeasure;
}
else SetMakeLogRows[nProcPos]["Message"] = ShortLogParamInfo.MEASURE;
}
else if (ShortLogParamInfo.DIM.IndexOf("STR") >= 0 ||
ShortLogParamInfo.DIM.IndexOf("STRING") >= 0 ||
ShortLogParamInfo.DIM.IndexOf("HEX") >= 0 ||
ShortLogParamInfo.DIM.IndexOf("NONE") >= 0 ||
ShortLogParamInfo.DIM.IndexOf("BIN") >= 0 ||
ShortLogParamInfo.DIM == string.Empty)
{
if (ShortLogParamInfo.MEASURE.Length > ShortLogParamInfo.MessageValLength)
{
strGetMeasure = ShortLogParamInfo.MEASURE;
strGetMeasure = strGetMeasure.Substring(0, ShortLogParamInfo.MessageValLength);
SetMakeLogRows[nProcPos]["MeasValStr"] = strGetMeasure;
}
else SetMakeLogRows[nProcPos]["MeasValStr"] = ShortLogParamInfo.MEASURE;
}
else
{
//상기 케이스에 다 해당 안될때 Decimal 삽입 아무값이 없을 때 0 삽입
if (ShortLogParamInfo.MEASURE.Length <= 0)
SetMakeLogRows[nProcPos]["MeasVal"] = Convert.ToDecimal(0);
else
{
//Measure 존재에 대한 값변환 시도 및 실패시 String 항목으로 삽입
decimal getMeasValue = decimal.Zero;
if (Decimal.TryParse(ShortLogParamInfo.MEASURE, out getMeasValue))
SetMakeLogRows[nProcPos]["MeasVal"] = getMeasValue;
else
{
//0 삽입 및 Str 에 >> 표시 및 Message 에 데이터 표시
SetMakeLogRows[nProcPos]["MeasVal"] = Convert.ToDecimal(0);
SetMakeLogRows[nProcPos]["MeasValStr"] = ">>";
SetMakeLogRows[nProcPos]["Message"] = ShortLogParamInfo.MEASURE;
}
}
}
//IS GLOBAL 이면 CpLog 에서 읽은 정보 삽입 아니면 VRFY 에서 읽은 정보 삽입
if (ShortLogParamInfo.GLOBAL_SPEC)
{
SetMakeLogRows[nProcPos]["GlobalMin"] = ShortLogParamInfo.MIN;
SetMakeLogRows[nProcPos]["GlobalMax"] = ShortLogParamInfo.MAX;
}
else
{
SetMakeLogRows[nProcPos]["GlobalMin"] = ShortLogParamInfo.VRFY_MIN;
SetMakeLogRows[nProcPos]["GlobalMax"] = ShortLogParamInfo.VRFY_MAX;
if (ShortLogParamInfo.VRFY_MIN.Length <= 0 &&
ShortLogParamInfo.VRFY_MAX.Length <= 0)
{
if (ShortLogParamInfo.MIN.Length > 0 ||
ShortLogParamInfo.MAX.Length > 0)
{
SetMakeLogRows[nProcPos]["GlobalMin"] = ShortLogParamInfo.MIN;
SetMakeLogRows[nProcPos]["GlobalMax"] = ShortLogParamInfo.MAX;
}
}
}
SetMakeLogRows[nProcPos]["Result"] = ShortLogParamInfo.CHECK;
SetMakeLogRows[nProcPos]["SpentTime"] = ShortLogParamInfo.SPENT_TIME;
nProcPos += 1;
}
private void RegisterCpLogLongData(ref int nProcPos, DataTable SetCpLogTable, DataSet dsVRFYInfo, DataRow dr, DataRow[] SetMakeLogRows)
{
string strGetMeasure = string.Empty;
@ -515,7 +633,7 @@ namespace SystemX.Net.MiddlewareUI
{
try
{
RegisterCpLogData(ref nProcPos, SetCpLogTable, dsVRFYInfo, dr, SetMakeLogRows);
RegisterCpLogShortData(ref nProcPos, SetCpLogTable, dsVRFYInfo, dr, SetMakeLogRows);
}
catch (Exception ex)
{
@ -579,7 +697,7 @@ namespace SystemX.Net.MiddlewareUI
{
try
{
RegisterCpLogData(ref nProcPos, SetCpLogTable, dsVRFYInfo, dr, SetMakeLogRows);
RegisterCpLogLongData(ref nProcPos, SetCpLogTable, dsVRFYInfo, dr, SetMakeLogRows);
}
catch (Exception ex)
{
@ -871,6 +989,11 @@ namespace SystemX.Net.MiddlewareUI
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CPXV2_CpLogProcessInfo.strProcessDebugInfo + @" CPXV2 CpLogProcess Log make information failed. [SystemX.Net.MiddlewareUI : MainForm.CPXV2_CpLogProcess]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
}
Task<DataRow> tskLongTerm = null;
Stopwatch stMeasTime = new Stopwatch();
stMeasTime.Start();
try
{
//CpLog 파일 읽은 여부 확인
@ -885,9 +1008,6 @@ namespace SystemX.Net.MiddlewareUI
CommonProtocol cp = new CommonProtocol();
//Summary 테이블 다중 접근 방지(인덱스)
Stopwatch stMeasTime = new Stopwatch();
stMeasTime.Start();
DataSet ds = null;
bool hasRows = false;
@ -1090,7 +1210,6 @@ namespace SystemX.Net.MiddlewareUI
CPXV2_CpLogProcessInfo.strSection,
ref summaryItem);
Task<DataRow> tskLongTerm = null;
//if (MngDBConn.InfoConnection.UTSI_STATE == false)
//tskLongTerm = Task.Run(async () => await CpLogProcessLongTerm(iPos, GetMappedInfo, getCpLogHeader, dtLogData, summaryItem[1]));
@ -1106,18 +1225,41 @@ namespace SystemX.Net.MiddlewareUI
bDupLogSkipState = true;
if (tskLongTerm != null)
lstBulkLongTermLog.Add(tskLongTerm.Result);
return false;
}
//Summary 객체를 이용해 DB 삽입할 SqlCommand 생성
SqlCommand cmd = cp.LogDataSummaryInsert(MngDBLogConn.GetDBConnectInfo().ConnShortTerm.SUMMARY_TABLE, summaryItem[0]);
SqlCommand cmd = null;
//
try
{
cmd = cp.LogDataSummaryInsert(MngDBLogConn.GetDBConnectInfo().ConnShortTerm.SUMMARY_TABLE, summaryItem[0]);
}
catch
{
Type type = typeof(HISTLogSummary);
FieldInfo[] f = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
//Summary 삽입 > 실패시 처리
bProcessResult = ExcuteNonQueryStreamProcess(eConnCategory.ShortTerm, cmd);
StringBuilder sb = new StringBuilder();
foreach (FieldInfo item in f)
{
sb.AppendLine(item.Name.Substring(item.Name.IndexOf("<") + 1, item.Name.IndexOf(">") - item.Name.IndexOf("<") - 1)
+ ">>>" + item.GetValue(summaryItem[0]).ToString().Trim());
}
MessageOutput.ConsoleWrite(sb.ToString());
throw new Exception("<Failed Make " + MngDBLogConn.GetDBConnectInfo().ConnShortTerm.SUMMARY_TABLE + " LogDataSummaryInsert eConnCategory.ShortTerm>");
}
//
try
{
//Summary 삽입 > 실패시 처리
bProcessResult = ExcuteNonQueryStreamProcess(eConnCategory.ShortTerm, cmd);
}
catch
{
throw new Exception("<Failed ExcuteNonQueryStreamProcess eConnCategory.ShortTerm - " + cmd.CommandText + ">");
}
// TODO : SHM JSON
/*
try
@ -1214,7 +1356,15 @@ namespace SystemX.Net.MiddlewareUI
lstBulkShortTermLog.Add(SetProcLogDr);
}
}
catch (Exception e)
{
bProcessResult = false;
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + strProcessDebugInfo + @" CPXV2 Make CpLogProcess fail.[SystemX.Net.MiddlewareUI : MainForm.CPXV2_CpLogProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
}
finally
{
if (tskLongTerm != null)
lstBulkLongTermLog.Add(tskLongTerm.Result);
@ -1228,15 +1378,7 @@ namespace SystemX.Net.MiddlewareUI
}
LogDataProcessText.Enqueue(new StringBuilder(">>[MainTime(ShortTerm)-MakeLogData][" + CPXV2_CpLogProcessInfo.lMainMeasTime + "][Include SubTime(LongTerm)-MakeLogData][" + CPXV2_CpLogProcessInfo.lLongTermMeasTime + "]\r\n"));
}
catch (Exception e)
{
bProcessResult = false;
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + strProcessDebugInfo + @" CPXV2 Make CpLogProcess fail.[SystemX.Net.MiddlewareUI : MainForm.CPXV2_CpLogProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
}
finally
{
if (bDupLogSkipState == false)
{
if (bProcessResult)
@ -1288,23 +1430,63 @@ namespace SystemX.Net.MiddlewareUI
CommonProtocol cp = new CommonProtocol();
//Summary 객체를 이용해 DB 삽입할 SqlCommand 생성
SqlCommand cmd = cp.LogDataSummaryInsert(MngDBLogConn.GetDBConnectInfo().ConnLongTerm.SUMMARY_TABLE, summaryItem);
/*
Type type = typeof(HISTLogSummary);
FieldInfo[] f = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
StringBuilder sb = new StringBuilder();
foreach (FieldInfo item in f)
{
sb.AppendLine(item.Name.Substring(item.Name.IndexOf("<") + 1, item.Name.IndexOf(">") - item.Name.IndexOf("<") - 1)
+ "-" + item.GetValue(summaryItem).ToString().Trim());
}
MessageOutput.ConsoleWrite(sb.ToString());
*/
SqlCommand cmd = null;
//
try
{
cmd = cp.LogDataSummaryInsert(MngDBLogConn.GetDBConnectInfo().ConnLongTerm.SUMMARY_TABLE, summaryItem);
}
catch
{
Type type = typeof(HISTLogSummary);
FieldInfo[] f = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
StringBuilder sb = new StringBuilder();
foreach (FieldInfo item in f)
{
sb.AppendLine(item.Name.Substring(item.Name.IndexOf("<") + 1, item.Name.IndexOf(">") - item.Name.IndexOf("<") - 1)
+ ">>>" + item.GetValue(summaryItem).ToString().Trim());
}
MessageOutput.ConsoleWrite(sb.ToString());
throw new Exception("<Failed Make " + MngDBLogConn.GetDBConnectInfo().ConnLongTerm.SUMMARY_TABLE + " LogDataSummaryInsert eConnCategory.LongTerm>");
}
//
if (chkDataTsk.Result)
{
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CPXV2_CpLogProcessInfo.strProcessDebugInfo +
@" CPXV2 LongTerm-CpLogProcess fail. Reason : LongTerm Duplicated Before CpLog-File. [SystemX.Net.MiddlewareUI : MainForm.CpLogProcessShortTerm]\r\n", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
@" CPXV2 LongTerm-CpLogProcess fail. Reason : LongTerm Duplicated Before CpLog-File. [SystemX.Net.MiddlewareUI : MainForm.CPXV2_CpLogProcessLongTerm]\r\n", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
return SetProcLogDr;
}
//Summary 삽입 > 실패시 처리
bProcessResult = ExcuteNonQueryStreamProcess(eConnCategory.LongTerm, cmd);
//
try
{
//Summary 삽입 > 실패시 처리
bProcessResult = ExcuteNonQueryStreamProcess(eConnCategory.LongTerm, cmd);
}
catch
{
throw new Exception("<Failed ExcuteNonQueryStreamProcess eConnCategory.LongTerm - " + cmd.CommandText + ">");
}
if (bProcessResult == false)
{
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CPXV2_CpLogProcessInfo.strProcessDebugInfo +
@" CPXV2 CpLogProcess HIST_LogSummary insert failed. [SystemX.Net.MiddlewareUI : MainForm.CpLogProcessLongTerm]", ConsoleColor.Red, LogMessageLevel.FATAL);
@" CPXV2 CpLogProcess HIST_LogSummary insert failed. [SystemX.Net.MiddlewareUI : MainForm.CPXV2_CpLogProcessLongTerm]", ConsoleColor.Red, LogMessageLevel.FATAL);
throw new Exception();
}