[성현모] CPXV2 Init
This commit is contained in:
@ -0,0 +1,35 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32630.194
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemX.Net.CP.XAdaptor.UIM", "SystemX.Net.PCAdaptor\SystemX.Net.CP.XAdaptor.UIM.csproj", "{211F9F09-5EA5-46F4-933E-BB1FCE92D2B5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemX.Net.CP.XAdaptor.UI", "SystemX.Net.PCAdaptorUI\SystemX.Net.CP.XAdaptor.UI.csproj", "{265215C7-2CC1-4A44-85DC-57FB9F035F71}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{211F9F09-5EA5-46F4-933E-BB1FCE92D2B5} = {211F9F09-5EA5-46F4-933E-BB1FCE92D2B5}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{211F9F09-5EA5-46F4-933E-BB1FCE92D2B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{211F9F09-5EA5-46F4-933E-BB1FCE92D2B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{211F9F09-5EA5-46F4-933E-BB1FCE92D2B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{211F9F09-5EA5-46F4-933E-BB1FCE92D2B5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{265215C7-2CC1-4A44-85DC-57FB9F035F71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{265215C7-2CC1-4A44-85DC-57FB9F035F71}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{265215C7-2CC1-4A44-85DC-57FB9F035F71}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{265215C7-2CC1-4A44-85DC-57FB9F035F71}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
VisualSVNWorkingCopyRoot = .
|
||||
SolutionGuid = {5792BD14-4FC3-4542-8FA0-D4E6DC61C8DF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
423
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptor/Commons.cs
Normal file
423
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptor/Commons.cs
Normal file
@ -0,0 +1,423 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
using SystemX.Net.BaseProtocol;
|
||||
|
||||
namespace SystemX.Net.XAdaptor
|
||||
{
|
||||
public enum SAVE_TABLE_LIST
|
||||
{
|
||||
HIST_ProdLoad = 0,
|
||||
HIST_CapDeassy = 1,
|
||||
HIST_PreHeating = 2,
|
||||
HIST_PreMeas = 3,
|
||||
HIST_Leak = 4,
|
||||
HIST_LaserTrim = 5,
|
||||
HIST_IsoRes = 6,
|
||||
HIST_CapAssy = 7,
|
||||
HIST_Function = 8,
|
||||
HIST_OutSealPress = 9,
|
||||
HIST_PinVision = 10,
|
||||
HIST_ProdUnload = 11,
|
||||
HIST_GrsDisp = 11
|
||||
}
|
||||
|
||||
public enum eResultCheck
|
||||
{
|
||||
None = -1024,
|
||||
InvalidFormat = -4,
|
||||
InvalidMacAddressFormat = -2,
|
||||
AlreadyIssued = -1,
|
||||
NotIssued = 0
|
||||
}
|
||||
|
||||
public enum eResultIssued
|
||||
{
|
||||
None = -1024,
|
||||
InvalidFormat = -128,
|
||||
InformationThatDoesNotExist = -64,
|
||||
InformationWithoutIssuanceHistory = -3,
|
||||
AlreadyIssued = -2,
|
||||
Failed = -1,
|
||||
Success = 0
|
||||
}
|
||||
|
||||
public enum eMacAddressType
|
||||
{
|
||||
InvalidMacAddressFormat = -1,
|
||||
Normal = 0,
|
||||
Colon = 1,
|
||||
Hyphen = 2,
|
||||
Dot = 3,
|
||||
}
|
||||
|
||||
public enum eLookUpOption
|
||||
{
|
||||
CompareToSame = 0,
|
||||
StartWith = 1,
|
||||
EndWith = 2,
|
||||
ContainWith = 3
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum eFileSendRecvResult
|
||||
{
|
||||
None = 0x8000,
|
||||
StreamSocketNoConnect = 0x8001,
|
||||
ConnectInitializeFail = 0x8002,
|
||||
NoFileTransferPermission = 0x8004,
|
||||
FileSizeOver = 0x8008,
|
||||
FileAccessError = 0x8010,
|
||||
FileProcFailed = 0x8020,
|
||||
//OppoentRecvNG = 0x8040,
|
||||
//OppoentRecvOKProcNG = 0x8080,
|
||||
MonitorLockUpState = 0x8100,
|
||||
FileProcSuccess = 0x0000,
|
||||
//OppoentRecvOKProcOK = 0x0000
|
||||
}
|
||||
|
||||
public enum eSetConfigFileResult
|
||||
{
|
||||
None = 0,
|
||||
SetConfigFail = -1,
|
||||
SetConfigSuccess = 1
|
||||
}
|
||||
|
||||
public enum eSetFileLogCategory
|
||||
{
|
||||
None = 0,
|
||||
FileLog = 1,
|
||||
FTPFileLog = 2
|
||||
}
|
||||
|
||||
public class ResultIssued
|
||||
{
|
||||
public eResultIssued eResult;
|
||||
public string strMacAddress;
|
||||
public string strErrMessage;
|
||||
|
||||
public ResultIssued(eResultIssued setResult) {
|
||||
eResult = setResult;
|
||||
strMacAddress = string.Empty;
|
||||
strErrMessage = string.Empty;
|
||||
}
|
||||
|
||||
public ResultIssued(eResultIssued setResult, string strSetMacAddress, string strSetErrMsg)
|
||||
{
|
||||
eResult = setResult;
|
||||
strMacAddress = strSetMacAddress;
|
||||
strErrMessage = strSetErrMsg;
|
||||
}
|
||||
}
|
||||
|
||||
public class ClientConnInfo
|
||||
{
|
||||
public string CONNECT_IP { set; get; }
|
||||
public string SECTION { set; get; }
|
||||
public string HOST_ID { set; get; }
|
||||
public string TEST_CODE { set; get; }
|
||||
|
||||
public int COMMAND_PORT { set; get; }
|
||||
public int STREAM_PORT { set; get; }
|
||||
|
||||
public bool LOGIN_RESULT { set; get; }
|
||||
public string LOGIN_MESSAGE { set; get; }
|
||||
|
||||
public ClientConnInfo()
|
||||
{
|
||||
CONNECT_IP = string.Empty;
|
||||
SECTION = string.Empty;
|
||||
HOST_ID = string.Empty;
|
||||
TEST_CODE = string.Empty;
|
||||
|
||||
COMMAND_PORT = int.MaxValue;
|
||||
STREAM_PORT = int.MaxValue;
|
||||
|
||||
LOGIN_RESULT = false;
|
||||
LOGIN_MESSAGE = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public class SubscriberClient
|
||||
{
|
||||
public bool bUIMUseMode;
|
||||
|
||||
public bool bSetChangeConnect;
|
||||
|
||||
public bool bReqConnectAbort;
|
||||
|
||||
public int nChangeCommandPort;
|
||||
public int nChangeStreamPort;
|
||||
|
||||
public DateTime dtSessionTime;
|
||||
|
||||
public bool bSessionStarted;
|
||||
|
||||
public bool bSubscriberClientResult;
|
||||
|
||||
public SubscriberClient()
|
||||
{
|
||||
bUIMUseMode = false;
|
||||
|
||||
bSetChangeConnect = false;
|
||||
|
||||
bReqConnectAbort = false;
|
||||
|
||||
nChangeCommandPort = 0;
|
||||
nChangeStreamPort = 0;
|
||||
|
||||
dtSessionTime = DateTime.Now;
|
||||
|
||||
bSessionStarted = false;
|
||||
|
||||
bSubscriberClientResult = false;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
bUIMUseMode = false;
|
||||
|
||||
bSetChangeConnect = false;
|
||||
|
||||
bReqConnectAbort = false;
|
||||
|
||||
nChangeCommandPort = 0;
|
||||
nChangeStreamPort = 0;
|
||||
|
||||
dtSessionTime = DateTime.Now;
|
||||
|
||||
bSessionStarted = false;
|
||||
|
||||
bSubscriberClientResult = false;
|
||||
}
|
||||
|
||||
public void SessionTimeSet()
|
||||
{
|
||||
dtSessionTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public TimeSpan GetSessionTime()
|
||||
{
|
||||
return DateTime.Now - dtSessionTime;
|
||||
}
|
||||
}
|
||||
|
||||
public class ClientInfoStore
|
||||
{
|
||||
public bool ConnectCommandState { set; get; }
|
||||
|
||||
public bool ConnectStreamState { set; get; }
|
||||
|
||||
public bool InitialInfoState { set; get; }
|
||||
|
||||
public int m_iSendCommandCnt { set; get; }
|
||||
public int m_iRecvCommandCnt { set; get; }
|
||||
|
||||
public int m_iSendStreamCnt { set; get; }
|
||||
public int m_iRecvStreamCnt { set; get; }
|
||||
|
||||
public int m_iSendCommandQueueSize { set; get; }
|
||||
public int m_iRecvCommandQueueSize { set; get; }
|
||||
|
||||
public int m_iSendStreamQueueSize { set; get; }
|
||||
public int m_iRecvStreamQueueSize { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Big Size File
|
||||
/// </summary>
|
||||
public List<Tuple<int, byte[]>> lstRecvFileBytes { set; get; }
|
||||
public int nFileRecvPos { set; get; }
|
||||
public int nFileRecvEndPos { set; get; }
|
||||
|
||||
public string strRecvFileName { set; get; }
|
||||
public string strRecvExtension { set; get; }
|
||||
|
||||
//LastProcessTime
|
||||
public Stopwatch stCommandProcessTime;
|
||||
public long lCommandTime;
|
||||
|
||||
public Stopwatch stStreamProcessTime;
|
||||
public long lStreamTime;
|
||||
|
||||
//Ping Check Time
|
||||
public Stopwatch stCommandCheckTime;
|
||||
public Stopwatch stStreamCheckTime;
|
||||
//
|
||||
public bool bHostLoginState;
|
||||
public Stopwatch stLoginTimeOut;
|
||||
|
||||
public void OnCommandTime() { stCommandProcessTime.Restart(); }
|
||||
public void OffCommandTime() { lCommandTime = stCommandProcessTime.ElapsedMilliseconds; }
|
||||
public void OnStreamTime() { stStreamProcessTime.Restart(); }
|
||||
public void OffStreamTime() { lStreamTime = stStreamProcessTime.ElapsedMilliseconds; }
|
||||
//
|
||||
public void OnCommandCheckTime() { stCommandCheckTime.Restart(); }
|
||||
public void OnStreamCheckTime() { stStreamCheckTime.Restart(); }
|
||||
//
|
||||
|
||||
public ClientInfoStore()
|
||||
{
|
||||
ConnectCommandState = false;
|
||||
ConnectStreamState = false;
|
||||
|
||||
InitialInfoState = false;
|
||||
|
||||
m_iSendCommandCnt = 0;
|
||||
m_iRecvCommandCnt = 0;
|
||||
|
||||
m_iSendStreamCnt = 0;
|
||||
m_iRecvStreamCnt = 0;
|
||||
|
||||
m_iSendCommandQueueSize = 0;
|
||||
m_iRecvCommandQueueSize = 0;
|
||||
|
||||
m_iSendStreamQueueSize = 0;
|
||||
m_iRecvStreamQueueSize = 0;
|
||||
|
||||
lstRecvFileBytes = new List<Tuple<int, byte[]>>();
|
||||
nFileRecvPos = 0;
|
||||
nFileRecvEndPos = 0;
|
||||
|
||||
strRecvFileName = string.Empty;
|
||||
strRecvExtension = string.Empty;
|
||||
|
||||
//
|
||||
stCommandProcessTime = new Stopwatch();
|
||||
stCommandProcessTime.Start();
|
||||
lCommandTime = 0;
|
||||
|
||||
stStreamProcessTime = new Stopwatch();
|
||||
stStreamProcessTime.Start();
|
||||
lStreamTime = 0;
|
||||
//
|
||||
stCommandCheckTime = new Stopwatch();
|
||||
stCommandCheckTime.Start();
|
||||
|
||||
stStreamCheckTime = new Stopwatch();
|
||||
stStreamCheckTime.Start();
|
||||
|
||||
bHostLoginState = true;
|
||||
stLoginTimeOut = new Stopwatch();
|
||||
stLoginTimeOut.Start();
|
||||
}
|
||||
}
|
||||
public static class SelectDataTable
|
||||
{
|
||||
private static Enum MakeCrrent;
|
||||
private static Type MakeType;
|
||||
|
||||
static SelectDataTable()
|
||||
{
|
||||
}
|
||||
|
||||
public static Type GetCurrentType()
|
||||
{
|
||||
return MakeType;
|
||||
}
|
||||
|
||||
public static void MakeDicList(string[] strTableName)
|
||||
{
|
||||
// Get the current application domain for the current thread
|
||||
AppDomain currentDomain = AppDomain.CurrentDomain;
|
||||
|
||||
// Create a dynamic Assembly in the current application domain,
|
||||
// and allow it to be executed and saved to disk.
|
||||
AssemblyName name = new AssemblyName("SaveListEnums");
|
||||
AssemblyBuilder assemblyBuilder = currentDomain.DefineDynamicAssembly(name,
|
||||
AssemblyBuilderAccess.RunAndSave);
|
||||
|
||||
// Define a dynamic module in "SaveListEnums" Assembly.
|
||||
// For a single-module Assembly, the module has the same name as the Assembly.
|
||||
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(name.Name,
|
||||
name.Name + ".dll");
|
||||
|
||||
// Define a public enumeration with the name "SaveListEnum" and an underlying type of Integer.
|
||||
EnumBuilder xEnum = moduleBuilder.DefineEnum("EnumeratedTypes.SaveListEnum",
|
||||
TypeAttributes.Public, typeof(int));
|
||||
|
||||
int iSetKey = 1;
|
||||
xEnum.DefineLiteral("None", 0);
|
||||
foreach (string strName in strTableName)
|
||||
xEnum.DefineLiteral(strName, iSetKey++);
|
||||
|
||||
MakeType = xEnum.CreateType();
|
||||
|
||||
// Create the enum
|
||||
MakeCrrent = (Enum)Activator.CreateInstance(xEnum.CreateType());
|
||||
|
||||
var sFilePath = Directory.GetCurrentDirectory() + "\\" + "SaveListEnums.dll";
|
||||
|
||||
if (File.Exists(sFilePath))
|
||||
File.Delete(sFilePath);
|
||||
|
||||
// Finally, save the Assembly
|
||||
assemblyBuilder.Save(name.Name + ".dll");
|
||||
}
|
||||
}
|
||||
public static class COMMON
|
||||
{
|
||||
public static bool FIX_INFO_MODE = false;
|
||||
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern uint timeGetTime();
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern bool SetLocalTime(ref SYSTEMTIME st);
|
||||
|
||||
public static T ConvertTextToTryValue<T>(string strText, object objFailValue)
|
||||
{
|
||||
object obj;
|
||||
obj = typeof(T);
|
||||
|
||||
int iGetValue = 0;
|
||||
uint uiGetValue = 0;
|
||||
double dGetValue = 0;
|
||||
|
||||
if (obj.ToString().IndexOf("Int") >= 0)
|
||||
{
|
||||
if (!int.TryParse(strText, out iGetValue))
|
||||
obj = objFailValue;
|
||||
else
|
||||
obj = iGetValue;
|
||||
}
|
||||
if (obj.ToString().IndexOf("UInt") >= 0)
|
||||
{
|
||||
if (!uint.TryParse(strText, out uiGetValue))
|
||||
obj = objFailValue;
|
||||
else
|
||||
obj = uiGetValue;
|
||||
}
|
||||
else if (obj.ToString().IndexOf("Double") >= 0)
|
||||
{
|
||||
if (!double.TryParse(strText, out dGetValue))
|
||||
obj = objFailValue;
|
||||
else
|
||||
obj = dGetValue;
|
||||
}
|
||||
|
||||
return (T)Convert.ChangeType(obj, typeof(T));
|
||||
}
|
||||
|
||||
public static T FindByName<T>(this object targetClass, string name) where T : class
|
||||
{
|
||||
System.Reflection.FieldInfo fi = targetClass.GetType().GetField(name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
|
||||
|
||||
return fi.GetValue(targetClass) as T;
|
||||
}
|
||||
public static T FindByName<T>(this string name, object targetClass) where T : class
|
||||
{
|
||||
System.Reflection.FieldInfo fi = targetClass.GetType().GetField(name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
|
||||
|
||||
return fi.GetValue(targetClass) as T;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
|
||||
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
|
||||
// 이러한 특성 값을 변경하세요.
|
||||
[assembly: AssemblyTitle("SystemX.Net.XAdaptor.PC")]
|
||||
[assembly: AssemblyDescription("For Middleware connect dll(XAdaptor.PC)")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("SystemX")]
|
||||
[assembly: AssemblyProduct("SystemX.Net.XAdaptor.PC")]
|
||||
[assembly: AssemblyCopyright("SystemX Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("SystemX.Net")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
|
||||
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
|
||||
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
|
||||
[assembly: ComVisible(true)]
|
||||
|
||||
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
|
||||
[assembly: Guid("211F9F09-5EA5-46F4-933E-BB1FCE92D2B5")]
|
||||
|
||||
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
|
||||
//
|
||||
// 주 버전
|
||||
// 부 버전
|
||||
// 빌드 번호
|
||||
// 수정 버전
|
||||
//
|
||||
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
|
||||
// 기본값으로 할 수 있습니다.
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{211F9F09-5EA5-46F4-933E-BB1FCE92D2B5}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SystemX.Net.XAdaptor.PC.UIM</RootNamespace>
|
||||
<AssemblyName>SystemX.Net.XAdaptor.PC.UIM</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output.SystemX\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<RegisterForComInterop>true</RegisterForComInterop>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output.SystemX\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<RegisterForComInterop>true</RegisterForComInterop>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="SystemX.Net.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Output.SystemX\SystemX.Net.Platform.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="XAdaptorManager.cs" />
|
||||
<Compile Include="XAdaptor.cs" />
|
||||
<Compile Include="XPCAdaptor\IUIM.cs" />
|
||||
<Compile Include="XPCAdaptor\IComXPCAdaptor.cs" />
|
||||
<Compile Include="XPCAdaptor\NgCode\DBSchemaMap.cs" />
|
||||
<Compile Include="XPCAdaptor\NgCode\NGCodeFinder.cs" />
|
||||
<Compile Include="XPCAdaptor\NgCode\NGCodeMgr.cs" />
|
||||
<Compile Include="XPCAdaptor\NgCode\NGHistDBFinder.cs" />
|
||||
<Compile Include="XPCAdaptor\Protocol Method\Command Protocol\CONNECT_STATE.cs" />
|
||||
<Compile Include="XPCAdaptor\Protocol Method\Command Protocol\HOST_INFO_CHECK.cs" />
|
||||
<Compile Include="XPCAdaptor\Protocol Method\Command Protocol\INITILALIZE_INFO.cs" />
|
||||
<Compile Include="XPCAdaptor\Protocol Method\ProtocolShell.cs" />
|
||||
<Compile Include="XList\lstList.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\TaskCommand.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\Interface Implement\XAdaptor.PC.UIM.Implement.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\Interface Implement\XAdaptor.PC.Interface.Implement.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\TaskSub.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\Tasks.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\TaskStream.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\FileScan.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\Interface Implement\XAdaptor.PC.ComInterface.Implement.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\Interface Implement\XAdaptor.PC.Query.Implement.cs" />
|
||||
<Compile Include="Commons.cs" />
|
||||
<Compile Include="XPCAdaptor\IXPCAdaptor.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="XPCAdaptor\XPCAdaptorSub\Events.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="XPCAdaptor\Protocol Method\Stream Protocol\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
641
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptor/XAdaptor.cs
Normal file
641
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptor/XAdaptor.cs
Normal file
@ -0,0 +1,641 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.Comm.IIS_FTP;
|
||||
using SystemX.Net.Schedule;
|
||||
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor
|
||||
{
|
||||
public class XAdaptorSystem
|
||||
{
|
||||
public string LoginID { set; protected get; }
|
||||
public string LoginKEY { set; protected get; }
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool StateClientSocketConnect { internal set; get; }
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool StateClientStreamSocketConnect { internal set; get; }
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool StateClientGetInformation { internal set; get; }
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool StateAdaptorConnect { internal set; get; }
|
||||
|
||||
//
|
||||
protected ClientConnInfo AdaptorInformation;
|
||||
|
||||
//private static object objFailedFileWriteLock = new object();
|
||||
|
||||
private static object objLogWriteLock = new object();
|
||||
|
||||
public bool ServerTestListLoadState;
|
||||
|
||||
public ClientConnInfo AdaptorInfor()
|
||||
{
|
||||
return AdaptorInformation;
|
||||
}
|
||||
|
||||
public string GetAdaptorConnectIP()
|
||||
{
|
||||
return AdaptorInformation.CONNECT_IP;
|
||||
}
|
||||
|
||||
public string GetAdaptorHostID()
|
||||
{
|
||||
return AdaptorInformation.HOST_ID;
|
||||
}
|
||||
|
||||
public string GetAdaptorSection()
|
||||
{
|
||||
return AdaptorInformation.SECTION;
|
||||
}
|
||||
|
||||
public string GetAdaptorTestCode()
|
||||
{
|
||||
return AdaptorInformation.TEST_CODE;
|
||||
}
|
||||
|
||||
public int GetAdaptorCommandPort()
|
||||
{
|
||||
return AdaptorInformation.COMMAND_PORT;
|
||||
}
|
||||
|
||||
public int GetAdaptorStreamPort()
|
||||
{
|
||||
return AdaptorInformation.STREAM_PORT;
|
||||
}
|
||||
|
||||
public bool GetAdaptorLoginResult()
|
||||
{
|
||||
return AdaptorInformation.LOGIN_RESULT;
|
||||
}
|
||||
|
||||
public string GetAdaptorLoginMessage()
|
||||
{
|
||||
return AdaptorInformation.LOGIN_MESSAGE;
|
||||
}
|
||||
|
||||
public long GetLastCommandTime()
|
||||
{
|
||||
return thisConnInfo.lCommandTime;
|
||||
}
|
||||
|
||||
public long GetLastStreamTime()
|
||||
{
|
||||
return thisConnInfo.lStreamTime;
|
||||
}
|
||||
|
||||
public int[] GetReloadNeedStation()
|
||||
{
|
||||
return dicTestListNeedReload.Keys.ToArray();
|
||||
}
|
||||
|
||||
public bool GetStateReloadNeedTestList(int nStationID)
|
||||
{
|
||||
if (dicTestListNeedReload.ContainsKey(nStationID))
|
||||
return dicTestListNeedReload[nStationID];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetStateReloadNeedTestList(int nStationID)
|
||||
{
|
||||
if (dicTestListNeedReload.ContainsKey(nStationID))
|
||||
dicTestListNeedReload[nStationID] = false;
|
||||
}
|
||||
|
||||
protected Dictionary<int, bool> dicTestListNeedReload = new Dictionary<int, bool>();
|
||||
|
||||
public COMM_INFO_PACKET GetConnectionInfo { protected set; get; }
|
||||
|
||||
public SubscriberClient SubscribeConnectInfo { protected set; get; }
|
||||
|
||||
protected bool ClientReadyEndPoint { set; get; }
|
||||
|
||||
protected ClientInfo LoadInfo;
|
||||
|
||||
public string REF_CONNECT_IP { protected set; get; }
|
||||
public bool ConnectStartStyleAuto { set; get; } = true;
|
||||
|
||||
//설정 파일과 별개로 IP를 변경해서 접속할때(for UIM)
|
||||
public void SetAdaptorConnectIP(string strSetIP)
|
||||
{
|
||||
string[] strGetSplitText = strSetIP.Split(',');
|
||||
|
||||
if (strGetSplitText.Length == 2)
|
||||
{
|
||||
string strGetIP = strGetSplitText[0];
|
||||
string strGetPort = strGetSplitText[1];
|
||||
|
||||
REF_CONNECT_IP = strGetIP;
|
||||
}
|
||||
else
|
||||
REF_CONNECT_IP = strSetIP;
|
||||
}
|
||||
|
||||
public double? GetIssueWorkerWaitTime()
|
||||
{
|
||||
return LoadInfo?.ISSUE_WORKER_WAIT_TIME_ms;
|
||||
}
|
||||
|
||||
public double? GetSessionTimeoutTime()
|
||||
{
|
||||
return LoadInfo?.SESSION_TIMEOUT_TIME_S;
|
||||
}
|
||||
|
||||
|
||||
public event EventHandler CommandConnectAlarmEvent;
|
||||
public event EventHandler StreamConnectAlarmEvent;
|
||||
|
||||
public event EventHandler ConnectionInfoRecvEvent;
|
||||
|
||||
public event EventHandler CommandDisconnectAlarmEvent;
|
||||
public event EventHandler StreamDisconnectAlarmEvent;
|
||||
|
||||
public event EventHandler LoginAlarmEvent;
|
||||
|
||||
public event EventHandler QueryCallEvent;
|
||||
|
||||
public XAdaptorSystem()
|
||||
{
|
||||
SubscribeConnectInfo = new SubscriberClient();
|
||||
|
||||
REF_CONNECT_IP = string.Empty;
|
||||
|
||||
LoginID = string.Empty;
|
||||
LoginKEY = string.Empty;
|
||||
|
||||
ServerTestListLoadState = false;
|
||||
}
|
||||
|
||||
// TODO : FTP ALIS
|
||||
public eFTPServiceStatus StateFTP { set; get; } = eFTPServiceStatus.None;
|
||||
|
||||
protected CtrlFTP ControlFTP;
|
||||
|
||||
protected void XAdaptorLogWrite(string strWriteMsg)
|
||||
{
|
||||
string strYYYY = DateTime.Today.ToString("yyyy");
|
||||
string strMM = DateTime.Today.ToString("MM");
|
||||
string strdd = DateTime.Today.ToString("dd");
|
||||
|
||||
string strHHmmssfff = DateTime.Today.ToString("HHmmssfff");
|
||||
|
||||
string strFileSubName = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
strFileSubName = AdaptorInformation.HOST_ID + "_" + AdaptorInformation.SECTION;
|
||||
}
|
||||
catch
|
||||
{
|
||||
strFileSubName = string.Empty;
|
||||
}
|
||||
|
||||
string strGetRoot = Path.GetPathRoot(Environment.CurrentDirectory);
|
||||
|
||||
string DirPath = strGetRoot + $@"\XLog\Log\{LoadInfo.HOST_ID}\{LoadInfo.SECTION}\{strYYYY}\{strMM}\{strdd}\";
|
||||
|
||||
string FilePath = string.Empty;
|
||||
|
||||
if (strFileSubName.Length > 0)
|
||||
FilePath = DirPath + @"\XLog_" + DateTime.Today.ToString("yyyyMMdd") + "_" + strFileSubName + ".Xlog";
|
||||
else
|
||||
FilePath = DirPath + @"\XLog_" + DateTime.Today.ToString("yyyyMMdd") + ".Xlog";
|
||||
|
||||
string temp;
|
||||
|
||||
lock (objLogWriteLock)
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(DirPath);
|
||||
FileInfo fi = new FileInfo(FilePath);
|
||||
|
||||
try
|
||||
{
|
||||
if (!di.Exists) Directory.CreateDirectory(DirPath);
|
||||
if (!fi.Exists)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(FilePath))
|
||||
{
|
||||
temp = string.Format("[{0}] : {1}", DateTime.Now, strWriteMsg);
|
||||
sw.WriteLine(temp);
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (StreamWriter sw = File.AppendText(FilePath))
|
||||
{
|
||||
temp = string.Format("[{0}] : {1}", DateTime.Now, strWriteMsg);
|
||||
sw.WriteLine(temp);
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message.ToString());
|
||||
Console.WriteLine(e.StackTrace.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void XAdaptorFileLogWrite(eSetFileLogCategory SetCategory, string strYYYY, string strMM, string strDD, string strGetLogHeader, string strGetFileName, string strMsg)
|
||||
{
|
||||
string strWriteMsg = "{" + strGetLogHeader + "}{" + strGetFileName + "} - " + strMsg;
|
||||
|
||||
string strFileSubName = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
strFileSubName = AdaptorInformation.HOST_ID + "_" + AdaptorInformation.SECTION;
|
||||
}
|
||||
catch
|
||||
{
|
||||
strFileSubName = string.Empty;
|
||||
}
|
||||
|
||||
string strGetRoot = Path.GetPathRoot(Environment.CurrentDirectory);
|
||||
|
||||
string DirPath = string.Empty;
|
||||
|
||||
string LogFilePath = string.Empty;
|
||||
|
||||
if (SetCategory == eSetFileLogCategory.FileLog)
|
||||
{
|
||||
DirPath = strGetRoot + $@"\XLog\FileFailedBackup\{LoadInfo.HOST_ID}\{LoadInfo.SECTION}\{strYYYY}\{strMM}\{strDD}\";
|
||||
|
||||
if (strFileSubName.Length > 0)
|
||||
LogFilePath = DirPath + @"\XLog_FailedCpLog_" + strYYYY + strMM + strDD + "_" + strFileSubName + ".Xlog";
|
||||
else
|
||||
LogFilePath = DirPath + @"\XLog_FailedCpLog_" + strYYYY + strMM + strDD + ".Xlog";
|
||||
}
|
||||
else if (SetCategory == eSetFileLogCategory.FTPFileLog)
|
||||
{
|
||||
DirPath = @strGetRoot + $@"XLog\FTP\{LoadInfo.HOST_ID}\{LoadInfo.SECTION}\{strYYYY}\{strMM}\{strDD}\";
|
||||
|
||||
if (strFileSubName.Length > 0)
|
||||
LogFilePath = DirPath + @"\XLog_FTPCpLog_" + strYYYY + strMM + strDD + "_" + strFileSubName + ".Xlog";
|
||||
else
|
||||
LogFilePath = DirPath + @"\XLog_FTPCpLog_" + strYYYY + strMM + strDD + ".Xlog";
|
||||
}
|
||||
|
||||
string temp;
|
||||
|
||||
lock (objLogWriteLock)
|
||||
{
|
||||
DirectoryInfo di1 = new DirectoryInfo(DirPath);
|
||||
if (!di1.Exists) Directory.CreateDirectory(DirPath);
|
||||
|
||||
try
|
||||
{
|
||||
FileInfo fi = new FileInfo(LogFilePath);
|
||||
|
||||
// 로그 쓰기
|
||||
if (!fi.Exists)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(LogFilePath))
|
||||
{
|
||||
temp = string.Format("[{0}] : {1}", DateTime.Now, strWriteMsg);
|
||||
sw.WriteLine(temp);
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (StreamWriter sw = File.AppendText(LogFilePath))
|
||||
{
|
||||
temp = string.Format("[{0}] : {1}", DateTime.Now, strWriteMsg);
|
||||
sw.WriteLine(temp);
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message.ToString());
|
||||
Console.WriteLine(e.StackTrace.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected string MakeZipIncludeInfoCpLog(string strGetLogHeader, string strGetFilePos, string strGetFileName, byte[] ucGetFileData)
|
||||
{
|
||||
string strWriteMsg = "{" + strGetLogHeader + "}{" + strGetFileName + "}";
|
||||
|
||||
string strYYYY = DateTime.Today.ToString("yyyy");
|
||||
string strMM = DateTime.Today.ToString("MM");
|
||||
string strdd = DateTime.Today.ToString("dd");
|
||||
|
||||
string strHHmmssfff = DateTime.Now.ToString("HHmmssfff");
|
||||
|
||||
string strGetRoot = Path.GetPathRoot(Environment.CurrentDirectory);
|
||||
|
||||
string DirPath = @strGetRoot + $@"XLog\FTP\{LoadInfo.HOST_ID}\{LoadInfo.SECTION}\{strYYYY}\{strMM}\{strdd}\";
|
||||
string CpLogDirPath = @strGetRoot + $@"XLog\FTP\{LoadInfo.HOST_ID}\{LoadInfo.SECTION}\{strYYYY}\{strMM}\{strdd}\{strHHmmssfff}\";
|
||||
|
||||
string HeaderFilePath = string.Empty;
|
||||
string CpLogFilePath = string.Empty;
|
||||
|
||||
string CpLogFileCompressPath = string.Empty;
|
||||
|
||||
HeaderFilePath = @CpLogDirPath + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ";" + strGetLogHeader + ".txt";
|
||||
CpLogFilePath = @CpLogDirPath + strGetFileName;
|
||||
|
||||
CpLogFileCompressPath = @DirPath + @"\" + ";" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ";" + strGetLogHeader + ";0;.zip";
|
||||
|
||||
DirectoryInfo di1 = new DirectoryInfo(@DirPath);
|
||||
if (!di1.Exists) Directory.CreateDirectory(@DirPath);
|
||||
|
||||
DirectoryInfo di2 = new DirectoryInfo(@CpLogDirPath);
|
||||
if (!di2.Exists) Directory.CreateDirectory(@CpLogDirPath);
|
||||
|
||||
try
|
||||
{
|
||||
FileInfo fi1 = new FileInfo(strGetFilePos);
|
||||
|
||||
//정보 파일 생성
|
||||
using (StreamWriter sw = new StreamWriter(HeaderFilePath, false))
|
||||
{
|
||||
//Create File
|
||||
}
|
||||
|
||||
FileInfo fi = new FileInfo(HeaderFilePath);
|
||||
fi.IsReadOnly = false;
|
||||
|
||||
//기존 전달받은 경로에 파일 존재 할 경우 해당 파일 복사
|
||||
if (fi1.Exists)
|
||||
{
|
||||
// 원본 파일 위치
|
||||
var sourceCpLogFile = strGetFilePos;
|
||||
|
||||
// 파일 이동할 곳
|
||||
var destCpLogFile = CpLogFilePath;
|
||||
|
||||
// 1. 압축할 폴더로 데이터 복사
|
||||
System.IO.File.Copy(sourceCpLogFile, destCpLogFile, true);
|
||||
|
||||
fi = new FileInfo(destCpLogFile);
|
||||
fi.IsReadOnly = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ucGetFileData == null)
|
||||
{
|
||||
throw new Exception("File info error.");
|
||||
}
|
||||
else
|
||||
{
|
||||
using (FileStream file = new FileStream(CpLogFilePath, FileMode.Create))
|
||||
{
|
||||
file.Write(ucGetFileData, 0, ucGetFileData.Length);
|
||||
file.Close();
|
||||
}
|
||||
|
||||
fi = new FileInfo(CpLogFilePath);
|
||||
fi.IsReadOnly = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 특정 폴더, .zip으로 압축
|
||||
ZipFile.CreateFromDirectory(CpLogDirPath, CpLogFileCompressPath);
|
||||
|
||||
// 압축 끝난 폴더 삭제
|
||||
System.IO.Directory.Delete(CpLogDirPath, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message.ToString());
|
||||
Console.WriteLine(e.StackTrace.ToString());
|
||||
|
||||
strWriteMsg += e.Message;
|
||||
|
||||
Console.WriteLine(strWriteMsg);
|
||||
|
||||
CpLogFileCompressPath = string.Empty;
|
||||
}
|
||||
|
||||
return CpLogFileCompressPath;
|
||||
}
|
||||
|
||||
protected void XAdaptorFailedFileBackupProc(eFileSendRecvResult eResult, string strGetLogHeader, string strGetFilePos, string strGetFileName, byte[] ucGetFileData)
|
||||
{
|
||||
string strWriteMsg = "{" + eResult.ToString() + "}{" + strGetLogHeader + "}{" + strGetFileName + "}";
|
||||
|
||||
string strYYYY = DateTime.Today.ToString("yyyy");
|
||||
string strMM = DateTime.Today.ToString("MM");
|
||||
string strdd = DateTime.Today.ToString("dd");
|
||||
|
||||
string strHHmmss = DateTime.Now.ToString("HHmmss");
|
||||
|
||||
string strFileSubName = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
strFileSubName = AdaptorInformation.HOST_ID + "_" + AdaptorInformation.SECTION;
|
||||
}
|
||||
catch
|
||||
{
|
||||
strFileSubName = string.Empty;
|
||||
}
|
||||
|
||||
string strGetRoot = Path.GetPathRoot(Environment.CurrentDirectory);
|
||||
|
||||
string DirPath = @strGetRoot + $@"XLog\FileFailedBackup\{LoadInfo.HOST_ID}\{LoadInfo.SECTION}\{strYYYY}\{strMM}\{strdd}\";
|
||||
string CpLogDirPath = @strGetRoot + $@"XLog\FileFailedBackup\{LoadInfo.HOST_ID}\{LoadInfo.SECTION}\{strYYYY}\{strMM}\{strdd}\{strHHmmss}\";
|
||||
|
||||
string LogFilePath = string.Empty;
|
||||
string HeaderFilePath = string.Empty;
|
||||
string CpLogFilePath = string.Empty;
|
||||
|
||||
string CpLogFileCompressPath = string.Empty;
|
||||
|
||||
if (strFileSubName.Length > 0)
|
||||
LogFilePath = @DirPath + @"\XLog_FailedCpLog_" + DateTime.Today.ToString("yyyyMMdd") + "_" + strFileSubName + ".Xlog";
|
||||
else
|
||||
LogFilePath = @DirPath + @"\XLog_FailedCpLog_" + DateTime.Today.ToString("yyyyMMdd") + ".Xlog";
|
||||
|
||||
HeaderFilePath = @CpLogDirPath + DateTime.Now.ToString("yyyyMMddHHmmss") + ";" + strGetLogHeader + ".txt";
|
||||
CpLogFilePath = @CpLogDirPath + strGetFileName;
|
||||
|
||||
CpLogFileCompressPath = @DirPath + @"\" + ";" + DateTime.Now.ToString("yyyyMMddHHmmss") + ";" + strGetLogHeader + ";0;.zip";
|
||||
|
||||
string temp;
|
||||
|
||||
lock (objLogWriteLock)
|
||||
{
|
||||
DirectoryInfo di1 = new DirectoryInfo(@DirPath);
|
||||
if (!di1.Exists) Directory.CreateDirectory(@DirPath);
|
||||
|
||||
DirectoryInfo di2 = new DirectoryInfo(@CpLogDirPath);
|
||||
if (!di2.Exists) Directory.CreateDirectory(@CpLogDirPath);
|
||||
|
||||
try
|
||||
{
|
||||
FileInfo fi1 = new FileInfo(strGetFilePos);
|
||||
|
||||
//정보 파일 생성
|
||||
using (StreamWriter sw = new StreamWriter(HeaderFilePath, false))
|
||||
{
|
||||
//Create File
|
||||
}
|
||||
|
||||
//기존 전달받은 경로에 파일 존재 할 경우 해당 파일 복사
|
||||
if (fi1.Exists)
|
||||
{
|
||||
// 원본 파일 위치
|
||||
var sourceCpLogFile = strGetFilePos;
|
||||
|
||||
// 파일 이동할 곳
|
||||
var destCpLogFile = CpLogFilePath;
|
||||
|
||||
// 1. 압축할 폴더로 데이터 복사
|
||||
System.IO.File.Copy(sourceCpLogFile, destCpLogFile, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ucGetFileData == null)
|
||||
{
|
||||
throw new Exception("File info error.");
|
||||
}
|
||||
else
|
||||
{
|
||||
using (FileStream file = new FileStream(CpLogFilePath, FileMode.Create))
|
||||
{
|
||||
file.Write(ucGetFileData, 0, ucGetFileData.Length);
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 특정 폴더, .zip으로 압축
|
||||
ZipFile.CreateFromDirectory(CpLogDirPath, CpLogFileCompressPath);
|
||||
|
||||
// 압축 끝난 폴더 삭제
|
||||
System.IO.Directory.Delete(CpLogDirPath, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message.ToString());
|
||||
Console.WriteLine(e.StackTrace.ToString());
|
||||
|
||||
strWriteMsg += e.Message;
|
||||
}
|
||||
//
|
||||
try
|
||||
{
|
||||
FileInfo fi2 = new FileInfo(LogFilePath);
|
||||
|
||||
// 1. 로그 쓰기
|
||||
if (!fi2.Exists)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(LogFilePath))
|
||||
{
|
||||
temp = string.Format("[{0}] : {1}", DateTime.Now, strWriteMsg);
|
||||
sw.WriteLine(temp);
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (StreamWriter sw = File.AppendText(LogFilePath))
|
||||
{
|
||||
temp = string.Format("[{0}] : {1}", DateTime.Now, strWriteMsg);
|
||||
sw.WriteLine(temp);
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message.ToString());
|
||||
Console.WriteLine(e.StackTrace.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//The event-invoking method that derived classes can override.
|
||||
protected virtual void OnCommandConnectAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
CommandConnectAlarmEvent?.Invoke(sender, e);
|
||||
}
|
||||
protected virtual void OnStreamConnectAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
StreamConnectAlarmEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
protected virtual void OnConnectionInfoRecv(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
ConnectionInfoRecvEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
protected virtual void OnCommandDisconnectAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
CommandDisconnectAlarmEvent?.Invoke(sender, e);
|
||||
}
|
||||
protected virtual void OnStreamDisconnectAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
StreamDisconnectAlarmEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
protected virtual void OnLoginAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
LoginAlarmEvent?.BeginInvoke(sender, e, null, null);
|
||||
}
|
||||
|
||||
protected virtual void OnQueryCall(object sender, ResultEventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
QueryCallEvent?.Invoke(sender, e);
|
||||
}
|
||||
protected virtual void OnBeginQueryCall(object sender, ResultEventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
QueryCallEvent?.BeginInvoke(sender, e, null, null);
|
||||
}
|
||||
|
||||
protected IControlTestListDataSet mgrPRODTestList { set; get; }
|
||||
|
||||
public IControlTestListDataSet CurrentTestList()
|
||||
{
|
||||
return mgrPRODTestList;
|
||||
}
|
||||
|
||||
protected IControlTestListDataSet CreateTestListMgr()
|
||||
{
|
||||
return new TProdTestListInfo();
|
||||
}
|
||||
|
||||
public string GetMiddlewareMessage { protected set; get; }
|
||||
|
||||
protected ClientInfoStore thisConnInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,255 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.Comm.IIS_FTP;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.XAdaptor.PC;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.Manager
|
||||
{
|
||||
public class XAdaptorManager
|
||||
{
|
||||
private string strCreateConfigFilePos;
|
||||
|
||||
public XAdaptorManager(string strConfigFilePos = "")
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Use CP-Server[X] Adaptor Version for [CPXV2][v240529] " +
|
||||
"[SystemX.Net.XAdaptor.Manager : XAdaptorManager]", ConsoleColor.Green, LogMessageLevel.FATAL);
|
||||
|
||||
strCreateConfigFilePos = string.Empty;
|
||||
|
||||
Create();
|
||||
|
||||
strCreateConfigFilePos = strConfigFilePos;
|
||||
|
||||
if(strCreateConfigFilePos.Length > 0)
|
||||
SetConfigureFilePos(strCreateConfigFilePos);
|
||||
}
|
||||
|
||||
public void Create()
|
||||
{
|
||||
xAdaptor = new XAdaptorPC();
|
||||
|
||||
if (strCreateConfigFilePos.Length > 0)
|
||||
SetConfigureFilePos(strCreateConfigFilePos);
|
||||
}
|
||||
|
||||
private XAdaptorPC xAdaptor;
|
||||
|
||||
public IXPCAdaptor MgrConn
|
||||
{
|
||||
get
|
||||
{
|
||||
return xAdaptor;
|
||||
}
|
||||
}
|
||||
|
||||
public IUIM MgrUIMConn
|
||||
{
|
||||
get
|
||||
{
|
||||
return xAdaptor;
|
||||
}
|
||||
}
|
||||
|
||||
public IComXPCAdaptor MgrComConn
|
||||
{
|
||||
get
|
||||
{
|
||||
return xAdaptor;
|
||||
}
|
||||
}
|
||||
|
||||
public XAdaptorSystem GetAdaptorHandler
|
||||
{
|
||||
get
|
||||
{
|
||||
return xAdaptor;
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetClientInfoState()
|
||||
{
|
||||
return xAdaptor.StateClientGetInformation;
|
||||
}
|
||||
|
||||
public long GetLastCommandTime()
|
||||
{
|
||||
return xAdaptor.GetLastCommandTime();
|
||||
}
|
||||
|
||||
public long GetLastStreamTime()
|
||||
{
|
||||
return xAdaptor.GetLastStreamTime();
|
||||
}
|
||||
|
||||
public bool IsConnect { get { return xAdaptor.StateClientSocketConnect && xAdaptor.StateClientStreamSocketConnect; } }
|
||||
|
||||
public bool CommandSocketConn { get { return xAdaptor.StateClientSocketConnect; } }
|
||||
|
||||
public bool StreamSocketConn { get { return xAdaptor.StateClientStreamSocketConnect; } }
|
||||
|
||||
public bool GetServerTestListLoadState()
|
||||
{
|
||||
return GetAdaptorHandler.ServerTestListLoadState;
|
||||
}
|
||||
|
||||
public bool CheckStationTestListReload(int nStationID)
|
||||
{
|
||||
bool bNeedReload = false;
|
||||
|
||||
foreach(int nStID in xAdaptor.GetReloadNeedStation())
|
||||
{
|
||||
if (nStID == nStationID)
|
||||
{
|
||||
if (xAdaptor.GetStateReloadNeedTestList(nStID))
|
||||
bNeedReload = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bNeedReload;
|
||||
}
|
||||
|
||||
private int[] NeedTestListReloadList()
|
||||
{
|
||||
return xAdaptor.GetReloadNeedStation();
|
||||
}
|
||||
private bool GetStationTestListReload(int nStationID)
|
||||
{
|
||||
return xAdaptor.GetStateReloadNeedTestList(nStationID);
|
||||
}
|
||||
public void SetStationTestListReloadStateOff(int nStationID)
|
||||
{
|
||||
xAdaptor.SetStateReloadNeedTestList(nStationID);
|
||||
}
|
||||
|
||||
public IControlTestListDataSet GetTestListContainer()
|
||||
{
|
||||
return xAdaptor.CurrentTestList();
|
||||
}
|
||||
|
||||
public DataSet GetTestListDataSet()
|
||||
{
|
||||
return xAdaptor.CurrentTestList().getTestListDataSet();
|
||||
}
|
||||
|
||||
public eSetConfigFileResult SetConfigureFilePos(string strConfigFilePos = "")
|
||||
{
|
||||
return xAdaptor.SetConfigureFile(strConfigFilePos);
|
||||
}
|
||||
|
||||
/*
|
||||
public bool CheckServerState()
|
||||
{
|
||||
return ((IXPCAdaptor)xAdaptor).WaitCheckServerState();
|
||||
}
|
||||
*/
|
||||
|
||||
public async Task<bool> AsyncWaitCheckServerState(bool bRetryAutoConnect = true)
|
||||
{
|
||||
bool bResult = await ((IXPCAdaptor)xAdaptor).RestoreConnAfterConfirmConn(bRetryAutoConnect).ConfigureAwait(false);
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
GetAdaptorHandler.ServerTestListLoadState = false;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
public eFTPServiceStatus CheckStateFTP()
|
||||
{
|
||||
return GetAdaptorHandler.StateFTP;
|
||||
}
|
||||
|
||||
private eFTPServiceStatus StartFTP()
|
||||
{
|
||||
GetAdaptorHandler.StateFTP = xAdaptor.StartFTPService();
|
||||
|
||||
return GetAdaptorHandler.StateFTP;
|
||||
}
|
||||
|
||||
public async Task<bool> Connect(string strConfigFilePos = "")
|
||||
{
|
||||
if (xAdaptor.SetConfigureFile(strConfigFilePos) == eSetConfigFileResult.SetConfigFail)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Config File Error. [SystemX.Net.XAdaptor.Manager : XAdaptorManager : Connect]\r\n",
|
||||
ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO : FTP ALIS
|
||||
StartFTP();
|
||||
|
||||
xAdaptor.ConnectStartStyleAuto = true;
|
||||
|
||||
bool bGetResult = true;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
bGetResult = await xAdaptor.ComClientTryDistributionConnet();
|
||||
|
||||
//return xAdaptor.ComClientTryConnet();
|
||||
|
||||
if (bGetResult)
|
||||
break;
|
||||
}
|
||||
|
||||
return bGetResult;
|
||||
}
|
||||
|
||||
public async Task<bool> WaitConnect(string strConfigFilePos = "")
|
||||
{
|
||||
if (xAdaptor.SetConfigureFile(strConfigFilePos) == eSetConfigFileResult.SetConfigFail)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Config File Error. [SystemX.Net.XAdaptor.Manager : XAdaptorManager : Connect]\r\n",
|
||||
ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO : FTP ALIS
|
||||
StartFTP();
|
||||
|
||||
xAdaptor.ConnectStartStyleAuto = false;
|
||||
|
||||
bool bGetResult = true;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
bGetResult = await xAdaptor.WaitComClientTryDistributionConnet();
|
||||
|
||||
if (bGetResult)
|
||||
break;
|
||||
}
|
||||
|
||||
return bGetResult;
|
||||
}
|
||||
|
||||
public bool Disconnect()
|
||||
{
|
||||
return xAdaptor.ComClientTryDisconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,377 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using SystemX.Common.Archive;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor
|
||||
{
|
||||
public class QueryGetInfo
|
||||
{
|
||||
public string ProdNo_C;
|
||||
public string ProdNo_P;
|
||||
public string TestCode;
|
||||
public string Gate1;
|
||||
public string Gate2;
|
||||
public string FileName;
|
||||
public string RegUserComment;
|
||||
public string Description;
|
||||
public string GroupName;
|
||||
public string ModelName;
|
||||
public string VariantNo;
|
||||
public string TestListNo;
|
||||
public string Config;
|
||||
public string TestType;
|
||||
public string Version;
|
||||
public string ProdCode;
|
||||
|
||||
public QueryGetInfo()
|
||||
{
|
||||
ProdNo_C = "";
|
||||
ProdNo_P = "";
|
||||
TestCode = "";
|
||||
Gate1 = "";
|
||||
Gate2 = "";
|
||||
FileName = "";
|
||||
RegUserComment = "";
|
||||
Description = "";
|
||||
GroupName = "";
|
||||
ModelName = "";
|
||||
VariantNo = "";
|
||||
TestListNo = "";
|
||||
Config = "";
|
||||
TestType = "";
|
||||
Version = "";
|
||||
ProdCode = "";
|
||||
}
|
||||
}
|
||||
|
||||
public interface IControlTestListDataSet
|
||||
{
|
||||
QueryGetInfo ReadInfo();
|
||||
|
||||
DataSet getTestListDataSet();
|
||||
|
||||
int getTestListCount();
|
||||
|
||||
string GetTestListCntID();
|
||||
|
||||
DataRow[] GetPRODTestList(string strProdP_No, string strProdC_No,
|
||||
string strTestType,
|
||||
string strTestCode,
|
||||
string strVersion,
|
||||
string strProdCode);
|
||||
|
||||
DataRow[] GetCurrentTestListRow();
|
||||
|
||||
byte[] getTestListFileBytes();
|
||||
|
||||
string getTestListFileFullName();
|
||||
|
||||
string getTestListFileName();
|
||||
|
||||
string getTestListFileExtension();
|
||||
|
||||
string MakeTestListFile(string strMakePath,
|
||||
bool bCreateDirectory = true,
|
||||
bool bDuplicateFileDelete = true);
|
||||
}
|
||||
|
||||
internal class TProdTestListInfo : IControlTestListDataSet
|
||||
{
|
||||
private QueryGetInfo tslInfo;
|
||||
|
||||
private DataSet dsQueryTestLists;
|
||||
|
||||
/*
|
||||
* Caution : Row 0 Index 고정
|
||||
*/
|
||||
private DataRow[] drFindInfos;
|
||||
|
||||
private byte[] ucGetTestListData;
|
||||
|
||||
private string strGetFileFullName;
|
||||
private string strGetFileName;
|
||||
private string strGetVersion;
|
||||
private string strGetProdCode;
|
||||
private string strGetExtension;
|
||||
|
||||
private string strGetTestListCntID;
|
||||
|
||||
public string GetTestListCntID()
|
||||
{
|
||||
return strGetTestListCntID;
|
||||
}
|
||||
|
||||
public void SetTestListCntID(string strSetValue)
|
||||
{
|
||||
strGetTestListCntID = strSetValue;
|
||||
}
|
||||
|
||||
public void SetTestListDataSet(DataSet ds)
|
||||
{
|
||||
dsQueryTestLists = new DataSet();
|
||||
dsQueryTestLists = ds.Copy();
|
||||
|
||||
if (dsQueryTestLists.Tables[0].Rows.Count == 1)
|
||||
{
|
||||
ucGetTestListData = dsQueryTestLists.Tables[0].Rows[0]["TestListData"] as byte[];
|
||||
ucGetTestListData = XDataArchive.DecompressGZipByteToByte(ucGetTestListData);
|
||||
|
||||
strGetFileName = dsQueryTestLists.Tables[0].Rows[0]["FileName"].ToString();
|
||||
strGetVersion = dsQueryTestLists.Tables[0].Rows[0]["Version"].ToString();
|
||||
strGetProdCode = dsQueryTestLists.Tables[0].Rows[0]["ProdCode"].ToString();
|
||||
strGetExtension = ".CpXv" + strGetVersion + strGetProdCode;
|
||||
|
||||
strGetFileFullName = strGetFileName + strGetExtension;
|
||||
|
||||
setQueryInfo(dsQueryTestLists.Tables[0].Rows[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public DataSet getTestListDataSet()
|
||||
{
|
||||
return dsQueryTestLists;
|
||||
}
|
||||
|
||||
public int getTestListCount()
|
||||
{
|
||||
return dsQueryTestLists != null ? dsQueryTestLists.Tables[0].Rows.Count : 0;
|
||||
}
|
||||
|
||||
public TProdTestListInfo()
|
||||
{
|
||||
tslInfo = new QueryGetInfo();
|
||||
|
||||
dsQueryTestLists = new DataSet();
|
||||
dsQueryTestLists.Clear();
|
||||
|
||||
ClearVar();
|
||||
}
|
||||
|
||||
public DataRow[] GetCurrentTestListRow()
|
||||
{
|
||||
return drFindInfos;
|
||||
}
|
||||
|
||||
public void ClearVar()
|
||||
{
|
||||
ucGetTestListData = null;
|
||||
|
||||
strGetFileName = "";
|
||||
strGetVersion = "";
|
||||
strGetProdCode = "";
|
||||
strGetExtension = "";
|
||||
|
||||
strGetTestListCntID = "";
|
||||
}
|
||||
|
||||
public QueryGetInfo ReadInfo()
|
||||
{
|
||||
return tslInfo;
|
||||
}
|
||||
|
||||
virtual public void setQueryInfo(DataRow dr)
|
||||
{
|
||||
tslInfo.ProdNo_C = dr["ProdNo_C"].ToString();
|
||||
tslInfo.ProdNo_P = dr["ProdNo_P"].ToString();
|
||||
tslInfo.TestCode = dr["TestCode"].ToString();
|
||||
tslInfo.Gate1 = dr["Gate1"].ToString();
|
||||
tslInfo.Gate2 = dr["Gate2"].ToString();
|
||||
tslInfo.FileName = dr["FileName"].ToString();
|
||||
tslInfo.RegUserComment = dr["RegUserComment"].ToString();
|
||||
tslInfo.Description = dr["Description"].ToString();
|
||||
tslInfo.GroupName = dr["GroupName"].ToString();
|
||||
tslInfo.ModelName = dr["ModelName"].ToString();
|
||||
tslInfo.VariantNo = dr["VariantNo"].ToString();
|
||||
tslInfo.TestListNo = dr["TestListNo"].ToString();
|
||||
tslInfo.Config = dr["Config"].ToString();
|
||||
tslInfo.TestType = dr["TestType"].ToString();
|
||||
tslInfo.Version = dr["Version"].ToString();
|
||||
tslInfo.ProdCode = dr["ProdCode"].ToString();
|
||||
}
|
||||
|
||||
private void setDataRowInsertInfo()
|
||||
{
|
||||
ucGetTestListData = drFindInfos[0]["TestListData"] as byte[];
|
||||
ucGetTestListData = XDataArchive.DecompressGZipByteToByte(ucGetTestListData);
|
||||
|
||||
strGetFileName = drFindInfos[0]["FileName"].ToString();
|
||||
strGetVersion = drFindInfos[0]["Version"].ToString();
|
||||
strGetProdCode = drFindInfos[0]["ProdCode"].ToString();
|
||||
strGetExtension = ".CpXv" + strGetVersion + strGetProdCode;
|
||||
|
||||
strGetFileFullName = strGetFileName + strGetExtension;
|
||||
}
|
||||
|
||||
public DataRow[] GetPRODTestList(string strProdP_No, string strProdC_No,
|
||||
string strTestType,
|
||||
string strTestCode,
|
||||
string strVersion,
|
||||
string strProdCode)
|
||||
{
|
||||
drFindInfos = null;
|
||||
|
||||
if (dsQueryTestLists.Tables.Count <= 0)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
if (dsQueryTestLists.Tables[0].Rows.Count == 1)
|
||||
{
|
||||
drFindInfos = dsQueryTestLists.Tables[0].Select("");
|
||||
|
||||
if (drFindInfos.Count() > 0)
|
||||
{
|
||||
setDataRowInsertInfo();
|
||||
|
||||
setQueryInfo(drFindInfos[0]);
|
||||
}
|
||||
else
|
||||
ClearVar();
|
||||
|
||||
return drFindInfos;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Failed to test-list info column check. check the dll-version. [SystemX.Net.XAdaptor : TestListInfo.GetPRODTestList]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
drFindInfos = null;
|
||||
}
|
||||
|
||||
if (drFindInfos == null)
|
||||
return drFindInfos;
|
||||
|
||||
string[] strParameters = new string[5];
|
||||
|
||||
strParameters[0] = strProdP_No;
|
||||
strParameters[1] = strTestType;
|
||||
strParameters[2] = strVersion;
|
||||
strParameters[3] = strProdCode;
|
||||
strParameters[4] = strTestCode;
|
||||
|
||||
string strSetSelectText = "";
|
||||
int iParameterCnt = 0;
|
||||
|
||||
for (int i = 0; i < strParameters.Length; i++)
|
||||
{
|
||||
if (strParameters[i].Length > 0)
|
||||
{
|
||||
iParameterCnt++;
|
||||
|
||||
if (iParameterCnt > 1)
|
||||
strSetSelectText += "AND ";
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 0: strSetSelectText += "ProdNo_P = '" + strParameters[i] + "' "; break;
|
||||
case 1: strSetSelectText += "TestType = '" + strParameters[i] + "' "; break;
|
||||
case 2: strSetSelectText += "Version = '" + strParameters[i] + "' "; break;
|
||||
case 3: strSetSelectText += "ProdCode = '" + strParameters[i] + "' "; break;
|
||||
case 4: strSetSelectText += "TestCode = '" + strParameters[i] + "' "; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(strSetSelectText.Length > 0)
|
||||
drFindInfos = dsQueryTestLists.Tables[0].Select(strSetSelectText);
|
||||
|
||||
if (drFindInfos != null && drFindInfos.Count() > 0)
|
||||
{
|
||||
setDataRowInsertInfo();
|
||||
|
||||
setQueryInfo(drFindInfos[0]);
|
||||
}
|
||||
else
|
||||
ClearVar();
|
||||
|
||||
return drFindInfos;
|
||||
}
|
||||
|
||||
public byte[] getTestListFileBytes()
|
||||
{
|
||||
return ucGetTestListData;
|
||||
}
|
||||
|
||||
public string getTestListFileFullName()
|
||||
{
|
||||
return strGetFileFullName;
|
||||
}
|
||||
|
||||
public string getTestListFileName()
|
||||
{
|
||||
return strGetFileName;
|
||||
}
|
||||
|
||||
public string getTestListFileExtension()
|
||||
{
|
||||
return strGetExtension;
|
||||
}
|
||||
|
||||
public string MakeTestListFile(string @strMakePath,
|
||||
bool bCreateDirectory = true,
|
||||
bool bDuplicateFileDelete = true)
|
||||
{
|
||||
string strSetMakePath = "";
|
||||
|
||||
if (Directory.Exists(@strMakePath) == false)
|
||||
{
|
||||
if (bCreateDirectory == false)
|
||||
{
|
||||
strSetMakePath = "The specified location does not exist.";
|
||||
return strSetMakePath;
|
||||
}
|
||||
else
|
||||
Directory.CreateDirectory(@strMakePath);
|
||||
}
|
||||
|
||||
if (strGetFileFullName.Length > 0)
|
||||
{
|
||||
if (Base.CheckPath(strMakePath) == false)
|
||||
{
|
||||
strSetMakePath = "Enter only the path excluding the file name and extension as parameters.";
|
||||
return strSetMakePath;
|
||||
}
|
||||
|
||||
string strSetFilePos = strMakePath + strGetFileFullName;
|
||||
|
||||
if (File.Exists(strSetFilePos))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bDuplicateFileDelete)
|
||||
File.Delete(strSetFilePos);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Failed to delete duplicate test-list file. [SystemX.Net.XAdaptor : TestListInfo.MakeTestListFile]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
strSetMakePath = strSetFilePos;
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(@strSetFilePos, ucGetTestListData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Failed to create test list file. [SystemX.Net.XAdaptor : TestListInfo.MakeTestListFile]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
strSetMakePath = "";
|
||||
}
|
||||
}
|
||||
|
||||
return strSetMakePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.XAdaptor;
|
||||
using static SystemX.Net.XAdaptor.PC.XAdaptorPC;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
[ComVisible(true)]
|
||||
[Guid("EF4648F0-5CAB-42CE-A184-F59D646FC1E3")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
|
||||
public interface IComXPCAdaptor
|
||||
{
|
||||
bool ComGetClientSocketConnect();
|
||||
bool ComGetClientStreamSocketConnect();
|
||||
bool ComGetClientInfo();
|
||||
bool ComGetAdaptorConnectState();
|
||||
|
||||
string ComGetCommandMessage();
|
||||
string ComGetStreamMessage();
|
||||
|
||||
Task<bool> ComClientTryConnet(int nCommandPortNum = int.MaxValue, int nStreamPortNum = int.MaxValue);
|
||||
Task<bool> ComClientTryDistributionConnet(int nCommandPortNum = int.MaxValue);
|
||||
Task<bool> WaitComClientTryDistributionConnet(int nCommandPortNum = int.MaxValue);
|
||||
|
||||
bool ComClientTryDisconnect();
|
||||
bool ComCheckConnectState();
|
||||
bool ComCheckConnectStreamState();
|
||||
|
||||
string ComSetConfigureFile(string strFilePos);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.XAdaptor;
|
||||
using static SystemX.Net.XAdaptor.PC.XAdaptorPC;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public interface IUIM
|
||||
{
|
||||
/*
|
||||
* UNIQUE INFO METHOD(MAC ADDRESS)
|
||||
*/
|
||||
|
||||
//발행된 아이디 인지
|
||||
eResultCheck CheckIssuedID(string strProductID);
|
||||
|
||||
//맥 어드레스 무결성 체크
|
||||
eMacAddressType IsMacAddressForm(string strMacAddress);
|
||||
|
||||
//목록에 존재하는 맥어드레스 인지
|
||||
bool CheckListMacAddress(string strMacAddress);
|
||||
|
||||
//발행된 맥어드레스 인지
|
||||
eResultCheck CheckIssuedMacAddress(string strMacAddress);
|
||||
|
||||
//현재 발행 예정 대상 주소
|
||||
string GetToBeIssuedMacAddress(eMacAddressType type = eMacAddressType.Normal);
|
||||
|
||||
//총개수
|
||||
int GetTotalAddressNumber();
|
||||
|
||||
//발행 개수 확인
|
||||
int GetCurrentIssuedAddressNumber();
|
||||
|
||||
//남은 개수 확인
|
||||
int GetRemainAddressNumber();
|
||||
|
||||
string LookUpIDbyMacAddress(string strMacAddress);
|
||||
|
||||
string LookUpMacAddressbyID(ref string strProductID, eLookUpOption SetLookUpOption = eLookUpOption.CompareToSame, eMacAddressType type = eMacAddressType.Normal);
|
||||
|
||||
ResultIssued IssuanceRequest(string strProductID, bool bReissuance = false, eMacAddressType type = eMacAddressType.Normal);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.XAdaptor;
|
||||
using static SystemX.Net.XAdaptor.PC.XAdaptorPC;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public interface IDataSaveTable
|
||||
{
|
||||
string GetTableName();
|
||||
}
|
||||
public interface IXPCAdaptor
|
||||
{
|
||||
//Common query object
|
||||
DataSet WaitUserQuery(string strQuery);
|
||||
|
||||
//bool Login(string strHost, string strSection, bool bUseUIM = false, bool bSimpleLookupOption = false);
|
||||
|
||||
/// <summary>
|
||||
/// Requires running the program with administrator privileges.
|
||||
/// </summary>
|
||||
/// <param name="bAutoApplyWinTime"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> WaitSyncTimeServer(bool bAutoApplyWinTime = true);
|
||||
|
||||
//bool WaitCheckServerState();
|
||||
|
||||
Task<bool> RestoreConnAfterConfirmConn(bool bRetryAutoConnect = true);
|
||||
|
||||
bool SetCustomPacket(params string[] strSetInfo);
|
||||
|
||||
/*
|
||||
bool WaitCheckTestList(uint nStationID, string strProdNo_C,
|
||||
string strTestType,
|
||||
string strTestCode,
|
||||
string strTestListVersion,
|
||||
string strProductionCode);
|
||||
*/
|
||||
|
||||
Task<bool> AsyncWaitCheckTestList(uint nStationID, string strProdNo_C,
|
||||
string strTestType,
|
||||
string strTestCode,
|
||||
string strTestListVersion,
|
||||
string strProductionCode);
|
||||
|
||||
bool QueryTestList(uint nStationID, string strProdNo_C,
|
||||
string strTestType,
|
||||
string strTestCode,
|
||||
string strTestListVersion,
|
||||
string strProductionCode);
|
||||
|
||||
/*
|
||||
bool WaitQueryTestList(uint nStationID, string strProdNo_C,
|
||||
string strTestType,
|
||||
string strTestCode,
|
||||
string strTestListVersion,
|
||||
string strProductionCode);
|
||||
*/
|
||||
Task<Tuple<string, int>> GetTestListQueryWithFilePath(string strFilePath, uint nStationID, string strProdNo_C,
|
||||
string strTestType,
|
||||
string strTestCode,
|
||||
string strTestListVersion,
|
||||
string strProductionCode,
|
||||
bool bCheckAfter = false);
|
||||
|
||||
Task<bool> AsyncWaitQueryTestList(uint nStationID, string strProdNo_C,
|
||||
string strTestType,
|
||||
string strTestCode,
|
||||
string strTestListVersion,
|
||||
string strProductionCode);
|
||||
|
||||
//File Transfer
|
||||
//FileSendRecvResult CPLogFileTransfer(string strFilePos, ushort usPalletIndex = 0);
|
||||
//bool CPLogFileTransfer(MemoryStream ms, ushort usPalletIndex);
|
||||
|
||||
Task<eFileSendRecvResult> AsyncCPLogFileTransfer(string strFilePos,
|
||||
string targetStationName,
|
||||
int targetTestListNo,
|
||||
string targetProcNo_P,
|
||||
string targetProcNo_C,
|
||||
string targetTestType,
|
||||
string targetTestCode,
|
||||
string targetVersion,
|
||||
string targetProdCode);
|
||||
|
||||
eFileSendRecvResult SendCustomFile(string strFilePos, bool bRecvResultWait = false, ushort usPalletIndex = 0);
|
||||
|
||||
eSetConfigFileResult SetConfigureFile(string strFilePos);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.O2Sensor.NgCode
|
||||
{
|
||||
public static class DBSchemaMap
|
||||
{
|
||||
public const string ProcessListTableName = "INFO_PROCESS";
|
||||
public const string TableName_NGCode = "INFO_NGCode";
|
||||
public const string TableName_DetailData = "HIST_TestResultDatail";
|
||||
|
||||
public enum eHistAllTableList
|
||||
{
|
||||
HIST_ProdLoad = 0,
|
||||
HIST_CapDeassy,
|
||||
HIST_PreHeating,
|
||||
HIST_PreMeas,
|
||||
HIST_Leak,
|
||||
HIST_LaserTrim,
|
||||
HIST_LaserTrimVision,
|
||||
HIST_IsoRes,
|
||||
HIST_CapAssy,
|
||||
HIST_Function,
|
||||
HIST_OutSealPress,
|
||||
HIST_PinVision,
|
||||
HIST_PinLVDT,
|
||||
HIST_ProdUnload
|
||||
}
|
||||
public enum eHistProcTableList
|
||||
{
|
||||
HIST_ProdLoad = 0,
|
||||
HIST_CapDeassy,
|
||||
HIST_PreHeating,
|
||||
HIST_PreMeas,
|
||||
HIST_Leak,
|
||||
HIST_LaserTrim,
|
||||
HIST_LaserTrimVision,
|
||||
HIST_IsoRes,
|
||||
HIST_CapAssy,
|
||||
HIST_Function,
|
||||
HIST_OutSealPress,
|
||||
HIST_PinVision,
|
||||
HIST_PinLVDT
|
||||
}
|
||||
public enum eHistTableCommonCols
|
||||
{
|
||||
No,
|
||||
LogAccessKey,
|
||||
ProcNo,
|
||||
PalletNumber,
|
||||
PalletID,
|
||||
PIndex,
|
||||
ProdNo,
|
||||
ProdID,
|
||||
TestID,
|
||||
Result,
|
||||
Status,
|
||||
UpdateDT
|
||||
}
|
||||
public enum eHistTableCols
|
||||
{
|
||||
No,
|
||||
ProcNo,
|
||||
PalletNumber,
|
||||
PalletID,
|
||||
PIndex,
|
||||
ProdNo,
|
||||
ProdID,
|
||||
TestID,
|
||||
LogDataPath,
|
||||
LogData,
|
||||
Status,
|
||||
UpdateDT
|
||||
}
|
||||
|
||||
public enum eHistDetailTableCols
|
||||
{
|
||||
No,
|
||||
LogAccessKey,
|
||||
STEP,
|
||||
POSITION,
|
||||
MO,
|
||||
FNC_NAME,
|
||||
MIN_VALUE,
|
||||
MEASURE_VALUE,
|
||||
MAX_VALUE,
|
||||
DIM,
|
||||
CHECK_RETURN,
|
||||
SPENT_TIME,
|
||||
INFO,
|
||||
UpdateDT
|
||||
}
|
||||
|
||||
public enum eStat_ProdLoad
|
||||
{
|
||||
No,
|
||||
PalletID,
|
||||
Index,
|
||||
ProdNo,
|
||||
ProdID,
|
||||
SensorType,
|
||||
Status
|
||||
}
|
||||
|
||||
public enum eHist_ProdUnload
|
||||
{
|
||||
No,
|
||||
PalletID,
|
||||
Index,
|
||||
ProdNo,
|
||||
ProdID,
|
||||
Status,
|
||||
NGCode,
|
||||
Result,
|
||||
UpdateDT
|
||||
}
|
||||
|
||||
public enum eHist_LeakTest
|
||||
{
|
||||
No,
|
||||
LogAccessKey,
|
||||
ProcNo,
|
||||
PalletNumber,
|
||||
PalletID,
|
||||
PIndex,
|
||||
ProdNo,
|
||||
ProdID,
|
||||
SensorType,
|
||||
Status,
|
||||
TestID,
|
||||
Result,
|
||||
UpdateDT,
|
||||
Val_Min,
|
||||
Val_Max,
|
||||
Val_Meas
|
||||
}
|
||||
|
||||
public enum eNGCodeTable
|
||||
{
|
||||
NGCode,
|
||||
Description,
|
||||
ProcNo,
|
||||
TestID,
|
||||
StepNo,
|
||||
Type,
|
||||
ReworkType,
|
||||
CustomCode,
|
||||
Status,
|
||||
UpdateDT
|
||||
}
|
||||
|
||||
|
||||
public enum eReworkType
|
||||
{
|
||||
Retest,
|
||||
M_Rework,
|
||||
Rework,
|
||||
Scrap,
|
||||
Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,607 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Net.XAdaptor.PC;
|
||||
using static SystemX.Net.XAdaptor.PC.O2Sensor.NgCode.DBSchemaMap;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.O2Sensor.NgCode
|
||||
{
|
||||
public class NGCodeFinder
|
||||
{
|
||||
public enum eNGFlag
|
||||
{
|
||||
NG,
|
||||
ERROR
|
||||
}
|
||||
|
||||
public enum eNGDataType
|
||||
{
|
||||
CP,
|
||||
LEAK,
|
||||
CHECK
|
||||
}
|
||||
|
||||
public enum eJudgeType
|
||||
{
|
||||
MIN,
|
||||
MAX,
|
||||
CHECK
|
||||
}
|
||||
|
||||
public string UnsortedNGTitle { get; set; } = "Unknown";
|
||||
|
||||
DataTable NGCodeTable { get; set; }
|
||||
|
||||
XAdaptorPC refPCAdaptor;
|
||||
|
||||
public NGCodeFinder(XAdaptorPC refAdaptor)
|
||||
{
|
||||
refPCAdaptor = refAdaptor;
|
||||
|
||||
NGCodeTable = GetNGCodeTable();
|
||||
}
|
||||
public void InitialNgCodeTable()
|
||||
{
|
||||
NGCodeTable = GetNGCodeTable();
|
||||
}
|
||||
|
||||
private DataTable GetNGCodeTable()
|
||||
{
|
||||
DataTable dtResult = null;
|
||||
string strQuery = $"SELECT * FROM {DBSchemaMap.TableName_NGCode};";
|
||||
DataSet dtSetResult = refPCAdaptor.WaitSystemQuery(strQuery);
|
||||
|
||||
if(((dtSetResult != null) ? dtSetResult.Tables.Cast<DataTable>().Any(table => table.Rows.Count != 0) : false))
|
||||
dtResult = dtSetResult.Tables[0];
|
||||
|
||||
return dtResult;
|
||||
}
|
||||
public Dictionary<string, string> GetNGCodeDictionary(DataRow dtNGRow)
|
||||
{
|
||||
Dictionary<string, string> dicNg = new Dictionary<string, string>();
|
||||
|
||||
bool bDisplayMessage = true;
|
||||
try
|
||||
{
|
||||
if (dtNGRow == null)
|
||||
{
|
||||
dicNg.Add("NTH", "-");
|
||||
|
||||
bDisplayMessage = false;
|
||||
throw new Exception("-");
|
||||
}
|
||||
|
||||
string strProcNo = dtNGRow[eHistTableCommonCols.ProcNo.ToString()].ToString().Trim();
|
||||
string strTestID = dtNGRow[eHistTableCommonCols.TestID.ToString()].ToString().Trim();
|
||||
|
||||
string strResult = "";
|
||||
try
|
||||
{
|
||||
strResult = dtNGRow[eHistTableCommonCols.Result.ToString()].ToString().Trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
strResult = "0";
|
||||
}
|
||||
|
||||
if (strResult == "1" || strResult == "True")
|
||||
{
|
||||
dicNg.Add("PASS", "-");
|
||||
|
||||
bDisplayMessage = false;
|
||||
throw new Exception("-");
|
||||
}
|
||||
|
||||
|
||||
string strUnknwonCode = GetUnknownNGCode(strProcNo, strTestID);
|
||||
|
||||
List<DataRow> vdtNGCodeRow = GetNGCodeList(strProcNo, strTestID);
|
||||
|
||||
if (vdtNGCodeRow == null ? true : vdtNGCodeRow.Count <= 0)
|
||||
{
|
||||
dicNg.Add(strUnknwonCode, "-");
|
||||
|
||||
bDisplayMessage = false;
|
||||
throw new Exception("-");
|
||||
}
|
||||
|
||||
string strLogAccessKey = "";
|
||||
|
||||
List<DataRow> vdtDetailRow = null;
|
||||
List<DataRow> vdtHISTRow = null;
|
||||
|
||||
//LogAccessKey Exist - PC/DEVICE
|
||||
//Not exist - PLC
|
||||
try
|
||||
{
|
||||
strLogAccessKey = dtNGRow[eHistTableCommonCols.LogAccessKey.ToString()]?.ToString().Trim();
|
||||
vdtDetailRow = GetNGDetailRow(GetNGDetailData(strProcNo, strLogAccessKey));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
|
||||
DataRow dtNGDetailRow = null;
|
||||
DataRow dtNGHISTRow = null;
|
||||
|
||||
DataRow dtNGCodeRow = null;
|
||||
|
||||
if (vdtDetailRow != null && vdtDetailRow.Count > 0)
|
||||
dtNGDetailRow = vdtDetailRow[0];
|
||||
|
||||
/*
|
||||
if (vdtNGCodeRow[0][eNGCodeTable.CustomCode.ToString()].ToString().Trim() == eNGDataType.CP.ToString())
|
||||
dtNGCodeRow = GetNGCodeRowCPLog(vdtNGCodeRow, dtNGDetailRow);
|
||||
else if (vdtNGCodeRow[0][eNGCodeTable.CustomCode.ToString()].ToString().Trim() == eNGDataType.LEAK.ToString())
|
||||
dtNGCodeRow = GeNGCodeRowLeakLog(vdtNGCodeRow, dtNGRow);
|
||||
else
|
||||
{
|
||||
List<DataRow> vdtFoundRow = vdtNGCodeRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vdtFoundRow.Count > 0)
|
||||
dtNGCodeRow = vdtFoundRow[0];
|
||||
else
|
||||
{
|
||||
dicNg.Add(strUnknwonCode, "-");
|
||||
|
||||
bDisplayMessage = false;
|
||||
throw new Exception("-");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (vdtNGCodeRow.Where(x => x[eNGCodeTable.CustomCode.ToString()].ToString().Trim() == eNGDataType.CP.ToString()).ToList().Count > 0)
|
||||
dtNGCodeRow = GetNGCodeRowCPLog(vdtNGCodeRow, dtNGDetailRow);
|
||||
else if (vdtNGCodeRow.Where(x => x[eNGCodeTable.CustomCode.ToString()].ToString().Trim() == eNGDataType.LEAK.ToString()).ToList().Count > 0)
|
||||
{
|
||||
vdtHISTRow = GetNGHistRow(GetNGHistData(eHistAllTableList.HIST_Leak, strLogAccessKey));
|
||||
|
||||
if (vdtHISTRow != null && vdtHISTRow.Count > 0)
|
||||
dtNGHISTRow = vdtHISTRow[0];
|
||||
|
||||
dtNGCodeRow = GeNGCodeRowLeakLog(vdtNGCodeRow, dtNGHISTRow);
|
||||
}
|
||||
|
||||
if(dtNGCodeRow == null)
|
||||
{
|
||||
List<DataRow> vdtFoundRow = vdtNGCodeRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vdtFoundRow.Count > 0)
|
||||
dtNGCodeRow = vdtFoundRow[0];
|
||||
else
|
||||
{
|
||||
dicNg.Add(strUnknwonCode, "-");
|
||||
|
||||
bDisplayMessage = false;
|
||||
throw new Exception("-");
|
||||
}
|
||||
}
|
||||
|
||||
if(dtNGCodeRow != null)
|
||||
dicNg.Add(dtNGCodeRow[eNGCodeTable.NGCode.ToString()].ToString().Trim(), dtNGCodeRow[eNGCodeTable.Status.ToString()].ToString().Trim());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (bDisplayMessage)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"NgCode<Exception> - NGCodeFinder - GetNGCodeDictionary()\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
finally { }
|
||||
|
||||
return dicNg;
|
||||
}
|
||||
public string GetNGCode(DataRow dtNGRow)
|
||||
{
|
||||
if (dtNGRow == null)
|
||||
return "NTH";
|
||||
|
||||
string strProcNo = dtNGRow[eHistTableCommonCols.ProcNo.ToString()].ToString().Trim();
|
||||
string strTestID = dtNGRow[eHistTableCommonCols.TestID.ToString()].ToString().Trim();
|
||||
|
||||
string strResult = "";
|
||||
|
||||
try
|
||||
{
|
||||
strResult = dtNGRow[eHistTableCommonCols.Result.ToString()].ToString().Trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
strResult = "0";
|
||||
}
|
||||
|
||||
if (strResult == "1" || strResult == "True")
|
||||
return "PASS";
|
||||
|
||||
string strUnknwonCode = GetUnknownNGCode(strProcNo, strTestID);
|
||||
|
||||
List<DataRow> vdtNGCodeRow = GetNGCodeList(strProcNo, strTestID);
|
||||
|
||||
if (vdtNGCodeRow == null ? true : vdtNGCodeRow.Count <= 0)
|
||||
return strUnknwonCode;
|
||||
|
||||
string strLogAccessKey = "";
|
||||
List<DataRow> vdtDetailRow = null;
|
||||
List<DataRow> vdtHISTRow = null;
|
||||
|
||||
//LogAccessKey Exist - PC/DEVICE
|
||||
//Not exist - PLC
|
||||
try
|
||||
{
|
||||
strLogAccessKey = dtNGRow[eHistTableCommonCols.LogAccessKey.ToString()]?.ToString().Trim();
|
||||
vdtDetailRow = GetNGDetailRow(GetNGDetailData(strProcNo, strLogAccessKey));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DataRow dtNGDetailRow = null;
|
||||
DataRow dtNGHISTRow = null;
|
||||
|
||||
DataRow dtNGCodeRow = null;
|
||||
|
||||
bool bUnknownState = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (vdtDetailRow != null && vdtDetailRow.Count > 0)
|
||||
dtNGDetailRow = vdtDetailRow[0];
|
||||
|
||||
/*
|
||||
if (vdtNGCodeRow[0][eNGCodeTable.CustomCode.ToString()].ToString().Trim() == eNGDataType.CP.ToString())
|
||||
dtNGCodeRow = GetNGCodeRowCPLog(vdtNGCodeRow, dtNGDetailRow);
|
||||
else if (vdtNGCodeRow[0][eNGCodeTable.CustomCode.ToString()].ToString().Trim() == eNGDataType.LEAK.ToString())
|
||||
dtNGCodeRow = GeNGCodeRowLeakLog(vdtNGCodeRow, dtNGRow);
|
||||
else
|
||||
{
|
||||
List<DataRow> vdtFoundRow = vdtNGCodeRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vdtFoundRow.Count > 0)
|
||||
dtNGCodeRow = vdtFoundRow[0];
|
||||
else
|
||||
bUnknownState = true;
|
||||
}
|
||||
*/
|
||||
|
||||
if (vdtNGCodeRow.Where(x => x[eNGCodeTable.CustomCode.ToString()].ToString().Trim() == eNGDataType.CP.ToString()).ToList().Count > 0)
|
||||
dtNGCodeRow = GetNGCodeRowCPLog(vdtNGCodeRow, dtNGDetailRow);
|
||||
else if (vdtNGCodeRow.Where(x => x[eNGCodeTable.CustomCode.ToString()].ToString().Trim() == eNGDataType.LEAK.ToString()).ToList().Count > 0)
|
||||
{
|
||||
vdtHISTRow = GetNGHistRow(GetNGHistData (eHistAllTableList.HIST_Leak, strLogAccessKey));
|
||||
|
||||
if (vdtHISTRow != null && vdtHISTRow.Count > 0)
|
||||
dtNGHISTRow = vdtHISTRow[0];
|
||||
|
||||
dtNGCodeRow = GeNGCodeRowLeakLog(vdtNGCodeRow, dtNGHISTRow);
|
||||
}
|
||||
|
||||
if(dtNGCodeRow == null)
|
||||
{
|
||||
List<DataRow> vdtFoundRow = vdtNGCodeRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vdtFoundRow.Count > 0)
|
||||
dtNGCodeRow = vdtFoundRow[0];
|
||||
else
|
||||
bUnknownState = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"NgCode<Exception> - NGCodeFinder - GetNGCode()\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
|
||||
if (bUnknownState)
|
||||
return strUnknwonCode;
|
||||
else
|
||||
{
|
||||
if (dtNGCodeRow != null)
|
||||
return dtNGCodeRow[eNGCodeTable.NGCode.ToString()].ToString().Trim();
|
||||
else
|
||||
return strUnknwonCode;
|
||||
|
||||
//return dtNGCodeRow[eNGCodeTable.NGCode.ToString()].ToString().Trim();
|
||||
}
|
||||
}
|
||||
|
||||
public List<DataRow> GetNGCodeList(string strProcNo, string strTestID)
|
||||
{
|
||||
List<DataRow> vdtRows = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (!(NGCodeTable == null))
|
||||
{
|
||||
/*
|
||||
vdtRows = (from dtRow in NGCodeTable.AsEnumerable()
|
||||
where dtRow[eNGCodeTable.ProcNo.ToString()].ToString().Trim() == strProcNo
|
||||
select dtRow).ToList();
|
||||
*/
|
||||
|
||||
vdtRows = (from dtRow in NGCodeTable.AsEnumerable()
|
||||
where dtRow[eNGCodeTable.ProcNo.ToString()].ToString().Trim() == strProcNo
|
||||
&& dtRow[eNGCodeTable.TestID.ToString()].ToString().Trim() == strTestID
|
||||
select dtRow).ToList();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"NgCode<Exception> - NGCodeFinder - GetNGCodeList()\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
|
||||
return vdtRows;
|
||||
}
|
||||
|
||||
public DataTable GetNGDetailData(string strProcNum, string strKeyCode)
|
||||
{
|
||||
DataTable dtResult = null;
|
||||
string strQuery = $"SELECT * FROM {TableName_DetailData}" + "_" + strProcNum + " WHERE " +
|
||||
$"No IN(SELECT No FROM {TableName_DetailData}" + "_" + strProcNum + " WHERE LogAccessKey = '" + strKeyCode +
|
||||
$"') ORDER BY {eHistDetailTableCols.STEP.ToString()} ASC;";
|
||||
|
||||
DataSet dtSet = refPCAdaptor.WaitSystemQuery(strQuery);
|
||||
|
||||
if (dtSet.Tables.Count > 0)
|
||||
dtResult = dtSet.Tables[0];
|
||||
|
||||
return dtResult;
|
||||
}
|
||||
|
||||
public List<DataRow> GetNGDetailRow(DataTable dtResult)
|
||||
{
|
||||
if(dtResult == null)
|
||||
return null;
|
||||
|
||||
List<DataRow> vRows = null;
|
||||
|
||||
try
|
||||
{
|
||||
List<string> vstrNGFlags = Enum.GetNames(typeof(eNGFlag)).ToList();
|
||||
vRows = (from unitRow in dtResult.AsEnumerable() where vstrNGFlags.Contains(unitRow[eHistDetailTableCols.CHECK_RETURN.ToString()].ToString().Trim()) select unitRow).ToList();
|
||||
|
||||
vRows = vRows.OrderBy(x => Convert.ToInt32(x[eHistDetailTableCols.STEP.ToString()].ToString().Trim())).Reverse().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"NgCode<Exception> - NGCodeFinder - GetNGDetailRow()\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
|
||||
return vRows;
|
||||
}
|
||||
public DataTable GetNGHistData(eHistAllTableList setTable, string strKeyCode)
|
||||
{
|
||||
DataTable dtResult = null;
|
||||
string strQuery = $"SELECT * FROM {setTable.ToString()} WHERE " +
|
||||
$"No IN(SELECT No FROM {setTable.ToString()} WHERE LogAccessKey = '" + strKeyCode +
|
||||
$"') ORDER BY No DESC;";
|
||||
|
||||
DataSet dtSet = refPCAdaptor.WaitSystemQuery(strQuery);
|
||||
|
||||
if (dtSet.Tables.Count > 0)
|
||||
dtResult = dtSet.Tables[0];
|
||||
|
||||
return dtResult;
|
||||
}
|
||||
|
||||
public List<DataRow> GetNGHistRow(DataTable dtResult)
|
||||
{
|
||||
if (dtResult == null)
|
||||
return null;
|
||||
|
||||
string strNgResult = "0";
|
||||
List<DataRow> vRows = null;
|
||||
|
||||
try
|
||||
{
|
||||
vRows = (from unitRow in dtResult.AsEnumerable() where strNgResult == (unitRow[eHistTableCommonCols.Result.ToString()].ToString().Trim()) select unitRow).ToList();
|
||||
vRows = vRows.OrderBy(x => Convert.ToInt32(x[eHistDetailTableCols.STEP.ToString()].ToString().Trim())).Reverse().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"NgCode<Exception> - NGCodeFinder - GetNGHistRow()\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
|
||||
return vRows;
|
||||
}
|
||||
|
||||
DataRow GeNGCodeRowLeakLog(List<DataRow> vdtRstRow, DataRow dtDetailNGRow)
|
||||
{
|
||||
List<DataRow> vFoundRow = null;
|
||||
|
||||
double dMVal = double.NaN;
|
||||
double dMin = double.NaN;
|
||||
double dMax = double.NaN;
|
||||
|
||||
if(dtDetailNGRow == null)
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if(vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
double.TryParse(dtDetailNGRow[eHist_LeakTest.Val_Meas.ToString()].ToString().Trim(), out dMVal);
|
||||
double.TryParse(dtDetailNGRow[eHist_LeakTest.Val_Min.ToString()].ToString().Trim(), out dMin);
|
||||
double.TryParse(dtDetailNGRow[eHist_LeakTest.Val_Max.ToString()].ToString().Trim(), out dMax);
|
||||
|
||||
if (double.IsNaN(dMVal) ||
|
||||
double.IsNaN(dMin) ||
|
||||
double.IsNaN(dMax))
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if(vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
}
|
||||
|
||||
if(dMVal < dMin)
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.MIN.ToString()).ToList();
|
||||
|
||||
if(vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
else
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
}
|
||||
}
|
||||
else if(dMVal > dMax)
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.MAX.ToString()).ToList();
|
||||
|
||||
if(vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
else
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
DataRow GetNGCodeRowCPLog(List<DataRow> vdtRstRow, DataRow dtDetailNGRow)
|
||||
{
|
||||
List<DataRow> vFoundRow = null;
|
||||
|
||||
double dMVal = double.NaN;
|
||||
double dMin = double.NaN;
|
||||
double dMax = double.NaN;
|
||||
|
||||
if(dtDetailNGRow == null)
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if(vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
double.TryParse(dtDetailNGRow[eHistDetailTableCols.MEASURE_VALUE.ToString()].ToString().Trim(), out dMVal);
|
||||
double.TryParse(dtDetailNGRow[eHistDetailTableCols.MIN_VALUE.ToString()].ToString().Trim(), out dMin);
|
||||
double.TryParse(dtDetailNGRow[eHistDetailTableCols.MAX_VALUE.ToString()].ToString().Trim(), out dMax);
|
||||
|
||||
int iGetStep = 0;
|
||||
int.TryParse(dtDetailNGRow[eHistDetailTableCols.STEP.ToString()].ToString().Trim(), out iGetStep);
|
||||
|
||||
if (double.IsNaN(dMVal) ||
|
||||
double.IsNaN(dMin) ||
|
||||
double.IsNaN(dMax))
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if(vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
}
|
||||
else if(dMVal < dMin)
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => (x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.MIN.ToString()) &&
|
||||
(x[eNGCodeTable.StepNo.ToString()].ToString().Trim() == iGetStep.ToString())).ToList();
|
||||
|
||||
if(vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
else
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
}
|
||||
}
|
||||
else if(dMVal > dMax)
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => (x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.MAX.ToString()) &&
|
||||
(x[eNGCodeTable.StepNo.ToString()].ToString().Trim() == iGetStep.ToString())).ToList();
|
||||
|
||||
if (vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
else
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vFoundRow = vdtRstRow.Where(x => x[eNGCodeTable.Type.ToString()].ToString().Trim() == eJudgeType.CHECK.ToString()).ToList();
|
||||
|
||||
if (vFoundRow.Count > 0)
|
||||
return vFoundRow[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
string GetUnknownNGCode(string strProcNo, string strTestID)
|
||||
{
|
||||
string strNGCodeResult = UnsortedNGTitle + ":" + strProcNo + "-" + strTestID;
|
||||
|
||||
return strNGCodeResult;
|
||||
}
|
||||
|
||||
public eReworkType GetReworkType(string strNGCode)
|
||||
{
|
||||
List<DataRow> vdtRstRow = (from dtNGRow in NGCodeTable.AsEnumerable() where dtNGRow[eNGCodeTable.NGCode.ToString()].ToString().Trim() == strNGCode select dtNGRow).ToList();
|
||||
eReworkType R_Type = eReworkType.Unknown;
|
||||
|
||||
if(vdtRstRow.Count == 0)
|
||||
return R_Type;
|
||||
|
||||
string strRType = "";
|
||||
|
||||
try
|
||||
{
|
||||
strRType = vdtRstRow[0][eNGCodeTable.ReworkType.ToString()].ToString().Trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"NgCode<Exception> - NGCodeFinder - GetReworkType()\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
|
||||
if (!Enum.TryParse(strRType, out R_Type))
|
||||
return R_Type;
|
||||
|
||||
return R_Type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static SystemX.Net.XAdaptor.PC.O2Sensor.NgCode.DBSchemaMap;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.O2Sensor.NgCode
|
||||
{
|
||||
public class NGCodeMgr
|
||||
{
|
||||
public bool CONNECT { internal set; get; }
|
||||
|
||||
NGCodeFinder NGCodeFinder { get; set; }
|
||||
NGHistDBFinder HistFinder { get; set; }
|
||||
|
||||
XAdaptorPC refPCAdaptor;
|
||||
|
||||
public NGCodeMgr(XAdaptorPC refAdaptor)
|
||||
{
|
||||
refPCAdaptor = refAdaptor;
|
||||
|
||||
CreateInstances();
|
||||
}
|
||||
|
||||
bool CreateInstances()
|
||||
{
|
||||
try
|
||||
{
|
||||
HistFinder = new NGHistDBFinder(refPCAdaptor);
|
||||
NGCodeFinder = new NGCodeFinder(refPCAdaptor);
|
||||
|
||||
NGCodeFinder.InitialNgCodeTable();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"Error during initiating NG Code Manager Instance: " + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"Recv NgTable.", ConsoleColor.White, LogMessageLevel.DEBUG);
|
||||
|
||||
return true;
|
||||
}
|
||||
public List<string> GetNGCodeHistory(string strProductID)
|
||||
{
|
||||
return HistFinder.GetNGCodeHistory(strProductID);
|
||||
}
|
||||
public Dictionary<eHistProcTableList, DataRow> GetProcResult(string strProductID, string strPalletID, bool bFirstNgFind)
|
||||
{
|
||||
return HistFinder.FindHistory(strProductID, strPalletID, bFirstNgFind);
|
||||
}
|
||||
public Tuple<eHistProcTableList, DataRow, bool> GetNGProcess(string strProductID, string strPalletID)
|
||||
{
|
||||
return HistFinder.FindNGHistory(strProductID, strPalletID);
|
||||
}
|
||||
public Dictionary<string, string> GetNGCodeDictionary(eHistProcTableList proc, DataRow dtRow)
|
||||
{
|
||||
Dictionary<string, string> dicNgCode = null;
|
||||
|
||||
dicNgCode = NGCodeFinder.GetNGCodeDictionary(dtRow);
|
||||
|
||||
return dicNgCode;
|
||||
}
|
||||
public string GetNGCode(eHistProcTableList proc, DataRow dtRow)
|
||||
{
|
||||
string strNGCode = string.Empty;
|
||||
|
||||
strNGCode = NGCodeFinder .GetNGCode(dtRow);
|
||||
|
||||
return strNGCode;
|
||||
}
|
||||
public eReworkType GetReworkType(string strNGCode)
|
||||
{
|
||||
return NGCodeFinder.GetReworkType(strNGCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,212 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Net.XAdaptor.PC;
|
||||
using SystemX.Net.Platform.Common.ExtensionMethods;
|
||||
using static SystemX.Net.XAdaptor.PC.O2Sensor.NgCode.DBSchemaMap;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.O2Sensor.NgCode
|
||||
{
|
||||
public class NGHistDBFinder
|
||||
{
|
||||
string SET_NG_HIST_TABLE_NAME = "HIST_TestNgResult";
|
||||
//Name - ProcNo - TestID
|
||||
Dictionary<eHistProcTableList, Tuple<int, string>> dicHistInfo;
|
||||
|
||||
XAdaptorPC refPCAdaptor;
|
||||
|
||||
public NGHistDBFinder(XAdaptorPC refAdaptor)
|
||||
{
|
||||
refPCAdaptor = refAdaptor;
|
||||
|
||||
dicHistInfo = new Dictionary<eHistProcTableList, Tuple<int, string>>();
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_ProdLoad, new Tuple<int, string>(180, "PL"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_CapDeassy, new Tuple<int, string>(180, "CDA"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_PreHeating, new Tuple<int, string>(190, "PH"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_PreMeas, new Tuple<int, string>(190, "PM"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_Leak, new Tuple<int, string>(200, "LK"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_LaserTrim, new Tuple<int, string>(210, "LT"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_LaserTrimVision, new Tuple<int, string>(220, "LTV"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_IsoRes, new Tuple<int, string>(220, "IR"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_CapAssy, new Tuple<int, string>(230, "CA"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_Function, new Tuple<int, string>(240, "FT"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_OutSealPress, new Tuple<int, string>(250, "OSP"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_PinVision, new Tuple<int, string>(260, "PV"));
|
||||
dicHistInfo.Add(eHistProcTableList.HIST_PinLVDT, new Tuple<int, string>(260, "LVDT"));
|
||||
}
|
||||
|
||||
public Dictionary<eHistProcTableList, DataRow> FindHistory(string strMESID, string strPalletID, bool bFristFailScan = false)
|
||||
{
|
||||
Dictionary<eHistProcTableList, DataRow> dicResult = new Dictionary<eHistProcTableList, DataRow>();
|
||||
|
||||
string strQuery = $"SELECT * FROM {SET_NG_HIST_TABLE_NAME.ToString()} WHERE No IN (SELECT No FROM {SET_NG_HIST_TABLE_NAME.ToString()} WHERE " +
|
||||
$"{eHistTableCommonCols.ProdID} = '{strMESID}' AND {eHistTableCommonCols.PalletID} = '{strPalletID}') " +
|
||||
$"ORDER BY {eHistTableCommonCols.ProcNo.ToString()};";
|
||||
|
||||
DataSet dsResult = null;
|
||||
|
||||
try
|
||||
{
|
||||
dsResult = refPCAdaptor.WaitSystemQuery(strQuery);
|
||||
DataRow dr = null;
|
||||
|
||||
foreach (eHistProcTableList tableName in Enum.GetValues(typeof(eHistProcTableList)))
|
||||
{
|
||||
int iProcNo = dicHistInfo[tableName].Item1;
|
||||
string strTestID = dicHistInfo[tableName].Item2;
|
||||
|
||||
bool bNgRowFind = false;
|
||||
dr = null;
|
||||
|
||||
foreach (var item in dsResult.Tables[0].Rows)
|
||||
{
|
||||
dr = item as DataRow;
|
||||
|
||||
int iIndex = dsResult.Tables[0].Rows.IndexOf(dr);
|
||||
|
||||
string strGetProcNo = dsResult.Tables[0].Rows[iIndex][eHistTableCommonCols.ProcNo.ToString()].ToString().Trim();
|
||||
string strGetTestID = dsResult.Tables[0].Rows[iIndex][eHistTableCommonCols.TestID.ToString()].ToString().Trim();
|
||||
|
||||
if (strGetProcNo == iProcNo.ToString() &&
|
||||
strGetTestID == strTestID)
|
||||
{
|
||||
bNgRowFind = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bNgRowFind)
|
||||
{
|
||||
dicResult.Add(tableName, dr);
|
||||
|
||||
//이력 존재시 NG
|
||||
if (bFristFailScan)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
dicResult.Add(tableName, null);
|
||||
|
||||
//이력 미 존재시 PASS
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"NgCode<Exception> - NGHistDBFinder - FindHistory()\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
|
||||
return dicResult;
|
||||
}
|
||||
public Tuple<eHistProcTableList, DataRow, bool> FindNGHistory(string strMESID, string strPalletID)
|
||||
{
|
||||
Tuple<eHistProcTableList, DataRow, bool> pairResult = null;
|
||||
Dictionary<eHistProcTableList, DataRow> dicResult = FindHistory(strMESID, strPalletID, true);
|
||||
|
||||
try
|
||||
{
|
||||
foreach (eHistProcTableList procTbl in Enum.GetValues(typeof(eHistProcTableList)))
|
||||
{
|
||||
DataRow dtRow = dicResult[procTbl];
|
||||
|
||||
if (dtRow == null)
|
||||
{
|
||||
if (pairResult == null)
|
||||
pairResult = new Tuple<eHistProcTableList, DataRow, bool>(procTbl, null, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
pairResult = new Tuple<eHistProcTableList, DataRow, bool>(procTbl, dtRow, false);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"NgCode<Exception> - NGHistDBFinder - FindNGHistory()\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
|
||||
return pairResult;
|
||||
}
|
||||
public List<string> GetOnloadedPalletIDs(string strMESID)
|
||||
{
|
||||
string strQuery = $"SELECT PalletID FROM {eHistAllTableList.HIST_ProdLoad.ToString()} WHERE {eHistTableCommonCols.ProdID} = '{strMESID}' ORDER BY {eHistTableCommonCols.UpdateDT.ToString()} DESC";
|
||||
|
||||
DataSet dtSet = refPCAdaptor.WaitSystemQuery(strQuery);
|
||||
|
||||
List<string> vstrPalletID = (from dtResult in dtSet.Tables[0].AsEnumerable()
|
||||
let strResult = dtResult[eHistTableCommonCols.PalletID.ToString()].ToString().Trim()
|
||||
select strResult).ToList();
|
||||
|
||||
return vstrPalletID;
|
||||
}
|
||||
public List<string> GetNGCodeHistory(string strMESID)
|
||||
{
|
||||
List<string> vstrNGCodes = null;
|
||||
|
||||
try
|
||||
{
|
||||
string strQuery = $"SELECT TOP 100 NGCode FROM {eHistAllTableList.HIST_ProdUnload.ToString()} WHERE {eHistTableCommonCols.ProdID} = '{strMESID}' ORDER BY {eHistTableCommonCols.UpdateDT.ToString()} DESC";
|
||||
|
||||
DataSet dtSet = refPCAdaptor.WaitSystemQuery(strQuery);
|
||||
|
||||
vstrNGCodes = (from dtResult in dtSet.Tables[0].AsEnumerable()
|
||||
let strResult = dtResult[eHist_ProdUnload.NGCode.ToString()].ToString().Trim()
|
||||
select strResult).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"NgCode<Exception> - NGHistDBFinder - GetNGCodeHistory()\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
|
||||
return vstrNGCodes;
|
||||
}
|
||||
string SearchRecentResultQuery(string strTable, string strMESID)
|
||||
{
|
||||
string strQuery = $"SELECT * FROM {strTable}";
|
||||
|
||||
return strQuery;
|
||||
}
|
||||
public string GetCurrentPalletID(string strMESID)
|
||||
{
|
||||
string strColPalletID = "PalletID";
|
||||
string strProdLoadState = "STAT_ProdLoad";
|
||||
string strQuery = $"SELECT {strColPalletID} FROM {strProdLoadState} WHERE {eStat_ProdLoad.ProdID} = '{strMESID}'";
|
||||
|
||||
DataSet dsResult = refPCAdaptor.WaitSystemQuery(QueryProcessList);
|
||||
|
||||
List<string> vstrPalletID = (from dtResult in dsResult.Tables[0].AsEnumerable()
|
||||
where dtResult[strColPalletID].ToString().Trim() == strMESID
|
||||
let strResult = dtResult[strColPalletID].ToString().Trim()
|
||||
select strResult).ToList();
|
||||
|
||||
if(vstrPalletID.Count <= 0)
|
||||
return string.Empty;
|
||||
|
||||
return vstrPalletID[0];
|
||||
}
|
||||
public DataTable GetProcessList()
|
||||
{
|
||||
DataSet dsResult = refPCAdaptor.WaitSystemQuery(QueryProcessList);
|
||||
|
||||
return dsResult.Tables[0];
|
||||
}
|
||||
|
||||
string QueryProcessList = $"SELECT * FROM {DBSchemaMap.ProcessListTableName}";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.XAdaptor.PC;
|
||||
using SystemX.Net.Schedule;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.ProtocolMethod
|
||||
{
|
||||
public class CONNECT_STATE : ProtocolShell, IProtocol
|
||||
{
|
||||
public CONNECT_STATE(XAdaptorPC xAdaptor, int iPos)
|
||||
: base(xAdaptor, iPos)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecuteProtocol(BASE_PROTOCOL GET_PROTOCOL,
|
||||
BASE_PROTOCOL.PROTOCOL_CODE CODE,
|
||||
HEADER_PACKET getHeader,
|
||||
object objData)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.XAdaptor.PC;
|
||||
using SystemX.Net.Schedule;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.ProtocolMethod
|
||||
{
|
||||
public class HOST_INFO_CHECK : ProtocolShell, IProtocol
|
||||
{
|
||||
public HOST_INFO_CHECK(XAdaptorPC xAdaptor, int iPos)
|
||||
: base(xAdaptor, iPos)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecuteProtocol(BASE_PROTOCOL GET_PROTOCOL,
|
||||
BASE_PROTOCOL.PROTOCOL_CODE CODE,
|
||||
HEADER_PACKET getHeader,
|
||||
object objData)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.XAdaptor.PC;
|
||||
using SystemX.Net.Schedule;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.ProtocolMethod
|
||||
{
|
||||
public class INITILALIZE_INFO : ProtocolShell, IProtocol
|
||||
{
|
||||
public INITILALIZE_INFO(XAdaptorPC xAdaptor, int iPos)
|
||||
: base(xAdaptor, iPos)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecuteProtocol(BASE_PROTOCOL GET_PROTOCOL,
|
||||
BASE_PROTOCOL.PROTOCOL_CODE CODE,
|
||||
HEADER_PACKET getHeader,
|
||||
object objData)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Common.Protocol.SIA;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.XAdaptor.PC;
|
||||
using SystemX.Net.Schedule;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.ProtocolMethod
|
||||
{
|
||||
public interface IProtocol
|
||||
{
|
||||
}
|
||||
|
||||
public class ProtocolShell
|
||||
{
|
||||
public XAdaptorPC xAdaptor_;
|
||||
|
||||
//protected CustomProtocol_ cp = new CustomProtocol_();
|
||||
|
||||
protected int nPos;
|
||||
|
||||
public ProtocolShell(XAdaptorPC xAdaptor, int iPos)
|
||||
{
|
||||
xAdaptor_ = xAdaptor;
|
||||
|
||||
nPos = iPos;
|
||||
}
|
||||
|
||||
public virtual void ExecuteProtocol(BASE_PROTOCOL GET_PROTOCOL,
|
||||
BASE_PROTOCOL.PROTOCOL_CODE CODE,
|
||||
HEADER_PACKET getHeader,
|
||||
object objData){ /*Virtual*/ }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,658 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.XAdaptor;
|
||||
using SystemX.Net.XAdaptor.PC.O2Sensor.NgCode;
|
||||
using SystemX.Net.Schedule;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
using WTimer = System.Windows.Forms.Timer;
|
||||
using System.IO.Compression;
|
||||
using SystemX.Net.Comm.IIS_FTP;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public partial class XAdaptorPC : XAdaptorSystem, IXPCAdaptor, IUIM, IComXPCAdaptor, IDisposable
|
||||
{
|
||||
private IPEndPoint ClientCommandEP;
|
||||
private IPEndPoint ClientStreamEP;
|
||||
|
||||
private const int DISP_CONNECT_TIME_OUT = 5000;
|
||||
|
||||
private const int CONNECT_TIME_OUT = 10000;
|
||||
private const int COMMAND_TIME_OUT = 20000;
|
||||
|
||||
private const int FILE_SCAN_TIME = 250;
|
||||
private const int DEVICE_SCAN_TIME = 250;
|
||||
|
||||
private const int RETRY_TIME = 5000;
|
||||
|
||||
private const int LOGIN_TIMEOUT = 90000;
|
||||
|
||||
private const int OBJECT_ACCESS_WAITTIME = 5000;
|
||||
|
||||
private const int FILE_ACCESS_WAITTIME = 100;
|
||||
|
||||
private const int OBJECT_ACCESS_CHECKTIME = 250;
|
||||
|
||||
//1분 파일 전송 간격
|
||||
private const int FILE_SEND_INTERVAL_TIME = 10000;
|
||||
|
||||
//TODO : For Debug Test
|
||||
//5분 이상 파일전송이 없을경우
|
||||
private const int FILE_SEND_MAX_WAITTIME = 300000; // 300000;
|
||||
|
||||
private const int COMM_RETRY = 3;
|
||||
//private const double SESSION_TIMEOUT_SECOND = 300.0;
|
||||
|
||||
#if FALSE
|
||||
private AsyncComClientSocket ClientCommandSock;
|
||||
private AsyncComClientSocket ClientStreamSock;
|
||||
#else
|
||||
private AsyncClientSocket ClientCommandSock;
|
||||
private AsyncClientSocket ClientStreamSock;
|
||||
#endif
|
||||
|
||||
private Task taskRecvCommandProcess;
|
||||
private bool m_bTaskCommandBlock;
|
||||
|
||||
private Task taskRecvStreamProcess;
|
||||
private bool m_bTaskStreamBlock;
|
||||
|
||||
private Task taskSubProcess;
|
||||
private bool m_bTaskSubBlock;
|
||||
//
|
||||
private CancellationTokenSource CommandCTS;
|
||||
private CancellationToken CommandCT;
|
||||
|
||||
private CancellationTokenSource StreamCTS;
|
||||
private CancellationToken StreamCT;
|
||||
|
||||
private CancellationTokenSource SubCTS;
|
||||
private CancellationToken SubCT;
|
||||
//
|
||||
private bool bConnectCommandSocketFlag;
|
||||
private bool bConnectStreamSocketFlag;
|
||||
//
|
||||
private PacketFlowControl FlowCommandControl;
|
||||
private PacketFlowControl FlowStreamControl;
|
||||
|
||||
private event RecvWaitEventHandler RecvWaitEvent;
|
||||
|
||||
private WaitParameter waitCommandParam;
|
||||
private WaitParameter waitStreamParam;
|
||||
|
||||
internal class QueryDataSetResult
|
||||
{
|
||||
public XData xData;
|
||||
|
||||
public bool bQueryResult;
|
||||
|
||||
public DataSet QueryDataSet;
|
||||
|
||||
public string strVarParam1;
|
||||
public string strVarParam2;
|
||||
public string strVarParam3;
|
||||
|
||||
public bool bFileRecvResult;
|
||||
public bool bFileProcessResult;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
xData = null;
|
||||
|
||||
bQueryResult = false;
|
||||
|
||||
QueryDataSet = null;
|
||||
|
||||
strVarParam1 = string.Empty;
|
||||
strVarParam2 = string.Empty;
|
||||
strVarParam3 = string.Empty;
|
||||
|
||||
bFileRecvResult = false;
|
||||
bFileProcessResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
private QueryDataSetResult QueryResult = new QueryDataSetResult();
|
||||
|
||||
//Command Socket Retry Time
|
||||
private Stopwatch streCommandConnectWatch;
|
||||
//Stream Socket Retry Time
|
||||
private Stopwatch streStreamConnectWatch;
|
||||
//File Send & File Backup Time
|
||||
private Stopwatch stFileSendTime;
|
||||
private Stopwatch stBackupFileSendTime;
|
||||
|
||||
private Task tkReCommandConnect;
|
||||
private Task tkReStreamConnect;
|
||||
|
||||
private WTimer reConnectTimer;
|
||||
//
|
||||
private bool[] START_EVENT_TRIGGER;
|
||||
|
||||
private string strSetAdaptorConfigFilePos;
|
||||
private string strCheckCommandMsg;
|
||||
private string strCheckStreamMsg;
|
||||
|
||||
private static SemaphoreSlim _smpSlim = new SemaphoreSlim(1, 1);
|
||||
|
||||
private static bool bTaskSubLockState = false;
|
||||
|
||||
//private static readonly object objFileSendLock = new object();
|
||||
|
||||
private static bool bTaskCommandWaitLock = false;
|
||||
private static bool bTaskStreamWaitLock = false;
|
||||
|
||||
private bool bReqConnectFailed;
|
||||
private int nReqConnectNum;
|
||||
//
|
||||
private NGCodeMgr dbNgCodeFinder;
|
||||
|
||||
public NGCodeMgr GetNgCodeMgr()
|
||||
{
|
||||
if (dbNgCodeFinder != null)
|
||||
return dbNgCodeFinder;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private enum TIMER_LOCK
|
||||
{
|
||||
RECONNECT_TIMER = 0
|
||||
}
|
||||
|
||||
private bool[] m_bTimerLock;
|
||||
|
||||
private void InitMember()
|
||||
{
|
||||
GetMiddlewareMessage = "OFF";
|
||||
|
||||
CommandCTS = new CancellationTokenSource();
|
||||
CommandCT = CommandCTS.Token;
|
||||
|
||||
StreamCTS = new CancellationTokenSource();
|
||||
StreamCT = StreamCTS.Token;
|
||||
|
||||
SubCTS = new CancellationTokenSource();
|
||||
SubCT = SubCTS.Token;
|
||||
//
|
||||
streCommandConnectWatch = new Stopwatch();
|
||||
streCommandConnectWatch.Start();
|
||||
|
||||
streStreamConnectWatch = new Stopwatch();
|
||||
streStreamConnectWatch.Start();
|
||||
|
||||
stFileSendTime = new Stopwatch();
|
||||
stFileSendTime.Start();
|
||||
|
||||
stBackupFileSendTime = new Stopwatch();
|
||||
stBackupFileSendTime.Start();
|
||||
//
|
||||
tkReCommandConnect = null;
|
||||
tkReStreamConnect = null;
|
||||
|
||||
strSetAdaptorConfigFilePos = string.Empty;
|
||||
|
||||
AdaptorInformation = new ClientConnInfo();
|
||||
//
|
||||
bConnectCommandSocketFlag = false;
|
||||
bConnectStreamSocketFlag = false;
|
||||
}
|
||||
|
||||
public XAdaptorPC()
|
||||
{
|
||||
InitMember();
|
||||
|
||||
/* For LeakTest */
|
||||
if (COMMON.FIX_INFO_MODE)
|
||||
{
|
||||
IPEndPoint CommandEp = null;
|
||||
IPEndPoint StreamEp = null;
|
||||
|
||||
CommandEp = new IPEndPoint(IPAddress.Parse("200.200.200.48"), 5124);
|
||||
StreamEp = new IPEndPoint(IPAddress.Parse("200.200.200.48"), 7124);
|
||||
|
||||
//TempCode
|
||||
//CommandEp = new IPEndPoint(IPAddress.Loopback, 5124);
|
||||
//StreamEp = new IPEndPoint(IPAddress.Loopback, 7124);
|
||||
|
||||
Initialize(CommandEp, StreamEp);
|
||||
}
|
||||
else
|
||||
{
|
||||
//For Normal Process
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
public XAdaptorPC(IPEndPoint SetCommandEp = null, IPEndPoint SetStreamEp = null)
|
||||
{
|
||||
InitMember();
|
||||
|
||||
Initialize(SetCommandEp, SetStreamEp);
|
||||
}
|
||||
|
||||
~XAdaptorPC()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool bDisposing)
|
||||
{
|
||||
RecvWaitEvent -= RecvWaitEventCall;
|
||||
|
||||
if (bDisposing)
|
||||
{
|
||||
ClearCommandWatchTask();
|
||||
ClearStreamWatchTask();
|
||||
}
|
||||
|
||||
ClearCommandClientInstance();
|
||||
ClearStreamClientInstance();
|
||||
|
||||
// do releasing unmanaged resource (종결자가 없는 객체의 자원 해제)
|
||||
// i.e. close file handle of operating systems
|
||||
|
||||
// suppress calling of Finalizer
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void SetRetryTimer()
|
||||
{
|
||||
reConnectTimer = new WTimer();
|
||||
reConnectTimer.Enabled = false;
|
||||
reConnectTimer.Interval = 1500;
|
||||
reConnectTimer.Tick += ReConnectTimer_Tick;
|
||||
reConnectTimer.Start();
|
||||
reConnectTimer.Enabled = true;
|
||||
}
|
||||
|
||||
private bool CheckConfigFileBuildEndPoint()
|
||||
{
|
||||
bool bCheckResult = true;
|
||||
|
||||
var sFilePath = "";
|
||||
|
||||
if (strSetAdaptorConfigFilePos.Length <= 0)
|
||||
sFilePath = Directory.GetCurrentDirectory() + @"\Configure\" + "ClientInformation.xml";
|
||||
else
|
||||
sFilePath = strSetAdaptorConfigFilePos;
|
||||
|
||||
if (File.Exists(sFilePath) == false)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"SystemX.Net.XAdaptor.PC Configuration file does not exist. " +
|
||||
"[SystemX.Net.XAdaptor.PC : XPCAdaptor.CheckConfigFileBuildEndPoint]", ConsoleColor.Yellow, LogMessageLevel.FATAL);
|
||||
|
||||
bCheckResult = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadInfo = new ClientInfo(sFilePath);
|
||||
|
||||
if (LoadInfo.Load() == false)
|
||||
{
|
||||
bCheckResult = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"SystemX.Net.XAdaptor.PC Configuration file loading Error. " +
|
||||
"[SystemX.Net.XAdaptor.PC : XPCAdaptor.CheckConfigFileBuildEndPoint]", ConsoleColor.Yellow, LogMessageLevel.FATAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdaptorInformation.CONNECT_IP = LoadInfo.CONNECT_IP;
|
||||
AdaptorInformation.SECTION = LoadInfo.SECTION;
|
||||
AdaptorInformation.HOST_ID = LoadInfo.HOST_ID;
|
||||
AdaptorInformation.TEST_CODE = LoadInfo.TEST_CODE;
|
||||
|
||||
AdaptorInformation.COMMAND_PORT = LoadInfo.COMMAND_PORT;
|
||||
AdaptorInformation.STREAM_PORT = LoadInfo.STREAM_PORT;
|
||||
|
||||
AdaptorInformation.LOGIN_RESULT = false;
|
||||
AdaptorInformation.LOGIN_MESSAGE = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
StateAdaptorConnect = bCheckResult;
|
||||
|
||||
if (ClientReadyEndPoint && bCheckResult)
|
||||
SetEpCommandStream();
|
||||
|
||||
return bCheckResult;
|
||||
}
|
||||
|
||||
private void SetDefaultConfig()
|
||||
{
|
||||
LoadInfo = new ClientInfo();
|
||||
LoadInfo.LOOP_BACK = false;
|
||||
|
||||
LoadInfo.CONNECT_IP = ClientCommandEP.Address.ToString();
|
||||
|
||||
LoadInfo.COMMAND_PORT = ClientCommandEP.Port;
|
||||
LoadInfo.STREAM_PORT = ClientStreamEP.Port;
|
||||
|
||||
LoadInfo.READ_INFO_STATE = true;
|
||||
|
||||
StateAdaptorConnect = true;
|
||||
}
|
||||
|
||||
private void SetEpCommandStream()
|
||||
{
|
||||
if (LoadInfo.LOOP_BACK)
|
||||
{
|
||||
ClientCommandEP = new IPEndPoint(IPAddress.Loopback, LoadInfo.COMMAND_PORT);
|
||||
ClientStreamEP = new IPEndPoint(IPAddress.Loopback, LoadInfo.STREAM_PORT);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClientCommandEP = new IPEndPoint(IPAddress.Parse(LoadInfo.CONNECT_IP), LoadInfo.COMMAND_PORT);
|
||||
ClientStreamEP = new IPEndPoint(IPAddress.Parse(LoadInfo.CONNECT_IP), LoadInfo.STREAM_PORT);
|
||||
}
|
||||
}
|
||||
|
||||
private void AdaptorAbort(bool bForceClear = false)
|
||||
{
|
||||
ClearCommonVar();
|
||||
|
||||
ClearCommandWatchTask();
|
||||
ClearStreamWatchTask();
|
||||
|
||||
if (bForceClear == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
XAdaptorLogWrite("AdaptorAbort - Command Socket Disconnect");
|
||||
XAdaptorLogWrite("AdaptorAbort - Stream Socket Disconnect");
|
||||
|
||||
streCommandConnectWatch.Restart();
|
||||
|
||||
streStreamConnectWatch.Restart();
|
||||
|
||||
thisConnInfo.ConnectCommandState = false;
|
||||
thisConnInfo.ConnectStreamState = false;
|
||||
|
||||
SubscribeConnectInfo.Initialize();
|
||||
|
||||
StateClientSocketConnect = false;
|
||||
StateClientGetInformation = false;
|
||||
StateClientStreamSocketConnect = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Abort socket all-clear information error. [SystemX.Net.XAdaptor.PC : XPCAdaptor.AdaptorAbort]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
OnCommandDisconnectAlarm(null, null);
|
||||
OnStreamDisconnectAlarm(null, null);
|
||||
|
||||
ClearCommandClientInstance();
|
||||
ClearStreamClientInstance();
|
||||
}
|
||||
|
||||
private async void ReConnectTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (m_bTimerLock[(int)TIMER_LOCK.RECONNECT_TIMER] == false)
|
||||
{
|
||||
m_bTimerLock[(int)TIMER_LOCK.RECONNECT_TIMER] = true;
|
||||
|
||||
if(SubscribeConnectInfo.bSetChangeConnect)
|
||||
{
|
||||
if (SubscribeConnectInfo.bReqConnectAbort == false)
|
||||
SubscribeConnectInfo.bReqConnectAbort = true;
|
||||
else
|
||||
{
|
||||
if (bReqConnectFailed)
|
||||
{
|
||||
bReqConnectFailed = false;
|
||||
|
||||
if (nReqConnectNum < 2)
|
||||
{
|
||||
SubscribeConnectInfo.bSetChangeConnect = false;
|
||||
|
||||
await ComClientTryDistributionConnet();
|
||||
}
|
||||
else
|
||||
SubscribeConnectInfo.bSetChangeConnect = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ConnectStartStyleAuto == false)
|
||||
SubscribeConnectInfo.bSetChangeConnect = false;
|
||||
else
|
||||
{
|
||||
if (await ComClientTryConnet(SubscribeConnectInfo.nChangeCommandPort, SubscribeConnectInfo.nChangeStreamPort))
|
||||
SubscribeConnectInfo.bSetChangeConnect = false;
|
||||
else
|
||||
{
|
||||
AdaptorAbort();
|
||||
|
||||
bReqConnectFailed = true;
|
||||
nReqConnectNum++;
|
||||
|
||||
SubscribeConnectInfo.bReqConnectAbort = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SubscribeConnectInfo.bUIMUseMode && SubscribeConnectInfo.bSessionStarted)
|
||||
{
|
||||
if (LoadInfo.SESSION_TIMEOUT_TIME_S > 0.0)
|
||||
{
|
||||
if (SubscribeConnectInfo.GetSessionTime().TotalSeconds >= LoadInfo.SESSION_TIMEOUT_TIME_S)
|
||||
{
|
||||
AdaptorAbort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
/*
|
||||
if (START_EVENT_TRIGGER[0])
|
||||
{
|
||||
START_EVENT_TRIGGER[0] = false;
|
||||
|
||||
//CommandConnectAlarmEvent?.BeginInvoke(null, null, null, null);
|
||||
//CommandConnectAlarmEvent?.Invoke(null, null);
|
||||
|
||||
OnCommandConnectAlarm(null, null);
|
||||
}
|
||||
if (START_EVENT_TRIGGER[1])
|
||||
{
|
||||
START_EVENT_TRIGGER[1] = false;
|
||||
|
||||
//StreamConnectAlarmEvent?.BeginInvoke(null, null, null, null);
|
||||
//StreamConnectAlarmEvent?.Invoke(null, null);
|
||||
|
||||
OnStreamConnectAlarm(null, null);
|
||||
}
|
||||
*/
|
||||
//
|
||||
/*
|
||||
//Command Stream Conn Check
|
||||
if (StateClientSocketConnect == false)
|
||||
goto ROUTINE_OUT;
|
||||
if (thisConnInfo.stCommandCheckTime.ElapsedMilliseconds >= 60000)
|
||||
{
|
||||
SendCommandConnectState();
|
||||
|
||||
thisConnInfo.OnCommandCheckTime();
|
||||
}
|
||||
//
|
||||
if (StateClientStreamSocketConnect == false)
|
||||
goto ROUTINE_OUT;
|
||||
if (thisConnInfo.stStreamCheckTime.ElapsedMilliseconds >= 60000)
|
||||
{
|
||||
SendStreamConnectState();
|
||||
|
||||
thisConnInfo.OnStreamCheckTime();
|
||||
}
|
||||
|
||||
ROUTINE_OUT:
|
||||
*/
|
||||
|
||||
m_bTimerLock[(int)TIMER_LOCK.RECONNECT_TIMER] = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Initialize(IPEndPoint SetCommandEp = null, IPEndPoint SetStreamEp = null)
|
||||
{
|
||||
waitCommandParam = new WaitParameter();
|
||||
waitStreamParam = new WaitParameter();
|
||||
|
||||
mgrPRODTestList = CreateTestListMgr();
|
||||
|
||||
bReqConnectFailed = false;
|
||||
nReqConnectNum = 0;
|
||||
|
||||
//Ng code decoder
|
||||
dbNgCodeFinder = null;
|
||||
|
||||
ClientReadyEndPoint = false;
|
||||
|
||||
if (SetCommandEp != null && SetStreamEp != null)
|
||||
{
|
||||
ClientCommandEP = SetCommandEp;
|
||||
ClientStreamEP = SetStreamEp;
|
||||
|
||||
ClientReadyEndPoint = true;
|
||||
}
|
||||
|
||||
MessageOutput.PrintLogLevel = LogMessageLevel.INFO;
|
||||
|
||||
StateAdaptorConnect = true;
|
||||
//
|
||||
StateClientSocketConnect = false;
|
||||
StateClientStreamSocketConnect = false;
|
||||
//
|
||||
StateClientGetInformation = false;
|
||||
//
|
||||
ClientCommandSock = null;
|
||||
ClientStreamSock = null;
|
||||
|
||||
FlowCommandControl = null;
|
||||
FlowStreamControl = null;
|
||||
|
||||
RecvWaitEvent += RecvWaitEventCall;
|
||||
|
||||
thisConnInfo = new ClientInfoStore();
|
||||
//
|
||||
m_bTimerLock = new bool[10];
|
||||
Array.Clear(m_bTimerLock, 0, 10);
|
||||
//
|
||||
if (ClientReadyEndPoint == false)
|
||||
CheckConfigFileBuildEndPoint();
|
||||
else
|
||||
SetDefaultConfig();
|
||||
//
|
||||
if (StateAdaptorConnect)
|
||||
{
|
||||
;//
|
||||
}
|
||||
//
|
||||
thisConnInfo.OnCommandTime();
|
||||
thisConnInfo.OnCommandCheckTime();
|
||||
|
||||
thisConnInfo.OnStreamTime();
|
||||
thisConnInfo.OnStreamCheckTime();
|
||||
//
|
||||
//if (CLIENT_AUTO_CONNECT)
|
||||
SetRetryTimer();
|
||||
}
|
||||
|
||||
// TODO : FTP ALIS
|
||||
internal eFTPServiceStatus StartFTPService()
|
||||
{
|
||||
if (LoadInfo.FTP_Use)
|
||||
{
|
||||
ControlFTP = new CtrlFTP(LoadInfo.FTP_Use,
|
||||
IPAddress.Parse(LoadInfo.FTP_IPAddress), Convert.ToInt32(LoadInfo.FTP_Port),
|
||||
LoadInfo.FTP_Account, LoadInfo.FTP_Password);
|
||||
|
||||
if (ControlFTP.FTPConnState)
|
||||
return eFTPServiceStatus.Connected;
|
||||
else
|
||||
return eFTPServiceStatus.Disconnected;
|
||||
}
|
||||
else
|
||||
return eFTPServiceStatus.Unused;
|
||||
}
|
||||
|
||||
public DataSet WaitSystemQuery(string strQuery)
|
||||
{
|
||||
if (thisConnInfo.ConnectCommandState == false)
|
||||
return null;
|
||||
if (thisConnInfo.InitialInfoState == false)
|
||||
return null;
|
||||
if (LoadInfo.SIMPLE_LOOKUP_OPTION == true)
|
||||
return null;
|
||||
|
||||
DataSet dsReturnSet = null;
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo.OnCommandTime();
|
||||
|
||||
try
|
||||
{
|
||||
QUERY_PACKET QueryPacket = new QUERY_PACKET();
|
||||
int iSizeQueryPacket = Marshal.SizeOf(QueryPacket);
|
||||
byte[] ucQueryPacketArray = new byte[iSizeQueryPacket];
|
||||
QueryPacket = (QUERY_PACKET)SystemXNetSerialization.RawDeSerialize(ucQueryPacketArray, QueryPacket.GetType());
|
||||
QueryPacket.objQueryText[0].Data = strQuery;
|
||||
ucQueryPacketArray = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.SYSTEM_QUERY), QueryPacket);
|
||||
|
||||
byte ucGetLabel = FlowCommandControl.InsertSendQueue(DateTime.Now, ucQueryPacketArray, null, true);
|
||||
|
||||
WaitThreadJoin(waitCommandParam, FlowCommandControl, ucGetLabel);
|
||||
|
||||
if (QueryResult.QueryDataSet != null)
|
||||
{
|
||||
if (QueryResult.bQueryResult) //Query 문 실행 성공
|
||||
dsReturnSet = QueryResult.QueryDataSet;
|
||||
else //Query 문 실행 실패(구문 오류 또는 연결 오류)
|
||||
dsReturnSet = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Internal use program query failure. [" + strQuery + "][SystemX.Net.XAdaptor.PC - IXPCAdaptor : XPCAdaptor.WaitSystemQuery]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.FATAL);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return dsReturnSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,647 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.XAdaptor.PC.O2Sensor.NgCode;
|
||||
using SystemX.Net.Schedule;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
using WTimer = System.Windows.Forms.Timer;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public partial class XAdaptorPC
|
||||
{
|
||||
protected override void OnCommandConnectAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
base.OnCommandConnectAlarm(sender, e);
|
||||
}
|
||||
protected override void OnStreamConnectAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
base.OnStreamConnectAlarm(sender, e);
|
||||
}
|
||||
|
||||
protected override void OnConnectionInfoRecv(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
base.OnConnectionInfoRecv(sender, e);
|
||||
}
|
||||
|
||||
protected override void OnCommandDisconnectAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
base.OnCommandDisconnectAlarm(sender, e);
|
||||
}
|
||||
protected override void OnStreamDisconnectAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
base.OnStreamDisconnectAlarm(sender, e);
|
||||
}
|
||||
|
||||
protected override void OnLoginAlarm(object sender, EventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
base.OnLoginAlarm(sender, e);
|
||||
}
|
||||
|
||||
protected override void OnQueryCall(object sender, ResultEventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
base.OnQueryCall(sender, e);
|
||||
}
|
||||
protected override void OnBeginQueryCall(object sender, ResultEventArgs e)
|
||||
{
|
||||
// Safely raise the event for all subscribers
|
||||
base.OnBeginQueryCall(sender, e);
|
||||
}
|
||||
|
||||
private void ClientCommandConnectEvent(object sender, ScheduleEvent e)
|
||||
{
|
||||
string strGetMsg = string.Empty;
|
||||
if (e != null)
|
||||
strGetMsg = e.STATE_MSG;
|
||||
|
||||
XAdaptorLogWrite("Command Socket Connect");
|
||||
|
||||
streCommandConnectWatch.Restart();
|
||||
|
||||
thisConnInfo.ConnectCommandState = true;
|
||||
|
||||
//ConnectCommandWaitEvent.Set();
|
||||
bConnectCommandSocketFlag = true;
|
||||
|
||||
thisConnInfo.OnCommandTime();
|
||||
thisConnInfo.OnCommandCheckTime();
|
||||
|
||||
StateClientSocketConnect = true;
|
||||
|
||||
//CommandConnectAlarmEvent?.BeginInvoke(null, null, null, null);
|
||||
//CommandConnectAlarmEvent?.Invoke(null, null);
|
||||
OnCommandConnectAlarm(null, null);
|
||||
}
|
||||
|
||||
private void ClientCommandErrorEvent(object sender, ScheduleEvent e)
|
||||
{
|
||||
string strGetMsg = string.Empty;
|
||||
if (e != null)
|
||||
strGetMsg = e.STATE_MSG;
|
||||
|
||||
XAdaptorLogWrite("Command Socket Disconnect");
|
||||
|
||||
ClearCommandWatchTask();
|
||||
|
||||
streCommandConnectWatch.Restart();
|
||||
|
||||
thisConnInfo.ConnectCommandState = false;
|
||||
|
||||
//ConnectCommandWaitEvent.Reset();
|
||||
bConnectCommandSocketFlag = false;
|
||||
|
||||
StateClientSocketConnect = false;
|
||||
StateClientGetInformation = false;
|
||||
|
||||
//SubscribeConnectInfo.Initialize();
|
||||
|
||||
//CommandDisconnectAlarmEvent?.BeginInvoke(null, null, null, null);
|
||||
//CommandDisconnectAlarmEvent?.Invoke(null, null);
|
||||
OnCommandDisconnectAlarm(null, null);
|
||||
}
|
||||
|
||||
private void ClientStreamConnectEvent(object sender, ScheduleEvent e)
|
||||
{
|
||||
string strGetMsg = string.Empty;
|
||||
|
||||
if (e != null)
|
||||
strGetMsg = e.STATE_MSG;
|
||||
|
||||
XAdaptorLogWrite("Stream Socket Connect");
|
||||
|
||||
stFileSendTime.Restart();
|
||||
stBackupFileSendTime.Restart();
|
||||
|
||||
streStreamConnectWatch.Restart();
|
||||
|
||||
thisConnInfo.ConnectStreamState = true;
|
||||
|
||||
//ConnectStreamWaitEvent.Set();
|
||||
bConnectStreamSocketFlag = true;
|
||||
|
||||
thisConnInfo.OnStreamTime();
|
||||
thisConnInfo.OnStreamCheckTime();
|
||||
|
||||
StateClientStreamSocketConnect = true;
|
||||
|
||||
//StreamConnectAlarmEvent?.BeginInvoke(null, null, null, null);
|
||||
//StreamConnectAlarmEvent?.Invoke(null, null);
|
||||
OnStreamConnectAlarm(null, null);
|
||||
}
|
||||
|
||||
private void ClientStreamErrorEvent(object sender, ScheduleEvent e)
|
||||
{
|
||||
string strGetMsg = string.Empty;
|
||||
if (e != null)
|
||||
strGetMsg = e.STATE_MSG;
|
||||
|
||||
XAdaptorLogWrite("Stream Socket Disconnect");
|
||||
|
||||
ClearStreamWatchTask();
|
||||
|
||||
streStreamConnectWatch.Restart();
|
||||
|
||||
thisConnInfo.ConnectStreamState = false;
|
||||
|
||||
//ConnectStreamWaitEvent.Reset();
|
||||
bConnectStreamSocketFlag = false;
|
||||
|
||||
StateClientStreamSocketConnect = false;
|
||||
|
||||
//SubscribeConnectInfo.Initialize();
|
||||
|
||||
//StreamDisconnectAlarmEvent?.BeginInvoke(null, null, null, null);
|
||||
//StreamDisconnectAlarmEvent?.Invoke(null, null);
|
||||
OnStreamDisconnectAlarm(null, null);
|
||||
}
|
||||
|
||||
private async Task<bool> SendCommandConnectState(bool bWaitRespons = false)
|
||||
{
|
||||
if (thisConnInfo.ConnectCommandState == false)
|
||||
return false;
|
||||
|
||||
if (thisConnInfo.stCommandCheckTime.ElapsedMilliseconds < 60000)
|
||||
return true;
|
||||
|
||||
bool bResult = true;
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo.OnCommandTime();
|
||||
|
||||
try
|
||||
{
|
||||
PING_PACKET MakePingPacket = new PING_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(MakePingPacket);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
MakePingPacket = (PING_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, MakePingPacket.GetType());
|
||||
|
||||
MakePingPacket.objCheckMsg[0].Data = "Who?";
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE), MakePingPacket);
|
||||
|
||||
byte ucGetLabel = FlowCommandControl.InsertSendQueue(DateTime.Now, ucSendByteInfo, null, bWaitRespons);
|
||||
|
||||
thisConnInfo.OnCommandCheckTime();
|
||||
|
||||
if (bWaitRespons)
|
||||
{
|
||||
await WaitTaskJoin(waitCommandParam, FlowCommandControl, ucGetLabel, false).ConfigureAwait(false);
|
||||
|
||||
if (QueryResult.bQueryResult)
|
||||
bResult = true;
|
||||
else
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Command Socket ping check error. [SystemX.Net.XAdaptor.PC : XPCAdaptor.SendCommandConnectState]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
private async Task<bool> SendStreamConnectState(bool bWaitRespons = false)
|
||||
{
|
||||
if (thisConnInfo.ConnectStreamState == false)
|
||||
return false;
|
||||
|
||||
if (thisConnInfo.stStreamCheckTime.ElapsedMilliseconds < 60000)
|
||||
return true;
|
||||
|
||||
bool bResult = true;
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo.OnStreamTime();
|
||||
|
||||
try
|
||||
{
|
||||
PING_PACKET MakePingPacket = new PING_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(MakePingPacket);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
MakePingPacket = (PING_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, MakePingPacket.GetType());
|
||||
|
||||
MakePingPacket.objCheckMsg[0].Data = "Who?";
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE), MakePingPacket);
|
||||
|
||||
byte ucGetLabel = FlowStreamControl.InsertSendQueue(DateTime.Now, ucSendByteInfo, null, bWaitRespons);
|
||||
|
||||
thisConnInfo.OnStreamCheckTime();
|
||||
|
||||
if (bWaitRespons)
|
||||
{
|
||||
await WaitTaskJoin(waitStreamParam, FlowStreamControl, ucGetLabel, false).ConfigureAwait(false);
|
||||
|
||||
if (QueryResult.bQueryResult)
|
||||
bResult = true;
|
||||
else
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Stream Socket ping check error. [SystemX.Net.XAdaptor.PC : XPCAdaptor.SendStreamConnectState]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
// The delegate must have the same signature as the method
|
||||
// it will call asynchronously.
|
||||
public delegate string AsyncMethodCaller(int callDuration, out int threadId);
|
||||
//public delegate void RecvWaitEventHandler(WaitParameter sender, EventArgs e);
|
||||
public delegate void RecvWaitEventHandler(WaitParameter sender, EventArgs e);
|
||||
|
||||
private void RecvWaitEventCall(WaitParameter sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"RecvWaitEventCall failed. [SystemX.Net.XAdaptor.PC.XPCAdaptor : XPCAdaptor.EventCall()]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally
|
||||
{
|
||||
sender.nSignaled = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void RecvWaitEnd(IAsyncResult ar)
|
||||
{
|
||||
// Retrieve the delegate.
|
||||
AsyncResult result = (AsyncResult)ar;
|
||||
}
|
||||
|
||||
/*
|
||||
private void WaitTskJoin(WaitParameter wp, PacketFlowControl getPF, byte ucGetLabel, bool bUseDataSet = true, long lTimeOut = COMMAND_TIME_OUT)
|
||||
{
|
||||
wp.Init(getPF);
|
||||
|
||||
Thread t = new Thread(delegate () {
|
||||
QueryResult.Initialize();
|
||||
QueryResult.xData = wp.TskCheckResult(ucGetLabel, lTimeOut);
|
||||
if (QueryResult.xData != null)
|
||||
{
|
||||
QueryResult.bQueryResult = QueryResult.xData.bReplayResult;
|
||||
|
||||
if (bUseDataSet)
|
||||
QueryResult.QueryDataSet = QueryResult.xData.objData as DataSet;
|
||||
else
|
||||
{
|
||||
QueryResult.QueryDataSet = null;
|
||||
|
||||
if (QueryResult.xData.objData is TRANSFER_PACKET)
|
||||
{
|
||||
TRANSFER_PACKET TransferResult = (TRANSFER_PACKET)QueryResult.xData.objData;
|
||||
|
||||
byte ucCheckLabel = QueryResult.xData.nLabel;
|
||||
|
||||
QueryResult.bFileRecvResult = TransferResult.bRecvResult;
|
||||
QueryResult.bFileProcessResult = TransferResult.bProcessResult;
|
||||
}
|
||||
else if (QueryResult.xData.objData is COMM_INFO_PACKET)
|
||||
{
|
||||
COMM_INFO_PACKET Result = (COMM_INFO_PACKET)QueryResult.xData.objData;
|
||||
|
||||
byte ucCheckLabel = QueryResult.xData.nLabel;
|
||||
}
|
||||
}
|
||||
|
||||
QueryResult.strVarParam1 = QueryResult.xData.HeaderPacket.objVarParam1[0].Data;
|
||||
QueryResult.strVarParam2 = QueryResult.xData.HeaderPacket.objVarParam2[0].Data;
|
||||
QueryResult.strVarParam3 = QueryResult.xData.HeaderPacket.objVarParam3[0].Data;
|
||||
}
|
||||
else
|
||||
getPF.STM.ClearLabel(ucGetLabel);
|
||||
});
|
||||
|
||||
t.Start();
|
||||
t.Join();
|
||||
}
|
||||
*/
|
||||
|
||||
private void WaitThreadJoin(WaitParameter wp, PacketFlowControl getPF, byte ucGetLabel, bool bUseDataSet = true, long lTimeOut = COMMAND_TIME_OUT)
|
||||
{
|
||||
wp.Init(getPF);
|
||||
|
||||
Thread t = new Thread(delegate ()
|
||||
{
|
||||
QueryResult.Initialize();
|
||||
QueryResult.xData = wp.ThreadWaitResult(ucGetLabel, lTimeOut);
|
||||
|
||||
if (QueryResult.xData != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
QueryResult.bQueryResult = QueryResult.xData.bReplayResult;
|
||||
|
||||
if (bUseDataSet)
|
||||
QueryResult.QueryDataSet = QueryResult.xData.objData as DataSet;
|
||||
else
|
||||
{
|
||||
QueryResult.QueryDataSet = null;
|
||||
|
||||
if (QueryResult.xData.objData is TRANSFER_PACKET)
|
||||
{
|
||||
TRANSFER_PACKET TransferResult = (TRANSFER_PACKET)QueryResult.xData.objData;
|
||||
|
||||
byte ucCheckLabel = QueryResult.xData.nLabel;
|
||||
|
||||
QueryResult.bFileRecvResult = TransferResult.bRecvResult;
|
||||
QueryResult.bFileProcessResult = TransferResult.bProcessResult;
|
||||
}
|
||||
else if (QueryResult.xData.objData is COMM_INFO_PACKET)
|
||||
{
|
||||
COMM_INFO_PACKET Result = (COMM_INFO_PACKET)QueryResult.xData.objData;
|
||||
|
||||
byte ucCheckLabel = QueryResult.xData.nLabel;
|
||||
}
|
||||
}
|
||||
|
||||
QueryResult.strVarParam1 = QueryResult.xData.HeaderPacket.objVarParam1[0].Data;
|
||||
QueryResult.strVarParam2 = QueryResult.xData.HeaderPacket.objVarParam2[0].Data;
|
||||
QueryResult.strVarParam3 = QueryResult.xData.HeaderPacket.objVarParam3[0].Data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
QueryResult.bQueryResult = false;
|
||||
QueryResult.QueryDataSet = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
;//
|
||||
}
|
||||
}
|
||||
else
|
||||
getPF.STM.ClearLabel(ucGetLabel);
|
||||
});
|
||||
|
||||
t.Start();
|
||||
t.Join();
|
||||
}
|
||||
|
||||
private async Task<bool> WaitTaskJoin(WaitParameter wp, PacketFlowControl getPF, byte ucGetLabel, bool bUseDataSet = true)
|
||||
{
|
||||
wp.Init(getPF);
|
||||
|
||||
bool bSetResult = true;
|
||||
|
||||
QueryResult.Initialize();
|
||||
QueryResult.xData = await wp.TaskWaitResult(ucGetLabel).ConfigureAwait(false);
|
||||
if (QueryResult.xData != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
QueryResult.bQueryResult = QueryResult.xData.bReplayResult;
|
||||
|
||||
if (bUseDataSet)
|
||||
QueryResult.QueryDataSet = QueryResult.xData.objData as DataSet;
|
||||
else
|
||||
{
|
||||
QueryResult.QueryDataSet = null;
|
||||
|
||||
if (QueryResult.xData.objData is TRANSFER_PACKET)
|
||||
{
|
||||
TRANSFER_PACKET TransferResult = (TRANSFER_PACKET)QueryResult.xData.objData;
|
||||
|
||||
byte ucCheckLabel = QueryResult.xData.nLabel;
|
||||
|
||||
QueryResult.bFileRecvResult = TransferResult.bRecvResult;
|
||||
QueryResult.bFileProcessResult = TransferResult.bProcessResult;
|
||||
}
|
||||
else if (QueryResult.xData.objData is COMM_INFO_PACKET)
|
||||
{
|
||||
COMM_INFO_PACKET Result = (COMM_INFO_PACKET)QueryResult.xData.objData;
|
||||
|
||||
byte ucCheckLabel = QueryResult.xData.nLabel;
|
||||
}
|
||||
}
|
||||
|
||||
QueryResult.strVarParam1 = QueryResult.xData.HeaderPacket.objVarParam1[0].Data;
|
||||
QueryResult.strVarParam2 = QueryResult.xData.HeaderPacket.objVarParam2[0].Data;
|
||||
QueryResult.strVarParam3 = QueryResult.xData.HeaderPacket.objVarParam3[0].Data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
QueryResult.bQueryResult = false;
|
||||
QueryResult.QueryDataSet = null;
|
||||
|
||||
bSetResult = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
;//
|
||||
}
|
||||
|
||||
return bSetResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
getPF.STM.ClearLabel(ucGetLabel);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private XData ComWaitResult(byte nCheckLabel)
|
||||
{
|
||||
XData getXData = null;
|
||||
bool bWaitLabel = false;
|
||||
|
||||
if (nCheckLabel < 0 || nCheckLabel >= FlowCommandControl.STM.GetLabelSize())
|
||||
return getXData;
|
||||
|
||||
Stopwatch stWaitTImeWatch = new Stopwatch();
|
||||
stWaitTImeWatch.Start();
|
||||
|
||||
while (stWaitTImeWatch.ElapsedMilliseconds <= COMMAND_TIME_OUT)
|
||||
{
|
||||
Application.DoEvents();
|
||||
|
||||
getXData = FlowCommandControl.STM.CheckLabel(nCheckLabel, ref bWaitLabel);
|
||||
|
||||
if (bWaitLabel)
|
||||
break;
|
||||
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
return getXData;
|
||||
}
|
||||
|
||||
public class WaitParameter
|
||||
{
|
||||
public int nSignaled;
|
||||
public bool tResult;
|
||||
|
||||
private PacketFlowControl fc;
|
||||
|
||||
public WaitParameter()
|
||||
{
|
||||
nSignaled = 0;
|
||||
tResult = false;
|
||||
}
|
||||
|
||||
public void Init(PacketFlowControl getFc)
|
||||
{
|
||||
nSignaled = 0;
|
||||
tResult = false;
|
||||
|
||||
fc = getFc;
|
||||
}
|
||||
|
||||
/*
|
||||
public XData TskCheckResult(byte nCheckLabel, long lTimeOut = COMMAND_TIME_OUT)
|
||||
{
|
||||
XData getXData = null;
|
||||
bool bWaitLabel = false;
|
||||
|
||||
if (nCheckLabel < 0 || nCheckLabel >= fc.STM.GetLabelSize())
|
||||
return getXData;
|
||||
|
||||
Stopwatch stWaitTImeWatch = new Stopwatch();
|
||||
stWaitTImeWatch.Start();
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (stWaitTImeWatch.ElapsedMilliseconds >= lTimeOut)
|
||||
break;
|
||||
|
||||
if (nSignaled == 1)
|
||||
{
|
||||
getXData = fc.STM.CheckLabel(nCheckLabel, ref bWaitLabel);
|
||||
|
||||
if (bWaitLabel)
|
||||
{
|
||||
tResult = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
return getXData;
|
||||
}
|
||||
*/
|
||||
|
||||
public XData ThreadWaitResult(byte nCheckLabel, long lTimeOut = COMMAND_TIME_OUT)
|
||||
{
|
||||
XData getXData = null;
|
||||
bool bWaitLabel = false;
|
||||
|
||||
if (nCheckLabel < 0 || nCheckLabel >= fc.STM.GetLabelSize())
|
||||
return getXData;
|
||||
|
||||
Stopwatch stWaitTImeWatch = new Stopwatch();
|
||||
stWaitTImeWatch.Start();
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (stWaitTImeWatch.ElapsedMilliseconds > lTimeOut)
|
||||
{
|
||||
fc.SetRefSocketPacketClear();
|
||||
|
||||
break;
|
||||
}
|
||||
if (nSignaled == 1)
|
||||
{
|
||||
getXData = fc.STM.CheckLabel(nCheckLabel, ref bWaitLabel);
|
||||
|
||||
if (bWaitLabel)
|
||||
{
|
||||
tResult = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
return getXData;
|
||||
}
|
||||
|
||||
public async Task<XData> TaskWaitResult(byte nCheckLabel)
|
||||
{
|
||||
XData getXData = null;
|
||||
bool bWaitLabel = false;
|
||||
|
||||
if (nCheckLabel < 0 || nCheckLabel >= fc.STM.GetLabelSize())
|
||||
return getXData;
|
||||
|
||||
Stopwatch stWaitTImeWatch = new Stopwatch();
|
||||
stWaitTImeWatch.Start();
|
||||
|
||||
while (true)
|
||||
{
|
||||
if(stWaitTImeWatch.ElapsedMilliseconds > COMMAND_TIME_OUT)
|
||||
{
|
||||
fc.SetRefSocketPacketClear();
|
||||
|
||||
break;
|
||||
}
|
||||
if (nSignaled == 1)
|
||||
{
|
||||
getXData = fc.STM.CheckLabel(nCheckLabel, ref bWaitLabel);
|
||||
|
||||
if (bWaitLabel)
|
||||
{
|
||||
tResult = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(1).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return getXData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Net.XAdaptor;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public partial class XAdaptorPC
|
||||
{
|
||||
private async Task<bool> CheckFileAccess(string strFilePos)
|
||||
{
|
||||
bool bAccessResult = true;
|
||||
|
||||
//File Access Check
|
||||
FileStream fs = null;
|
||||
|
||||
try
|
||||
{
|
||||
//0.1초 간격으로 3회 체크 후 성공 반환
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
fs = new FileStream(strFilePos, FileMode.Open, FileAccess.Read);
|
||||
|
||||
if (fs != null)
|
||||
{
|
||||
fs.Close();
|
||||
fs = null;
|
||||
}
|
||||
|
||||
await Task.Delay(100).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (fs != null)
|
||||
{
|
||||
fs.Close();
|
||||
fs = null;
|
||||
}
|
||||
|
||||
bAccessResult = false;
|
||||
|
||||
//File Access fail next file
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"Send file access check fail." + strFilePos + " [SystemX.Net.XAdaptor.PC : XPCAdaptor.WatchLogFolderScan]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
return bAccessResult;
|
||||
}
|
||||
private async Task<int> DirFileSearch(string strCreateName, string strSetPath, string fileExtension, bool bCpLogFileSend)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] dirs = Directory.GetDirectories(strSetPath);
|
||||
string[] files = Directory.GetFiles(strSetPath, $"*.{fileExtension}");
|
||||
|
||||
if (files.Length > 0)
|
||||
{
|
||||
foreach (string f in files)
|
||||
{
|
||||
if (await CheckFileAccess(f).ConfigureAwait(false))
|
||||
{
|
||||
if (FlowStreamControl.getRawQueueCnt() > 0)
|
||||
break;
|
||||
|
||||
//FileProcess
|
||||
if (bCpLogFileSend)
|
||||
{
|
||||
if (CPLogFileTransfer(f) == eFileSendRecvResult.FileProcSuccess)
|
||||
{
|
||||
Random randNumber = new Random();
|
||||
|
||||
string getFileName = Path.GetFileName(f);
|
||||
|
||||
if (File.Exists(strCreateName + getFileName))
|
||||
{
|
||||
File.Delete(strCreateName + getFileName);
|
||||
File.Move(f, strCreateName + getFileName);
|
||||
}
|
||||
else
|
||||
File.Move(f, strCreateName + getFileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SendCustomFile(f) == eFileSendRecvResult.FileProcSuccess)
|
||||
{
|
||||
Random randNumber = new Random();
|
||||
|
||||
string getFileName = Path.GetFileName(f);
|
||||
|
||||
if (File.Exists(strCreateName + getFileName))
|
||||
{
|
||||
File.Delete(strCreateName + getFileName);
|
||||
File.Move(f, strCreateName + getFileName);
|
||||
}
|
||||
else
|
||||
File.Move(f, strCreateName + getFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//1 time 1 file slow process per 0.25 second
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (dirs.Length > 0)
|
||||
{
|
||||
foreach (string dir in dirs)
|
||||
{
|
||||
if (dir.IndexOf("Backup Folder") >= 0)
|
||||
continue;
|
||||
|
||||
await DirFileSearch(strCreateName, dir, fileExtension, bCpLogFileSend);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (Exception ex) { }
|
||||
|
||||
await Task.Delay(1).ConfigureAwait(false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,498 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.Schedule;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
[ComVisible(true)]
|
||||
[Guid("837C547C-E1EC-453E-BA98-2F5EEDFD6CF6")]
|
||||
[ClassInterface(ClassInterfaceType.None)]
|
||||
[ProgId("SystemX.Net.XAdaptor.PC.XAdaptorPC")]
|
||||
[ComDefaultInterface(typeof(IComXPCAdaptor))]
|
||||
public partial class XAdaptorPC
|
||||
{
|
||||
private string MakeDataSetToText(DataSet ds)
|
||||
{
|
||||
string strMakeText = string.Empty;
|
||||
string strMakeColInfo = "000@";
|
||||
string[] strRowTextArray = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (ds != null)
|
||||
{
|
||||
foreach (DataTable dt in ds.Tables)
|
||||
{
|
||||
strRowTextArray = new string[dt.Rows.Count];
|
||||
|
||||
foreach (DataColumn dc in dt.Columns)
|
||||
strMakeColInfo += dc.ColumnName + ",";
|
||||
|
||||
strMakeColInfo = strMakeColInfo.Remove(strMakeColInfo.Length - 1, 1);
|
||||
|
||||
strMakeColInfo += ";";
|
||||
|
||||
strMakeText = strMakeColInfo;
|
||||
|
||||
int iPos = 0;
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
string[] strRowTrimArray = new string[dr.ItemArray.Count()];
|
||||
for (int i = 0; i < dr.ItemArray.Count(); i++)
|
||||
strRowTrimArray[i] = dr.ItemArray[i].ToString().Trim();
|
||||
|
||||
strRowTextArray[iPos] = string.Join(",", strRowTrimArray);
|
||||
strRowTextArray[iPos] = strRowTextArray[iPos].Trim();
|
||||
|
||||
strMakeText += (iPos + 1).ToString("D3") + "@" + strRowTextArray[iPos] + ";";
|
||||
|
||||
iPos++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (strRowTextArray == null)
|
||||
strMakeText = "";
|
||||
else if (strRowTextArray.Count() <= 0)
|
||||
strMakeText = "";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
strMakeText = "";
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Dataset to text process fail. [SystemX.Net.XAdaptor.PC : XPCAdaptor.MakeDataSetToText]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
return strMakeText;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool ComGetClientSocketConnect()
|
||||
{
|
||||
return StateClientSocketConnect;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool ComGetClientStreamSocketConnect()
|
||||
{
|
||||
return StateClientStreamSocketConnect;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool ComGetClientInfo()
|
||||
{
|
||||
return StateClientGetInformation;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool ComGetAdaptorConnectState()
|
||||
{
|
||||
return StateAdaptorConnect;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public string ComGetCommandMessage()
|
||||
{
|
||||
return strCheckCommandMsg;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public string ComGetStreamMessage()
|
||||
{
|
||||
return strCheckCommandMsg;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public async Task<bool> ComClientTryConnet(int nCommandPortNum = int.MaxValue, int nStreamPortNum = int.MaxValue)
|
||||
{
|
||||
bool bResult = true;
|
||||
|
||||
StateAdaptorConnect = true;
|
||||
|
||||
try
|
||||
{
|
||||
//ConnectCommandWaitEvent.Reset();
|
||||
//ConnectStreamWaitEvent.Reset();
|
||||
|
||||
bConnectCommandSocketFlag = false;
|
||||
bConnectStreamSocketFlag = false;
|
||||
|
||||
StateAdaptorConnect &= ClientCommandSet(SOCKET_TYPE.TCP, false, nCommandPortNum);
|
||||
StateAdaptorConnect &= ClientStreamSet(SOCKET_TYPE.TCP, false, nStreamPortNum);
|
||||
|
||||
Stopwatch stWaitConnect = new Stopwatch();
|
||||
stWaitConnect.Start();
|
||||
|
||||
while(stWaitConnect.ElapsedMilliseconds < CONNECT_TIME_OUT)
|
||||
{
|
||||
if(bConnectCommandSocketFlag)
|
||||
{
|
||||
await Task.Delay(100).ConfigureAwait(false);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
}
|
||||
if(bConnectCommandSocketFlag)
|
||||
SetCommandWatchTask();
|
||||
else
|
||||
{
|
||||
bResult = false;
|
||||
|
||||
throw new Exception("Can not connect Command Socket.");
|
||||
}
|
||||
//
|
||||
stWaitConnect.Restart();
|
||||
while (stWaitConnect.ElapsedMilliseconds < CONNECT_TIME_OUT)
|
||||
{
|
||||
if (bConnectStreamSocketFlag)
|
||||
{
|
||||
await Task.Delay(100).ConfigureAwait(false);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
}
|
||||
if (bConnectStreamSocketFlag)
|
||||
SetStreamWatchTask();
|
||||
else
|
||||
{
|
||||
bResult = false;
|
||||
|
||||
throw new Exception("Can not connect Stream Socket.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bResult = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Client Connection Attempt Error. [SystemX.Net.XAdaptor.PC - IComXPCAdaptor : XPCAdaptor.ComClientTryConnet]\r\n" +
|
||||
ex.Message, ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally
|
||||
{
|
||||
;//
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public async Task<bool> ComClientTryDistributionConnet(int nCommandPortNum = int.MaxValue)
|
||||
{
|
||||
bool bResult = true;
|
||||
|
||||
StateAdaptorConnect = true;
|
||||
|
||||
thisConnInfo.stLoginTimeOut.Restart();
|
||||
|
||||
try
|
||||
{
|
||||
ClearCommandClientInstance();
|
||||
|
||||
//ConnectCommandWaitEvent.Reset();
|
||||
|
||||
bConnectCommandSocketFlag = false;
|
||||
|
||||
StateAdaptorConnect &= ClientCommandSet(SOCKET_TYPE.TCP, true, nCommandPortNum);
|
||||
|
||||
Stopwatch stWaitConnect = new Stopwatch();
|
||||
stWaitConnect.Start();
|
||||
|
||||
while (stWaitConnect.ElapsedMilliseconds < CONNECT_TIME_OUT)
|
||||
{
|
||||
if (bConnectCommandSocketFlag)
|
||||
{
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
}
|
||||
if (bConnectCommandSocketFlag)
|
||||
SetCommandWatchTask();
|
||||
else
|
||||
{
|
||||
bResult = false;
|
||||
|
||||
throw new Exception("Can not connect Command Socket.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bResult = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Client Connection Attempt Error. [SystemX.Net.XAdaptor.PC - IComXPCAdaptor : XPCAdaptor.ComClientTryConnet]\r\n" +
|
||||
ex.Message, ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (ClientCommandSock.SOCK_TYPE == SOCKET_TYPE.UDP && bResult)
|
||||
{
|
||||
COMM_INFO_PACKET ConnectCommSendInfo = new COMM_INFO_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(ConnectCommSendInfo);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
ConnectCommSendInfo = (COMM_INFO_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, ConnectCommSendInfo.GetType());
|
||||
|
||||
ConnectCommSendInfo.bPortDistribution = true;
|
||||
|
||||
ConnectCommSendInfo.usPortCommandNumber = (ushort)0;
|
||||
ConnectCommSendInfo.usPortStreamNumber = (ushort)0;
|
||||
|
||||
ConnectCommSendInfo.objConnLocalAddress[0].Data = ClientCommandSock.strGetLocalAddress;
|
||||
ConnectCommSendInfo.objConnLocalPort[0].Data = ClientCommandSock.strGetLocalPort;
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.INITILALIZE_INFO), ConnectCommSendInfo);
|
||||
|
||||
FlowCommandControl.InsertSendQueue(DateTime.Now, ucSendByteInfo, null);
|
||||
}
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public async Task<bool> WaitComClientTryDistributionConnet(int nCommandPortNum = int.MaxValue)
|
||||
{
|
||||
bool bResult = true;
|
||||
|
||||
StateAdaptorConnect = true;
|
||||
|
||||
thisConnInfo.stLoginTimeOut.Restart();
|
||||
|
||||
try
|
||||
{
|
||||
ClearCommandClientInstance();
|
||||
|
||||
//ConnectCommandWaitEvent.Reset();
|
||||
|
||||
bConnectCommandSocketFlag = false;
|
||||
|
||||
StateAdaptorConnect &= ClientCommandSet(SOCKET_TYPE.TCP, true, nCommandPortNum);
|
||||
|
||||
Stopwatch stWaitConnect = new Stopwatch();
|
||||
stWaitConnect.Start();
|
||||
|
||||
while (stWaitConnect.ElapsedMilliseconds < CONNECT_TIME_OUT)
|
||||
{
|
||||
if (bConnectCommandSocketFlag)
|
||||
{
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
}
|
||||
if (bConnectCommandSocketFlag)
|
||||
SetCommandWatchTask();
|
||||
else
|
||||
{
|
||||
bResult = false;
|
||||
|
||||
throw new Exception("Can not connect Command Socket.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bResult = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Client Connection Attempt Error. [SystemX.Net.XAdaptor.PC - IComXPCAdaptor : XPCAdaptor.ComClientTryConnet]\r\n" +
|
||||
ex.Message, ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
}
|
||||
//
|
||||
finally
|
||||
{
|
||||
if (bResult)
|
||||
{
|
||||
await Task.Delay(500).ConfigureAwait(false);
|
||||
|
||||
COMM_INFO_PACKET ConnectCommSendInfo = new COMM_INFO_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(ConnectCommSendInfo);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
ConnectCommSendInfo = (COMM_INFO_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, ConnectCommSendInfo.GetType());
|
||||
|
||||
ConnectCommSendInfo.bPortDistribution = true;
|
||||
|
||||
ConnectCommSendInfo.usPortCommandNumber = (ushort)0;
|
||||
ConnectCommSendInfo.usPortStreamNumber = (ushort)0;
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.INITILALIZE_INFO), ConnectCommSendInfo);
|
||||
|
||||
FlowCommandControl.InsertSendQueue(DateTime.Now, ucSendByteInfo, null, PacketFlowControl.CommInfoManualToken, false);
|
||||
|
||||
await WaitTaskJoin(waitCommandParam, FlowCommandControl, PacketFlowControl.CommInfoManualToken, false);
|
||||
|
||||
if (QueryResult.bQueryResult)
|
||||
bResult = true;
|
||||
else
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
if (await ComClientTryConnet(SubscribeConnectInfo.nChangeCommandPort, SubscribeConnectInfo.nChangeStreamPort) == false)
|
||||
{
|
||||
AdaptorAbort();
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool ComClientTryDisconnect()
|
||||
{
|
||||
bool bResult = true;
|
||||
|
||||
try
|
||||
{
|
||||
ClearCommonVar();
|
||||
|
||||
ClearCommandWatchTask();
|
||||
ClearStreamWatchTask();
|
||||
|
||||
ClearCommandClientInstance();
|
||||
ClearStreamClientInstance();
|
||||
|
||||
this.ClientCommandErrorEvent(null, null);
|
||||
this.ClientStreamErrorEvent(null, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bResult = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Client Disconnect Attempt Error. [SystemX.Net.XAdaptor.PC - IComXPCAdaptor : XPCAdaptor.ComClientTryDisconnect]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool ComCheckConnectState()
|
||||
{
|
||||
bool bStatus = false;
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo.OnCommandTime();
|
||||
|
||||
try
|
||||
{
|
||||
PING_PACKET MakePingPacket = new PING_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(MakePingPacket);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
MakePingPacket = (PING_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, MakePingPacket.GetType());
|
||||
|
||||
MakePingPacket.objCheckMsg[0].Data = "Who?";
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE), MakePingPacket);
|
||||
|
||||
byte ucGetLabel = FlowCommandControl.InsertSendQueue(DateTime.Now, ucSendByteInfo, null, true);
|
||||
|
||||
if (ComWaitResult(ucGetLabel) == null)
|
||||
{
|
||||
FlowCommandControl.STM.ClearLabel(ucGetLabel);
|
||||
}
|
||||
else
|
||||
bStatus = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Command Socket ping check error. [SystemX.Net.XAdaptor.PC - IComXPCAdaptor : XPCAdaptor.ComCheckConnectState]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return bStatus;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public bool ComCheckConnectStreamState()
|
||||
{
|
||||
try
|
||||
{
|
||||
thisConnInfo.OnStreamTime();
|
||||
|
||||
try
|
||||
{
|
||||
PING_PACKET MakePingPacket = new PING_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(MakePingPacket);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
MakePingPacket = (PING_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, MakePingPacket.GetType());
|
||||
|
||||
MakePingPacket.objCheckMsg[0].Data = "Who?";
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE), MakePingPacket);
|
||||
|
||||
FlowStreamControl.InsertSendQueue(DateTime.Now, ucSendByteInfo, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Stream Socket ping check error. [SystemX.Net.XAdaptor.PC - IComXPCAdaptor: XPCAdaptor.ComCheckConnectStreamState]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[ComVisible(true)]
|
||||
public string ComSetConfigureFile(string strFilePos)
|
||||
{
|
||||
if (File.Exists(strFilePos))
|
||||
{
|
||||
strSetAdaptorConfigFilePos = strFilePos;
|
||||
|
||||
if (CheckConfigFileBuildEndPoint())
|
||||
{
|
||||
return strFilePos;
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,222 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.XAdaptor;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public partial class XAdaptorPC
|
||||
{
|
||||
private byte SendCallQuery(string strQueryCallID, params string[] strParameterValues)
|
||||
{
|
||||
QUERY_PACKET QueryPacket = new QUERY_PACKET();
|
||||
int iSizeQueryPacket = Marshal.SizeOf(QueryPacket);
|
||||
byte[] ucQueryPacketArray = new byte[iSizeQueryPacket];
|
||||
|
||||
QueryPacket = (QUERY_PACKET)SystemXNetSerialization.RawDeSerialize(ucQueryPacketArray, QueryPacket.GetType());
|
||||
|
||||
string strSendText = string.Empty;
|
||||
strSendText = "UserQueryCall;";
|
||||
|
||||
if (strParameterValues.Length > 0)
|
||||
{
|
||||
strSendText += (strQueryCallID + ";");
|
||||
|
||||
foreach (string strParam in strParameterValues)
|
||||
{
|
||||
strSendText += (strParam + ";");
|
||||
}
|
||||
|
||||
strSendText = strSendText.Remove(strSendText.Length - 1, 1);
|
||||
}
|
||||
else
|
||||
strSendText += strQueryCallID;
|
||||
|
||||
QueryPacket.objQueryText[0].Data = strSendText;
|
||||
|
||||
ucQueryPacketArray = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.USER_QUERY), QueryPacket);
|
||||
|
||||
return FlowCommandControl.InsertSendQueue(DateTime.Now, ucQueryPacketArray, null, true);
|
||||
}
|
||||
|
||||
private DataSet WaitCallQueryLookUp(string strQueryCallID, params string[] strParameterValues)
|
||||
{
|
||||
if (thisConnInfo.ConnectCommandState == false)
|
||||
return null;
|
||||
if (thisConnInfo.InitialInfoState == false)
|
||||
return null;
|
||||
|
||||
DataSet dsReturnSet = null;
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo.OnCommandTime();
|
||||
|
||||
try
|
||||
{
|
||||
byte ucGetLabel = SendCallQuery(strQueryCallID, strParameterValues);
|
||||
|
||||
WaitThreadJoin(waitCommandParam, FlowCommandControl, ucGetLabel);
|
||||
|
||||
if (QueryResult.QueryDataSet != null)
|
||||
{
|
||||
if (QueryResult.bQueryResult) //Query 문 실행 성공
|
||||
dsReturnSet = QueryResult.QueryDataSet;
|
||||
else //Query 문 실행 실패(구문 오류 또는 연결 오류)
|
||||
dsReturnSet = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Registered query call error. [" + strQueryCallID + "][SystemX.Net.XAdaptor.PC - IXPCAdaptor : XPCAdaptor.WaitCallQuery]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally
|
||||
{
|
||||
;//
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return dsReturnSet;
|
||||
}
|
||||
|
||||
private DataSet WaitCallQuery(string strQueryCallID, params string[] strParameterValues)
|
||||
{
|
||||
if (thisConnInfo.ConnectCommandState == false)
|
||||
return null;
|
||||
if (thisConnInfo.InitialInfoState == false)
|
||||
return null;
|
||||
if (LoadInfo.SIMPLE_LOOKUP_OPTION == true)
|
||||
return null;
|
||||
|
||||
DataSet dsReturnSet = null;
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo.OnCommandTime();
|
||||
|
||||
try
|
||||
{
|
||||
byte ucGetLabel = SendCallQuery(strQueryCallID, strParameterValues);
|
||||
|
||||
WaitThreadJoin(waitCommandParam, FlowCommandControl, ucGetLabel);
|
||||
|
||||
if (QueryResult.QueryDataSet != null)
|
||||
{
|
||||
if (QueryResult.bQueryResult) //Query 문 실행 성공
|
||||
dsReturnSet = QueryResult.QueryDataSet;
|
||||
else //Query 문 실행 실패(구문 오류 또는 연결 오류)
|
||||
dsReturnSet = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"Registered query call error. [" + strQueryCallID + "][SystemX.Net.XAdaptor.PC - IXPCAdaptor : XPCAdaptor.WaitCallQuery]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally
|
||||
{
|
||||
;//
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return dsReturnSet;
|
||||
}
|
||||
|
||||
public DataSet WaitUserQuery(string strQuery)
|
||||
{
|
||||
if (thisConnInfo.ConnectCommandState == false)
|
||||
return null;
|
||||
if (thisConnInfo.InitialInfoState == false)
|
||||
return null;
|
||||
if (LoadInfo.SIMPLE_LOOKUP_OPTION == true)
|
||||
return null;
|
||||
|
||||
string[] strCheck = strQuery.Split(' ');
|
||||
string strUpperText = string.Empty;
|
||||
|
||||
foreach (string strItem in strCheck)
|
||||
{
|
||||
strUpperText = strItem.ToUpper();
|
||||
|
||||
if (strUpperText.CompareTo("INSERT") == 0 ||
|
||||
strUpperText.CompareTo("UPDATE") == 0 ||
|
||||
strUpperText.CompareTo("DELETE") == 0)
|
||||
{
|
||||
MessageBox.Show("SQL control syntax other than SELECT syntax is not supported.", "XAdaptor", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
string strQueryText = strQuery.ToUpper();
|
||||
|
||||
DataSet dsReturnSet = null;
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo.OnCommandTime();
|
||||
|
||||
try
|
||||
{
|
||||
QUERY_PACKET QueryPacket = new QUERY_PACKET();
|
||||
int iSizeQueryPacket = Marshal.SizeOf(QueryPacket);
|
||||
byte[] ucQueryPacketArray = new byte[iSizeQueryPacket];
|
||||
QueryPacket = (QUERY_PACKET)SystemXNetSerialization.RawDeSerialize(ucQueryPacketArray, QueryPacket.GetType());
|
||||
QueryPacket.objQueryText[0].Data = strQuery;
|
||||
ucQueryPacketArray = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.SYSTEM_QUERY), QueryPacket);
|
||||
|
||||
byte ucGetLabel = FlowCommandControl.InsertSendQueue(DateTime.Now, ucQueryPacketArray, null, true);
|
||||
|
||||
WaitThreadJoin(waitCommandParam, FlowCommandControl, ucGetLabel);
|
||||
|
||||
if (QueryResult.QueryDataSet != null)
|
||||
{
|
||||
if (QueryResult.bQueryResult) //Query 문 실행 성공
|
||||
dsReturnSet = QueryResult.QueryDataSet;
|
||||
else //Query 문 실행 실패(구문 오류 또는 연결 오류)
|
||||
dsReturnSet = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"User program query call error. [" + strQuery + "][SystemX.Net.XAdaptor.PC - IXPCAdaptor : XPCAdaptor.WaitUserQuery]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return dsReturnSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,432 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.XAdaptor;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public partial class XAdaptorPC
|
||||
{
|
||||
public eResultCheck CheckIssuedID(string strProductID)
|
||||
{
|
||||
if(strProductID.Length <= 0)
|
||||
return eResultCheck.InvalidFormat;
|
||||
|
||||
DataSet dsResult = WaitCallQuery("ID_IsIssued", strProductID);
|
||||
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
return eResultCheck.AlreadyIssued;
|
||||
else
|
||||
return eResultCheck.NotIssued;
|
||||
}
|
||||
|
||||
//맥 어드레스 무결성 체크
|
||||
public eMacAddressType IsMacAddressForm(string strMacAddress)
|
||||
{
|
||||
// IP4 ADDRESS (25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}
|
||||
/* IP6 ADDRESS
|
||||
(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:)
|
||||
{1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:)
|
||||
{1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4})
|
||||
{1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:)
|
||||
{1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})
|
||||
|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]
|
||||
{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}
|
||||
[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]
|
||||
{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]
|
||||
|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))
|
||||
*/
|
||||
// MAC ADDRESS
|
||||
// ([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}
|
||||
//^([[:xdigit:]]{2}[:.-]?){5}[[:xdigit:]]{2}$
|
||||
//^([0-9a-fA-F]{2}[:.-]?){5}[0-9a-fA-F]{2}$/g
|
||||
Regex r1 = new Regex("^([0-9a-fA-F]{2}){5}[0-9a-fA-F]{2}$");
|
||||
Regex r2 = new Regex("^([0-9a-fA-F]{2}[:]+){5}[0-9a-fA-F]{2}$");
|
||||
Regex r3 = new Regex("^([0-9a-fA-F]{2}[-]+){5}[0-9a-fA-F]{2}$");
|
||||
Regex r4 = new Regex("^([0-9a-fA-F]{2}[.]+){5}[0-9a-fA-F]{2}$");
|
||||
Regex r5 = new Regex("^([0-9a-fA-F]{2}[:.-]?){5}[0-9a-fA-F]{2}$");
|
||||
|
||||
bool b1 = r1.Match(strMacAddress).Success;
|
||||
bool b2 = r2.Match(strMacAddress).Success;
|
||||
bool b3 = r3.Match(strMacAddress).Success;
|
||||
bool b4 = r4.Match(strMacAddress).Success;
|
||||
bool b5 = r5.Match(strMacAddress).Success;
|
||||
|
||||
eMacAddressType type = eMacAddressType.Normal;
|
||||
|
||||
if (b5 == false)
|
||||
return eMacAddressType.InvalidMacAddressFormat;
|
||||
|
||||
if (b2)
|
||||
type = eMacAddressType.Colon;
|
||||
else if (b3)
|
||||
type = eMacAddressType.Hyphen;
|
||||
else if (b4)
|
||||
type = eMacAddressType.Dot;
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
private string MacAddressFormatRecalculation(string strMacAddress)
|
||||
{
|
||||
string strFindMacAddress = string.Empty;
|
||||
|
||||
foreach (char c in strMacAddress)
|
||||
{
|
||||
if (char.IsLetterOrDigit(c))
|
||||
strFindMacAddress += c;
|
||||
}
|
||||
|
||||
return strFindMacAddress;
|
||||
}
|
||||
|
||||
private string MacAddressFormatChange(string strText, eMacAddressType type)
|
||||
{
|
||||
string strChangeMacAddress = string.Empty;
|
||||
|
||||
int nPos = 0;
|
||||
foreach (char c in strText)
|
||||
{
|
||||
if(nPos / 2 == 1)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case eMacAddressType.Colon:
|
||||
strChangeMacAddress += ":";
|
||||
break;
|
||||
case eMacAddressType.Hyphen:
|
||||
strChangeMacAddress += "-";
|
||||
break;
|
||||
case eMacAddressType.Dot:
|
||||
strChangeMacAddress += ".";
|
||||
break;
|
||||
}
|
||||
|
||||
nPos = 0;
|
||||
}
|
||||
|
||||
if (char.IsLetterOrDigit(c))
|
||||
strChangeMacAddress += c;
|
||||
|
||||
nPos++;
|
||||
}
|
||||
|
||||
return strChangeMacAddress;
|
||||
}
|
||||
|
||||
|
||||
//목록에 존재하는 맥어드레스 인지
|
||||
public bool CheckListMacAddress(string strMacAddress)
|
||||
{
|
||||
if (IsMacAddressForm(strMacAddress) == eMacAddressType.InvalidMacAddressFormat)
|
||||
return false;
|
||||
|
||||
string strFindMacAddress = MacAddressFormatRecalculation(strMacAddress);
|
||||
|
||||
DataSet dsResult = WaitCallQuery("MacAddress_Check", strFindMacAddress);
|
||||
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public eResultCheck CheckIssuedMacAddress(string strMacAddress)
|
||||
{
|
||||
if (IsMacAddressForm(strMacAddress) == eMacAddressType.InvalidMacAddressFormat)
|
||||
return eResultCheck.InvalidMacAddressFormat;
|
||||
|
||||
string strFindMacAddress = MacAddressFormatRecalculation(strMacAddress);
|
||||
|
||||
DataSet dsResult = WaitCallQuery("MacAddress_IsIssued", strFindMacAddress);
|
||||
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
return eResultCheck.AlreadyIssued;
|
||||
else
|
||||
return eResultCheck.NotIssued;
|
||||
}
|
||||
private int GetCurrentQuantity()
|
||||
{
|
||||
int nCurCnt = int.MaxValue;
|
||||
|
||||
DataSet dsResult = WaitCallQuery("Check_Mac_Quantity");
|
||||
|
||||
try
|
||||
{
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
{
|
||||
if (int.TryParse(dsResult.Tables[0].Rows[0][0].ToString(), out nCurCnt) == false)
|
||||
throw new Exception();
|
||||
}
|
||||
else
|
||||
nCurCnt = int.MinValue;
|
||||
}
|
||||
catch
|
||||
{
|
||||
nCurCnt = int.MinValue;
|
||||
}
|
||||
|
||||
return nCurCnt;
|
||||
}
|
||||
|
||||
//현재 발행 예정 대상 주소
|
||||
public string GetToBeIssuedMacAddress(eMacAddressType type = eMacAddressType.Normal)
|
||||
{
|
||||
int nGetCurrent = GetCurrentQuantity();
|
||||
|
||||
if (nGetCurrent == int.MaxValue || nGetCurrent == int.MinValue)
|
||||
return "";
|
||||
|
||||
DataSet dsResult = WaitCallQuery("MacAddress_ToBeIssuedCheck", nGetCurrent.ToString());
|
||||
|
||||
string strGetMacAddress = string.Empty;
|
||||
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
{
|
||||
strGetMacAddress = dsResult.Tables[0].Rows[0][1].ToString();
|
||||
|
||||
strGetMacAddress = MacAddressFormatChange(strGetMacAddress, type);
|
||||
}
|
||||
|
||||
return strGetMacAddress;
|
||||
}
|
||||
|
||||
//총개수
|
||||
public int GetTotalAddressNumber()
|
||||
{
|
||||
DataSet dsResult = WaitCallQuery("Check_Mac_Quantity");
|
||||
|
||||
int nValue = 0;
|
||||
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
{
|
||||
if (int.TryParse(dsResult.Tables[0].Rows[0][1].ToString(), out nValue) == false)
|
||||
nValue = -1;
|
||||
}
|
||||
|
||||
return nValue;
|
||||
}
|
||||
|
||||
//발행 개수 확인
|
||||
public int GetCurrentIssuedAddressNumber()
|
||||
{
|
||||
DataSet dsResult = WaitCallQuery("Check_Mac_Quantity");
|
||||
|
||||
int nValue = 0;
|
||||
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
{
|
||||
if (int.TryParse(dsResult.Tables[0].Rows[0][0].ToString(), out nValue) == false)
|
||||
nValue = -1;
|
||||
}
|
||||
|
||||
return nValue;
|
||||
}
|
||||
|
||||
//남은 개수 확인
|
||||
public int GetRemainAddressNumber()
|
||||
{
|
||||
DataSet dsResult = WaitCallQuery("Check_Mac_Quantity");
|
||||
|
||||
int nValue1 = 0;
|
||||
int nValue2 = 0;
|
||||
|
||||
int nResult = 0;
|
||||
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
{
|
||||
if (int.TryParse(dsResult.Tables[0].Rows[0][0].ToString(), out nValue1) == false)
|
||||
nValue1 = -1;
|
||||
if (int.TryParse(dsResult.Tables[0].Rows[0][1].ToString(), out nValue2) == false)
|
||||
nValue2 = -1;
|
||||
|
||||
if (nValue1 == -1 || nValue2 == -1)
|
||||
nResult = -1;
|
||||
else
|
||||
nResult = nValue2 - nValue1;
|
||||
}
|
||||
|
||||
return nResult;
|
||||
}
|
||||
|
||||
protected string GetTableValue(DataSet ds, string strParam1)
|
||||
{
|
||||
string strValue = string.Empty;
|
||||
|
||||
if (strParam1.Length > 0)
|
||||
{
|
||||
int nIndex = int.MaxValue;
|
||||
|
||||
if (int.TryParse(strParam1, out nIndex))
|
||||
strValue = ds.Tables[0].Rows[0][nIndex].ToString();
|
||||
else
|
||||
strValue = ds.Tables[0].Rows[0][strParam1].ToString();
|
||||
}
|
||||
else
|
||||
strValue = ds.Tables[0].Rows[0][0].ToString();
|
||||
|
||||
return strValue;
|
||||
}
|
||||
|
||||
public string LookUpIDbyMacAddress(string strMacAddress)
|
||||
{
|
||||
if (IsMacAddressForm(strMacAddress) == eMacAddressType.InvalidMacAddressFormat)
|
||||
return "InvalidMacAddressFormat";
|
||||
|
||||
string strFindMacAddress = MacAddressFormatRecalculation(strMacAddress);
|
||||
|
||||
DataSet dsResult = WaitCallQueryLookUp("LookUpID_ByMacAddress", strFindMacAddress);
|
||||
|
||||
string strValue = string.Empty;
|
||||
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
strValue = GetTableValue(dsResult, QueryResult.strVarParam1);
|
||||
|
||||
return strValue;
|
||||
}
|
||||
|
||||
|
||||
public string LookUpMacAddressbyID(ref string strProductID, eLookUpOption SetLookUpOption = eLookUpOption.CompareToSame, eMacAddressType type = eMacAddressType.Normal)
|
||||
{
|
||||
DataSet dsResult = null;
|
||||
|
||||
if(SetLookUpOption == eLookUpOption.StartWith)
|
||||
dsResult = WaitCallQueryLookUp("LookUpMacAddress_ByLikeID", strProductID + "%");
|
||||
else if (SetLookUpOption == eLookUpOption.EndWith)
|
||||
dsResult = WaitCallQueryLookUp("LookUpMacAddress_ByLikeID", "%" + strProductID);
|
||||
else if(SetLookUpOption == eLookUpOption.ContainWith)
|
||||
dsResult = WaitCallQueryLookUp("LookUpMacAddress_ByLikeID", "%" + strProductID + "%");
|
||||
else
|
||||
dsResult = WaitCallQueryLookUp("LookUpMacAddress_ByID", strProductID);
|
||||
|
||||
string strGetMacAddress = string.Empty;
|
||||
|
||||
string strValue = string.Empty;
|
||||
|
||||
if (XCommons.isHasRow(dsResult))
|
||||
{
|
||||
strValue = GetTableValue(dsResult, QueryResult.strVarParam1);
|
||||
|
||||
strValue = MacAddressFormatChange(strValue, type);
|
||||
|
||||
strProductID = dsResult.Tables[0].Rows[0][4].ToString();
|
||||
}
|
||||
|
||||
return strValue;
|
||||
}
|
||||
|
||||
private string RequestMacAddressIssuance(string strProductID, ref string strRetrunMessage, out int nErrCode, bool bReissuance = false)
|
||||
{
|
||||
nErrCode = int.MinValue;
|
||||
|
||||
strRetrunMessage = string.Empty;
|
||||
|
||||
string strGetUniqueInfo = string.Empty;
|
||||
|
||||
if (thisConnInfo.ConnectCommandState == false)
|
||||
return "[Error] Need connect command socket.";
|
||||
if (thisConnInfo.InitialInfoState == false)
|
||||
return "[Error] Need InitialInfoState information.";
|
||||
if (LoadInfo.SIMPLE_LOOKUP_OPTION == true)
|
||||
return "[Error] Cannot do this in simple lookup mode.";
|
||||
|
||||
try
|
||||
{
|
||||
thisConnInfo.OnCommandTime();
|
||||
|
||||
try
|
||||
{
|
||||
PROCESS_PACKET MakeProcessPacket = new PROCESS_PACKET();
|
||||
int iSendSize = Marshal.SizeOf(MakeProcessPacket);
|
||||
byte[] ucSendArray = new byte[iSendSize];
|
||||
MakeProcessPacket = (PROCESS_PACKET)SystemXNetSerialization.RawDeSerialize(ucSendArray, MakeProcessPacket.GetType());
|
||||
|
||||
MakeProcessPacket.nStationID = 0;
|
||||
MakeProcessPacket.objProdNo_C[0].Data = "";
|
||||
MakeProcessPacket.objTestType[0].Data = "";
|
||||
MakeProcessPacket.objTestCode[0].Data = ((bReissuance == false) ? "ISSUANCE" : "REISSUANCE");
|
||||
MakeProcessPacket.objTestListFileVersion[0].Data = "";
|
||||
MakeProcessPacket.objProductionCode[0].Data = "";
|
||||
MakeProcessPacket.objProductID[0].Data = strProductID;
|
||||
|
||||
byte[] ucSendByteInfo = XCommons.SpecialObjectToByteStream(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.PROCESS_QUERY, BASE_PROTOCOL.OPTION_CODE.GET_ISSUANCE_MACADDRESS), MakeProcessPacket);
|
||||
|
||||
byte ucGetLabel = FlowCommandControl.InsertSendQueue(DateTime.Now, ucSendByteInfo, null, true);
|
||||
|
||||
WaitThreadJoin(waitCommandParam, FlowCommandControl, ucGetLabel);
|
||||
|
||||
if (XCommons.isHasRow(QueryResult.QueryDataSet))
|
||||
strGetUniqueInfo = GetTableValue(QueryResult.QueryDataSet, QueryResult.strVarParam1);
|
||||
|
||||
int.TryParse(QueryResult.strVarParam3, out nErrCode);
|
||||
|
||||
strRetrunMessage = QueryResult.strVarParam2;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"MacAddress issuance request error. [SystemX.Net.XAdaptor.PC - IXPCAdaptor : RequestMacAddressIssuance]\r\n" +
|
||||
ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
finally { }
|
||||
}
|
||||
finally
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return strGetUniqueInfo;
|
||||
}
|
||||
|
||||
public ResultIssued IssuanceRequest(string strProductID, bool bReissuance = false, eMacAddressType type = eMacAddressType.Normal)
|
||||
{
|
||||
int nGetErrCode = 0;
|
||||
|
||||
string strGetErrMsg = string.Empty;
|
||||
|
||||
string strGetUniqueInfo = string.Empty;
|
||||
|
||||
if (strProductID.Length <= 0)
|
||||
return new ResultIssued(eResultIssued.InvalidFormat);
|
||||
|
||||
strGetUniqueInfo = RequestMacAddressIssuance(strProductID, ref strGetErrMsg, out nGetErrCode, bReissuance);
|
||||
|
||||
if(IsMacAddressForm(strGetUniqueInfo) != eMacAddressType.InvalidMacAddressFormat)
|
||||
strGetUniqueInfo = MacAddressFormatChange(strGetUniqueInfo, type);
|
||||
|
||||
eResultIssued riReturn = eResultIssued.None;
|
||||
|
||||
switch(nGetErrCode)
|
||||
{
|
||||
case 0:
|
||||
riReturn = eResultIssued.Success;
|
||||
break;
|
||||
case -2:
|
||||
riReturn = eResultIssued.AlreadyIssued;
|
||||
break;
|
||||
case -3:
|
||||
riReturn = eResultIssued.InformationWithoutIssuanceHistory;
|
||||
break;
|
||||
default:
|
||||
riReturn = eResultIssued.Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
return new ResultIssued(riReturn, strGetUniqueInfo, strGetErrMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,412 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using SystemX.Common;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.XAdaptor.PC.O2Sensor.NgCode;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.XAdaptor;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public partial class XAdaptorPC
|
||||
{
|
||||
//private async void SendCommandEvent(byte[] senderData, ScheduleEvent e)
|
||||
private void SendCommandEvent(byte[] senderData, ScheduleEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
thisConnInfo.m_iSendCommandCnt++;
|
||||
|
||||
if (thisConnInfo.m_iSendCommandCnt + 1 == int.MaxValue)
|
||||
thisConnInfo.m_iSendCommandCnt = 0;
|
||||
|
||||
if (FlowCommandControl == null)
|
||||
return;
|
||||
|
||||
//소켓 샌드 행위 내부 결과
|
||||
if (e.PROCESS_RESULT == false)
|
||||
{
|
||||
//해당 패킷 횟수 상승 일단 회 차시 기록남기고 드랍
|
||||
FlowCommandControl.SendPacketCycle();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"General <SendCommandEvent> failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : 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
|
||||
{
|
||||
thisConnInfo.m_iRecvCommandCnt++;
|
||||
|
||||
if (thisConnInfo.m_iRecvCommandCnt + 1 == int.MaxValue)
|
||||
thisConnInfo.m_iRecvCommandCnt = 0;
|
||||
|
||||
if (FlowCommandControl == null)
|
||||
return;
|
||||
|
||||
int iStoreCnt = senderData.Count();
|
||||
byte[] recvStoreBuffer = senderData;
|
||||
|
||||
//소켓 리시브 행위 결과 전송
|
||||
if (e.PROCESS_RESULT == false)
|
||||
{
|
||||
//받기 실패 단순 실패 응답
|
||||
FlowCommandControl.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.SetSendPacketDrop();
|
||||
else
|
||||
FlowCommandControl.SendPacketCycle();
|
||||
}
|
||||
//파일 끝 응답
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.RAW_END)
|
||||
{
|
||||
if (XCommons.GetSimpleResponsResult(iStoreCnt, recvStoreBuffer))
|
||||
FlowCommandControl.RawStoreQueuePOP();
|
||||
else
|
||||
FlowStreamControl.RawStoreQueuePOP();
|
||||
}
|
||||
//일반 응답
|
||||
else
|
||||
{
|
||||
//성공 응답
|
||||
FlowCommandControl.InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.SIMPLE_RESPONSE), true), null, false, false);
|
||||
|
||||
//받은 큐에 넣어놓기
|
||||
FlowCommandControl.InsertRecvQueue(senderData, null, e.nLABEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"General <RecvCommandEvent> failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : RecvCommandEvent]\r\n" + ex.Message,
|
||||
ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
private async void WatchRecvCommandQueue()
|
||||
{
|
||||
await Task.Delay(250).ConfigureAwait(false);
|
||||
|
||||
thisConnInfo.OnCommandTime();
|
||||
thisConnInfo.OnCommandCheckTime();
|
||||
|
||||
while (!m_bTaskCommandBlock)
|
||||
{
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
CommandCT.ThrowIfCancellationRequested();
|
||||
}
|
||||
catch (OperationCanceledException CancelEx)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@" Work Canceled. [SystemX.Net.XAdaptor.PC.XPCAdaptor : RecvProcessTask.WatchRecvCommandQueue]\r\n" + CancelEx.Message,
|
||||
ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
try
|
||||
{
|
||||
if (StateClientSocketConnect == false)
|
||||
continue;
|
||||
|
||||
if (thisConnInfo.stCommandCheckTime.ElapsedMilliseconds >= 60000)
|
||||
{
|
||||
await SendCommandConnectState().ConfigureAwait(false);
|
||||
|
||||
thisConnInfo.OnCommandCheckTime();
|
||||
}
|
||||
|
||||
if (bTaskCommandWaitLock == false)
|
||||
{
|
||||
bool bResult = QueryRecvCommandQueue();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//throw new CommonScheduleException("General Queue Process failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : RecvProcessTask.WatchRecvQueue]");
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"General Queue Process failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : RecvProcessTask.WatchRecvCommandQueue]\r\n" + ex.Message,
|
||||
ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool CommandQueueCheck()
|
||||
{
|
||||
if (ClientCommandSock == null)
|
||||
return false;
|
||||
|
||||
if (ClientCommandSock != null)
|
||||
{
|
||||
if (ClientCommandSock.CONNECT == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FlowCommandControl == null)
|
||||
return false;
|
||||
|
||||
//Login 타임아웃
|
||||
if (thisConnInfo.bHostLoginState == false)
|
||||
{
|
||||
if (thisConnInfo.stLoginTimeOut.ElapsedMilliseconds >= LOGIN_TIMEOUT)
|
||||
{
|
||||
AdaptorAbort(true);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool QueryRecvCommandQueue()
|
||||
{
|
||||
bool bState = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (CommandQueueCheck() == false)
|
||||
return false;
|
||||
|
||||
bTaskCommandWaitLock = true;
|
||||
|
||||
if (FlowCommandControl.GetCurrentRecvProcessData() != null)
|
||||
return false;
|
||||
|
||||
thisConnInfo.m_iSendCommandQueueSize = FlowCommandControl.GetSendQueueSize();
|
||||
thisConnInfo.m_iRecvCommandQueueSize = FlowCommandControl.GetRecvQueueSize();
|
||||
|
||||
if ((thisConnInfo.m_iSendCommandQueueSize + 1) == int.MaxValue)
|
||||
thisConnInfo.m_iSendCommandQueueSize = 0;
|
||||
if ((thisConnInfo.m_iRecvCommandQueueSize + 1) == int.MaxValue)
|
||||
thisConnInfo.m_iRecvCommandQueueSize = 0;
|
||||
|
||||
XData getXData = FlowCommandControl.GetResultPacketData();
|
||||
|
||||
if (getXData == null)
|
||||
return false;
|
||||
|
||||
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;
|
||||
|
||||
thisConnInfo.OnCommandCheckTime();
|
||||
|
||||
switch (CODE)
|
||||
{
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE:
|
||||
{
|
||||
PING_PACKET GetPingPacket = (PING_PACKET)objData;
|
||||
|
||||
string strGetMsg = GetPingPacket.objCheckMsg[0].Data;
|
||||
|
||||
strCheckCommandMsg = strGetMsg;
|
||||
|
||||
if (strCheckCommandMsg.IndexOf("TLRL") >= 0)
|
||||
{
|
||||
string[] getStationCheck = strCheckCommandMsg.Split(';');
|
||||
|
||||
if (getStationCheck.Length >= 2)
|
||||
{
|
||||
int nGetStaionID = Convert.ToInt32(getStationCheck[1]);
|
||||
|
||||
if (dicTestListNeedReload.ContainsKey(nGetStaionID))
|
||||
{
|
||||
if (dicTestListNeedReload[nGetStaionID] == false)
|
||||
dicTestListNeedReload[nGetStaionID] = true;
|
||||
}
|
||||
else
|
||||
dicTestListNeedReload.Add(nGetStaionID, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.DATASET_TRANSEFER:
|
||||
{
|
||||
/*bQueryResult = getXData.bReplayResult;
|
||||
|
||||
if (bQueryResult)
|
||||
{
|
||||
//Query 문 실행 성공
|
||||
QueryDataSet = objData as DataSet;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Query 문 실행 실패(구문 오류 또는 연결 오류)
|
||||
QueryDataSet = null;
|
||||
}*/
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.HOST_INFO_CHECK:
|
||||
{
|
||||
thisConnInfo.stLoginTimeOut.Restart();
|
||||
thisConnInfo.bHostLoginState = false;
|
||||
|
||||
SYSTEM_HOST_PACKET usPacket = (SYSTEM_HOST_PACKET)objData;
|
||||
|
||||
string strGetHostID = usPacket.objHostID[0].Data;
|
||||
string strGetSection = usPacket.objSection[0].Data;
|
||||
string strGetTestCode = usPacket.objTestCode[0].Data;
|
||||
string strGetMessage = usPacket.objMessage[0].Data;
|
||||
|
||||
if (strGetMessage.IndexOf("[SUCCESS]") >= 0)
|
||||
{
|
||||
thisConnInfo.bHostLoginState = true;
|
||||
|
||||
SubscribeConnectInfo.bSubscriberClientResult = true;
|
||||
|
||||
if (SubscribeConnectInfo.bUIMUseMode)
|
||||
{
|
||||
SubscribeConnectInfo.SessionTimeSet();
|
||||
|
||||
SubscribeConnectInfo.bSessionStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
AdaptorInformation.LOGIN_RESULT = thisConnInfo.bHostLoginState;
|
||||
AdaptorInformation.LOGIN_MESSAGE = strGetMessage;
|
||||
|
||||
OnLoginAlarm(null, null);
|
||||
|
||||
if (thisConnInfo.bHostLoginState)
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"Middleware login reply infomation : " + strGetMessage, ConsoleColor.Green, LogMessageLevel.DEBUG);
|
||||
else
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"The middleware connection will be closed after " + (LOGIN_TIMEOUT / 1000).ToString() + " seconds. ", ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"Middleware login reply infomation : " + strGetMessage, ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.SYSTEM_QUERY:
|
||||
{
|
||||
QUERY_PACKET usPacket = (QUERY_PACKET)objData;
|
||||
|
||||
string strGetQuery = usPacket.objQueryText[0].Data;
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.USER_QUERY:
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.RAW_SIZE:
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.ETC:
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.INITILALIZE_INFO:
|
||||
{
|
||||
GetConnectionInfo = (COMM_INFO_PACKET)objData;
|
||||
|
||||
StateClientGetInformation = true;
|
||||
|
||||
if (ConnectStartStyleAuto == false)
|
||||
{
|
||||
//if (getXData.nLabel == PacketFlowControl.CommInfoManualToken)
|
||||
// break;
|
||||
if (GetConnectionInfo.objConnLocalAddress[0].Data.CompareTo("AUTO") == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
//ConnectionInfoRecvEvent?.BeginInvoke(null, null, null, null);
|
||||
//ConnectionInfoRecvEvent?.Invoke(null, null);
|
||||
|
||||
if (GetConnectionInfo.bPortDistribution == false)
|
||||
{
|
||||
OnConnectionInfoRecv(null, null);
|
||||
|
||||
thisConnInfo.InitialInfoState = true;
|
||||
}
|
||||
|
||||
SubscribeConnectInfo.Initialize();
|
||||
|
||||
if (GetConnectionInfo.bPortDistribution)
|
||||
{
|
||||
SubscribeConnectInfo.nChangeCommandPort = GetConnectionInfo.usPortCommandNumber;
|
||||
SubscribeConnectInfo.nChangeStreamPort = GetConnectionInfo.usPortStreamNumber;
|
||||
|
||||
AdaptorAbort();
|
||||
|
||||
SubscribeConnectInfo.bReqConnectAbort = false;
|
||||
SubscribeConnectInfo.bSetChangeConnect = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
string strSetInfoID = string.Empty;
|
||||
string strSetInfoKey = string.Empty;
|
||||
string strSetInfoTestCode = string.Empty;
|
||||
|
||||
if (LoginID.Length > 0)
|
||||
{
|
||||
//UIM 모드 : 사용자 프로그램(Session 존재)
|
||||
SubscribeConnectInfo.bUIMUseMode = true;
|
||||
|
||||
strSetInfoID = LoginID;
|
||||
strSetInfoKey = LoginKEY;
|
||||
|
||||
strSetInfoTestCode = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
strSetInfoID = LoadInfo.HOST_ID;
|
||||
strSetInfoKey = LoadInfo.SECTION;
|
||||
|
||||
strSetInfoTestCode = LoadInfo.TEST_CODE;
|
||||
}
|
||||
|
||||
if (Login(strSetInfoID, strSetInfoKey, strSetInfoTestCode,
|
||||
SubscribeConnectInfo.bUIMUseMode, LoadInfo.SIMPLE_LOOKUP_OPTION) == false)
|
||||
{
|
||||
AdaptorAbort();
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"SystemX.Net.XAdaptor.PC Login Unknown Error. [SystemX.Net.PCAdaptor : XPCAdaptor.QueryRecvCommandQueue]", ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
thisConnInfo.OffCommandTime();
|
||||
|
||||
RecvWaitEvent?.BeginInvoke(waitCommandParam, null, new AsyncCallback(RecvWaitEnd), null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" General Queue Process <Command> failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : RecvProcessTask.QueryRecvCommandQueue]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
bState = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
bTaskCommandWaitLock = false;
|
||||
}
|
||||
|
||||
return bState;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,360 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Archive;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Schedule;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public partial class XAdaptorPC
|
||||
{
|
||||
//private async void SendStreamEvent(byte[] senderData, ScheduleEvent e)
|
||||
private void SendStreamEvent(byte[] senderData, ScheduleEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
thisConnInfo.m_iSendStreamCnt++;
|
||||
|
||||
if (thisConnInfo.m_iSendStreamCnt + 1 == int.MaxValue)
|
||||
thisConnInfo.m_iSendStreamCnt = 0;
|
||||
|
||||
if (FlowStreamControl == null)
|
||||
return;
|
||||
|
||||
//소켓 샌드 행위 내부 결과
|
||||
if (e.PROCESS_RESULT == false)
|
||||
{
|
||||
//해당 패킷 횟수 상승 일단 회 차시 기록남기고 드랍
|
||||
FlowStreamControl.SendPacketCycle();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General <SendStreamEvent> failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : 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
|
||||
{
|
||||
thisConnInfo.m_iRecvStreamCnt++;
|
||||
|
||||
if (thisConnInfo.m_iRecvStreamCnt + 1 == int.MaxValue)
|
||||
thisConnInfo.m_iRecvStreamCnt = 0;
|
||||
|
||||
if (FlowStreamControl == null)
|
||||
return;
|
||||
|
||||
int iStoreCnt = senderData.Count();
|
||||
byte[] recvStoreBuffer = senderData;
|
||||
|
||||
//소켓 리시브 행위 결과 전송
|
||||
if (e.PROCESS_RESULT == false)
|
||||
{
|
||||
//받기 실패 단순 실패 응답
|
||||
FlowStreamControl.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.SetSendPacketDrop();
|
||||
else
|
||||
FlowStreamControl.SendPacketCycle();
|
||||
|
||||
thisConnInfo.OffStreamTime();
|
||||
}
|
||||
//파일 끝 응답
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.RAW_END)
|
||||
{
|
||||
if (XCommons.GetSimpleResponsResult(iStoreCnt, recvStoreBuffer))
|
||||
FlowStreamControl.RawStoreQueuePOP();
|
||||
else
|
||||
FlowStreamControl.RawStoreQueuePOP();
|
||||
|
||||
thisConnInfo.OffStreamTime();
|
||||
}
|
||||
//일반 응답
|
||||
else
|
||||
{
|
||||
//성공 응답
|
||||
FlowStreamControl.InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.SIMPLE_RESPONSE), true), null, false, false);
|
||||
|
||||
//받은 큐에 넣어놓기
|
||||
FlowStreamControl.InsertRecvQueue(senderData, null, e.nLABEL);
|
||||
|
||||
thisConnInfo.OffStreamTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General <RecvStreamEvent> failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : RecvStreamEvent]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
private async void WatchRecvStreamQueue()
|
||||
{
|
||||
await Task.Delay(500).ConfigureAwait(false);
|
||||
|
||||
while (!StateClientGetInformation)
|
||||
{
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
thisConnInfo.OnStreamTime();
|
||||
thisConnInfo.OnStreamCheckTime();
|
||||
|
||||
while (!m_bTaskStreamBlock)
|
||||
{
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
StreamCT.ThrowIfCancellationRequested();
|
||||
}
|
||||
catch (OperationCanceledException CancelEx)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Work Canceled. [SystemX.Net.XAdaptor.PC.XPCAdaptor : RecvProcessTask.WatchRecvStreamQueue]\r\n" + CancelEx.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
try
|
||||
{
|
||||
if (StateClientStreamSocketConnect == false)
|
||||
continue;
|
||||
|
||||
if (thisConnInfo.stStreamCheckTime.ElapsedMilliseconds >= 60000)
|
||||
{
|
||||
await SendStreamConnectState().ConfigureAwait(false);
|
||||
|
||||
thisConnInfo.OnStreamCheckTime();
|
||||
}
|
||||
|
||||
if (bTaskStreamWaitLock == false)
|
||||
{
|
||||
bool bResult = QueryRecvStreamQueue();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// throw new CommonScheduleException("General Queue Process failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : RecvProcessTask.WatchRecvStreamQueue]");
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General Queue Process failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : RecvProcessTask.WatchRecvStreamQueue]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
//return true;
|
||||
}
|
||||
|
||||
private bool StreamQueueCheck()
|
||||
{
|
||||
if (ClientStreamSock == null)
|
||||
return false;
|
||||
|
||||
if (ClientStreamSock != null)
|
||||
{
|
||||
if (ClientStreamSock.CONNECT == false)
|
||||
return false;
|
||||
}
|
||||
//
|
||||
if (FlowStreamControl == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool QueryRecvStreamQueue()
|
||||
{
|
||||
bool bState = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (StreamQueueCheck() == false)
|
||||
return false;
|
||||
|
||||
bTaskStreamWaitLock = true;
|
||||
//
|
||||
if (FlowStreamControl.GetCurrentRecvProcessData() != null)
|
||||
return false;
|
||||
|
||||
thisConnInfo.m_iSendCommandQueueSize = FlowStreamControl.GetSendQueueSize();
|
||||
thisConnInfo.m_iRecvCommandQueueSize = FlowStreamControl.GetRecvQueueSize();
|
||||
|
||||
if ((thisConnInfo.m_iSendStreamQueueSize + 1) == int.MaxValue)
|
||||
thisConnInfo.m_iSendStreamQueueSize = 0;
|
||||
if ((thisConnInfo.m_iRecvStreamQueueSize + 1) == int.MaxValue)
|
||||
thisConnInfo.m_iRecvStreamQueueSize = 0;
|
||||
|
||||
XData getXData = FlowStreamControl.GetResultPacketData();
|
||||
|
||||
if (getXData == null)
|
||||
return false;
|
||||
|
||||
thisConnInfo.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;
|
||||
|
||||
thisConnInfo.OnStreamCheckTime();
|
||||
|
||||
switch (CODE)
|
||||
{
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE:
|
||||
{
|
||||
PING_PACKET GetPingPacket = (PING_PACKET)objData;
|
||||
|
||||
string strGetMsg = GetPingPacket.objCheckMsg[0].Data;
|
||||
|
||||
strCheckStreamMsg = strGetMsg;
|
||||
|
||||
RecvWaitEvent?.BeginInvoke(waitStreamParam, null, new AsyncCallback(RecvWaitEnd), null);
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.SYNC_TIME_SERVER:
|
||||
{
|
||||
TIME_PACKET GetTimePacket = (TIME_PACKET)objData;
|
||||
|
||||
string strGetMsg = GetTimePacket.objMsg[0].Data;
|
||||
|
||||
RecvWaitEvent?.BeginInvoke(waitStreamParam, null, new AsyncCallback(RecvWaitEnd), null);
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.MIDDLEWARE_MESSAGE:
|
||||
{
|
||||
MESSAGE_PACKET GetMessagePacket = (MESSAGE_PACKET)objData;
|
||||
|
||||
string strGetMsg = GetMessagePacket.objMessage[0].Data;
|
||||
|
||||
GetMiddlewareMessage = strGetMsg;
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.FILE_TRANSFER:
|
||||
{
|
||||
byte[] ucFileData = objData as byte[];
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.TRANSFER_RESULT:
|
||||
{
|
||||
RecvWaitEvent?.BeginInvoke(waitStreamParam, null, new AsyncCallback(RecvWaitEnd), null);
|
||||
}
|
||||
break;
|
||||
case BASE_PROTOCOL.PROTOCOL_CODE.RAW_SIZE:
|
||||
{
|
||||
if (getHeader.uiSourDataNum > 1)
|
||||
{
|
||||
if (thisConnInfo.nFileRecvPos > 0)
|
||||
{
|
||||
if ((thisConnInfo.nFileRecvPos + 1) != getHeader.uiSourDataNum ||
|
||||
thisConnInfo.nFileRecvEndPos == 0)
|
||||
{
|
||||
thisConnInfo.nFileRecvPos = 0;
|
||||
thisConnInfo.nFileRecvEndPos = 0;
|
||||
|
||||
FlowStreamControl.InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.RAW_END), false), null, false, false);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
if (getHeader.uiSourDataNum == 1)
|
||||
{
|
||||
thisConnInfo.lstRecvFileBytes = new List<Tuple<int, byte[]>>();
|
||||
thisConnInfo.lstRecvFileBytes.Clear();
|
||||
|
||||
thisConnInfo.lstRecvFileBytes.Add(new Tuple<int, byte[]>((int)getHeader.uiSourDataNum, objData as byte[]));
|
||||
|
||||
thisConnInfo.nFileRecvPos = (int)getHeader.uiSourDataNum;
|
||||
thisConnInfo.nFileRecvEndPos = (int)getHeader.uiDestDataNum;
|
||||
|
||||
thisConnInfo.strRecvFileName = getHeader.objOptionName[0].Data;
|
||||
thisConnInfo.strRecvExtension = getHeader.objOptionExtension[0].Data;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisConnInfo.lstRecvFileBytes.Add(new Tuple<int, byte[]>((int)getHeader.uiSourDataNum, objData as byte[]));
|
||||
|
||||
thisConnInfo.nFileRecvPos++;
|
||||
}
|
||||
//
|
||||
if (thisConnInfo.nFileRecvPos >= thisConnInfo.nFileRecvEndPos)
|
||||
{
|
||||
int iSize = 0;
|
||||
|
||||
foreach (Tuple<int, byte[]> tData in thisConnInfo.lstRecvFileBytes)
|
||||
iSize += tData.Item2.Count();
|
||||
|
||||
byte[] ucGetDatas = new byte[iSize];
|
||||
|
||||
int iCopyPos = 0;
|
||||
|
||||
foreach (Tuple<int, byte[]> tData in thisConnInfo.lstRecvFileBytes)
|
||||
{
|
||||
Array.Copy(tData.Item2, 0, ucGetDatas, iCopyPos, tData.Item2.Count());
|
||||
|
||||
iCopyPos += tData.Item2.Count();
|
||||
}
|
||||
|
||||
if (getHeader.usPalletIndex == ushort.MaxValue)
|
||||
{
|
||||
string strGetTestListCntID = getHeader.objVarParam1[0].Data;
|
||||
|
||||
QueryTestListProcess(ucGetDatas, strGetTestListCntID);
|
||||
|
||||
//Task<int> tkProcTestlist = new Task<int>(new Func<int>(() => QueryTestListProcess(ucGetDatas).Result));
|
||||
//tkProcTestlist.Start();
|
||||
|
||||
//PacketFlowControl.TestListResultToken
|
||||
if (FlowStreamControl.STM.GetLabel(getXData.nLabel) == getXData.nLabel)
|
||||
{
|
||||
FlowStreamControl.STM.SetLabel(getXData.nLabel, getXData);
|
||||
|
||||
RecvWaitEvent?.BeginInvoke(waitStreamParam, null, new AsyncCallback(RecvWaitEnd), null);
|
||||
}
|
||||
}
|
||||
|
||||
thisConnInfo.nFileRecvPos = 0;
|
||||
thisConnInfo.nFileRecvEndPos = 0;
|
||||
|
||||
FlowStreamControl.InsertSendQueue(DateTime.Now, XCommons.SetSimpleResponsPacket(new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.RAW_END), true), null, false, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
thisConnInfo.lStreamTime = thisConnInfo.stStreamProcessTime.ElapsedMilliseconds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" General Queue Process <Stream> failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : PCAdaptor.QueryRecvStreamQueue]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
bState = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
bTaskStreamWaitLock = false;
|
||||
}
|
||||
|
||||
return bState;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Archive;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Schedule;
|
||||
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public partial class XAdaptorPC
|
||||
{
|
||||
private async void WatchSubProcess()
|
||||
{
|
||||
await Task.Delay(500).ConfigureAwait(false);
|
||||
|
||||
while (!StateClientGetInformation)
|
||||
{
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
while (!m_bTaskSubBlock)
|
||||
{
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
StreamCT.ThrowIfCancellationRequested();
|
||||
}
|
||||
catch (OperationCanceledException CancelEx)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" Work Canceled. [SystemX.Net.XAdaptor.PC.XPCAdaptor : ProcessTask.WatchFailedFile]\r\n" + CancelEx.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
try
|
||||
{
|
||||
if (StateClientStreamSocketConnect == false)
|
||||
continue;
|
||||
///
|
||||
/// 5분이상 기존 파일전송이 없을 경우
|
||||
///
|
||||
if (stFileSendTime.ElapsedMilliseconds < FILE_SEND_MAX_WAITTIME)
|
||||
goto ROUTINE_OUT;
|
||||
///
|
||||
/// 직전 전송이 10초 이상 일때(완전 처리 대기)
|
||||
///
|
||||
if (stBackupFileSendTime.ElapsedMilliseconds < FILE_SEND_INTERVAL_TIME)
|
||||
goto ROUTINE_OUT;
|
||||
|
||||
if (bTaskSubLockState)
|
||||
goto ROUTINE_OUT;
|
||||
|
||||
try
|
||||
{
|
||||
bTaskSubLockState = await _smpSlim.WaitAsync(100);
|
||||
|
||||
if (bTaskSubLockState == false)
|
||||
goto ROUTINE_OUT;
|
||||
|
||||
//Scan And Send File
|
||||
//오늘 포함 -6일전까지 검색
|
||||
string[] strYYYY = new string[7];
|
||||
string[] strMM = new string[7];
|
||||
string[] strdd = new string[7];
|
||||
|
||||
for (int i = 6; i >= 0; i--)
|
||||
{
|
||||
DateTime dtSet = DateTime.Today.AddDays(-i);
|
||||
strYYYY[i] = dtSet.ToString("yyyy");
|
||||
strMM[i] = dtSet.ToString("MM");
|
||||
strdd[i] = dtSet.ToString("dd");
|
||||
}
|
||||
//
|
||||
// 7일치 위치 확인
|
||||
//
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
string strGetRoot = Path.GetPathRoot(Environment.CurrentDirectory);
|
||||
|
||||
string DirPath = strGetRoot + $@"\XLog\FileFailedBackup\{LoadInfo.HOST_ID}\{LoadInfo.SECTION}\{strYYYY[i]}\{strMM[i]}\{strdd[i]}\";
|
||||
string DirMovePath = strGetRoot + $@"\XLog\FileFailedBackup\{LoadInfo.HOST_ID}\{LoadInfo.SECTION}\{strYYYY[i]}\{strMM[i]}\{strdd[i]}\History\";
|
||||
|
||||
//생성 폴더가 없을경우 SKIP
|
||||
if (Directory.Exists(DirPath) == false)
|
||||
continue;
|
||||
|
||||
if (Directory.Exists(DirMovePath) == false)
|
||||
Directory.CreateDirectory(DirMovePath);
|
||||
|
||||
string fileExtension = "zip";
|
||||
|
||||
string[] dirs = Directory.GetDirectories(DirPath);
|
||||
string[] files = Directory.GetFiles(DirPath, $"*.{fileExtension}", SearchOption.TopDirectoryOnly);
|
||||
|
||||
if (files.Length > 0)
|
||||
{
|
||||
string strExtractFilePos = string.Empty;
|
||||
string strOrgRemoveFilePos = string.Empty;
|
||||
|
||||
string strHeaderInfo = string.Empty;
|
||||
string strLogFileNameInfo = string.Empty;
|
||||
|
||||
foreach (string f in files)
|
||||
{
|
||||
strOrgRemoveFilePos = f;
|
||||
|
||||
strHeaderInfo = string.Empty;
|
||||
strLogFileNameInfo = string.Empty;
|
||||
|
||||
string[] strInfos = f.Split(';');
|
||||
|
||||
//파일정보 확인(로그 저장관련 정보)
|
||||
string strSetDateTime = strInfos[1];
|
||||
string strSetStationName = strInfos[2];
|
||||
int nSetTestListVariantNo = int.Parse(strInfos[3]);
|
||||
string strSetProcNoP = strInfos[4];
|
||||
string strSetProcNoC = strInfos[5];
|
||||
string strSetTestType = strInfos[6];
|
||||
string strSetTestCode = strInfos[7];
|
||||
string strSetVersion = strInfos[8];
|
||||
string strSetProdCode = strInfos[9];
|
||||
string strSetTestListCntID = strInfos[10];
|
||||
int nSetTryNo = int.Parse(strInfos[11]);
|
||||
|
||||
for (int n = 1; n < 10; n++)
|
||||
strHeaderInfo += (strInfos[n + 1] + ";");
|
||||
|
||||
strHeaderInfo = strHeaderInfo.Remove(strHeaderInfo.Length - 1, 1);
|
||||
|
||||
//압축해제 하여 로그 파일 추출
|
||||
using (FileStream fs = new FileStream(f, FileMode.Open))
|
||||
using (ZipArchive zip = new ZipArchive(fs, ZipArchiveMode.Update, false))
|
||||
{
|
||||
foreach (ZipArchiveEntry zae in zip.Entries)
|
||||
{
|
||||
strLogFileNameInfo = zae.FullName;
|
||||
|
||||
if (strLogFileNameInfo.IndexOf(".txt") >= 0)
|
||||
continue;
|
||||
|
||||
strExtractFilePos = DirPath + strLogFileNameInfo;
|
||||
|
||||
zae.ExtractToFile(strExtractFilePos, true);
|
||||
}
|
||||
}
|
||||
|
||||
//로그 파일 전송
|
||||
if (await AsyncFailedLogFileTransfer(strExtractFilePos,
|
||||
strSetStationName,
|
||||
nSetTestListVariantNo,
|
||||
strSetProcNoP,
|
||||
strSetProcNoC,
|
||||
strSetTestType,
|
||||
strSetTestCode,
|
||||
strSetVersion,
|
||||
strSetProdCode,
|
||||
strSetTestListCntID) == eFileSendRecvResult.FileProcSuccess)
|
||||
{
|
||||
//성공시
|
||||
string strCopyPos = DirMovePath;
|
||||
for (int n = 0; n < 10; n++)
|
||||
strCopyPos += (";" + strInfos[n + 1]);
|
||||
|
||||
strCopyPos += (";" + nSetTryNo.ToString() + ";.zip");
|
||||
|
||||
File.Copy(f, strCopyPos, true);
|
||||
|
||||
XAdaptorFileLogWrite(eSetFileLogCategory.FileLog, strYYYY[i], strMM[i], strdd[i], strHeaderInfo, strLogFileNameInfo, "FailedFileTrySend>Success");
|
||||
}
|
||||
else
|
||||
{
|
||||
//실패시
|
||||
nSetTryNo++;
|
||||
|
||||
string strTryNo = string.Empty;
|
||||
|
||||
string strCopyPos = string.Empty;
|
||||
|
||||
//재시도 3회 초과 일시 히스토리로 이동
|
||||
if (nSetTryNo > 3)
|
||||
{
|
||||
strCopyPos = DirMovePath;
|
||||
|
||||
strTryNo = "X";
|
||||
|
||||
XAdaptorFileLogWrite(eSetFileLogCategory.FileLog, strYYYY[i], strMM[i], strdd[i], strHeaderInfo, strLogFileNameInfo, "FailedFileTrySend>UnprocessableFile");
|
||||
}
|
||||
else
|
||||
{
|
||||
strCopyPos = DirPath;
|
||||
|
||||
strTryNo = nSetTryNo.ToString();
|
||||
|
||||
XAdaptorFileLogWrite(eSetFileLogCategory.FileLog, strYYYY[i], strMM[i], strdd[i], strHeaderInfo, strLogFileNameInfo, "FailedFileTrySend>Fail");
|
||||
}
|
||||
|
||||
for (int n = 0; n < 10; n++)
|
||||
strCopyPos += (";" + strInfos[n + 1]);
|
||||
|
||||
strCopyPos += (";" + strTryNo + ";.zip");
|
||||
|
||||
File.Copy(f, strCopyPos, true);
|
||||
}
|
||||
|
||||
//압축해제 파일 삭제
|
||||
File.Delete(strExtractFilePos);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//성공시나 실패시 새로운 파일생성 되기 때문에 기존 파일 삭제
|
||||
if (strOrgRemoveFilePos != string.Empty)
|
||||
File.Delete(strOrgRemoveFilePos);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stBackupFileSendTime.Restart();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (bTaskSubLockState)
|
||||
{
|
||||
try
|
||||
{
|
||||
_smpSlim.Release();
|
||||
}
|
||||
catch
|
||||
{
|
||||
;//smp release lock exception
|
||||
}
|
||||
|
||||
bTaskSubLockState = false;
|
||||
}
|
||||
}
|
||||
|
||||
ROUTINE_OUT:;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General Queue Process failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : ProcessTask.WatchFailedFile]\r\n" + ex.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,413 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using SystemX.Common;
|
||||
using SystemX.Common.Archive;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Comm;
|
||||
using SystemX.Net.XAdaptor.PC.O2Sensor.NgCode;
|
||||
using SystemX.Net.Schedule;
|
||||
using SystemX.Net.XAdaptor;
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
using WTimer = System.Windows.Forms.Timer;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC
|
||||
{
|
||||
public partial class XAdaptorPC
|
||||
{
|
||||
private bool QueryTestListProcess(byte[] ucGetDatas, string strGetTestListCntID)
|
||||
{
|
||||
bool bSetResult = false;
|
||||
|
||||
try
|
||||
{
|
||||
DataSet QueryTestList = null;
|
||||
QueryTestList = XDataArchive.DecompressByteToDataset(ucGetDatas);
|
||||
|
||||
(mgrPRODTestList as TProdTestListInfo).SetTestListDataSet(QueryTestList);
|
||||
(mgrPRODTestList as TProdTestListInfo).SetTestListCntID(strGetTestListCntID);
|
||||
|
||||
if (XCommons.isHasRow(mgrPRODTestList.getTestListDataSet()))
|
||||
{
|
||||
if (mgrPRODTestList.getTestListDataSet().Tables[0].Columns.Contains("TestListData"))
|
||||
{
|
||||
int iCol1 = mgrPRODTestList.getTestListDataSet().Tables[0].Columns.IndexOf("TestListData");
|
||||
mgrPRODTestList.getTestListDataSet().Tables[0].Columns[iCol1].ColumnMapping = MappingType.Hidden;
|
||||
}
|
||||
if (mgrPRODTestList.getTestListDataSet().Tables[0].Columns.Contains("FileName"))
|
||||
{
|
||||
int iCol2 = mgrPRODTestList.getTestListDataSet().Tables[0].Columns.IndexOf("FileName");
|
||||
}
|
||||
|
||||
bSetResult = true;
|
||||
}
|
||||
|
||||
base.ServerTestListLoadState = true;
|
||||
|
||||
//QueryCallEvent?.BeginInvoke(mgrPRODTestList.getTestListDataSet(), new ResultEventArgs(bSetResult), null, null);
|
||||
OnBeginQueryCall(mgrPRODTestList.getTestListDataSet(), new ResultEventArgs(bSetResult));
|
||||
}
|
||||
catch
|
||||
{
|
||||
bSetResult = false;
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
;//
|
||||
}
|
||||
|
||||
return bSetResult;
|
||||
}
|
||||
|
||||
/*
|
||||
private async void ClientCommandConnect()
|
||||
{
|
||||
dbNgCodeFinder = null;
|
||||
|
||||
ConnectCommandWaitEvent.Reset();
|
||||
StateAdaptorConnect &= ClientCommandSet(SOCKET_TYPE.TCP, false);
|
||||
|
||||
if (ConnectCommandWaitEvent.WaitOne(CONNECT_TIME_OUT))
|
||||
SetCommandWatchTask();
|
||||
else
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"SystemX.Net.XAdaptor.PC Command Connect Error.[SystemX.Net.PCAdaptor : XPCAdaptor.XPCAdaptor]", ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
|
||||
await Task.Delay(1).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async void ClientStreamConnect()
|
||||
{
|
||||
ConnectStreamWaitEvent.Reset();
|
||||
StateAdaptorConnect &= ClientStreamSet(SOCKET_TYPE.TCP, false);
|
||||
|
||||
if (ConnectStreamWaitEvent.WaitOne(CONNECT_TIME_OUT))
|
||||
SetStreamWatchTask();
|
||||
else
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"SystemX.Net.XAdaptor.PC Stream Connect Error.[SystemX.Net.PCAdaptor : XPCAdaptor.XPCAdaptor]", ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
|
||||
await Task.Delay(1).ConfigureAwait(false);
|
||||
}
|
||||
*/
|
||||
|
||||
private void ClearCommandClientInstance()
|
||||
{
|
||||
if (FlowCommandControl != null)
|
||||
{
|
||||
FlowCommandControl.Dispose();
|
||||
FlowCommandControl = null;
|
||||
}
|
||||
|
||||
if (ClientCommandSock != null)
|
||||
{
|
||||
ClientCommandSock.Comm_Connect_Event -= ClientCommandConnectEvent;
|
||||
ClientCommandSock.Socket_Error_Event -= ClientCommandErrorEvent;
|
||||
|
||||
ClientCommandSock.Comm_Send_Event -= SendCommandEvent;
|
||||
ClientCommandSock.Comm_Recv_Event -= RecvCommandEvent;
|
||||
|
||||
ClientCommandSock.Dispose();
|
||||
ClientCommandSock = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearStreamClientInstance()
|
||||
{
|
||||
if (FlowStreamControl != null)
|
||||
{
|
||||
FlowStreamControl.Dispose();
|
||||
FlowStreamControl = null;
|
||||
}
|
||||
|
||||
if (ClientStreamSock != null)
|
||||
{
|
||||
ClientStreamSock.Comm_Connect_Event -= ClientStreamConnectEvent;
|
||||
ClientStreamSock.Socket_Error_Event -= ClientStreamErrorEvent;
|
||||
|
||||
ClientStreamSock.Comm_Send_Event -= SendStreamEvent;
|
||||
ClientStreamSock.Comm_Recv_Event -= RecvStreamEvent;
|
||||
|
||||
ClientStreamSock.Dispose();
|
||||
ClientStreamSock = null;
|
||||
}
|
||||
}
|
||||
|
||||
private IPAddress GetConnectIPAddress()
|
||||
{
|
||||
IPAddress setIP = null;
|
||||
|
||||
if (LoadInfo.LOOP_BACK)
|
||||
setIP = IPAddress.Loopback;
|
||||
else
|
||||
{
|
||||
if (REF_CONNECT_IP.Length > 0)
|
||||
setIP = IPAddress.Parse(REF_CONNECT_IP);
|
||||
else
|
||||
setIP = IPAddress.Parse(LoadInfo.CONNECT_IP);
|
||||
}
|
||||
|
||||
return setIP;
|
||||
}
|
||||
|
||||
private int GetDistributionPort(Random r, int nStartPort)
|
||||
{
|
||||
//최대값 미만 + 1
|
||||
r.Next();
|
||||
return r.Next(nStartPort, nStartPort + 10);
|
||||
}
|
||||
|
||||
private bool ClientCommandSet(SOCKET_TYPE SOCK_TYPE, bool bUseRandDistribution = true, int nSetPortNumber = int.MaxValue)
|
||||
{
|
||||
thisConnInfo.bHostLoginState = true;
|
||||
|
||||
bool bClientStartState = true;
|
||||
//
|
||||
int nPortNumber = int.MaxValue;
|
||||
|
||||
if (nSetPortNumber == int.MaxValue)
|
||||
{
|
||||
nPortNumber = LoadInfo.COMMAND_PORT;
|
||||
}
|
||||
else
|
||||
nPortNumber = nSetPortNumber;
|
||||
|
||||
if (bUseRandDistribution)
|
||||
{
|
||||
Random r = new Random((int)(DateTime.Now.Ticks));
|
||||
|
||||
nPortNumber = GetDistributionPort(r, nPortNumber);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (ClientReadyEndPoint == false)
|
||||
{
|
||||
/*if (LoadInfo.LOOP_BACK)
|
||||
ClientCommandEP = new IPEndPoint(IPAddress.Loopback, nPortNumber);
|
||||
else
|
||||
ClientCommandEP = new IPEndPoint(IPAddress.Parse(LoadInfo.CONNECT_IP), nPortNumber);*/
|
||||
|
||||
if (LoadInfo.LOOP_BACK)
|
||||
ClientCommandEP = new IPEndPoint(GetConnectIPAddress(), nPortNumber);
|
||||
else
|
||||
ClientCommandEP = new IPEndPoint(GetConnectIPAddress(), nPortNumber);
|
||||
}
|
||||
|
||||
ClearCommandClientInstance();
|
||||
|
||||
//COMMAND
|
||||
#if FALSE
|
||||
ClientCommandSock = new AsyncComClientSocket(ClientCommandEP);
|
||||
#else
|
||||
ClientCommandSock = new AsyncClientSocket(SOCK_TYPE, ClientCommandEP);
|
||||
#endif
|
||||
|
||||
ClientCommandSock.Comm_Connect_Event += ClientCommandConnectEvent;
|
||||
ClientCommandSock.Socket_Error_Event += ClientCommandErrorEvent;
|
||||
|
||||
ClientCommandSock.Comm_Send_Event += SendCommandEvent;
|
||||
ClientCommandSock.Comm_Recv_Event += RecvCommandEvent;
|
||||
|
||||
FlowCommandControl = new PacketFlowControl(FlowControlType.Commnad, ClientCommandSock);
|
||||
|
||||
ClientCommandSock.Connect();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bClientStartState = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"Client Command connect set failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : XPCAdaptor.ClientCommandSet()]\r\n" + ex.Message, ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
return bClientStartState;
|
||||
}
|
||||
|
||||
private bool ClientStreamSet(SOCKET_TYPE SOCK_TYPE, bool bUseRandDistribution = true, int nSetPortNumber = int.MaxValue)
|
||||
{
|
||||
bool bClientStartState = true;
|
||||
|
||||
int nPortNumber = int.MaxValue;
|
||||
|
||||
if (nSetPortNumber == int.MaxValue)
|
||||
nPortNumber = LoadInfo.STREAM_PORT;
|
||||
else
|
||||
nPortNumber = nSetPortNumber;
|
||||
|
||||
if (bUseRandDistribution)
|
||||
{
|
||||
Random r = new Random((int)(DateTime.Now.Ticks));
|
||||
|
||||
nPortNumber = GetDistributionPort(r, nPortNumber);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (ClientReadyEndPoint == false)
|
||||
{
|
||||
if (LoadInfo.LOOP_BACK)
|
||||
ClientStreamEP = new IPEndPoint(GetConnectIPAddress(), nPortNumber);
|
||||
else
|
||||
ClientStreamEP = new IPEndPoint(GetConnectIPAddress(), nPortNumber);
|
||||
|
||||
/*if (LoadInfo.LOOP_BACK)
|
||||
ClientStreamEP = new IPEndPoint(IPAddress.Loopback, nPortNumber);
|
||||
else
|
||||
ClientStreamEP = new IPEndPoint(IPAddress.Parse(LoadInfo.CONNECT_IP), nPortNumber);*/
|
||||
}
|
||||
|
||||
ClearStreamClientInstance();
|
||||
|
||||
//STREAM
|
||||
#if FALSE
|
||||
ClientStreamSock = new AsyncComClientSocket(ClientStreamEP);
|
||||
#else
|
||||
ClientStreamSock = new AsyncClientSocket(SOCK_TYPE, ClientStreamEP);
|
||||
#endif
|
||||
|
||||
ClientStreamSock.Comm_Connect_Event += ClientStreamConnectEvent;
|
||||
ClientStreamSock.Socket_Error_Event += ClientStreamErrorEvent;
|
||||
|
||||
ClientStreamSock.Comm_Send_Event += SendStreamEvent;
|
||||
ClientStreamSock.Comm_Recv_Event += RecvStreamEvent;
|
||||
|
||||
FlowStreamControl = new PacketFlowControl(FlowControlType.Stream, ClientStreamSock);
|
||||
|
||||
ClientStreamSock.Connect();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bClientStartState = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"Client Stream connect set failed.[SystemX.Net.XAdaptor.PC.XPCAdaptor : XPCAdaptor.ClientStreamSet()]\r\n" + ex.Message, ConsoleColor.Red, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
return bClientStartState;
|
||||
}
|
||||
|
||||
private void ClearCommonVar()
|
||||
{
|
||||
SubscribeConnectInfo.bSessionStarted = false;
|
||||
}
|
||||
|
||||
private void ClearCommandWatchTask()
|
||||
{
|
||||
CommandCTS.Cancel();
|
||||
|
||||
if (taskRecvCommandProcess != null)
|
||||
{
|
||||
taskRecvCommandProcess.ContinueWith(t =>
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"taskRecvCommandProcess END. [SystemX.Net.XAdaptor.PC : XPCAdaptor.ClearWatchTask - Command]",
|
||||
ConsoleColor.White,
|
||||
LogMessageLevel.DEBUG);
|
||||
});
|
||||
|
||||
m_bTaskCommandBlock = true;
|
||||
|
||||
taskRecvCommandProcess.ConfigureAwait(false);
|
||||
//taskRecvCommandProcess.Wait();
|
||||
|
||||
taskRecvCommandProcess = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearStreamWatchTask()
|
||||
{
|
||||
StreamCTS.Cancel();
|
||||
|
||||
if (taskRecvStreamProcess != null)
|
||||
{
|
||||
taskRecvStreamProcess.ContinueWith(t =>
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"taskRecvStreamProcess END. [SystemX.Net.XAdaptor.PC : XPCAdaptor.ClearWatchTask - Stream]",
|
||||
ConsoleColor.White,
|
||||
LogMessageLevel.DEBUG);
|
||||
});
|
||||
|
||||
m_bTaskStreamBlock = true;
|
||||
|
||||
taskRecvStreamProcess.ConfigureAwait(false);
|
||||
//taskRecvStreamProcess.Wait();
|
||||
|
||||
taskRecvStreamProcess = null;
|
||||
}
|
||||
//
|
||||
SubCTS.Cancel();
|
||||
|
||||
if (taskSubProcess != null)
|
||||
{
|
||||
taskSubProcess.ContinueWith(t =>
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") +
|
||||
@"taskSubProcess END. [SystemX.Net.XAdaptor.PC : XPCAdaptor.ClearWatchTask - Stream(Sub)]",
|
||||
ConsoleColor.White,
|
||||
LogMessageLevel.DEBUG);
|
||||
});
|
||||
|
||||
m_bTaskSubBlock = true;
|
||||
|
||||
taskSubProcess.ConfigureAwait(false);
|
||||
//taskSubProcess.Wait();
|
||||
|
||||
taskSubProcess = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCommandWatchTask()
|
||||
{
|
||||
if (StateAdaptorConnect == false)
|
||||
return;
|
||||
|
||||
ClearCommandWatchTask();
|
||||
|
||||
taskRecvCommandProcess = null;
|
||||
m_bTaskCommandBlock = false;
|
||||
|
||||
CommandCTS = new CancellationTokenSource();
|
||||
CommandCT = CommandCTS.Token;
|
||||
|
||||
taskRecvCommandProcess = new Task(new Action(WatchRecvCommandQueue), CommandCT);
|
||||
taskRecvCommandProcess.Start();
|
||||
}
|
||||
|
||||
private void SetStreamWatchTask()
|
||||
{
|
||||
if (StateAdaptorConnect == false)
|
||||
return;
|
||||
|
||||
ClearStreamWatchTask();
|
||||
|
||||
taskRecvStreamProcess = null;
|
||||
m_bTaskStreamBlock = false;
|
||||
|
||||
StreamCTS = new CancellationTokenSource();
|
||||
StreamCT = StreamCTS.Token;
|
||||
|
||||
taskRecvStreamProcess = new Task(new Action(WatchRecvStreamQueue), StreamCT);
|
||||
taskRecvStreamProcess.Start();
|
||||
//
|
||||
taskSubProcess = null;
|
||||
m_bTaskSubBlock = false;
|
||||
|
||||
SubCTS = new CancellationTokenSource();
|
||||
SubCT = StreamCTS.Token;
|
||||
|
||||
taskSubProcess = new Task(new Action(WatchSubProcess), SubCT);
|
||||
taskSubProcess.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
185
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/LoginForm.Designer.cs
generated
Normal file
185
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/LoginForm.Designer.cs
generated
Normal file
@ -0,0 +1,185 @@
|
||||
namespace SystemX.Net.XAdaptor.PC.UI
|
||||
{
|
||||
partial class LoginForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginForm));
|
||||
this.Login_Btn = new System.Windows.Forms.Button();
|
||||
this.Cancel_Btn = new System.Windows.Forms.Button();
|
||||
this.Password_Edit = new System.Windows.Forms.TextBox();
|
||||
this.Chg_Password_Edit1 = new System.Windows.Forms.TextBox();
|
||||
this.Chg_Password_Edit2 = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.Chg_Password_Btn = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Login_Btn
|
||||
//
|
||||
this.Login_Btn.Location = new System.Drawing.Point(415, 7);
|
||||
this.Login_Btn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.Login_Btn.Name = "Login_Btn";
|
||||
this.Login_Btn.Size = new System.Drawing.Size(85, 29);
|
||||
this.Login_Btn.TabIndex = 3;
|
||||
this.Login_Btn.Text = "Ok";
|
||||
this.Login_Btn.UseVisualStyleBackColor = true;
|
||||
this.Login_Btn.Click += new System.EventHandler(this.Login_Btn_Click);
|
||||
//
|
||||
// Cancel_Btn
|
||||
//
|
||||
this.Cancel_Btn.Location = new System.Drawing.Point(415, 76);
|
||||
this.Cancel_Btn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.Cancel_Btn.Name = "Cancel_Btn";
|
||||
this.Cancel_Btn.Size = new System.Drawing.Size(85, 29);
|
||||
this.Cancel_Btn.TabIndex = 5;
|
||||
this.Cancel_Btn.Text = "Cancel";
|
||||
this.Cancel_Btn.UseVisualStyleBackColor = true;
|
||||
this.Cancel_Btn.Click += new System.EventHandler(this.Cancel_Btn_Click);
|
||||
//
|
||||
// Password_Edit
|
||||
//
|
||||
this.Password_Edit.Location = new System.Drawing.Point(231, 9);
|
||||
this.Password_Edit.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.Password_Edit.MaxLength = 30;
|
||||
this.Password_Edit.Name = "Password_Edit";
|
||||
this.Password_Edit.PasswordChar = '*';
|
||||
this.Password_Edit.Size = new System.Drawing.Size(176, 25);
|
||||
this.Password_Edit.TabIndex = 0;
|
||||
this.Password_Edit.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Password_Edit_KeyDown);
|
||||
//
|
||||
// Chg_Password_Edit1
|
||||
//
|
||||
this.Chg_Password_Edit1.Location = new System.Drawing.Point(231, 43);
|
||||
this.Chg_Password_Edit1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.Chg_Password_Edit1.MaxLength = 30;
|
||||
this.Chg_Password_Edit1.Name = "Chg_Password_Edit1";
|
||||
this.Chg_Password_Edit1.PasswordChar = '*';
|
||||
this.Chg_Password_Edit1.Size = new System.Drawing.Size(176, 25);
|
||||
this.Chg_Password_Edit1.TabIndex = 1;
|
||||
this.Chg_Password_Edit1.Visible = false;
|
||||
//
|
||||
// Chg_Password_Edit2
|
||||
//
|
||||
this.Chg_Password_Edit2.Location = new System.Drawing.Point(231, 76);
|
||||
this.Chg_Password_Edit2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.Chg_Password_Edit2.MaxLength = 30;
|
||||
this.Chg_Password_Edit2.Name = "Chg_Password_Edit2";
|
||||
this.Chg_Password_Edit2.PasswordChar = '*';
|
||||
this.Chg_Password_Edit2.Size = new System.Drawing.Size(176, 25);
|
||||
this.Chg_Password_Edit2.TabIndex = 2;
|
||||
this.Chg_Password_Edit2.Visible = false;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("맑은 고딕", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
this.label1.ForeColor = System.Drawing.Color.White;
|
||||
this.label1.Location = new System.Drawing.Point(13, 12);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(104, 23);
|
||||
this.label1.TabIndex = 5;
|
||||
this.label1.Text = "PASSWORD:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("맑은 고딕", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
this.label2.ForeColor = System.Drawing.Color.White;
|
||||
this.label2.Location = new System.Drawing.Point(13, 45);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(145, 23);
|
||||
this.label2.TabIndex = 6;
|
||||
this.label2.Text = "CHG PASSWORD:";
|
||||
this.label2.Visible = false;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Font = new System.Drawing.Font("맑은 고딕", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
this.label3.ForeColor = System.Drawing.Color.White;
|
||||
this.label3.Location = new System.Drawing.Point(13, 78);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(209, 23);
|
||||
this.label3.TabIndex = 7;
|
||||
this.label3.Text = "REPEAT CHG PASSWORD:";
|
||||
this.label3.Visible = false;
|
||||
//
|
||||
// Chg_Password_Btn
|
||||
//
|
||||
this.Chg_Password_Btn.Location = new System.Drawing.Point(415, 40);
|
||||
this.Chg_Password_Btn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.Chg_Password_Btn.Name = "Chg_Password_Btn";
|
||||
this.Chg_Password_Btn.Size = new System.Drawing.Size(85, 29);
|
||||
this.Chg_Password_Btn.TabIndex = 4;
|
||||
this.Chg_Password_Btn.Text = "Change";
|
||||
this.Chg_Password_Btn.UseVisualStyleBackColor = true;
|
||||
this.Chg_Password_Btn.Click += new System.EventHandler(this.Chg_Password_Btn_Click);
|
||||
//
|
||||
// LoginForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.ClientSize = new System.Drawing.Size(511, 117);
|
||||
this.Controls.Add(this.Chg_Password_Btn);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.Chg_Password_Edit2);
|
||||
this.Controls.Add(this.Chg_Password_Edit1);
|
||||
this.Controls.Add(this.Password_Edit);
|
||||
this.Controls.Add(this.Cancel_Btn);
|
||||
this.Controls.Add(this.Login_Btn);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.Name = "LoginForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "LOGIN";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button Login_Btn;
|
||||
private System.Windows.Forms.Button Cancel_Btn;
|
||||
private System.Windows.Forms.TextBox Password_Edit;
|
||||
private System.Windows.Forms.TextBox Chg_Password_Edit1;
|
||||
private System.Windows.Forms.TextBox Chg_Password_Edit2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button Chg_Password_Btn;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices; // DLL support
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.UI
|
||||
{
|
||||
public partial class LoginForm : Form
|
||||
{
|
||||
private string sSecretKey;
|
||||
private string strGetPassword;
|
||||
private bool bPasswordChgMode;
|
||||
|
||||
private string strKeyPath;
|
||||
|
||||
public LoginForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
string strGetExcutePath = Application.ExecutablePath;
|
||||
|
||||
strKeyPath = strGetExcutePath;
|
||||
|
||||
bPasswordChgMode = false;
|
||||
|
||||
string strFilepath;
|
||||
strFilepath = @strKeyPath + @"Info.ini";
|
||||
|
||||
iniUtil Configini = new iniUtil(strFilepath);
|
||||
strGetPassword = Configini.GetIniValue("PASSWORD", "KEY");
|
||||
}
|
||||
|
||||
private void SetChgPassword(string strGetChgPassword)
|
||||
{
|
||||
string strFilepath;
|
||||
strFilepath = @strKeyPath + @"Info.ini";
|
||||
iniUtil Configini = new iniUtil(strFilepath);
|
||||
|
||||
Configini.SetIniValue("PASSWORD", "KEY", strGetChgPassword);
|
||||
|
||||
strGetPassword = strGetChgPassword;
|
||||
|
||||
MessageBox.Show("Password change success.", "LOGIN", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
label2.Visible = false;
|
||||
label3.Visible = false;
|
||||
Chg_Password_Edit1.Visible = false;
|
||||
Chg_Password_Edit2.Visible = false;
|
||||
Login_Btn.Visible = true;
|
||||
|
||||
bPasswordChgMode = false;
|
||||
|
||||
Password_Edit.Text = "";
|
||||
Chg_Password_Edit1.Text = "";
|
||||
Chg_Password_Edit2.Text = "";
|
||||
}
|
||||
|
||||
private void Login_Btn_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoginFunc();
|
||||
}
|
||||
|
||||
private void Chg_Password_Btn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!bPasswordChgMode)
|
||||
{
|
||||
label2.Visible = true;
|
||||
label3.Visible = true;
|
||||
Chg_Password_Edit1.Visible = true;
|
||||
Chg_Password_Edit2.Visible = true;
|
||||
Login_Btn.Visible = false;
|
||||
|
||||
bPasswordChgMode = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PasswordChgFunc();
|
||||
}
|
||||
}
|
||||
|
||||
private void Cancel_Btn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (bPasswordChgMode)
|
||||
{
|
||||
label2.Visible = false;
|
||||
label3.Visible = false;
|
||||
Chg_Password_Edit1.Visible = false;
|
||||
Chg_Password_Edit2.Visible = false;
|
||||
Login_Btn.Visible = true;
|
||||
|
||||
bPasswordChgMode = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
private void LoginFunc()
|
||||
{
|
||||
string strGetInputPassword = Password_Edit.Text;
|
||||
|
||||
if (string.Compare(strGetInputPassword, strGetPassword) == 0)
|
||||
this.DialogResult = DialogResult.OK;
|
||||
else
|
||||
{
|
||||
if (string.Compare(strGetInputPassword, "SystemX") == 0)
|
||||
this.DialogResult = DialogResult.OK;
|
||||
else
|
||||
MessageBox.Show("Passwords do not match.", "LOGIN", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void PasswordChgFunc()
|
||||
{
|
||||
if ((Chg_Password_Edit1.Text.Length <= 0) || (Chg_Password_Edit2.Text.Length <= 0))
|
||||
{
|
||||
MessageBox.Show("Empty password is not allowed.", "LOGIN", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Change
|
||||
string strGetInputPassword = Password_Edit.Text;
|
||||
|
||||
string strGetChgPassword1 = Chg_Password_Edit1.Text;
|
||||
string strGetChgPassword2 = Chg_Password_Edit2.Text;
|
||||
|
||||
if (string.Compare(strGetInputPassword, strGetPassword) == 0)
|
||||
{
|
||||
if (string.Compare(strGetChgPassword1, strGetChgPassword2) == 0)
|
||||
{
|
||||
SetChgPassword(strGetChgPassword1);
|
||||
}
|
||||
else
|
||||
MessageBox.Show("Change passwords do not match.", "LOGIN", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.Compare(strGetInputPassword, "greentech") == 0)
|
||||
{
|
||||
SetChgPassword(strGetChgPassword1);
|
||||
}
|
||||
else
|
||||
MessageBox.Show("Passwords do not match.", "LOGIN", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Password_Edit_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
if (!bPasswordChgMode)
|
||||
{
|
||||
LoginFunc();
|
||||
}
|
||||
else
|
||||
{
|
||||
PasswordChgFunc();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAEAICAAAAAAAACoCAAAFgAAACgAAAAgAAAAQAAAAAEACAAAAAAAgAQAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP//
|
||||
AAD///8AlpaWAK+vrwDh4eEAtra2AMXGxgCqqqoAm5ubALu7uwDOz88Ara+vAJ6dnQBzc3MAnp6eAJ2Z
|
||||
mQC2rq4Ao6WlAF9fXwCJiYkAq62tAKaengC2o6MAnKCgAEtLSwBdXV0AsrKyAJmbmwCrrq4Ao6KiAHx8
|
||||
fAA8PDwAhISEALGxsQCTk5MAq6qqAKKiogB0dHQAQkJCAG1tbQCLi4sAmZmZALi4uACsrKwAf39/AE9P
|
||||
TwCQkJAAn5+fAKurqwB+fn4ASEhIAFNTUwCYmJgApaWlAMHBwQC9vb0AREREAFtbWwB7e3sApqamANLS
|
||||
0gDQ0NAAQ0NDAF5eXgCGhoYAo6OjAH19fQBFRUUAYWFhAIWFhQBYWFgAVlZWAIODgwB6enoAdnZ2AHBw
|
||||
cAB5eXkAgYGBAJ+vhwCru5MAt8efAMvbswDX578A4/PLAAtvmwAPe6MAE4evABePtwAbm8MAF6fPABuz
|
||||
2wAjv+cAK8vzADfX/wD/8/8A/+v/AP/f/wD/0/8A/8f/AP+3/wD/o/8A/5f/AP+D/wD/a/8A/0v/AOcA
|
||||
5wDXANcAwwDHALcAtwCjAKcAlwCXAIsAiwB3AHcAZwBnAE8AUwAvADMA6///AOf//wDf//8A0///ALv/
|
||||
/wCb//8AP///AADz9wAA5+sAAN/fAADT0wAAx8cAALu7AACzrwAAp6cAAJuXAACXjwAAf38AAHd3AABf
|
||||
XwAAR0cAADMzAP//9wD//+cA///bAP//xwD//7sA//+XAP//fwD//1MA7+8AAOPjAADX1wAAy8sAAL+/
|
||||
AACzswAAo6MAAJeTAACLgwAAe3sAAGdrAABbWwAAR0sAACMjAADz//MA3//nANf/1wDD/88Au/+7AKP/
|
||||
owCH/4cAZ/9nADf/NwAL/wAAAPMAAADrAAAA4wAAANcAAADLAAAAvwAAALMAAACnAAAAnwAAAJMAAACH
|
||||
AAAAfwAAAHcAAABvAAAAZwAAAF8AAABTAAAARwAAADcAAAAjAAD38/8A6+v/AN/f/wDT0/8Aw8P/AK+v
|
||||
/wCbm/8Ai4v/AHd3/wBnZ/8AU1P/AEND/wAvL/8AFxf/AAAARwAAAFcAAABnAAAAcwAAAH8AAACLAAAA
|
||||
lwAAAKMAAACvAAAAuwAAAMMAAADPAAAA2wAAAOcAAADzAHwAVACbAGkAugB+ANkAkwDwAKoA/yS2AP9I
|
||||
wgD/bM4A/5DaAP+05gDw8PAA3NzcAMjIyAC0tLQAoKCgAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP//
|
||||
AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAACAgICAgICAgICAgICAgICAgIAAAAAAAAAAAAAAAAAAgICAgICAgI
|
||||
CAgICAgICAgICAgIAAAAAAAAAAAAAAAIAAAAAAAAAAACAAAAAAAAAAAAAAgIAAAAAAAAAAAACAAAAAAA
|
||||
AAoAAAIAAAAACgAAAAAAAAgIAAAAAAAAAAAIAAAAAAAACgAAAgAAAAAKAAAAAAAACAgAAAAAAAAAAAgA
|
||||
AAAAAAoACgACAAAACgAKAAAAAAAICAAAAAAAAAAACAAAAAAACgAKAAIAAAAKAAoAAAAAAAgIAAAAAAAA
|
||||
AAAIAAAAAAAKAAoAAgAAAAoACgAAAAAACAgAAAAAAAAAAAgACgoACgAAAAoCAAAKAAAACgAKCgAICAAA
|
||||
AAAAAAAACAAACgAKAAAACgIAAAoAAAAKAAoAAAgIAAAAAAAAAAAIAAAACgoAAAAKAgAACgAAAAoKAAAA
|
||||
CAgAAAAAAAAAAAgAAAAKAAAAAAAKAAoAAAAAAAoAAAAICAAAAAAAAAAACAICAgICAgICAgoCCgICAgIC
|
||||
AgICAggIAAAAAAAAAAAIAAAAAAAAAAAACgAKAAAAAAAAAAAACAgAAAAAAAAAAAgAAAAAAAAAAAACCgAA
|
||||
AAAAAAAAAAAICAAAAAAAAAAACAAAAAAAAAAAAAIKAAAAAAAAAAAAAAgAAAAAAAAAAAAACAAAAAAAAAAA
|
||||
AgAAAAAAAAAAAAAIAAAAAAAAAAAAAAAACAgICAgICAgICAgICAgICAgICAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAP/////////////////////+AAB//AAAP/gAAB/wAAAP8AAAD/AAAA/wAAAP8AAAD/AA
|
||||
AA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAf+AAAP/wAAH//////////////////////////////
|
||||
////////////////////////
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using SystemX.Net.Platform.Common.ExtensionMethods;
|
||||
using SystemX.Net.Platform.Common.Util;
|
||||
namespace SystemX.Net.XAdaptor.PC.UI
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
1729
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/MainForm.Designer.cs
generated
Normal file
1729
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/MainForm.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
1166
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/MainForm.cs
Normal file
1166
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/MainForm.cs
Normal file
File diff suppressed because it is too large
Load Diff
1307
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/MainForm.resx
Normal file
1307
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/MainForm.resx
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.UI
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 해당 애플리케이션의 주 진입점입니다.
|
||||
/// </summary>
|
||||
///
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
|
||||
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
|
||||
// 이러한 특성 값을 변경하세요.
|
||||
[assembly: AssemblyTitle("SystemX.Net.XAdaptor.PC.UI")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("SystemX.Net.XAdaptor.PC.UI")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
|
||||
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
|
||||
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
|
||||
[assembly: Guid("265215c7-2cc1-4a44-85dc-57fb9f035f71")]
|
||||
|
||||
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
|
||||
//
|
||||
// 주 버전
|
||||
// 부 버전
|
||||
// 빌드 번호
|
||||
// 수정 버전
|
||||
//
|
||||
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
|
||||
// 기본값으로 할 수 있습니다.
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
73
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/Properties/Resources.Designer.cs
generated
Normal file
73
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 도구를 사용하여 생성되었습니다.
|
||||
// 런타임 버전:4.0.30319.42000
|
||||
//
|
||||
// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
|
||||
// 이러한 변경 내용이 손실됩니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SystemX.Net.PCAdaptorUI.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다.
|
||||
/// </summary>
|
||||
// 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder
|
||||
// 클래스에서 자동으로 생성되었습니다.
|
||||
// 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을
|
||||
// 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SystemX.Net.PCAdaptorUI.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을
|
||||
/// 재정의합니다.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap CI {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("CI", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="CI" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\CI.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
26
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/Properties/Settings.Designer.cs
generated
Normal file
26
SystemX.Net.CP.PCAdaptor.UIM/SystemX.Net.PCAdaptorUI/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 도구를 사용하여 생성되었습니다.
|
||||
// 런타임 버전:4.0.30319.42000
|
||||
//
|
||||
// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
|
||||
// 이러한 변경 내용이 손실됩니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.UI.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.3 KiB |
@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{265215C7-2CC1-4A44-85DC-57FB9F035F71}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>SystemX.Net.PCAdaptorUI</RootNamespace>
|
||||
<AssemblyName>SystemX.Net.PCAdaptorUI</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\SystemX.Manual\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\SystemX.Manual\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>ALIS ICON.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.Linq" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="SystemX.Net.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Output.SystemX\SystemX.Net.Platform.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SystemX.Net.XAdaptor.PC.UIM, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Output.SystemX\SystemX.Net.XAdaptor.PC.UIM.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="iniUtil.cs" />
|
||||
<Compile Include="LoginForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="LoginForm.designer.cs">
|
||||
<DependentUpon>LoginForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainForm Sub\TestForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="LoginForm.resx">
|
||||
<DependentUpon>LoginForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ALIS ICON.ico" />
|
||||
<None Include="Resources\CI.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace SystemX.Net.XAdaptor.PC.UI
|
||||
{
|
||||
public class iniUtil
|
||||
{
|
||||
private string iniPath;
|
||||
|
||||
public iniUtil(string path)
|
||||
{
|
||||
this.iniPath = path; //INI 파일 위치를 생성할때 인자
|
||||
}
|
||||
//
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern int GetPrivateProfileString( // GetIniValue String
|
||||
String section,
|
||||
String key,
|
||||
String def,
|
||||
StringBuilder retVal,
|
||||
int size,
|
||||
String filePath);
|
||||
//
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern long WritePrivateProfileString( // SetIniValue String
|
||||
String section,
|
||||
String key,
|
||||
String val,
|
||||
String filePath);
|
||||
|
||||
// INI 값을 읽어 온다.
|
||||
public string GetIniValue(String Section, String Key)
|
||||
{
|
||||
StringBuilder temp = new StringBuilder(255);
|
||||
int i = GetPrivateProfileString(Section, Key, "", temp, 255, iniPath);
|
||||
|
||||
if (temp.Length > 0)
|
||||
return temp.ToString();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
//
|
||||
// INI 값을 셋팅
|
||||
public void SetIniValue(String Section, String Key, string Value)
|
||||
{
|
||||
WritePrivateProfileString(Section, Key, Value, iniPath);
|
||||
}
|
||||
//
|
||||
/*
|
||||
FileInfo exefileinfo = new FileInfo(Application.ExecutablePath);
|
||||
string path = exefileinfo.Directory.FullName.ToString() //프로그램 실행되고 있는데 path 가져오기
|
||||
string fileName = @"\config.ini"; //파일명
|
||||
*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user