[성현모] CPXV2 Init
This commit is contained in:
@ -0,0 +1,538 @@
|
||||
using DevExpress.Data.Helpers;
|
||||
using DevExpress.XtraBars;
|
||||
using DevExpress.XtraBars.Navigation;
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
using SystemX.Net;
|
||||
using SystemX.Common;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.DB;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Common.Archive;
|
||||
using DevExpress.Utils.Extensions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SystemX.Common.Protocol.SIA;
|
||||
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
using System.Threading;
|
||||
using SystemX.Net.MiddlewareUI.UIM.Protocol_Method;
|
||||
|
||||
using static SystemX.Net.DB.XDBConnManager;
|
||||
|
||||
namespace SystemX.Net.MiddlewareUI
|
||||
{
|
||||
public partial class MainForm : DevExpress.XtraBars.FluentDesignSystem.FluentDesignForm
|
||||
{
|
||||
private async void WatchRecvCommandQueue()
|
||||
{
|
||||
await Task.Delay(250);
|
||||
|
||||
while (!m_bTaskCommandBlock)
|
||||
{
|
||||
try
|
||||
{
|
||||
CT.ThrowIfCancellationRequested();
|
||||
}
|
||||
catch (OperationCanceledException CancelEx)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Work Canceled. [SystemX.Net.MiddlewareUI : MainForm.WatchRecvCommndQueue]\r\n" + CancelEx.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
try
|
||||
{
|
||||
if (bTaskCommandWaitLock == false) QueryRecvCommandQueue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General Queue Process failed.[1] [SystemX.Net.MiddlewareUI : MainForm.WatchRecvCommndQueue]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (MngDBConn.GetMainDBAccessTime() >= 120000)
|
||||
{
|
||||
//lock (objSingleTransactionDataAccessWait)
|
||||
{
|
||||
QueryCommandProcess(eConnCategory.Main, "SELECT GETDATE() AS 'CHECK PING';");
|
||||
}
|
||||
}
|
||||
if (MngDBConn.GetShortTermDBAccessTime() >= 120000)
|
||||
{
|
||||
//lock (objSingleTransactionDataAccessWait)
|
||||
{
|
||||
QueryCommandProcess(eConnCategory.ShortTerm, "SELECT GETDATE() AS 'CHECK PING';");
|
||||
}
|
||||
}
|
||||
if (MngDBConn.GetLongTermDBAccessTime() >= 120000)
|
||||
{
|
||||
//lock (objSingleTransactionDataAccessWait)
|
||||
{
|
||||
QueryCommandProcess(eConnCategory.LongTerm, "SELECT GETDATE() AS 'CHECK PING';");
|
||||
}
|
||||
}
|
||||
/*
|
||||
For TestList Update Check
|
||||
*/
|
||||
for (int i = PORT_DISTRIBUTION_NUM; i < ALL_MANAGE_NUM; i++)
|
||||
{
|
||||
if (thisConnInfo[i].ClientConnectState == false)
|
||||
continue;
|
||||
|
||||
foreach (var valuePair in thisTLLoadInfo[i].dicTLInfo)
|
||||
{
|
||||
if (valuePair.Value.bLoaded == false)
|
||||
continue;
|
||||
|
||||
if (valuePair.Value.GetLoadedTime() <= 60000)
|
||||
continue;
|
||||
|
||||
CustomProtocol_ cp = new CustomProtocol_();
|
||||
string strGetQuery = cp.CheckTestListUpdate(valuePair.Value.strProdNo_C, valuePair.Value.strTestCode, valuePair.Value.strTestType, valuePair.Value.strVersion, valuePair.Value.strProdCode);
|
||||
|
||||
DataSet ds = null;
|
||||
|
||||
//lock (objSingleTransactionDataAccessWait)
|
||||
{
|
||||
ds = QueryCommandProcess(eConnCategory.Main, strGetQuery);
|
||||
}
|
||||
|
||||
if (XCommons.isHasRow(ds) == false)
|
||||
continue;
|
||||
|
||||
int nGetStationID = Convert.ToInt32(valuePair.Key.Split(';')[2]);
|
||||
|
||||
DateTime getTestListFileUpdateDT = Convert.ToDateTime(ds.Tables[0].Rows[0]["TestListFileUpdateDT"]);
|
||||
|
||||
if (valuePair.Value.TestListFileUpdateDT != getTestListFileUpdateDT)
|
||||
SendClientAlarmUsePingPacket(i, "TLRL;" + nGetStationID.ToString("D2"));
|
||||
|
||||
valuePair.Value.SetLoadedTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General Queue Process failed.[2] [SystemX.Net.MiddlewareUI : MainForm.WatchRecvCommndQueue]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
await Task.Delay(10);
|
||||
}
|
||||
|
||||
//return m_bTaskCommandBlock;
|
||||
}
|
||||
//private async void SendCommandEvent(byte[] senderData, ScheduleEvent e)
|
||||
private void SendCommandEvent(byte[] senderData, ScheduleEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int iGetCall = e.CALL_NUMBER;
|
||||
|
||||
if (thisConnInfo[e.CALL_NUMBER].m_ucSendCommandToken == 0x00)
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucSendCommandToken = 0x01;
|
||||
else if(thisConnInfo[e.CALL_NUMBER].m_ucSendCommandToken == 0x01)
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucSendCommandToken = 0x02;
|
||||
else
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucSendCommandToken = 0x01;
|
||||
|
||||
thisConnInfo[e.CALL_NUMBER].m_iSendCommandCnt++;
|
||||
|
||||
if (thisConnInfo[e.CALL_NUMBER].m_iSendCommandCnt + 1 == int.MaxValue)
|
||||
thisConnInfo[e.CALL_NUMBER].m_iSendCommandCnt = 0;
|
||||
|
||||
if (FlowCommandControl[iGetCall] == null)
|
||||
return;
|
||||
|
||||
//소켓 샌드 행위 내부 결과
|
||||
if (e.PROCESS_RESULT == false)
|
||||
{
|
||||
//해당 패킷 횟수 상승 일단 회 차시 기록남기고 드랍
|
||||
FlowCommandControl[iGetCall].SendPacketCycle();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General <SendCommandEvent> failed.[SystemX.Net.MiddlewareUI : MainForm.SendCommandEvent]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
//private async void RecvCommandEvent(byte[] senderData, ScheduleEvent e)
|
||||
private void RecvCommandEvent(byte[] senderData, ScheduleEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int iGetCall = e.CALL_NUMBER;
|
||||
|
||||
if (thisConnInfo[e.CALL_NUMBER].m_ucRecvCommandToken == 0x00)
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucRecvCommandToken = 0x01;
|
||||
else if (thisConnInfo[e.CALL_NUMBER].m_ucRecvCommandToken == 0x01)
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucRecvCommandToken = 0x02;
|
||||
else
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucRecvCommandToken = 0x01;
|
||||
|
||||
thisConnInfo[e.CALL_NUMBER].m_iRecvCommandCnt++;
|
||||
|
||||
if (thisConnInfo[e.CALL_NUMBER].m_iRecvCommandCnt + 1 == int.MaxValue)
|
||||
thisConnInfo[e.CALL_NUMBER].m_iRecvCommandCnt = 0;
|
||||
|
||||
if (FlowCommandControl[iGetCall] == null)
|
||||
return;
|
||||
|
||||
int iStoreCnt = senderData.Count();
|
||||
byte[] recvStoreBuffer = senderData;
|
||||
|
||||
//소켓 리시브 행위 결과 전송
|
||||
if (e.PROCESS_RESULT == false)
|
||||
{
|
||||
//받기 실패 단순 실패 응답
|
||||
FlowCommandControl[iGetCall].InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.SIMPLE_RESPONSE), false), null, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
BASE_PROTOCOL GET_PROTOCOL = XCommons.GetHeaderProtocol(iStoreCnt, recvStoreBuffer);
|
||||
BASE_PROTOCOL.PROTOCOL_CODE GET_CODE = GET_PROTOCOL.GET_CURRENT_PROTOCOL;
|
||||
|
||||
//응답
|
||||
if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.SIMPLE_RESPONSE)
|
||||
{
|
||||
if (XCommons.GetSimpleResponsResult(iStoreCnt, recvStoreBuffer))
|
||||
FlowCommandControl[iGetCall].SetSendPacketDrop();
|
||||
else
|
||||
FlowCommandControl[iGetCall].SendPacketCycle();
|
||||
}
|
||||
//파일 끝 응답
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.RAW_END)
|
||||
{
|
||||
if (XCommons.GetSimpleResponsResult(iStoreCnt, recvStoreBuffer))
|
||||
FlowCommandControl[iGetCall].RawStoreQueuePOP();
|
||||
else
|
||||
FlowCommandControl[iGetCall].RawStoreQueuePOP();
|
||||
}
|
||||
//일반 응답
|
||||
else
|
||||
{
|
||||
//성공 응답
|
||||
FlowCommandControl[iGetCall].InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.SIMPLE_RESPONSE), true), null, false, false);
|
||||
|
||||
//받은 큐에 넣어놓기
|
||||
FlowCommandControl[iGetCall].InsertRecvQueue(senderData, null, e.nLABEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General <RecvCommandEvent> failed.[SystemX.Net.MiddlewareUI : MainForm.RecvCommandEvent]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
private bool QueryRecvCommandProcess(int iFlowPos, string strProcessInfo)
|
||||
{
|
||||
int i = iFlowPos;
|
||||
|
||||
bool bState = true;
|
||||
//
|
||||
XData getXData = FlowCommandControl[i].GetResultPacketData();
|
||||
|
||||
if (getXData == null)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo[i].stCommandProcessTime.Restart();
|
||||
|
||||
BASE_PROTOCOL GET_PROTOCOL = getXData.BaseProtocol;
|
||||
BASE_PROTOCOL.PROTOCOL_CODE CODE = GET_PROTOCOL.GET_CURRENT_PROTOCOL;
|
||||
|
||||
HEADER_PACKET getHeader = getXData.HeaderPacket;
|
||||
object objData = getXData.objData;
|
||||
|
||||
byte ucGetLabel = getXData.nLabel;
|
||||
|
||||
bool bUseLabel = true;
|
||||
|
||||
ProtocolShell PS = null;
|
||||
|
||||
switch (CODE)
|
||||
{
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE:
|
||||
PS = new CONNECT_STATE(this, i, ucGetLabel);
|
||||
PS.ExecuteProtocol(GET_PROTOCOL,
|
||||
CODE,
|
||||
getHeader,
|
||||
objData);
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.DATASET_TRANSEFER:
|
||||
{
|
||||
DataSet ds = null;
|
||||
|
||||
if (getXData.bReplayResult) //Query 성공
|
||||
ds = objData as DataSet;
|
||||
else //Query 실패
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + strProcessInfo + @" PROTOCOL_CODE.DATASET_TRANSEFER Fail.[SystemX.Net.MiddlewareUI : MainForm.QueryRecvCommandQueue]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.HOST_INFO_CHECK:
|
||||
if (LoadInfo.USE_HOST_INFO)
|
||||
{
|
||||
PS = new HOST_INFO_CHECK(this, i, ucGetLabel);
|
||||
PS.ExecuteProtocol(GET_PROTOCOL,
|
||||
CODE,
|
||||
getHeader,
|
||||
objData);
|
||||
bUseLabel = false;
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.PROCESS_QUERY:
|
||||
PS = new PROCESS_QUERY(this, i, ucGetLabel);
|
||||
PS.ExecuteProtocol(GET_PROTOCOL,
|
||||
CODE,
|
||||
getHeader,
|
||||
objData);
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.SYSTEM_QUERY:
|
||||
PS = new SYSTEM_QUERY(this, i, ucGetLabel);
|
||||
PS.ExecuteProtocol(GET_PROTOCOL,
|
||||
CODE,
|
||||
getHeader,
|
||||
objData);
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.USER_QUERY:
|
||||
PS = new USER_QUERY(this, i, ucGetLabel);
|
||||
PS.ExecuteProtocol(GET_PROTOCOL,
|
||||
CODE,
|
||||
getHeader,
|
||||
objData);
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.ETC:
|
||||
{
|
||||
try
|
||||
{
|
||||
USER_PACKET CustomPacket = (USER_PACKET)objData;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + strProcessInfo + @" <BASE_PROTOCOL.PROTOCOL_CODE.ETC:> Recv queue process fail.[SystemX.Net.MiddlewareUI : MainForm.QueryRecvCommandQueue]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally
|
||||
{ }
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.INITILALIZE_INFO:
|
||||
{
|
||||
COMM_INFO_PACKET usPacket = (COMM_INFO_PACKET)objData;
|
||||
|
||||
if (ServerCommandSock[i].SOCK_TYPE == SOCKET_TYPE.TCP)
|
||||
{
|
||||
stWatchInitialTime[i].Restart();
|
||||
m_bInitialCallState[i] = false;
|
||||
|
||||
InitializePortDistributionInfoSend(i, "MANUAL", false, PacketFlowControl.CommInfoManualToken);
|
||||
|
||||
thisConnInfo[i].ClientConnectState = false;
|
||||
}
|
||||
else if (ServerCommandSock[i].SOCK_TYPE == SOCKET_TYPE.UDP)
|
||||
{
|
||||
ServerCommandSock[i].strSetRemoteAddress = usPacket.objConnLocalAddress[0].Data;
|
||||
ServerCommandSock[i].strSetRemotePort = usPacket.objConnLocalPort[0].Data;
|
||||
|
||||
stWatchInitialTime[i].Restart();
|
||||
m_bInitialCallState[i] = true;
|
||||
|
||||
ConnPool[i].ConnWaitTimerReset();
|
||||
|
||||
thisConnInfo[i].Initialize();
|
||||
|
||||
thisConnInfo[i].ClientConnectState = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (ServerCommandSock[i].CLIENT_CONNECT && PS != null)
|
||||
{
|
||||
if (PS.GetShellSendOnState())
|
||||
{
|
||||
if (PS.nByteListSize > 0 && PS.IsByteList)
|
||||
{
|
||||
DateTime dtSendTime = DateTime.Now;
|
||||
for (int j = 0; j < PS.nByteListSize; j++)
|
||||
{
|
||||
if (FlowStreamControl[i].InsertSendQueue(dtSendTime, PS.ArrSendByte(j), null, ucGetLabel, true, true) == PacketFlowControl.CommonErrCode)
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PS.ArrSendByte() != null)
|
||||
{
|
||||
if (bUseLabel)
|
||||
FlowCommandControl[i].InsertSendQueue(DateTime.Now, PS.ArrSendByte(), null, ucGetLabel);
|
||||
else
|
||||
FlowCommandControl[i].InsertSendQueue(DateTime.Now, PS.ArrSendByte(), null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thisConnInfo[i].lCommandTime = thisConnInfo[i].stCommandProcessTime.ElapsedMilliseconds;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + strProcessInfo + @" Recv queue process fail.[SystemX.Net.MiddlewareUI : MainForm.QueryRecvCommandProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
bState = false;
|
||||
}
|
||||
|
||||
return bState;
|
||||
}
|
||||
private bool QueryRecvCommandQueue()
|
||||
{
|
||||
bool bState = true;
|
||||
|
||||
string strProcessDebugInfo = "[Unknown]";
|
||||
|
||||
try
|
||||
{
|
||||
bTaskCommandWaitLock = true;
|
||||
|
||||
//Port-distribution
|
||||
for (int i = 0; i < PORT_DISTRIBUTION_NUM; i++)
|
||||
{
|
||||
if (m_bTaskCommandBlock)
|
||||
break;
|
||||
if (ListenServerOnState[i] == false)
|
||||
continue;
|
||||
|
||||
//0 ~ 10 : Listen Distribution
|
||||
if (m_bInitialCallState[i])
|
||||
{
|
||||
if (stWatchInitialTime[i].ElapsedMilliseconds >= 100)
|
||||
{
|
||||
stWatchInitialTime[i].Restart();
|
||||
m_bInitialCallState[i] = false;
|
||||
|
||||
InitializePortDistributionInfoSend(i, "AUTO", false, PacketFlowControl.CommInfoAutoToken);
|
||||
|
||||
thisConnInfo[i].ClientConnectState = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ServerCommandSock[i] == null)
|
||||
continue;
|
||||
if (FlowCommandControl[i] == null)
|
||||
continue;
|
||||
if (FlowCommandControl[i].GetCurrentRecvProcessData() != null)
|
||||
continue;
|
||||
|
||||
strProcessDebugInfo = "[" + (i).ToString("D2") + "]" +
|
||||
"[" + ConnPool[i].nUseCommandPort + "]" +
|
||||
"[" + thisConnInfo[i].strConnectHostID + "]" +
|
||||
"[" + thisConnInfo[i].strConnectSection + "]";
|
||||
|
||||
bState = QueryRecvCommandProcess(i, strProcessDebugInfo);
|
||||
|
||||
/*
|
||||
else
|
||||
{
|
||||
if (thisConnInfo[i].ClientConnectState)
|
||||
{
|
||||
if (stWatchInitialTime[i].ElapsedMilliseconds >= 5000)
|
||||
{
|
||||
stWatchInitialTime[i].Restart();
|
||||
|
||||
InitializePortDistributionInfoSend(i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//Process
|
||||
for (int i = PORT_DISTRIBUTION_NUM; i < ALL_MANAGE_NUM && !m_bTaskCommandBlock; i++)
|
||||
{
|
||||
if (ServerCommandSock[i] == null)
|
||||
continue;
|
||||
else {
|
||||
if (ServerCommandSock[i].CLIENT_CONNECT == false) {
|
||||
if (ConnPool[i].bLastConnState)
|
||||
continue;
|
||||
|
||||
if (ConnPool[i].ConnWaitTime() >= 90000) {
|
||||
//RemoveElement(i);
|
||||
|
||||
ClearServerInstance(i);
|
||||
|
||||
ConnPool[i].Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
if (FlowCommandControl[i] == null)
|
||||
continue;
|
||||
if (FlowCommandControl[i].GetCurrentRecvProcessData() != null)
|
||||
continue;
|
||||
//
|
||||
if (m_bInitialCallState[i])
|
||||
{
|
||||
//접속 후 1초 뒤 Initial
|
||||
if (stWatchInitialTime[i].ElapsedMilliseconds >= 1000)
|
||||
{
|
||||
m_bInitialCallState[i] = false;
|
||||
|
||||
InitializeInfoSend(i);
|
||||
}
|
||||
}
|
||||
//
|
||||
thisConnInfo[i].m_iSendCommandQueueSize = FlowCommandControl[i].GetSendQueueSize();
|
||||
thisConnInfo[i].m_iRecvCommandQueueSize = FlowCommandControl[i].GetRecvQueueSize();
|
||||
|
||||
if ((thisConnInfo[i].m_iSendCommandQueueSize + 1) == int.MaxValue)
|
||||
thisConnInfo[i].m_iSendCommandQueueSize = 0;
|
||||
if ((thisConnInfo[i].m_iRecvCommandQueueSize + 1) == int.MaxValue)
|
||||
thisConnInfo[i].m_iRecvCommandQueueSize = 0;
|
||||
|
||||
strProcessDebugInfo = "[" + (i).ToString("D2") + "]" +
|
||||
"[" + ConnPool[i].nUseCommandPort + "]" +
|
||||
"[" + thisConnInfo[i].strConnectHostID + "]" +
|
||||
"[" + thisConnInfo[i].strConnectSection + "]";
|
||||
|
||||
bState = QueryRecvCommandProcess(i, strProcessDebugInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + strProcessDebugInfo + @" Recv queue process fail.[SystemX.Net.MiddlewareUI : MainForm.QueryRecvCommandQueue]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
bState = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
bTaskCommandWaitLock = false;
|
||||
|
||||
nCommandNumber++;
|
||||
|
||||
if (nCommandNumber >= ALL_MANAGE_NUM)
|
||||
nCommandNumber = 0;
|
||||
}
|
||||
|
||||
return bState;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
using DevExpress.Data.Helpers;
|
||||
using DevExpress.XtraBars;
|
||||
using DevExpress.XtraBars.Navigation;
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
using SystemX.Net;
|
||||
using SystemX.Common;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.DB;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Common.Archive;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SystemX.Common.Protocol.SIA;
|
||||
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
using SystemX.Net.Platform.Common.ExtensionMethods;
|
||||
|
||||
namespace SystemX.Net.MiddlewareUI
|
||||
{
|
||||
public partial class MainForm : DevExpress.XtraBars.FluentDesignSystem.FluentDesignForm
|
||||
{
|
||||
static internal class CpLogProcessInfo
|
||||
{
|
||||
static public string strProcessDebugInfo = string.Empty;
|
||||
static public string strGetFileName = string.Empty;
|
||||
|
||||
//Summary 삽입 정보 생성
|
||||
static public string strHostID = string.Empty;
|
||||
static public string strSection = string.Empty;
|
||||
static public string strStationID = string.Empty;
|
||||
static public string strIdent = string.Empty;
|
||||
static public string strStationName = string.Empty;
|
||||
static public string strProdNo_P = string.Empty;
|
||||
static public string strProdNo_C = string.Empty;
|
||||
static public string strTestType = string.Empty;
|
||||
static public string strTestCode = string.Empty;
|
||||
static public string strVersion = string.Empty;
|
||||
static public string strProdCode = string.Empty;
|
||||
static public string strTestListCntID = string.Empty;
|
||||
|
||||
static public int nTestListFileNo = int.MaxValue;
|
||||
static public int nTestListVariantNo = int.MaxValue;
|
||||
static public int nTestListReleaseNo = int.MaxValue;
|
||||
|
||||
static public string strCpLogFileComment = string.Empty;
|
||||
|
||||
static public Dictionary<string, string> dicCpLogHeader = new Dictionary<string, string>();
|
||||
|
||||
static public int nGetReadStepVersion = int.MaxValue;
|
||||
|
||||
/*
|
||||
* CpLog Header 상 검사 시작 시간 획득 및 맨앞 공백 제거
|
||||
*/
|
||||
static public string strStTime = string.Empty;
|
||||
|
||||
static public long lMainMeasTime = 0;
|
||||
static public long lLongTermMeasTime = 0;
|
||||
}
|
||||
|
||||
private string GetFileName(int iPos, HEADER_PACKET getHeader, string strCreateName, string strSubName)
|
||||
{
|
||||
Random randNumber = new Random();
|
||||
|
||||
string strFileName = strCreateName;
|
||||
|
||||
if (getHeader.objOptionName[0].Data.CompareTo("-") == 0)
|
||||
strFileName += @strSubName + @randNumber.Next().ToString() + @thisConnInfo[iPos].strRecvFileExtension;
|
||||
else
|
||||
strFileName += @thisConnInfo[iPos].strRecvFileName + @thisConnInfo[iPos].strRecvFileExtension;
|
||||
|
||||
if (File.Exists(strFileName) == true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
strFileName = strCreateName;
|
||||
|
||||
if (getHeader.objOptionName[0].Data.CompareTo("-") == 0)
|
||||
strFileName += @strSubName + @randNumber.Next().ToString() + @thisConnInfo[iPos].strRecvFileExtension;
|
||||
else
|
||||
strFileName += @thisConnInfo[iPos].strRecvFileName + "_" + @randNumber.Next().ToString() + @thisConnInfo[iPos].strRecvFileExtension;
|
||||
|
||||
if (File.Exists(strFileName) == false)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return strFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,456 @@
|
||||
using DevExpress.Data.Helpers;
|
||||
using DevExpress.XtraBars;
|
||||
using DevExpress.XtraBars.Navigation;
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
using SystemX.Net;
|
||||
using SystemX.Common;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.DB;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Common.Archive;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SystemX.Common.Protocol.SIA;
|
||||
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
using System.Threading;
|
||||
using SystemX.Net.Middleware.Commons;
|
||||
using SystemX.Net.Platform.SystemX.Common;
|
||||
using CpTesterPlatform.CpLogUtil;
|
||||
|
||||
namespace SystemX.Net.MiddlewareUI
|
||||
{
|
||||
public partial class MainForm : DevExpress.XtraBars.FluentDesignSystem.FluentDesignForm
|
||||
{
|
||||
private async void WatchMappedLogQueue()
|
||||
{
|
||||
await Task.Delay(250);
|
||||
|
||||
while (!m_bTaskMappedLogBlock)
|
||||
{
|
||||
try
|
||||
{
|
||||
CT.ThrowIfCancellationRequested();
|
||||
}
|
||||
catch (OperationCanceledException CancelEx)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Work Canceled. [SystemX.Net.MiddlewareUI : MainForm.WatchRecvStreamQueue]\r\n" + CancelEx.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
try
|
||||
{
|
||||
if (MappedLogQueueData.Count > 0)
|
||||
{
|
||||
Tuple<string, int, HEADER_PACKET, byte[]> GetMappedLogData;
|
||||
|
||||
if (MappedLogQueueData.TryPeek(out GetMappedLogData))
|
||||
{
|
||||
if (SetMemoryMappedFile(GetMappedLogData.Item1, GetMappedLogData.Item2, GetMappedLogData.Item3, GetMappedLogData.Item4))
|
||||
{
|
||||
nMappedLogDataInOutFailedCnt = 0;
|
||||
|
||||
if (MappedLogQueueData.TryDequeue(out GetMappedLogData) == false)
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Dequeue(PASS) failed. [SystemX.Net.MiddlewareUI : MainForm.WatchRecvStreamQueue]\r\n", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nMappedLogDataInOutFailedCnt > 1)
|
||||
{
|
||||
nMappedLogDataInOutFailedCnt = 0;
|
||||
|
||||
if (MappedLogQueueData.TryDequeue(out GetMappedLogData) == false)
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Dequeue(FAIL) failed. [SystemX.Net.MiddlewareUI : MainForm.WatchRecvStreamQueue]\r\n", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
nMappedLogDataInOutFailedCnt++;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" SetMemoryMappedFile Process failed. [SystemX.Net.MiddlewareUI : MainForm.WatchRecvStreamQueue]\r\n", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
else
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" TryPeek failed. [SystemX.Net.MiddlewareUI : MainForm.WatchRecvStreamQueue]\r\n", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" General Queue Process failed. [SystemX.Net.MiddlewareUI : MainForm.WatchRecvStreamQueue]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
if(bUseMapLogProcess)
|
||||
await Task.Delay(100);
|
||||
else
|
||||
await Task.Delay(10000);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetMemoryMappedFile(string strType, int nPos, HEADER_PACKET getHeader, byte[] ucFileData)
|
||||
{
|
||||
bool bMapLogCreateResult = true;
|
||||
|
||||
int nSetSize = int.MaxValue;
|
||||
|
||||
byte[] ucSetLogArray = null;
|
||||
|
||||
int nSetReadyPos = (nPos - PORT_DISTRIBUTION_NUM) * LogSharedMemory.nMaxStationSize;
|
||||
|
||||
string strProcessDebugInfo = string.Empty;
|
||||
strProcessDebugInfo = "[" + (nPos).ToString("D2") + "]" +
|
||||
"[" + ConnPool[nPos].nUseStreamPort + "]" +
|
||||
"[" + thisConnInfo[nPos].strConnectHostID + "]" +
|
||||
"[" + thisConnInfo[nPos].strConnectSection + "]";
|
||||
|
||||
CpLogProcessInfo.strProcessDebugInfo = strProcessDebugInfo;
|
||||
|
||||
try
|
||||
{
|
||||
using (InfoLogSharedMemory memInfoLog = new InfoLogSharedMemory(ParamterMapInfoLog))
|
||||
{
|
||||
InfoLogMappedPacket InfoLogMapFile = new InfoLogMappedPacket();
|
||||
nSetSize = Marshal.SizeOf(InfoLogMapFile);
|
||||
ucSetLogArray = new byte[nSetSize];
|
||||
InfoLogMapFile = (InfoLogMappedPacket)SystemXNetSerialization.RawDeSerialize(ucSetLogArray, InfoLogMapFile.GetType());
|
||||
|
||||
if (memInfoLog.CheckFile())
|
||||
{
|
||||
bool bFindInfoLogResult = false;
|
||||
|
||||
//로그 처리가 필요한 위치 조회
|
||||
bool[] bGetStationReadyLog = memInfoLog.Get(out bFindInfoLogResult, nSetSize);
|
||||
|
||||
if (bFindInfoLogResult)
|
||||
Array.Copy(bGetStationReadyLog, 0, InfoLogMapFile.bLogDataReady, 0, SharedMemory.nMaxInfoFullAccessSize);
|
||||
|
||||
using (LogSharedMemory memLog = new LogSharedMemory(ParamterMapLog))
|
||||
{
|
||||
LogMappedPacket LogMapFile = new LogMappedPacket();
|
||||
nSetSize = Marshal.SizeOf(LogMapFile);
|
||||
ucSetLogArray = new byte[nSetSize];
|
||||
LogMapFile = (LogMappedPacket)SystemXNetSerialization.RawDeSerialize(ucSetLogArray, LogMapFile.GetType());
|
||||
|
||||
LogMapFile.bSectionUse = true;
|
||||
LogMapFile.objLogType[0].Data = strType;
|
||||
LogMapFile.bLogFileReadComplete = false;
|
||||
LogMapFile.bLogFileProcessComplete = false;
|
||||
LogMapFile.nNumber = nPos;
|
||||
LogMapFile.bShowCpLogProcessTime = bShowCpLogProcessTime;
|
||||
LogMapFile.nCommandPort = ConnPool[nPos].nUseCommandPort;
|
||||
LogMapFile.nStreamPort = ConnPool[nPos].nUseStreamPort;
|
||||
LogMapFile.objHost[0].Data = thisConnInfo[nPos].strConnectHostID;
|
||||
LogMapFile.objSection[0].Data = thisConnInfo[nPos].strConnectSection;
|
||||
|
||||
bool bMakeTempTestListCntID = false;
|
||||
string strGetStationNameChk = getHeader.objCP_Packet[0].objStationName[0].Data;
|
||||
string strSetOrgStationName = string.Empty;
|
||||
|
||||
bool bHaveTestListID = false;
|
||||
string strGetTransferTestListCntID = string.Empty;
|
||||
|
||||
if (strGetStationNameChk.IndexOf(";@#$%;TFL") >= 0)
|
||||
{
|
||||
bMakeTempTestListCntID = true;
|
||||
|
||||
strSetOrgStationName = strGetStationNameChk.Substring(0, strGetStationNameChk.IndexOf(";@#$%;TFL"));
|
||||
}
|
||||
else
|
||||
strSetOrgStationName = strGetStationNameChk;
|
||||
|
||||
strGetTransferTestListCntID = getHeader.objVarParam1[0].Data;
|
||||
|
||||
if (strGetTransferTestListCntID.Split('@').Count() > 1)
|
||||
bHaveTestListID = true;
|
||||
|
||||
LogMapFile.objStationName[0].Data = strSetOrgStationName;
|
||||
LogMapFile.objOptionFileName[0].Data = getHeader.objOptionName[0].Data;
|
||||
LogMapFile.objOptionFileExtension[0].Data = getHeader.objOptionExtension[0].Data;
|
||||
|
||||
LogMapFile.nStationID = 0;
|
||||
LogMapFile.objProdPNo[0].Data = getHeader.objCP_Packet[0].objProdNo_P[0].Data;
|
||||
LogMapFile.objProdCNo[0].Data = getHeader.objCP_Packet[0].objProdNo_C[0].Data;
|
||||
LogMapFile.objTestType[0].Data = getHeader.objCP_Packet[0].objTestType[0].Data;
|
||||
LogMapFile.objTestCode[0].Data = getHeader.objCP_Packet[0].objTestCode[0].Data;
|
||||
LogMapFile.objVersion[0].Data = getHeader.objCP_Packet[0].objVersion[0].Data;
|
||||
LogMapFile.objProdCode[0].Data = getHeader.objCP_Packet[0].objProdCode[0].Data;
|
||||
LogMapFile.nTestListVariantNo = (int)getHeader.objCP_Packet[0].uiTestListNo;
|
||||
|
||||
bool bCheckResult = string.IsNullOrEmpty(thisConnInfo[nPos].strResultTestListCntID);
|
||||
if (bCheckResult || bMakeTempTestListCntID)
|
||||
{
|
||||
string strSetTempTestListCntID = string.Empty;
|
||||
|
||||
if (bHaveTestListID == false)
|
||||
strSetTempTestListCntID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "@0";
|
||||
else
|
||||
strSetTempTestListCntID = strGetTransferTestListCntID;
|
||||
|
||||
/// TODO : Failed Transfer File
|
||||
/// Ver 0
|
||||
/// 빈 아이디가 아닐 경우 현재 아이디 정보와 재전송 파일 정보 비교하여 동일할 경우 현재 아이디로 저장
|
||||
/// > 추후 분류(검색)에 문제가 될경우 임시 아이디로 변경 해야 할수도 있다.
|
||||
///
|
||||
/// Ver 1
|
||||
/// 실패한 파일일때만 아이디 확인, 없으면 임시, 있으면 보낸 아이디로 저장
|
||||
/*
|
||||
if (bCheckResult == false)
|
||||
{
|
||||
string strHostSectionInfo =
|
||||
thisConnInfo[nPos].strConnectHostID + ";" +
|
||||
thisConnInfo[nPos].strConnectSection;
|
||||
|
||||
string strMakeCntID =
|
||||
getHeader.objCP_Packet[0].objProdNo_C[0].Data + ";" +
|
||||
getHeader.objCP_Packet[0].objTestType[0].Data + ";" +
|
||||
getHeader.objCP_Packet[0].objTestCode[0].Data + ";" +
|
||||
getHeader.objCP_Packet[0].objVersion[0].Data + ";" +
|
||||
getHeader.objCP_Packet[0].objProdCode[0].Data;// + ";" +
|
||||
//strFileName;
|
||||
|
||||
//패킷의 정보로 Dic 검색 후 존재 한다면 생성하여 현재 아이디랑 비교후 일치한다면 현재 ID 사용
|
||||
if (dicQueryTestListCntID.ContainsKey(strHostSectionInfo))
|
||||
{
|
||||
if (dicQueryTestListCntID[strHostSectionInfo].ContainsKey(strMakeCntID))
|
||||
{
|
||||
string strGetCurTLCntID = dicQueryTestListCntID[strHostSectionInfo][strMakeCntID].dtAccessTime.ToString("yyyyMMddHHmmssfff") + "@" +
|
||||
dicQueryTestListCntID[strHostSectionInfo][strMakeCntID].nCnt.ToString();
|
||||
|
||||
if (thisConnInfo[nPos].strResultTestListCntID.CompareTo(strGetCurTLCntID) == 0)
|
||||
strSetTempTestListCntID = thisConnInfo[nPos].strResultTestListCntID;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
LogMapFile.objResultTestListCntID[0].Data = strSetTempTestListCntID;
|
||||
}
|
||||
else
|
||||
LogMapFile.objResultTestListCntID[0].Data = thisConnInfo[nPos].strResultTestListCntID;
|
||||
|
||||
ucFileData.CopyTo(LogMapFile.ucLogData, 0);
|
||||
|
||||
LogMapFile.nLogDataSize = ucFileData.Count();
|
||||
//
|
||||
string strRandFilePath = string.Empty;
|
||||
|
||||
byte[] ucGetFileData = null;
|
||||
byte[] ucSetFileData = null;
|
||||
|
||||
try
|
||||
{
|
||||
ucGetFileData = new byte[LogMapFile.nLogDataSize];
|
||||
Array.Copy(LogMapFile.ucLogData, 0, ucGetFileData, 0, LogMapFile.nLogDataSize);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - Create file data make failed. [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
ucGetFileData = null;
|
||||
|
||||
bMapLogCreateResult = false;
|
||||
}
|
||||
//
|
||||
try
|
||||
{
|
||||
string strRandName = Path.GetRandomFileName();
|
||||
string strRandFile = Path.GetFileNameWithoutExtension(strRandName);
|
||||
|
||||
string strRandPath = Path.GetTempPath();
|
||||
strRandFilePath = strRandPath + strRandFile + LogMapFile.objOptionFileExtension[0].Data;
|
||||
|
||||
if (ucGetFileData == null)
|
||||
throw new Exception("CpLog - Log file data null.");
|
||||
|
||||
if (LogMapFile.objLogType[0].Data == "RAW_SIZE")
|
||||
ucSetFileData = XDataArchive.DecompressGZipByteToByte(ucGetFileData);
|
||||
else if (LogMapFile.objLogType[0].Data == "FILE_TRANSFER")
|
||||
ucSetFileData = XDataArchive.DecompressDeflateByteToByte(ucGetFileData);
|
||||
|
||||
if (ucSetFileData == null)
|
||||
throw new Exception("CpLog - Log file data decompress failed.");
|
||||
|
||||
CpLogHeader getCpLogHeader = null;
|
||||
|
||||
File.WriteAllBytes(strRandFilePath, ucSetFileData);
|
||||
|
||||
//해당 CpLog 파일 읽기 및 헤더 정보 획득
|
||||
DataTable dtLogData = null;
|
||||
dtLogData = CpLogFileIO.GetLogData(strRandFilePath, out getCpLogHeader);
|
||||
|
||||
if (dtLogData != null && getCpLogHeader != null)
|
||||
{
|
||||
string strGetStationID = getCpLogHeader.CHANNEL.Trim();
|
||||
|
||||
int nGetStationID = int.MaxValue;
|
||||
if (int.TryParse(strGetStationID, out nGetStationID))
|
||||
LogMapFile.nStationID = nGetStationID;
|
||||
|
||||
if (nGetStationID < 0)
|
||||
{
|
||||
LogMapFile.nStationID = 0;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - StationID negative value [" + nGetStationID.ToString() + "] detect. [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] ", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
if (LogMapFile.nStationID >= LogSharedMemory.nMaxStationSize)
|
||||
{
|
||||
if (InfoLogMapFile.bLogDataReady[nSetReadyPos])
|
||||
InfoLogMapFile.bLogDataReady[nSetReadyPos] = false;
|
||||
else
|
||||
InfoLogMapFile.bLogDataReady[nSetReadyPos] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (InfoLogMapFile.bLogDataReady[nSetReadyPos + LogMapFile.nStationID])
|
||||
InfoLogMapFile.bLogDataReady[nSetReadyPos + LogMapFile.nStationID] = false;
|
||||
else
|
||||
InfoLogMapFile.bLogDataReady[nSetReadyPos + LogMapFile.nStationID] = true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - Check StationID failed. [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
bMapLogCreateResult = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(strRandFilePath))
|
||||
File.Delete(strRandFilePath);
|
||||
|
||||
if (bMapLogCreateResult == false)
|
||||
{
|
||||
//문제 발생 로그 확인 파일생성 위치 및 파일명 생성
|
||||
if (ucGetFileData == null)
|
||||
goto CHECK_LOG_FILE_MAKE_SKIP;
|
||||
if (ucSetFileData == null)
|
||||
goto CHECK_LOG_FILE_MAKE_SKIP;
|
||||
|
||||
try
|
||||
{
|
||||
string strMakeDate = DateTime.Now.ToString(@"yyyy\\MM\\dd\\");
|
||||
|
||||
string strCreateFileName = CPXV2_GetCheckLogFilePath(LogMapFile, strMakeDate);
|
||||
|
||||
if (File.Exists(strCreateFileName) == false)
|
||||
File.WriteAllBytes(strCreateFileName, ucSetFileData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - Check log file create failed. [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_LOG_FILE_MAKE_SKIP:;
|
||||
}
|
||||
|
||||
memLog.Set(nPos, LogMapFile);
|
||||
}
|
||||
|
||||
memInfoLog.Set(InfoLogMapFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(memInfoLog.CheckExistsInfoFile() == false)
|
||||
memInfoLog.Set(InfoLogMapFile);
|
||||
|
||||
//Info File Access Failed
|
||||
bMapLogCreateResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
/*
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Frame Count {st.FrameCount} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
|
||||
for (int n = 0; n < st.FrameCount; n++)
|
||||
{
|
||||
StackFrame sf = st.GetFrame(n);
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Method To String {sf.GetMethod()} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Method Name {sf.GetMethod().Name} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Line Number {sf.GetFileLineNumber()} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Column Number {sf.GetFileColumnNumber()} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
}
|
||||
*/
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - Create Map Log failed. [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
|
||||
bMapLogCreateResult = false;
|
||||
}
|
||||
|
||||
//long l1 = stChkTime.ElapsedMilliseconds;
|
||||
|
||||
return bMapLogCreateResult;
|
||||
}
|
||||
|
||||
private string CPXV2_GetLogFileName(LogMappedPacket GetMappedInfo, string strCreateName)
|
||||
{
|
||||
Random randNumber = new Random();
|
||||
|
||||
string strFileName = strCreateName;
|
||||
|
||||
if (GetMappedInfo.objOptionFileName[0].Data.CompareTo("-") == 0)
|
||||
strFileName += @"LogFileTemp" + @randNumber.Next().ToString() + @GetMappedInfo.objOptionFileExtension[0].Data;
|
||||
else
|
||||
strFileName += @GetMappedInfo.objOptionFileName[0].Data + @GetMappedInfo.objOptionFileExtension[0].Data;
|
||||
|
||||
if (File.Exists(strFileName) == true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
strFileName = strCreateName;
|
||||
|
||||
if (GetMappedInfo.objOptionFileName[0].Data.CompareTo("-") == 0)
|
||||
strFileName += @"LogFileTemp" + @randNumber.Next().ToString() + @GetMappedInfo.objOptionFileExtension[0].Data;
|
||||
else
|
||||
strFileName += @GetMappedInfo.objOptionFileName[0].Data + "_" + @randNumber.Next().ToString() + @GetMappedInfo.objOptionFileExtension[0].Data;
|
||||
|
||||
if (File.Exists(strFileName) == false)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return strFileName;
|
||||
}
|
||||
|
||||
private string CPXV2_GetCheckLogFilePath(LogMappedPacket GetMappedInfo,
|
||||
string strMakeDate,
|
||||
bool bGetOnlyFilePath = false)
|
||||
{
|
||||
string strMakeInfo = string.Empty;
|
||||
string strMakeName = string.Empty;
|
||||
|
||||
strMakeInfo = LoadInfo.SERVER_SAVE_POS + @"\" + strMakeDate;
|
||||
strMakeInfo += @"LogFileSave_ProcessPort" + "(" + GetMappedInfo.nStreamPort + ")_" + GetMappedInfo.objHost[0].Data + "_" + GetMappedInfo.objSection[0].Data + @"\LogCheck\";
|
||||
|
||||
if (Directory.Exists(strMakeInfo) == false)
|
||||
Directory.CreateDirectory(strMakeInfo);
|
||||
|
||||
if (bGetOnlyFilePath == false)
|
||||
strMakeName = CPXV2_GetLogFileName(GetMappedInfo, strMakeInfo);
|
||||
else
|
||||
strMakeName = strMakeInfo;
|
||||
|
||||
return strMakeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,434 @@
|
||||
using DevExpress.Data.Helpers;
|
||||
using DevExpress.XtraBars;
|
||||
using DevExpress.XtraBars.Navigation;
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
using SystemX.Net;
|
||||
using SystemX.Common;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.DB;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Common.Archive;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SystemX.Common.Protocol.SIA;
|
||||
|
||||
using SystemX.Net.Middleware.Commons;
|
||||
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
using System.Threading;
|
||||
using static SystemX.Net.DB.XDBConnManager;
|
||||
|
||||
namespace SystemX.Net.MiddlewareUI
|
||||
{
|
||||
public partial class MainForm : DevExpress.XtraBars.FluentDesignSystem.FluentDesignForm
|
||||
{
|
||||
private bool IsImageExtension(string strFileNameInfo, bool bOnlyExtension = true)
|
||||
{
|
||||
if (bOnlyExtension)
|
||||
return -1 != Array.IndexOf(COMMON.mediaExtensions, strFileNameInfo.ToUpperInvariant());
|
||||
else
|
||||
return -1 != Array.IndexOf(COMMON.mediaExtensions, Path.GetExtension(strFileNameInfo).ToUpperInvariant());
|
||||
}
|
||||
|
||||
public List<byte[]> QueryStreamProcess(string strGetQuery, out byte[] ucQueryByteArray, out DataSet setResultDataSet, params string[] strSendParameters)
|
||||
{
|
||||
SqlDataReader xSqlReader = null;
|
||||
|
||||
int iFieldCnt = 0;
|
||||
int iRecordsAffectedCnt = 0;
|
||||
bool bHasRow = false;
|
||||
|
||||
ucQueryByteArray = null;
|
||||
|
||||
setResultDataSet = null;
|
||||
|
||||
DataSet ds = new DataSet();
|
||||
DataTable dt = new DataTable();
|
||||
|
||||
DataSet getDS = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
xSqlReader = MngDBConn.CurrentConnection(eConnCategory.Main).QueryDatabase(strGetQuery);
|
||||
|
||||
if (xSqlReader != null)
|
||||
{
|
||||
iFieldCnt = xSqlReader.FieldCount;
|
||||
iRecordsAffectedCnt = xSqlReader.RecordsAffected;
|
||||
bHasRow = xSqlReader.HasRows;
|
||||
|
||||
dt.Load(xSqlReader);
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"<" + strGetQuery + "> Query process fail![SystemX.Net.MiddlewareUI : MainForm.QueryProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (xSqlReader != null)
|
||||
xSqlReader.Close();
|
||||
|
||||
xSqlReader = null;
|
||||
}
|
||||
|
||||
return ds;
|
||||
}).Result;
|
||||
|
||||
if(XCommons.isHasRow(ds))
|
||||
setResultDataSet = ds.Copy();
|
||||
|
||||
List<byte[]> getStreamList = XCommons.ObjectToByteStreamList(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.RAW_SIZE), getDS, null, 0, strSendParameters);
|
||||
|
||||
return getStreamList;
|
||||
}
|
||||
|
||||
public void QueryResultRemake(DataSet dsResult, int iSetFieldCnt, int iSetRecordsAffectedCnt, bool bSetHasRow, out byte[] ucQueryByteArray, params string[] strParameters)
|
||||
{
|
||||
int iFieldCnt = iSetFieldCnt;
|
||||
int iRecordsAffectedCnt = iSetRecordsAffectedCnt;
|
||||
bool bHasRow = bSetHasRow;
|
||||
|
||||
ucQueryByteArray = null;
|
||||
|
||||
ucQueryByteArray = XCommons.ObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.DATASET_TRANSEFER),
|
||||
dsResult,
|
||||
null,
|
||||
0,
|
||||
iRecordsAffectedCnt,
|
||||
bHasRow,
|
||||
iFieldCnt,
|
||||
strParameters);
|
||||
}
|
||||
|
||||
public Tuple<DataSet, int, int, bool> QueryProcess(string strGetQuery, out byte[] ucQueryByteArray, params string[] strParameters)
|
||||
{
|
||||
SqlDataReader xSqlReader = null;
|
||||
|
||||
int iFieldCnt = 0;
|
||||
int iRecordsAffectedCnt = 0;
|
||||
bool bHasRow = false;
|
||||
|
||||
ucQueryByteArray = null;
|
||||
|
||||
DataSet getDS = Task.Run(() =>
|
||||
{
|
||||
DataSet ds = new DataSet();
|
||||
DataTable dt = new DataTable();
|
||||
|
||||
bool bLockProcess = false;
|
||||
if (strGetQuery.IndexOf("HIST_TestResult") >= 0)
|
||||
bLockProcess = true;
|
||||
|
||||
if(bLockProcess)
|
||||
{
|
||||
//lock (objSingleTransactionDataAccessWait)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
xSqlReader = MngDBConn.CurrentConnection(eConnCategory.Main).QueryDatabase(strGetQuery);
|
||||
|
||||
if (xSqlReader != null)
|
||||
{
|
||||
iFieldCnt = xSqlReader.FieldCount;
|
||||
iRecordsAffectedCnt = xSqlReader.RecordsAffected;
|
||||
bHasRow = xSqlReader.HasRows;
|
||||
|
||||
dt.Load(xSqlReader);
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"<" + strGetQuery + "> Query process fail![SystemX.Net.MiddlewareUI : MainForm.QueryProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (xSqlReader != null)
|
||||
xSqlReader.Close();
|
||||
|
||||
xSqlReader = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
xSqlReader = MngDBConn.CurrentConnection(eConnCategory.Main).QueryDatabase(strGetQuery);
|
||||
|
||||
if (xSqlReader != null)
|
||||
{
|
||||
iFieldCnt = xSqlReader.FieldCount;
|
||||
iRecordsAffectedCnt = xSqlReader.RecordsAffected;
|
||||
bHasRow = xSqlReader.HasRows;
|
||||
|
||||
dt.Load(xSqlReader);
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"<" + strGetQuery + "> Query process fail![SystemX.Net.MiddlewareUI : MainForm.QueryProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (xSqlReader != null)
|
||||
xSqlReader.Close();
|
||||
|
||||
xSqlReader = null;
|
||||
}
|
||||
}
|
||||
|
||||
return ds;
|
||||
}).Result;
|
||||
|
||||
ucQueryByteArray = XCommons.ObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.DATASET_TRANSEFER),
|
||||
getDS,
|
||||
null,
|
||||
0,
|
||||
iRecordsAffectedCnt,
|
||||
bHasRow,
|
||||
iFieldCnt,
|
||||
strParameters);
|
||||
|
||||
return new Tuple<DataSet, int, int, bool>(getDS, iRecordsAffectedCnt, iFieldCnt, bHasRow);
|
||||
}
|
||||
|
||||
private bool ExcuteNonQueryCommandProcess(SqlCommand cmd)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
bool bExcuteResult = true;
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
bExcuteResult = MngDBConn.CurrentConnection(eConnCategory.Main).ExecuteNonCommandQuery(cmd);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
bExcuteResult = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"<" + cmd.CommandText + "> Query excute fail![SystemX.Net.MiddlewareUI : MainForm.AsyncExcuteNonQueryProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return bExcuteResult;
|
||||
}).Result;
|
||||
}
|
||||
|
||||
private bool ExcuteNonQueryStreamProcess(eConnCategory eConnType, SqlCommand cmd)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
bool bExcuteResult = true;
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
bExcuteResult = MngDBConn.CurrentConnection(eConnType).ExecuteNonStreamQuery(cmd);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
bExcuteResult = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"<" + cmd.CommandText + "> Query excute fail![SystemX.Net.MiddlewareUI : MainForm.AsyncExcuteNonQueryProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return bExcuteResult;
|
||||
}).Result;
|
||||
}
|
||||
|
||||
private DataSet QueryCommandProcess(eConnCategory eConnType, string strGetQuery, bool bUseTransaction = false)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
DataSet ds = new DataSet();
|
||||
DataTable dt = new DataTable();
|
||||
|
||||
try
|
||||
{
|
||||
SqlDataReader xSqlReader = null;
|
||||
|
||||
try
|
||||
{
|
||||
int iFieldCnt = 0;
|
||||
int iRecordsAffectedCnt = 0;
|
||||
bool bHasRow = false;
|
||||
|
||||
try
|
||||
{
|
||||
xSqlReader = MngDBConn.CurrentConnection(eConnType).QueryCommandDatabase(strGetQuery, bUseTransaction);
|
||||
|
||||
if (xSqlReader != null)
|
||||
{
|
||||
iFieldCnt = xSqlReader.FieldCount;
|
||||
iRecordsAffectedCnt = xSqlReader.RecordsAffected;
|
||||
bHasRow = xSqlReader.HasRows;
|
||||
|
||||
dt.Load(xSqlReader);
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"<" + strGetQuery + "> Query process fail![SystemX.Net.MiddlewareUI : MainForm.AsyncQueryProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (xSqlReader != null)
|
||||
xSqlReader.Close();
|
||||
|
||||
xSqlReader = null;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return ds;
|
||||
}).Result;
|
||||
}
|
||||
|
||||
private DataSet QueryStreamProcess(eConnCategory eConnType, string strGetQuery)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
DataSet ds = new DataSet();
|
||||
DataTable dt = new DataTable();
|
||||
|
||||
try
|
||||
{
|
||||
SqlDataReader xSqlReader = null;
|
||||
|
||||
try
|
||||
{
|
||||
int iFieldCnt = 0;
|
||||
int iRecordsAffectedCnt = 0;
|
||||
bool bHasRow = false;
|
||||
|
||||
try
|
||||
{
|
||||
xSqlReader = MngDBConn.CurrentConnection(eConnType).QueryStreamDatabase(strGetQuery);
|
||||
|
||||
if (xSqlReader != null)
|
||||
{
|
||||
iFieldCnt = xSqlReader.FieldCount;
|
||||
iRecordsAffectedCnt = xSqlReader.RecordsAffected;
|
||||
bHasRow = xSqlReader.HasRows;
|
||||
|
||||
dt.Load(xSqlReader);
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"<" + strGetQuery + "> Query process fail![SystemX.Net.MiddlewareUI : MainForm.AsyncQueryProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (xSqlReader != null)
|
||||
xSqlReader.Close();
|
||||
|
||||
xSqlReader = null;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return ds;
|
||||
}).Result;
|
||||
}
|
||||
|
||||
private DataSet QueryProcess(string strGetQuery)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
SqlDataReader xSqlReader = null;
|
||||
|
||||
DataSet ds = new DataSet();
|
||||
DataTable dt = new DataTable();
|
||||
|
||||
int iFieldCnt = 0;
|
||||
int iRecordsAffectedCnt = 0;
|
||||
bool bHasRow = false;
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
xSqlReader = MngDBConn.CurrentConnection(eConnCategory.Main).QueryDatabaseSub(strGetQuery);
|
||||
|
||||
if (xSqlReader != null)
|
||||
{
|
||||
iFieldCnt = xSqlReader.FieldCount;
|
||||
iRecordsAffectedCnt = xSqlReader.RecordsAffected;
|
||||
bHasRow = xSqlReader.HasRows;
|
||||
|
||||
dt.Load(xSqlReader);
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"<" + strGetQuery + "> Query process fail![SystemX.Net.MiddlewareUI : MainForm.QueryProcess]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (xSqlReader != null)
|
||||
xSqlReader.Close();
|
||||
|
||||
xSqlReader = null;
|
||||
}
|
||||
|
||||
return ds;
|
||||
}).Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,477 @@
|
||||
using DevExpress.Data.Helpers;
|
||||
using DevExpress.XtraBars;
|
||||
using DevExpress.XtraBars.Navigation;
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
using SystemX.Net;
|
||||
using SystemX.Common;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.DB;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Common.Archive;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SystemX.Common.Protocol.SIA;
|
||||
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
using System.Threading;
|
||||
using SystemX.Net.Middleware.Commons;
|
||||
using SystemX.Net.Platform.SystemX.Common;
|
||||
using CpTesterPlatform.CpLogUtil;
|
||||
|
||||
namespace SystemX.Net.MiddlewareUI
|
||||
{
|
||||
public partial class MainForm : DevExpress.XtraBars.FluentDesignSystem.FluentDesignForm
|
||||
{
|
||||
private async void WatchRecvStreamQueue()
|
||||
{
|
||||
await Task.Delay(250);
|
||||
|
||||
Stopwatch stLogScanTimer = new Stopwatch();
|
||||
stLogScanTimer.Start();
|
||||
|
||||
while (!m_bTaskStreamBlock)
|
||||
{
|
||||
try
|
||||
{
|
||||
CT.ThrowIfCancellationRequested();
|
||||
}
|
||||
catch (OperationCanceledException CancelEx)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Work Canceled. [SystemX.Net.MiddlewareUI : MainForm.WatchRecvStreamQueue]\r\n" + CancelEx.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
try
|
||||
{
|
||||
if (bTaskStreamWaitLock == false) QueryRecvStreamQueue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General Queue Process failed.[SystemX.Net.MiddlewareUI : MainForm.WatchRecvStreamQueue]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
await Task.Delay(10);
|
||||
}
|
||||
|
||||
//return m_bTaskStreamBlock;
|
||||
}
|
||||
//private async void SendStreamEvent(byte[] senderData, ScheduleEvent e)
|
||||
private void SendStreamEvent(byte[] senderData, ScheduleEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int iGetCall = e.CALL_NUMBER;
|
||||
|
||||
if (thisConnInfo[e.CALL_NUMBER].m_ucSendStreamToken == 0x00)
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucSendStreamToken = 0x01;
|
||||
else if (thisConnInfo[e.CALL_NUMBER].m_ucSendStreamToken == 0x01)
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucSendStreamToken = 0x02;
|
||||
else
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucSendStreamToken = 0x01;
|
||||
|
||||
thisConnInfo[e.CALL_NUMBER].m_iSendStreamCnt++;
|
||||
|
||||
if (thisConnInfo[e.CALL_NUMBER].m_iSendStreamCnt + 1 == int.MaxValue)
|
||||
thisConnInfo[e.CALL_NUMBER].m_iSendStreamCnt = 0;
|
||||
|
||||
if (FlowStreamControl[iGetCall] == null)
|
||||
return;
|
||||
|
||||
//소켓 샌드 행위 내부 결과
|
||||
if (e.PROCESS_RESULT == false)
|
||||
{
|
||||
//해당 패킷 횟수 상승 일단 회 차시 기록남기고 드랍
|
||||
FlowStreamControl[iGetCall].SendPacketCycle();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General <SendStreamEvent> failed.[SystemX.Net.MiddlewareUI : MainForm.SendStreamEvent]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
//private async void RecvStreamEvent(byte[] senderData, ScheduleEvent e)
|
||||
private void RecvStreamEvent(byte[] senderData, ScheduleEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int iGetCall = e.CALL_NUMBER;
|
||||
|
||||
if (thisConnInfo[e.CALL_NUMBER].m_ucRecvStreamToken == 0x00)
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucRecvStreamToken = 0x01;
|
||||
else if (thisConnInfo[e.CALL_NUMBER].m_ucRecvStreamToken == 0x01)
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucRecvStreamToken = 0x02;
|
||||
else
|
||||
thisConnInfo[e.CALL_NUMBER].m_ucRecvStreamToken = 0x01;
|
||||
|
||||
thisConnInfo[e.CALL_NUMBER].m_iRecvStreamCnt++;
|
||||
|
||||
if (thisConnInfo[e.CALL_NUMBER].m_iRecvStreamCnt + 1 == int.MaxValue)
|
||||
thisConnInfo[e.CALL_NUMBER].m_iRecvStreamCnt = 0;
|
||||
|
||||
if (FlowStreamControl[iGetCall] == null)
|
||||
return;
|
||||
|
||||
int iStoreCnt = senderData.Count();
|
||||
byte[] recvStoreBuffer = senderData;
|
||||
|
||||
//소켓 리시브 행위 결과 전송
|
||||
if (e.PROCESS_RESULT == false)
|
||||
{
|
||||
//받기 실패 단순 실패 응답
|
||||
FlowStreamControl[iGetCall].InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.SIMPLE_RESPONSE), false), null, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
BASE_PROTOCOL GET_PROTOCOL = XCommons.GetHeaderProtocol(iStoreCnt, recvStoreBuffer);
|
||||
BASE_PROTOCOL.PROTOCOL_CODE GET_CODE = GET_PROTOCOL.GET_CURRENT_PROTOCOL;
|
||||
|
||||
//응답
|
||||
if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.SIMPLE_RESPONSE)
|
||||
{
|
||||
if (XCommons.GetSimpleResponsResult(iStoreCnt, recvStoreBuffer))
|
||||
FlowStreamControl[iGetCall].SetSendPacketDrop();
|
||||
else
|
||||
FlowStreamControl[iGetCall].SendPacketCycle();
|
||||
}
|
||||
//파일 끝 응답
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.RAW_END)
|
||||
{
|
||||
if (XCommons.GetSimpleResponsResult(iStoreCnt, recvStoreBuffer))
|
||||
FlowStreamControl[iGetCall].RawStoreQueuePOP();
|
||||
else
|
||||
FlowStreamControl[iGetCall].RawStoreQueuePOP();
|
||||
}
|
||||
//일반 응답
|
||||
else
|
||||
{
|
||||
//성공 응답
|
||||
FlowStreamControl[iGetCall].InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.SIMPLE_RESPONSE), true), null, false, false);
|
||||
|
||||
//받은 큐에 넣어놓기
|
||||
FlowStreamControl[iGetCall].InsertRecvQueue(senderData, null, e.nLABEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General <RecvStreamEvent> failed.[SystemX.Net.MiddlewareUI : MainForm.RecvStreamEvent]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
private void SendMiddlewareMessage(int iPos, string strMessage)
|
||||
{
|
||||
if (thisConnInfo[iPos].StreamConnectState == false)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
MESSAGE_PACKET MakeMessagePacket = new MESSAGE_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(MakeMessagePacket);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
MakeMessagePacket = (MESSAGE_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, MakeMessagePacket.GetType());
|
||||
|
||||
MakeMessagePacket.objMessage[0].Data = strMessage;
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.MIDDLEWARE_MESSAGE), MakeMessagePacket);
|
||||
|
||||
FlowStreamControl[iPos].InsertSendQueue(DateTime.Now, ucSendByteInfo, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Send error <Middleware> message.[SystemX.Net.MiddlewareUI : MainForm.SendMiddlewareMessage]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] MakeTransferResult(bool bSetRecvResult, bool bSetProcessResult)
|
||||
{
|
||||
TRANSFER_PACKET TransferResult = new TRANSFER_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(TransferResult);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
TransferResult = (TRANSFER_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, TransferResult.GetType());
|
||||
|
||||
TransferResult.bRecvResult = bSetRecvResult;
|
||||
TransferResult.bProcessResult = bSetProcessResult;
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.TRANSFER_RESULT), TransferResult);
|
||||
|
||||
return ucSendByteInfo;
|
||||
}
|
||||
|
||||
private bool QueryRecvStreamProcess(int iFlowPos, string strProcessInfo)
|
||||
{
|
||||
int i = iFlowPos;
|
||||
|
||||
bool bState = true;
|
||||
//
|
||||
XData getXData = FlowStreamControl[i].GetResultPacketData();
|
||||
|
||||
if (getXData == null)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo[i].stStreamProcessTime.Restart();
|
||||
|
||||
BASE_PROTOCOL GET_PROTOCOL = getXData.BaseProtocol;
|
||||
BASE_PROTOCOL.PROTOCOL_CODE CODE = GET_PROTOCOL.GET_CURRENT_PROTOCOL;
|
||||
|
||||
HEADER_PACKET getHeader = getXData.HeaderPacket;
|
||||
object objData = getXData.objData;
|
||||
|
||||
byte ucGetLabel = getXData.nLabel;
|
||||
|
||||
switch (CODE)
|
||||
{
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE:
|
||||
{
|
||||
PING_PACKET GetPingPacket = (PING_PACKET)objData;
|
||||
|
||||
string strGetMsg = GetPingPacket.objCheckMsg[0].Data;
|
||||
|
||||
PING_PACKET PingPacketMake = new PING_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(PingPacketMake);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
PingPacketMake = (PING_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, PingPacketMake.GetType());
|
||||
|
||||
PingPacketMake.objCheckMsg[0].Data = "SystemX";
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE), PingPacketMake);
|
||||
|
||||
if (ServerStreamSock[i].CLIENT_CONNECT)
|
||||
{
|
||||
if (ucSendByteInfo != null)
|
||||
FlowStreamControl[i].InsertSendQueue(DateTime.Now, ucSendByteInfo, null, ucGetLabel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.SYNC_TIME_SERVER:
|
||||
{
|
||||
TIME_PACKET GetTimePacket = (TIME_PACKET)objData;
|
||||
string strGetMsg = GetTimePacket.objMsg[0].Data;
|
||||
|
||||
TIME_PACKET timePacketMake = new TIME_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(timePacketMake);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
timePacketMake = (TIME_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, timePacketMake.GetType());
|
||||
|
||||
TimeControl.GetSyncTime(ref timePacketMake.objTime[0]);
|
||||
|
||||
timePacketMake.objMsg[0].Data = "SyncTimeSend";
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.SYNC_TIME_SERVER), timePacketMake);
|
||||
|
||||
if (ServerStreamSock[i].CLIENT_CONNECT)
|
||||
{
|
||||
if (ucSendByteInfo != null)
|
||||
FlowStreamControl[i].InsertSendQueue(DateTime.Now, ucSendByteInfo, null, ucGetLabel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.FILE_TRANSFER:
|
||||
{
|
||||
string strFileExtension = getHeader.objOptionExtension[0].Data;
|
||||
|
||||
bool bGetResult = false;
|
||||
|
||||
if (strFileExtension.IndexOf(".CpLog") >= 0 ||
|
||||
strFileExtension.IndexOf(".csv") >= 0)
|
||||
{
|
||||
//if (bUseMapLogProcess)
|
||||
MappedLogQueueData.Enqueue(new Tuple<string, int, HEADER_PACKET, byte[]>("FILE_TRANSFER", i, getHeader, objData as byte[]));
|
||||
|
||||
bGetResult = true;
|
||||
}
|
||||
|
||||
FlowStreamControl[i].InsertSendQueue(DateTime.Now, MakeTransferResult(true, bGetResult), null, PacketFlowControl.TransferResultToken, false);
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.RAW_SIZE:
|
||||
{
|
||||
if (getHeader.uiSourDataNum > 1)
|
||||
{
|
||||
if (thisConnInfo[i].nFileRecvPos > 0)
|
||||
{
|
||||
if ((thisConnInfo[i].nFileRecvPos + 1) != getHeader.uiSourDataNum ||
|
||||
thisConnInfo[i].nFileRecvEndPos == 0)
|
||||
{
|
||||
thisConnInfo[i].nFileRecvPos = 0;
|
||||
thisConnInfo[i].nFileRecvEndPos = 0;
|
||||
|
||||
FlowStreamControl[i].InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.RAW_END), false), null, false, false);
|
||||
|
||||
FlowStreamControl[i].InsertSendQueue(DateTime.Now, MakeTransferResult(false, false), null, PacketFlowControl.TransferResultToken, false);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
if (getHeader.uiSourDataNum == 1)
|
||||
{
|
||||
thisConnInfo[i].lstRecvFileBytes = new List<Tuple<int, byte[]>>();
|
||||
thisConnInfo[i].lstRecvFileBytes.Clear();
|
||||
|
||||
thisConnInfo[i].lstRecvFileBytes.Add(new Tuple<int, byte[]>((int)getHeader.uiSourDataNum, objData as byte[]));
|
||||
|
||||
thisConnInfo[i].nFileRecvPos = (int)getHeader.uiSourDataNum;
|
||||
thisConnInfo[i].nFileRecvEndPos = (int)getHeader.uiDestDataNum;
|
||||
|
||||
thisConnInfo[i].strRecvFileName = getHeader.objOptionName[0].Data;
|
||||
thisConnInfo[i].strRecvFileExtension = getHeader.objOptionExtension[0].Data;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisConnInfo[i].lstRecvFileBytes.Add(new Tuple<int, byte[]>((int)getHeader.uiSourDataNum, objData as byte[]));
|
||||
|
||||
thisConnInfo[i].nFileRecvPos++;
|
||||
}
|
||||
//
|
||||
if (thisConnInfo[i].nFileRecvPos >= thisConnInfo[i].nFileRecvEndPos)
|
||||
{
|
||||
int iSize = 0;
|
||||
|
||||
thisConnInfo[i].lstRecvFileBytes.Sort();
|
||||
|
||||
foreach (Tuple<int, byte[]> tData in thisConnInfo[i].lstRecvFileBytes)
|
||||
iSize += tData.Item2.Count();
|
||||
|
||||
byte[] ucGetDatas = new byte[iSize];
|
||||
int iCopyPos = 0;
|
||||
|
||||
foreach (Tuple<int, byte[]> tData in thisConnInfo[i].lstRecvFileBytes)
|
||||
{
|
||||
Array.Copy(tData.Item2, 0, ucGetDatas, iCopyPos, tData.Item2.Count());
|
||||
|
||||
iCopyPos += tData.Item2.Count();
|
||||
}
|
||||
|
||||
bool bGetResult = false;
|
||||
|
||||
if (thisConnInfo[i].strRecvFileExtension.IndexOf(".CpLog") >= 0 ||
|
||||
thisConnInfo[i].strRecvFileExtension.IndexOf(".csv") >= 0)
|
||||
{
|
||||
//if (bUseMapLogProcess)
|
||||
MappedLogQueueData.Enqueue(new Tuple<string, int, HEADER_PACKET, byte[]>("RAW_SIZE", i, getHeader, objData as byte[]));
|
||||
|
||||
bGetResult = true;
|
||||
}
|
||||
|
||||
thisConnInfo[i].nFileRecvPos = 0;
|
||||
thisConnInfo[i].nFileRecvEndPos = 0;
|
||||
|
||||
FlowStreamControl[i].InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.RAW_END), true), null, false, false);
|
||||
|
||||
FlowStreamControl[i].InsertSendQueue(DateTime.Now, MakeTransferResult(true, bGetResult), null, PacketFlowControl.TransferResultToken, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
thisConnInfo[i].lStreamTime = thisConnInfo[i].stStreamProcessTime.ElapsedMilliseconds;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + strProcessInfo + @" Recv queue stream process fail.[SystemX.Net.MiddlewareUI : MainForm.QueryRecvStreamQueue]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
bState = false;
|
||||
}
|
||||
|
||||
return bState;
|
||||
}
|
||||
|
||||
private bool QueryRecvStreamQueue()
|
||||
{
|
||||
//StackTrace st = new StackTrace(true);
|
||||
|
||||
bool bState = true;
|
||||
|
||||
try
|
||||
{
|
||||
bTaskStreamWaitLock = true;
|
||||
|
||||
for (int i = PORT_DISTRIBUTION_NUM; i < ALL_MANAGE_NUM && !m_bTaskStreamBlock; i++)
|
||||
{
|
||||
if (ServerStreamSock[i] == null)
|
||||
continue;
|
||||
//
|
||||
if (ServerStreamSock[i] != null)
|
||||
{
|
||||
if (ServerStreamSock[i].CLIENT_CONNECT == false)
|
||||
continue;
|
||||
}
|
||||
//
|
||||
if (FlowStreamControl[i] == null)
|
||||
continue;
|
||||
if (FlowStreamControl[i].GetCurrentRecvProcessData() != null)
|
||||
continue;
|
||||
//
|
||||
thisConnInfo[i].m_iSendStreamQueueSize = FlowStreamControl[i].GetSendQueueSize();
|
||||
thisConnInfo[i].m_iRecvStreamQueueSize = FlowStreamControl[i].GetRecvQueueSize();
|
||||
|
||||
if ((thisConnInfo[i].m_iSendStreamQueueSize + 1) == int.MaxValue)
|
||||
thisConnInfo[i].m_iSendStreamQueueSize = 0;
|
||||
if ((thisConnInfo[i].m_iRecvStreamQueueSize + 1) == int.MaxValue)
|
||||
thisConnInfo[i].m_iRecvStreamQueueSize = 0;
|
||||
//
|
||||
string strProcessDebugInfo = string.Empty;
|
||||
strProcessDebugInfo = "[" + (i).ToString("D2") + "]" +
|
||||
"[" + ConnPool[i].nUseStreamPort + "]" +
|
||||
"[" + thisConnInfo[i].strConnectHostID + "]" +
|
||||
"[" + thisConnInfo[i].strConnectSection + "]";
|
||||
|
||||
bState = QueryRecvStreamProcess(i, strProcessDebugInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
/*
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Frame Count {st.FrameCount} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
|
||||
for (int n = 0; n < st.FrameCount; n++)
|
||||
{
|
||||
StackFrame sf = st.GetFrame(n);
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Method To String {sf.GetMethod()} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Method Name {sf.GetMethod().Name} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Line Number {sf.GetFileLineNumber()} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + CpLogProcessInfo.strProcessDebugInfo + @" CpLog - " + $"ST Column Number {sf.GetFileColumnNumber()} [SystemX.Net.MiddlewareUI : MainForm.SetMemoryMappedFile] " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
}
|
||||
*/
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Recv queue stream process unknown fail.[SystemX.Net.MiddlewareUI : MainForm.QueryRecvStreamQueue]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
bState = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
bTaskStreamWaitLock = false;
|
||||
|
||||
nStreamNumber++;
|
||||
|
||||
if (nStreamNumber >= ALL_MANAGE_NUM)
|
||||
nStreamNumber = 0;
|
||||
}
|
||||
|
||||
return bState;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,653 @@
|
||||
using DevExpress.Data.Helpers;
|
||||
using DevExpress.XtraBars;
|
||||
using DevExpress.XtraBars.Navigation;
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
using SystemX.Net;
|
||||
using SystemX.Common;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.DB;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Common.Archive;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SystemX.Common.Protocol.SIA;
|
||||
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
using System.Threading;
|
||||
using SystemX.Net.Platform.Common.Util;
|
||||
using SystemX.Net.Platform.Common.ExtensionMethods;
|
||||
using SystemX.Net.Middleware.Commons;
|
||||
using static SystemX.Net.DB.XDBConnManager;
|
||||
|
||||
namespace SystemX.Net.MiddlewareUI
|
||||
{
|
||||
public partial class MainForm : DevExpress.XtraBars.FluentDesignSystem.FluentDesignForm
|
||||
{
|
||||
private void Chktimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
Chktimer.Enabled = false;
|
||||
|
||||
if (MIDDLEWARE_START_STATE == false)
|
||||
{
|
||||
ConsoleUtil.ConsoleVisibleControl();
|
||||
|
||||
//The program is automatically terminated.
|
||||
MessageBox.Show("Server information could not be retrieved. Check the console error text.", "Middleware for Line Bridge", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
//this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUserQueryRead_Click(object sender, EventArgs e)
|
||||
{
|
||||
xCallQuery.Load();
|
||||
}
|
||||
|
||||
|
||||
private void buttonListenReset_Click(object sender, EventArgs e)
|
||||
{
|
||||
dataGridViewListen.Rows.Clear();
|
||||
|
||||
ListenServerReset();
|
||||
}
|
||||
|
||||
private void WritePortSendRecvInfo(int nGetPos, int iRowPos)
|
||||
{
|
||||
if (thisConnInfo[nGetPos].m_ucSendCommandToken == 0x1)
|
||||
{
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[3].Style.BackColor != Color.Yellow)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[3].Style.BackColor = Color.Yellow;
|
||||
}
|
||||
else if (thisConnInfo[nGetPos].m_ucSendCommandToken == 0x2)
|
||||
{
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[3].Style.BackColor != Color.LightYellow)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[3].Style.BackColor = Color.LightYellow;
|
||||
}
|
||||
//
|
||||
if (thisConnInfo[nGetPos].m_ucRecvCommandToken == 0x1)
|
||||
{
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[4].Style.BackColor != Color.DeepSkyBlue)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[4].Style.BackColor = Color.DeepSkyBlue;
|
||||
}
|
||||
else if (thisConnInfo[nGetPos].m_ucRecvCommandToken == 0x2)
|
||||
{
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[4].Style.BackColor != Color.LightSkyBlue)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[4].Style.BackColor = Color.LightSkyBlue;
|
||||
}
|
||||
//
|
||||
if (thisConnInfo[nGetPos].m_ucSendStreamToken == 0x1)
|
||||
{
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[5].Style.BackColor != Color.Yellow)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[5].Style.BackColor = Color.Yellow;
|
||||
}
|
||||
else if (thisConnInfo[nGetPos].m_ucSendStreamToken == 0x2)
|
||||
{
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[5].Style.BackColor != Color.LightYellow)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[5].Style.BackColor = Color.LightYellow;
|
||||
}
|
||||
//
|
||||
if (thisConnInfo[nGetPos].m_ucRecvStreamToken == 0x1)
|
||||
{
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[6].Style.BackColor != Color.DeepSkyBlue)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[6].Style.BackColor = Color.DeepSkyBlue;
|
||||
}
|
||||
else if (thisConnInfo[nGetPos].m_ucRecvStreamToken == 0x2)
|
||||
{
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[6].Style.BackColor != Color.LightSkyBlue)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[6].Style.BackColor = Color.LightSkyBlue;
|
||||
}
|
||||
|
||||
dataGridViewPort.Rows[iRowPos].Cells[3].Value = thisConnInfo[nGetPos].m_iSendCommandCnt;
|
||||
dataGridViewPort.Rows[iRowPos].Cells[4].Value = thisConnInfo[nGetPos].m_iRecvCommandCnt;
|
||||
dataGridViewPort.Rows[iRowPos].Cells[5].Value = thisConnInfo[nGetPos].m_iSendStreamCnt;
|
||||
dataGridViewPort.Rows[iRowPos].Cells[6].Value = thisConnInfo[nGetPos].m_iRecvStreamCnt;
|
||||
}
|
||||
|
||||
private void PortInfoGridInitialize(int iRowPos)
|
||||
{
|
||||
/*
|
||||
if (strGetText.CompareTo(strSetProcessInfo[nGetPos]) != 0)
|
||||
dataGridViewPort.Rows[i].Cells[2].Value = strSetProcessInfo[nGetPos];
|
||||
*/
|
||||
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[3].Style.BackColor != Color.White)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[3].Style.BackColor = Color.White;
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[4].Style.BackColor != Color.White)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[4].Style.BackColor = Color.White;
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[5].Style.BackColor != Color.White)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[5].Style.BackColor = Color.White;
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[6].Style.BackColor != Color.White)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[6].Style.BackColor = Color.White;
|
||||
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[3].Value.ToString().Length > 0)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[3].Value = string.Empty;
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[4].Value.ToString().Length > 0)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[4].Value = string.Empty;
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[5].Value.ToString().Length > 0)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[5].Value = string.Empty;
|
||||
if (dataGridViewPort.Rows[iRowPos].Cells[6].Value.ToString().Length > 0)
|
||||
dataGridViewPort.Rows[iRowPos].Cells[6].Value = string.Empty;
|
||||
}
|
||||
|
||||
private void UItimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (m_bTimerLock[(int)TIMER_LOCK.UI_TIMER] == false)
|
||||
{
|
||||
m_bTimerLock[(int)TIMER_LOCK.UI_TIMER] = true;
|
||||
|
||||
if (TimeControl.SyncServerTimeResult)
|
||||
{
|
||||
if (barStaticItemSyncTime.Visibility == BarItemVisibility.Never)
|
||||
{
|
||||
barStaticItemSyncTime.Caption = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] Server time synchronization progressed successfully.";
|
||||
barStaticItemSyncTime.Visibility = BarItemVisibility.Always;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (barStaticItemSyncTime.Visibility == BarItemVisibility.Always)
|
||||
barStaticItemSyncTime.Visibility = BarItemVisibility.Never;
|
||||
}
|
||||
//
|
||||
if (progressBarProgram.Value + 20 <= 100)
|
||||
progressBarProgram.Value += 20;
|
||||
else
|
||||
progressBarProgram.Value = 0;
|
||||
|
||||
//Disconnect Listen Server Reset
|
||||
for (int i = 0; i < PORT_DISTRIBUTION_NUM; i++)
|
||||
{
|
||||
if (ConnPool[i].bRequiredPortReset == false)
|
||||
{
|
||||
//Listen Server Auto Reset 5 Minute
|
||||
if (ConnPool[i].stPortTimer.ElapsedMilliseconds >= 300000)
|
||||
ConnPool[i].bRequiredPortReset = true;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ConnPool[i].bRequiredPortResetReady == false)
|
||||
{
|
||||
ListenServerOnState[i] = false;
|
||||
|
||||
ClearListenElement(i);
|
||||
|
||||
ClearListenServerInstance(i);
|
||||
|
||||
ConnPool[i].bRequiredPortResetReady = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
StartListenServer(i, ConnPool[i].nUseCommandPort, ConnPool[i].nUseStreamPort);
|
||||
|
||||
DisplayListenElement(i);
|
||||
|
||||
ListenServerOnState[i] = true;
|
||||
|
||||
ConnPool[i].PortTImerRestart();
|
||||
|
||||
ConnPool[i].bRequiredPortResetReady = false;
|
||||
ConnPool[i].bRequiredPortReset = false;
|
||||
}
|
||||
|
||||
/*
|
||||
ListenServerOnState[i] = false;
|
||||
|
||||
ClearListenElement(i);
|
||||
|
||||
ClearListenServerInstance(i);
|
||||
|
||||
StartListenServer(i, ConnPool[i].nUseCommandPort, ConnPool[i].nUseStreamPort);
|
||||
|
||||
DisplayListenElement(i);
|
||||
|
||||
ListenServerOnState[i] = true;
|
||||
|
||||
ConnPool[i].bRequiredPortReset = false;
|
||||
*/
|
||||
}
|
||||
|
||||
//Listen
|
||||
dataGridViewListen.SuspendLayout();
|
||||
for (int i = 0; i < dataGridViewListen.RowCount; i++)
|
||||
{
|
||||
if (dataGridViewListen.Rows[i].Cells[0].Value == null)
|
||||
continue;
|
||||
|
||||
string strSetText = string.Empty;
|
||||
|
||||
string strGetNumText = dataGridViewListen.Rows[i].Cells[0].Value.ToString();
|
||||
string strGetText = dataGridViewListen.Rows[i].Cells[1].Value.ToString();
|
||||
|
||||
int nGetPos = int.MaxValue;
|
||||
|
||||
if (int.TryParse(strGetNumText, out nGetPos) == false)
|
||||
continue;
|
||||
|
||||
if (thisConnInfo[nGetPos].ClientConnectState)
|
||||
strSetText = "CONNECT - Assigning port";
|
||||
else
|
||||
strSetText = "WAIT";
|
||||
|
||||
if (strGetText.CompareTo(strSetText) != 0)
|
||||
dataGridViewListen.Rows[i].Cells[1].Value = strSetText;
|
||||
}
|
||||
dataGridViewListen.ResumeLayout();
|
||||
|
||||
//Distribution
|
||||
dataGridViewPort.SuspendLayout();
|
||||
for (int i = 0; i < dataGridViewPort.RowCount; i++)
|
||||
{
|
||||
if (dataGridViewPort.Rows[i].Cells[0].Value == null)
|
||||
continue;
|
||||
|
||||
string strGetText = dataGridViewPort.Rows[i].Cells[2].Value.ToString();
|
||||
string strGetName = dataGridViewPort.Rows[i].Cells[0].Value.ToString();
|
||||
string strConnState = dataGridViewPort.Rows[i].Cells[1].Value.ToString();
|
||||
int nGetPos = Convert.ToInt32(strGetName);
|
||||
|
||||
if (thisConnInfo[nGetPos].ClientConnectState && thisConnInfo[nGetPos].StreamConnectState)
|
||||
{
|
||||
if (thisConnInfo[nGetPos].bHostLoginState)
|
||||
{
|
||||
string strSetText = string.Empty;
|
||||
|
||||
strSetText = strSetProcessInfo[nGetPos] + ("@" + thisConnInfo[nGetPos].strConnectHostID +
|
||||
":" + thisConnInfo[nGetPos].strConnectSection +
|
||||
"@" + thisConnInfo[nGetPos].strCommandEndPointInfo);
|
||||
|
||||
if (strGetText.CompareTo(strSetText) != 0)
|
||||
dataGridViewPort.Rows[i].Cells[2].Value = strSetText;
|
||||
if (strConnState.CompareTo("CONNECT") != 0)
|
||||
dataGridViewPort.Rows[i].Cells[1].Value = "CONNECT";
|
||||
}
|
||||
|
||||
WritePortSendRecvInfo(nGetPos, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
PortInfoGridInitialize(i);
|
||||
|
||||
if (ConnPool[nGetPos].bUseState == false)
|
||||
{
|
||||
if (strGetText.CompareTo("-") != 0)
|
||||
dataGridViewPort.Rows[i].Cells[2].Value = "-";
|
||||
if (strConnState.CompareTo("-") != 0)
|
||||
dataGridViewPort.Rows[i].Cells[1].Value = "-";
|
||||
}
|
||||
}
|
||||
}
|
||||
dataGridViewListen.ResumeLayout();
|
||||
|
||||
/*
|
||||
if (m_iLastGetIndex != -1)
|
||||
DisplayConnectInfo(m_iLastGetIndex);
|
||||
*/
|
||||
|
||||
//DisplayConnectInfoDetect();
|
||||
|
||||
DriveInfo df = new DriveInfo(@LoadInfo.DISK_MONITOR_POS1);
|
||||
string strTip = string.Empty;
|
||||
int nPositionValue = int.MaxValue;
|
||||
|
||||
if (df.IsReady)
|
||||
{
|
||||
strTip = "Drive Name " + df.Name + " Available space " + ((double)df.AvailableFreeSpace / (double)df.TotalSize * 100).ToString("F2") + "%";
|
||||
|
||||
nPositionValue = (int)((double)df.AvailableFreeSpace / (double)df.TotalSize * 100);
|
||||
|
||||
if (progressBarControlC.ToolTip.CompareTo(strTip) != 0)
|
||||
progressBarControlC.ToolTip = strTip;
|
||||
|
||||
if (progressBarControlC.Position != nPositionValue)
|
||||
progressBarControlC.Position = (int)((double)df.AvailableFreeSpace / (double)df.TotalSize * 100);
|
||||
}
|
||||
df = new DriveInfo(@LoadInfo.DISK_MONITOR_POS2);
|
||||
if (df.IsReady)
|
||||
{
|
||||
strTip = "Drive Name " + df.Name + " Available space " + ((double)df.AvailableFreeSpace / (double)df.TotalSize * 100).ToString("F2") + "%";
|
||||
|
||||
nPositionValue = (int)((double)df.AvailableFreeSpace / (double)df.TotalSize * 100);
|
||||
|
||||
if (progressBarControlD.ToolTip.CompareTo(strTip) != 0)
|
||||
progressBarControlD.ToolTip = strTip;
|
||||
|
||||
if (progressBarControlC.Position != nPositionValue)
|
||||
progressBarControlD.Position = (int)((double)df.AvailableFreeSpace / (double)df.TotalSize * 100);
|
||||
}
|
||||
|
||||
m_bTimerLock[(int)TIMER_LOCK.UI_TIMER] = false;
|
||||
}
|
||||
}
|
||||
|
||||
private string MakeInfoConnectProcessText(int nPos, int nCommandPort, int nStreamPort)
|
||||
{
|
||||
string strSetProcessInfo = nPos.ToString("D2") + ":" +
|
||||
nCommandPort.ToString("D4") + ":" +
|
||||
nStreamPort.ToString("D4");
|
||||
|
||||
return strSetProcessInfo;
|
||||
}
|
||||
|
||||
private void DisplayListenElement()
|
||||
{
|
||||
dataGridViewListen.SuspendLayout();
|
||||
for (int i = 0; i < PORT_DISTRIBUTION_NUM; i++)
|
||||
{
|
||||
dataGridViewListen.Rows.Add();
|
||||
|
||||
strSetProcessInfo[i] = MakeInfoConnectProcessText(i, LoadInfo.nListenCommandPort[i], LoadInfo.nListenStreamPort[i]);
|
||||
|
||||
dataGridViewListen.Rows[i].Cells[0].Value = i.ToString();
|
||||
dataGridViewListen.Rows[i].Cells[1].Value = "WAIT";
|
||||
dataGridViewListen.Rows[i].Cells[2].Value = strSetProcessInfo[i];
|
||||
}
|
||||
dataGridViewListen.ResumeLayout();
|
||||
}
|
||||
|
||||
private void DisplayListenElement(int nPos)
|
||||
{
|
||||
dataGridViewListen.SuspendLayout();
|
||||
strSetProcessInfo[nPos] = MakeInfoConnectProcessText(nPos, LoadInfo.nListenCommandPort[nPos], LoadInfo.nListenStreamPort[nPos]);
|
||||
|
||||
dataGridViewListen.Rows[nPos].Cells[0].Value = nPos.ToString();
|
||||
dataGridViewListen.Rows[nPos].Cells[1].Value = "WAIT";
|
||||
dataGridViewListen.Rows[nPos].Cells[2].Value = strSetProcessInfo[nPos];
|
||||
dataGridViewListen.ResumeLayout();
|
||||
}
|
||||
|
||||
private void ClearListenElement(int nPos)
|
||||
{
|
||||
dataGridViewListen.SuspendLayout();
|
||||
strSetProcessInfo[nPos] = string.Empty;
|
||||
|
||||
dataGridViewListen.Rows[nPos].Cells[0].Value = "-";
|
||||
dataGridViewListen.Rows[nPos].Cells[1].Value = "-";
|
||||
dataGridViewListen.Rows[nPos].Cells[2].Value = strSetProcessInfo[nPos];
|
||||
|
||||
dataGridViewListen.ResumeLayout();
|
||||
}
|
||||
|
||||
private void DisplayPortElement()
|
||||
{
|
||||
dataGridViewPort.SuspendLayout();
|
||||
for (int i = PORT_DISTRIBUTION_NUM; i < ALL_MANAGE_NUM; i++)
|
||||
{
|
||||
dataGridViewPort.Rows.Add();
|
||||
|
||||
dataGridViewPort.Rows[i - PORT_DISTRIBUTION_NUM].Cells[0].Value = i.ToString();
|
||||
dataGridViewPort.Rows[i - PORT_DISTRIBUTION_NUM].Cells[1].Value = "-";
|
||||
dataGridViewPort.Rows[i - PORT_DISTRIBUTION_NUM].Cells[2].Value = "-";
|
||||
dataGridViewPort.Rows[i - PORT_DISTRIBUTION_NUM].Cells[3].Value = string.Empty;
|
||||
dataGridViewPort.Rows[i - PORT_DISTRIBUTION_NUM].Cells[4].Value = string.Empty;
|
||||
dataGridViewPort.Rows[i - PORT_DISTRIBUTION_NUM].Cells[5].Value = string.Empty;
|
||||
dataGridViewPort.Rows[i - PORT_DISTRIBUTION_NUM].Cells[6].Value = string.Empty;
|
||||
}
|
||||
dataGridViewPort.ResumeLayout();
|
||||
}
|
||||
|
||||
private void MakeElement(int nPos, int nCommandPort, int nStreamPort)
|
||||
{
|
||||
strSetProcessInfo[nPos] = MakeInfoConnectProcessText(nPos, nCommandPort, nStreamPort);
|
||||
|
||||
dataGridViewPort.Rows[nPos - PORT_DISTRIBUTION_NUM].Cells[1].Value = "WAIT";
|
||||
dataGridViewPort.Rows[nPos - PORT_DISTRIBUTION_NUM].Cells[2].Value = strSetProcessInfo[nPos];
|
||||
}
|
||||
|
||||
private void AddElement(int nPos, int nCommandPort, int nStreamPort)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
MakeElement(nPos, nCommandPort, nStreamPort);
|
||||
}));
|
||||
}
|
||||
else
|
||||
MakeElement(nPos, nCommandPort, nStreamPort);
|
||||
}
|
||||
|
||||
private void DeleteElement(int nPos)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
;//
|
||||
}
|
||||
catch {
|
||||
throw new Exception(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"RemoveElement-DeleteElement " + nPos.ToString("D3") + " [SystemX.Net.MiddlewareUI : MainForm.DeleteElement]\r\n");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
MessageOutput.ConsoleWrite(e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveElement(int nPos)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
DeleteElement(nPos);
|
||||
}));
|
||||
}
|
||||
else
|
||||
DeleteElement(nPos);
|
||||
}
|
||||
|
||||
private void DisplayConnectInfo(int iGetIndex)
|
||||
{
|
||||
if (thisConnInfo[iGetIndex].ClientConnectState &&
|
||||
thisConnInfo[iGetIndex].StreamConnectState)
|
||||
{
|
||||
/*
|
||||
string strRemoteInfo = string.Empty, strLocalInfo = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
if (thisConnInfo[iGetIndex].ClientConnectSocket != null)
|
||||
{
|
||||
strLocalInfo = thisConnInfo[iGetIndex]?.ClientConnectSocket?.LocalEndPoint?.ToString();
|
||||
strRemoteInfo = thisConnInfo[iGetIndex]?.ClientConnectSocket?.RemoteEndPoint?.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"DisplayConnectInfo exception state detect[1]. [SystemX.Net.MiddlewareUI : MainForm.DisplayConnectInfo]\r\n" + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
|
||||
m_iLastGetIndex = -1;
|
||||
|
||||
strRemoteInfo = "";
|
||||
strLocalInfo = "";
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (strRemoteInfo.IsNullOrEmpty())
|
||||
strRemoteInfo = "";
|
||||
if (strLocalInfo.IsNullOrEmpty())
|
||||
strLocalInfo = "";
|
||||
}
|
||||
*/
|
||||
//
|
||||
try
|
||||
{
|
||||
/* MODIFY
|
||||
dataGridViewState.Rows[0].Cells[0].Value = strLocalInfo;
|
||||
dataGridViewState.Rows[0].Cells[1].Value = "-";
|
||||
dataGridViewState.Rows[0].Cells[2].Value = "ON";
|
||||
dataGridViewState.Rows[0].Cells[3].Value = strRemoteInfo;
|
||||
|
||||
dataGridViewState.Rows[0].Cells[4].Value = thisConnInfo[iGetIndex].m_iSendCommandCnt.ToString("D6") + "," + thisConnInfo[iGetIndex].m_iSendStreamCnt.ToString("D6");
|
||||
dataGridViewState.Rows[0].Cells[5].Value = thisConnInfo[iGetIndex].m_iRecvCommandCnt.ToString("D6") + "," + thisConnInfo[iGetIndex].m_iRecvStreamCnt.ToString("D6");
|
||||
|
||||
dataGridViewState.Rows[0].Cells[6].Value = thisConnInfo[iGetIndex].m_iSendCommandQueueSize.ToString("D6") + "," + thisConnInfo[iGetIndex].m_iSendStreamQueueSize.ToString("D6");
|
||||
dataGridViewState.Rows[0].Cells[7].Value = thisConnInfo[iGetIndex].m_iRecvCommandQueueSize.ToString("D6") + "," + thisConnInfo[iGetIndex].m_iRecvStreamQueueSize.ToString("D6");
|
||||
|
||||
dataGridViewTime.Rows[0].Cells[0].Value = thisConnInfo[iGetIndex].lCommandTime.ToString();
|
||||
dataGridViewTime.Rows[0].Cells[1].Value = thisConnInfo[iGetIndex].lStreamTime.ToString();
|
||||
|
||||
dataGridViewTime.Rows[0].Cells[2].Value = ServerCommandSock[iGetIndex].ServerTokenPosCheck(0);
|
||||
dataGridViewTime.Rows[0].Cells[3].Value = ServerStreamSock[iGetIndex].ServerTokenPosCheck(1);
|
||||
*/
|
||||
}
|
||||
catch (Exception e) {
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"DisplayConnectInfo exception state detect[2]. [SystemX.Net.MiddlewareUI : MainForm.DisplayConnectInfo]\r\n" + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
|
||||
m_iLastGetIndex = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* MODIFY
|
||||
dataGridViewState.Rows[0].Cells[0].Value = string.Empty;
|
||||
dataGridViewState.Rows[0].Cells[1].Value = "-";
|
||||
dataGridViewState.Rows[0].Cells[2].Value = "OFF";
|
||||
dataGridViewState.Rows[0].Cells[3].Value = string.Empty;
|
||||
|
||||
dataGridViewState.Rows[0].Cells[4].Value = string.Empty;
|
||||
dataGridViewState.Rows[0].Cells[5].Value = string.Empty;
|
||||
|
||||
dataGridViewState.Rows[0].Cells[6].Value = string.Empty;
|
||||
dataGridViewState.Rows[0].Cells[7].Value = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
if (ServerCommandSock[iGetIndex] != null)
|
||||
dataGridViewTime.Rows[0].Cells[2].Value = ServerCommandSock[iGetIndex].ServerTokenPosCheck(0);
|
||||
if (ServerStreamSock[iGetIndex] != null)
|
||||
dataGridViewTime.Rows[0].Cells[3].Value = ServerStreamSock[iGetIndex].ServerTokenPosCheck(1);
|
||||
}
|
||||
catch (Exception e) {
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"Server socket status check failed. [SystemX.Net.MiddlewareUI : MainForm.DisplayConnectInfo]\r\n" + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
|
||||
m_iLastGetIndex = -1;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private void DisplayConnectInfoDetect()
|
||||
{
|
||||
for (int i = PORT_DISTRIBUTION_NUM; i < ALL_MANAGE_NUM; i++)
|
||||
{
|
||||
if (thisConnInfo[i].ClientConnectState == false)
|
||||
continue;
|
||||
|
||||
//
|
||||
if (thisConnInfo[i].ConnectStreamCheck)
|
||||
{
|
||||
if (thisConnInfo[i].stStreamCheckTime.ElapsedMilliseconds >= 20000)
|
||||
{
|
||||
thisConnInfo[i].stStreamCheckTime.Restart();
|
||||
thisConnInfo[i].ConnectStreamCheck = false;
|
||||
|
||||
if (thisConnInfo[i].StreamConnectState == false)
|
||||
{
|
||||
ResetStreamConnectSetCheck(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
/*
|
||||
string strRemoteInfo = string.Empty, strLocalInfo = string.Empty;
|
||||
|
||||
bool bGetSocketInfo = true;
|
||||
try
|
||||
{
|
||||
if (thisConnInfo[i].ClientConnectSocket != null)
|
||||
{
|
||||
strLocalInfo = thisConnInfo[i]?.ClientConnectSocket?.LocalEndPoint?.ToString();
|
||||
strRemoteInfo = thisConnInfo[i]?.ClientConnectSocket?.RemoteEndPoint?.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ServerStreamSock[i].ServerSocketUnknownError(false);
|
||||
ServerCommandSock[i].ServerSocketUnknownError(false);
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" " + i.ToString("D2") + " ConnectInfo exception state detect. - Socket clear[1]. [SystemX.Net.MiddlewareUI : MainForm.DisplayConnectInfoDetect]\r\n" + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
|
||||
strRemoteInfo = "";
|
||||
strLocalInfo = "";
|
||||
|
||||
bGetSocketInfo = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (strRemoteInfo.IsNullOrEmpty())
|
||||
strRemoteInfo = "";
|
||||
if (strLocalInfo.IsNullOrEmpty())
|
||||
strLocalInfo = "";
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if (bGetSocketInfo == false)
|
||||
continue;
|
||||
//
|
||||
try
|
||||
{
|
||||
;//
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" " + i.ToString("D2") + " ConnectInfo exception state detect. - Socket clear[2]. [SystemX.Net.MiddlewareUI : MainForm.DisplayConnectInfoDetect]\r\n" + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);
|
||||
|
||||
ResetConnectSetCheck(i);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private void GridRowCellClick(object sender, EventArgs e)
|
||||
{
|
||||
string[] strGetEleInfo = ((AccordionControlElement)sender).Text.Split(':');
|
||||
|
||||
if (strGetEleInfo.Count() > 0)
|
||||
{
|
||||
int iGetIndex = Convert.ToInt32(strGetEleInfo[0]);
|
||||
|
||||
m_iLastGetIndex = iGetIndex;
|
||||
|
||||
DisplayConnectInfo(iGetIndex);
|
||||
|
||||
if (thisConnInfo[iGetIndex].stCheckTime.ElapsedMilliseconds <= 400)
|
||||
{
|
||||
string strTextMsg = ((AccordionControlElement)sender).Text;
|
||||
if (MessageBox.Show("You want to [" + strTextMsg + "] server point initialize?", "Middleware for Line Bridge - Middleware UI", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResetConnectSetCheck(iGetIndex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"[" + strTextMsg + "] initialize failed. [SystemX.Net.MiddlewareUI : MainForm.accordionControlElement_Click]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
thisConnInfo[iGetIndex].stCheckTime.Restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user