[성현모] CPXV2 Init
This commit is contained in:
@ -0,0 +1,361 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Common.Serialization;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
using SystemX.Net.Schedule;
|
||||
|
||||
namespace SystemX.Common.Protocol
|
||||
{
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
public class PacketProgressChangedEventArgs : EventArgs
|
||||
{
|
||||
public PacketProgressChangedEventArgs(int progressPercentage, object userState)
|
||||
{
|
||||
this.ProgressPercentage = progressPercentage;
|
||||
|
||||
this.UserState = userState;
|
||||
}
|
||||
|
||||
public int ProgressPercentage { get; private set; }
|
||||
|
||||
public object UserState { get; private set; }
|
||||
}
|
||||
|
||||
public class PacketAnalyzerCompletedEventArgs : AsyncCompletedEventArgs
|
||||
{
|
||||
private object result;
|
||||
|
||||
public PacketAnalyzerCompletedEventArgs(object result, Exception error, bool cancelled, object userState) : base(error, cancelled, userState)
|
||||
{
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public object Result
|
||||
{
|
||||
get
|
||||
{
|
||||
base.RaiseExceptionIfNecessary();
|
||||
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new object UserState
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.UserState;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class PacketCalculate
|
||||
{
|
||||
public event EventHandler<PacketAnalyzerCompletedEventArgs> PacketAnalyzerCompleted;
|
||||
public event EventHandler<PacketProgressChangedEventArgs> ProgressChanged;
|
||||
|
||||
/// <summary>
|
||||
/// ThreadContext에서 실행하기 위한 AsyncOperation.
|
||||
/// </summary>
|
||||
private AsyncOperation asyncOperation;
|
||||
|
||||
/// <summary>
|
||||
/// AsyncOperation 로 Completed 호출을 위한 델리게이트.
|
||||
/// </summary>
|
||||
private SendOrPostCallback operationCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// AsyncOperation 로 ProgressChanged 호출을 위한 델리게이트.
|
||||
/// </summary>
|
||||
private SendOrPostCallback progressReporter;
|
||||
|
||||
public bool IsBusy { get; private set; }
|
||||
public bool CancellationPending { get; private set; }
|
||||
|
||||
private readonly Action<object> startDelegate;
|
||||
public bool WorkerReportsProgress { get; set; }
|
||||
|
||||
public bool WorkerSupportsCancellation { get; set; }
|
||||
|
||||
#region CREATE
|
||||
public PacketCalculate()
|
||||
{
|
||||
this.startDelegate = this.WorkerThreadStart;
|
||||
this.operationCompleted = this.SendOperationCompletedEvent;
|
||||
this.progressReporter = this.SendProgressChangedEvent;
|
||||
}
|
||||
#endregion
|
||||
private void SendOperationCompletedEvent(object arg)
|
||||
{
|
||||
this.IsBusy = false;
|
||||
|
||||
this.CancellationPending = false;
|
||||
|
||||
var eventArgs = arg as PacketAnalyzerCompletedEventArgs;
|
||||
|
||||
if (eventArgs == null)
|
||||
return;
|
||||
|
||||
var completed = this.PacketAnalyzerCompleted;
|
||||
|
||||
if (completed != null)
|
||||
completed(this, eventArgs);
|
||||
}
|
||||
private void SendProgressChangedEvent(object arg)
|
||||
{
|
||||
var eventArgs = arg as PacketProgressChangedEventArgs;
|
||||
|
||||
if (eventArgs == null)
|
||||
return;
|
||||
|
||||
var progressChanged = this.ProgressChanged;
|
||||
|
||||
if (progressChanged != null)
|
||||
progressChanged(this, eventArgs);
|
||||
}
|
||||
private void WorkerThreadStart(object argument)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
Exception error = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = this.Calculate(argument, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex;
|
||||
}
|
||||
|
||||
this.asyncOperation.PostOperationCompleted(this.operationCompleted, new PacketAnalyzerCompletedEventArgs(result, error, this.CancellationPending, null));
|
||||
}
|
||||
private void ReportProgress(int percentProgress)
|
||||
{
|
||||
if (!this.WorkerReportsProgress)
|
||||
{
|
||||
//throw new InvalidOperationException("BackgroundWorker_WorkerDoesntReportProgress.[SystemX.Common.AsyncEvent : PacketCalculate.ReportProgress]");
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"BackgroundWorker_WorkerDoesntReportProgress.[SystemX.Common.AsyncEvent : PacketCalculate.ReportProgress]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
var arg = new PacketProgressChangedEventArgs(percentProgress, null);
|
||||
|
||||
if (this.asyncOperation != null)
|
||||
{
|
||||
this.asyncOperation.Post(this.progressReporter, arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.progressReporter(arg);
|
||||
}
|
||||
}
|
||||
public void CalculateAsync(object argument)
|
||||
{
|
||||
this.IsBusy = true;
|
||||
|
||||
this.CancellationPending = false;
|
||||
|
||||
this.asyncOperation = AsyncOperationManager.CreateOperation(null);
|
||||
|
||||
this.startDelegate.BeginInvoke(argument, null, null);
|
||||
}
|
||||
|
||||
public void CancelAsync()
|
||||
{
|
||||
if (!this.WorkerSupportsCancellation)
|
||||
{
|
||||
//throw new InvalidOperationException("BackgroundWorker_WorkerDoesntSupportCancellation.[SystemX.Common.AsyncEvent : PacketCalculate.CancelAsync]");
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"General packet marshalling failed.[SystemX.Common : COMMON.GetHeaderProtocol]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
this.CancellationPending = true;
|
||||
}
|
||||
public XData Calculate(object objPacket, bool isAsync = false)
|
||||
{
|
||||
XData ResultData = null;
|
||||
|
||||
XPacket getPacket = (XPacket)objPacket;
|
||||
|
||||
int iStoreCnt = getPacket.ucPacketBytes.Count();
|
||||
byte[] recvStoreBuffer = getPacket.ucPacketBytes;
|
||||
|
||||
BASE_PROTOCOL GET_PROTOCOL = new BASE_PROTOCOL();
|
||||
BASE_PROTOCOL.PROTOCOL_CODE GET_CODE = new BASE_PROTOCOL.PROTOCOL_CODE();
|
||||
HEADER_PACKET GET_HEADER = new HEADER_PACKET();
|
||||
|
||||
byte ucSetLabel = getPacket.nLabel;
|
||||
|
||||
bool bReplayResult = true;
|
||||
object objData = null;
|
||||
|
||||
try
|
||||
{
|
||||
GET_PROTOCOL = XCommons.GetHeaderProtocol(iStoreCnt, recvStoreBuffer);
|
||||
GET_HEADER = XCommons.GetHeaderPacket(iStoreCnt, recvStoreBuffer);
|
||||
|
||||
GET_CODE = GET_PROTOCOL.GET_CURRENT_PROTOCOL;
|
||||
|
||||
if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.CONNECT_STATE)
|
||||
{
|
||||
PING_PACKET PacketData = new PING_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<PING_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.MIDDLEWARE_MESSAGE)
|
||||
{
|
||||
MESSAGE_PACKET PacketData = new MESSAGE_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<MESSAGE_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.HOST_INFO_CHECK)
|
||||
{
|
||||
SYSTEM_HOST_PACKET PacketData = new SYSTEM_HOST_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<SYSTEM_HOST_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.SYNC_TIME_SERVER)
|
||||
{
|
||||
TIME_PACKET PacketData = new TIME_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<TIME_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.FILE_TRANSFER)
|
||||
{
|
||||
byte[] PacketData = XCommons.ByteStreamToObject<byte[]>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.DATASET_TRANSEFER)
|
||||
{
|
||||
DataSet PacketData = XCommons.ByteStreamToObject<DataSet>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
bReplayResult = GET_HEADER.bResponsState;
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.RAW_SIZE)
|
||||
{
|
||||
byte[] PacketData = XCommons.ByteStreamToObject<byte[]>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.INITILALIZE_INFO)
|
||||
{
|
||||
COMM_INFO_PACKET PacketData = new COMM_INFO_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<COMM_INFO_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.SYSTEM_QUERY)
|
||||
{
|
||||
QUERY_PACKET PacketData = new QUERY_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<QUERY_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.USER_QUERY)
|
||||
{
|
||||
QUERY_PACKET PacketData = new QUERY_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<QUERY_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.TRANSFER_RESULT)
|
||||
{
|
||||
TRANSFER_PACKET PacketData = new TRANSFER_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<TRANSFER_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.ETC)
|
||||
{
|
||||
USER_PACKET PacketData = new USER_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<USER_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else if (GET_CODE == BASE_PROTOCOL.PROTOCOL_CODE.PROCESS_QUERY)
|
||||
{
|
||||
PROCESS_PACKET PacketData = new PROCESS_PACKET();
|
||||
PacketData = XCommons.ByteStreamToSpecialObject<PROCESS_PACKET>(GET_CODE, iStoreCnt, recvStoreBuffer);
|
||||
|
||||
objData = PacketData;
|
||||
}
|
||||
else
|
||||
{
|
||||
GET_PROTOCOL = new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.NONE);
|
||||
|
||||
bReplayResult = false;
|
||||
|
||||
objData = null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GET_PROTOCOL = new BASE_PROTOCOL(BASE_PROTOCOL.PROTOCOL_CODE.NONE);
|
||||
|
||||
bReplayResult = false;
|
||||
|
||||
objData = null;
|
||||
|
||||
string strErrMsg = e.Message;
|
||||
}
|
||||
|
||||
ResultData = new XData();
|
||||
ResultData.dtTime = DateTime.Now;
|
||||
ResultData.bReplayResult = bReplayResult;
|
||||
ResultData.BaseProtocol = GET_PROTOCOL;
|
||||
ResultData.HeaderPacket = GET_HEADER;
|
||||
ResultData.objData = objData;
|
||||
ResultData.nLabel = ucSetLabel;
|
||||
|
||||
return ResultData;
|
||||
}
|
||||
}
|
||||
|
||||
public class EventBaseAsyncPattern
|
||||
{
|
||||
public void Run(int p)
|
||||
{
|
||||
var PacketAnalyzerWait = new PacketCalculate
|
||||
{
|
||||
WorkerReportsProgress = true,
|
||||
|
||||
WorkerSupportsCancellation = true
|
||||
};
|
||||
|
||||
PacketAnalyzerWait.PacketAnalyzerCompleted += calculatorPacket_CalculateCompleted;
|
||||
PacketAnalyzerWait.ProgressChanged += calculatorPacket_ProgressChanged;
|
||||
|
||||
var i = 0;
|
||||
while (i < 5)
|
||||
{
|
||||
if (PacketAnalyzerWait.IsBusy)
|
||||
continue;
|
||||
|
||||
PacketAnalyzerWait.CalculateAsync(p + i);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void calculatorPacket_ProgressChanged(object sender, PacketProgressChangedEventArgs e)
|
||||
{
|
||||
//"Calculating : {0}% Completed", e.ProgressPercentage;
|
||||
}
|
||||
|
||||
void calculatorPacket_CalculateCompleted(object sender, PacketAnalyzerCompletedEventArgs e)
|
||||
{
|
||||
//e.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Net;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
|
||||
namespace SystemX.Common.Protocol
|
||||
{
|
||||
using ParamElement = Tuple<SqlDbType, int, byte, byte>;
|
||||
|
||||
public static class CommonParamSet
|
||||
{
|
||||
public static Dictionary<string, ParamElement> fParam= new Dictionary<string, ParamElement>();
|
||||
|
||||
public static void TestResultField()
|
||||
{
|
||||
fParam.Clear();
|
||||
fParam = new Dictionary<string, ParamElement>();
|
||||
fParam.Add("No", new ParamElement(SqlDbType.BigInt, 0, 0, 0));
|
||||
fParam.Add("TestDT", new ParamElement(SqlDbType.DateTime2, 7, 0, 0));
|
||||
fParam.Add("LogData", new ParamElement(SqlDbType.NVarChar, -1, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
public static SqlParameter GetMakeSqlParameterInfo(Dictionary<string, ParamElement> refField, string strSetName, object objValue)
|
||||
{
|
||||
if (refField.ContainsKey(strSetName))
|
||||
{
|
||||
SqlParameter param = null;
|
||||
|
||||
if (refField[strSetName].Item2 != 0)
|
||||
param = new SqlParameter("@" + strSetName, refField[strSetName].Item1, refField[strSetName].Item2);
|
||||
else
|
||||
param = new SqlParameter("@" + strSetName, refField[strSetName].Item1);
|
||||
|
||||
if (refField[strSetName].Item1 == SqlDbType.Decimal)
|
||||
{
|
||||
param.Precision = refField[strSetName].Item3;
|
||||
param.Scale = refField[strSetName].Item4;
|
||||
}
|
||||
|
||||
param.Value = objValue;
|
||||
return param;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class CommonCustomProtocol : BASE_PROTOCOL
|
||||
{
|
||||
public CommonCustomProtocol() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public CommonCustomProtocol(ushort usGetCommnad, ushort usGetSubCommand) : base(usGetCommnad, usGetSubCommand)
|
||||
{
|
||||
}
|
||||
|
||||
public CommonCustomProtocol(PROTOCOL_CODE SET_CODE) : base(SET_CODE)
|
||||
{
|
||||
}
|
||||
|
||||
public SqlCommand LogDataResultInsert(string strTableName, DataRow itemData)
|
||||
{
|
||||
string columns = string.Empty;
|
||||
columns = "No,TestDT,DataLog";
|
||||
|
||||
string values = string.Join(",", columns.Split(',').Select(c => string.Format("@{0}", c)));
|
||||
string sqlCommand = string.Format("INSERT INTO [" + strTableName + "] ({0}) VALUES ({1})", columns, values);
|
||||
|
||||
CommonParamSet.TestResultField();
|
||||
|
||||
SqlCommand cmd = new SqlCommand(sqlCommand);
|
||||
|
||||
SqlParameter[] setParams = new SqlParameter[columns.Split(',').Count()];
|
||||
|
||||
setParams[0] = CommonParamSet.GetMakeSqlParameterInfo(CommonParamSet.fParam, "No", itemData["No"]);
|
||||
setParams[1] = CommonParamSet.GetMakeSqlParameterInfo(CommonParamSet.fParam, "TestDT", itemData["TestDT"]);
|
||||
setParams[2] = CommonParamSet.GetMakeSqlParameterInfo(CommonParamSet.fParam, "LogData", itemData["LogData"]);
|
||||
|
||||
cmd.Parameters.AddRange(setParams);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,593 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Net;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
|
||||
namespace SystemX.Common.Protocol.LSU
|
||||
{
|
||||
public class CustomProtocol_ : BASE_PROTOCOL
|
||||
{
|
||||
public CustomProtocol_() : base()
|
||||
{
|
||||
}
|
||||
public CustomProtocol_(ushort usGetCommnad, ushort usGetSubCommand) : base(usGetCommnad, usGetSubCommand)
|
||||
{
|
||||
}
|
||||
public CustomProtocol_(PROTOCOL_CODE SET_CODE) : base(SET_CODE)
|
||||
{
|
||||
}
|
||||
//REF
|
||||
public string QueryRefModelList()
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
strQueryInfo = "SELECT * FROM REFS_Model ORDER BY No";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryRefModelAllInfo(string strSensorID)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
//INNER JOIN REFS_Model C ON C.RefSnrsID = A.RefSnrsID
|
||||
strQueryInfo = "SELECT B.Model_Type, B.RefSnrsID, B.Name, B.Status, " +
|
||||
"A.Pressure, A.ZeroPoint, A.SetPointPM, A.SetPointFT, A.MRG1, A.MRG3, A.MRG4, A.MRG5, A.SFG20, A.SFG45, A.RI, " +
|
||||
"X.CountWarning, X.CountLimit " +
|
||||
"FROM REFS_Model AS B, REFS_UsagePlan AS X, REFS_ModelChar AS A " +
|
||||
"WHERE B.RefSnrsID = '" + strSensorID + "' AND B.RefSnrsID = A.RefSnrsID AND A.RefSnrsID = X.RefSnrsID;";
|
||||
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryRefModelPlanInfo(string strSensorID)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
strQueryInfo = "SELECT A.Model_Type, A.RefSnrsID, A.Name, A.Status, " +
|
||||
"X.CountWarning, X.CountLimit " +
|
||||
"FROM REFS_Model AS A, REFS_UsagePlan AS X " +
|
||||
"WHERE A.RefSnrsID = '" + strSensorID + "' AND A.RefSnrsID = X.RefSnrsID;";
|
||||
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryRefModelGetCnt(string strSensroID, string strUsageID)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
strQueryInfo = "SELECT A.RefSnrsID, A.UsagePlaceID, A.LastUpdateDT, A.Count, A.AccumulateCount " +
|
||||
"FROM REFS_UsageHistory AS A " +
|
||||
"INNER JOIN(SELECT MAX(B.LastUpdateDT) AS LAST_DATE, B.RefSnrsID AS ID, B.UsagePlaceID AS UPI " +
|
||||
"FROM REFS_UsageHistory AS B WHERE B.RefSnrsID = '" + strSensroID + "' AND B.UsagePlaceID = '" + strUsageID + "' GROUP BY B.RefSnrsID, B.UsagePlaceID) AS SUB " +
|
||||
"ON SUB.LAST_DATE = A.LastUpdateDT " +
|
||||
"AND A.RefSnrsID = SUB.ID " +
|
||||
"AND A.UsagePlaceID = SUB.UPI;";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryRefModelSetCnt(string strSensroID, string strUsageID)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
strQueryInfo = "UPDATE A SET A.Count = A.Count + 1, A.AccumulateCount = A.AccumulateCount + 1, A.LastUpdateDT = GETDATE() " +
|
||||
"FROM REFS_UsageHistory A " +
|
||||
"JOIN(SELECT MAX(B.LastUpdateDT) AS LAST_DATE, B.RefSnrsID AS ID, B.UsagePlaceID AS UPI " +
|
||||
"FROM REFS_UsageHistory AS B WHERE B.RefSnrsID = '" + strSensroID + "' AND B.UsagePlaceID = '" + strUsageID + "' GROUP BY B.RefSnrsID, B.UsagePlaceID) AS SUB " +
|
||||
"ON SUB.LAST_DATE = A.LastUpdateDT " +
|
||||
"AND A.RefSnrsID = SUB.ID " +
|
||||
"AND A.UsagePlaceID = SUB.UPI;";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryRefModelChangeKnowNewPlace(string strSensroID, string strUsageID, string strNewUsageID)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
strQueryInfo = "INSERT INTO REFS_UsageHistory (RefSnrsID, UsagePlaceID, Count, AccumulateCount, Description) " +
|
||||
"SELECT RefSnrsID, '" + strNewUsageID + "', '0', AccumulateCount, Description FROM REFS_UsageHistory AS A " +
|
||||
"INNER JOIN(SELECT MAX(B.LastUpdateDT) AS LAST_DATE, B.RefSnrsID AS ID, B.UsagePlaceID AS UPI " +
|
||||
"FROM REFS_UsageHistory AS B WHERE B.RefSnrsID = '" + strSensroID + "' AND B.UsagePlaceID = '" + strUsageID + "' GROUP BY B.RefSnrsID, B.UsagePlaceID) AS SUB " +
|
||||
"ON SUB.LAST_DATE = A.LastUpdateDT " +
|
||||
"AND A.RefSnrsID = SUB.ID " +
|
||||
"AND A.UsagePlaceID = SUB.UPI;";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryRefModelChange(string strSensroID, string strNewUsageID)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
strQueryInfo = "INSERT INTO REFS_UsageHistory(RefSnrsID, UsagePlaceID, Count, AccumulateCount, Description) " +
|
||||
"SELECT A.RefSnrsID, '" + strNewUsageID + "', '0', A.AccumulateCount, A.Description FROM REFS_UsageHistory AS A " +
|
||||
"INNER JOIN(SELECT * FROM REFS_UsageHistory WHERE " +
|
||||
"LastUpdateDT = (SELECT MAX(LastUpdateDT) FROM REFS_UsageHistory B WHERE B.RefSnrsID = '" + strSensroID + "' " +
|
||||
"GROUP BY B.RefSnrsID)) AS SUB " +
|
||||
"ON SUB.LastUpdateDT = A.LastUpdateDT " +
|
||||
"AND A.RefSnrsID = SUB.RefSnrsID " +
|
||||
"AND A.UsagePlaceID = SUB.UsagePlaceID;";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryRefModelRegister(string strSensroID, string strUsageID)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
strQueryInfo = "IF EXISTS(SELECT RefSnrsID FROM [REFS_Model] AS B WHERE B.RefSnrsID = '" + strSensroID + "') " +
|
||||
"BEGIN " +
|
||||
"IF NOT EXISTS(SELECT RefSnrsID FROM REFS_UsageHistory AS A WHERE A.RefSnrsID = '" + strSensroID + "') " +
|
||||
"BEGIN " +
|
||||
"INSERT INTO REFS_UsageHistory (RefSnrsID, UsagePlaceID, Count, AccumulateCount, Description) VALUES('" + strSensroID + "', '" + strUsageID + "', 0, 0, '-'); " +
|
||||
"END " +
|
||||
"END;";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryRefModelLastSensorAtPlaceID(string strUsageID)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
strQueryInfo = "SELECT * FROM[REFS_UsageHistory] A " +
|
||||
"WHERE LastUpdateDT = (SELECT MAX(LastUpdateDT) " +
|
||||
"FROM[REFS_UsageHistory] B " +
|
||||
"WHERE B.UsagePlaceID = '" + strUsageID + "' " +
|
||||
"GROUP BY B.UsagePlaceID);";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
public string QueryMakeModeInfo(PROCESS_PACKET getPaket)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
strQueryInfo = "SELECT ModeID FROM [CONST_WorkMode] WHERE PalletNumber = '" + getPaket.objPalletNumber[0].Data + "';";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryFindTrimmingImage(int iProcNum, PROCESS_PACKET getPaket)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
int iSetType = 0;
|
||||
|
||||
if (getPaket.objPalletID[0].Data.IndexOf("-") >= 0)
|
||||
iSetType = 1;
|
||||
if (getPaket.objPalletNumber[0].Data.IndexOf("-") >= 0)
|
||||
iSetType = 2;
|
||||
|
||||
//Normal
|
||||
strQueryInfo = "SELECT TOP 1 No, LogData, UpdateDT FROM [HIST_TestResultData_" + iProcNum.ToString() + "] WHERE No " +
|
||||
"IN(SELECT No FROM [HIST_TestResultData_" + iProcNum.ToString() + "] WHERE " +
|
||||
"PalletNumber = '" + getPaket.objPalletNumber[0].Data + "' " +
|
||||
"AND PalletID = '" + getPaket.objPalletID[0].Data + "' " +
|
||||
"AND ProdID = '" + getPaket.objProductID[0].Data + "' " +
|
||||
"AND TestID = 'LTV' " +
|
||||
"AND Status = 50) " +
|
||||
"ORDER BY No DESC;";
|
||||
|
||||
if(iSetType == 1)
|
||||
{
|
||||
strQueryInfo = "SELECT TOP 1 No, LogData, UpdateDT FROM [HIST_TestResultData_" + iProcNum.ToString() + "] WHERE No " +
|
||||
"IN(SELECT No FROM [HIST_TestResultData_" + iProcNum.ToString() + "] WHERE " +
|
||||
"PalletNumber = '" + getPaket.objPalletNumber[0].Data + "' " +
|
||||
"AND ProdID = '" + getPaket.objProductID[0].Data + "' " +
|
||||
"AND TestID = 'LTV' " +
|
||||
"AND Status = 50) " +
|
||||
"ORDER BY No DESC;";
|
||||
}
|
||||
else if (iSetType == 2)
|
||||
{
|
||||
strQueryInfo = "SELECT TOP 1 No, LogData, UpdateDT FROM [HIST_TestResultData_" + iProcNum.ToString() + "] WHERE No " +
|
||||
"IN(SELECT No FROM [HIST_TestResultData_" + iProcNum.ToString() + "] WHERE " +
|
||||
"ProdID = '" + getPaket.objProductID[0].Data + "' " +
|
||||
"AND TestID = 'LTV' " +
|
||||
"AND Status = 50) " +
|
||||
"ORDER BY No DESC;";
|
||||
}
|
||||
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryMakePalletInfo(PROCESS_PACKET getPaket)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
//Unused Pallet Position
|
||||
if (getPaket.objProductID[0].Data.Length == 0)
|
||||
strQueryInfo = "SELECT * FROM STAT_ProdLoad A WHERE A.PalletNumber = '" + getPaket.objPalletNumber[0].Data + "' ORDER BY A.No;";
|
||||
else
|
||||
strQueryInfo = "SELECT * FROM STAT_ProdLoad A WHERE A.PalletNumber = '" + getPaket.objPalletNumber[0].Data +
|
||||
"' AND A.ProdID = '" + getPaket.objProductID[0].Data + "' ORDER BY A.No;";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
*/
|
||||
public string QueryMakePalletInfo(string strPalletNumber, string strProductID = "")
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
//Unused Pallet Position
|
||||
if (strProductID.Length == 0)
|
||||
strQueryInfo = "SELECT * FROM STAT_ProdLoad A WHERE A.PalletNumber = '" + strPalletNumber + "' ORDER BY A.No;";
|
||||
else
|
||||
strQueryInfo = "SELECT * FROM STAT_ProdLoad A WHERE A.PalletNumber = '" + strPalletNumber +
|
||||
"' AND A.ProdID = '" + strProductID + "' ORDER BY A.No;";
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
public string QueryMakeModelInfo(int iPos, ServerInfo getServerInfo, XTableInfo getSchemaTableInfo, string strProdNo)
|
||||
{
|
||||
//int iGetProcessCode = getServerInfo.ConnectInfo[iPos].Item4;
|
||||
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
/*IEnumerable<InfoProcess> queryFindProcessInfo =
|
||||
from Process in getServerInfo.ProcessInfo
|
||||
where Process.nNum == (iPos + 1)
|
||||
select Process;
|
||||
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
foreach (InfoProcess fpi in queryFindProcessInfo)
|
||||
{
|
||||
//Find Process Info
|
||||
|
||||
//기본 Child 및 Parent Model info Inner join Query 문 생성
|
||||
if (fpi.bParameterInfoUse == false)
|
||||
{
|
||||
strQueryInfo = "SELECT B.Model_Type, A.PrtProdNo, A.Plug_Type AS 'C Plug Type', B.Plug_Type AS 'P Plug Type', A.ProdNo, A.Name AS 'C Name', A.CableLength, A.FillPrs_Target, A.FillPrs_USpec, A.FillPrs_LSpec," +
|
||||
"B.Name AS 'P Name', B.RegulationType, B.ProtTubeType, B.RiSetPoint" +
|
||||
//
|
||||
" FROM PROD_ModelParent AS B, " +
|
||||
//
|
||||
"PROD_ModelChild AS A INNER JOIN PROD_ModelParent C ON C.PrtProdNo = A.PrtProdNo" +
|
||||
" WHERE A.ProdNo = '" + strProdNo + "' AND B.PrtProdNo = A.PrtProdNo;";
|
||||
}
|
||||
else
|
||||
{
|
||||
strQueryInfo = "SELECT B.Model_Type, A.PrtProdNo, A.Plug_Type AS 'C Plug Type', B.Plug_Type AS 'P Plug Type', A.ProdNo, A.Name AS 'C Name', A.CableLength, A.FillPrs_Target, A.FillPrs_USpec, A.FillPrs_LSpec," +
|
||||
"B.Name AS 'P Name', B.RegulationType, B.ProtTubeType, B.RiSetPoint,";
|
||||
|
||||
string[] strParameterTableList = null;
|
||||
strParameterTableList = fpi.strParameterInfoTableName.Split(',');
|
||||
|
||||
if (strParameterTableList.Count() > 3)
|
||||
return "ERROR - Parameter table use max 3.";
|
||||
|
||||
string[] strSubAs = new string[3] { "X", "Y", "Z" };
|
||||
string[] strSubTable = new string[3] { "", "", "" };
|
||||
|
||||
int iSet = 0;
|
||||
foreach (string strName in strParameterTableList)
|
||||
{
|
||||
int iTp = Array.FindIndex<XTable>(getSchemaTableInfo._table.ToArray(), x => x.tableName == strName);
|
||||
XTable xt = getSchemaTableInfo._table[iTp];
|
||||
|
||||
string[] strAddModelInfo = new string[xt.lstName.Count];
|
||||
for (int i = 0; i < xt.lstName.Count; i++)
|
||||
{
|
||||
strAddModelInfo[i] = string.Empty;
|
||||
strAddModelInfo[i] = @" " + strSubAs[iSet] + "." + xt.lstName[i] + " AS '" + strName + " " + xt.lstName[i] + "',";
|
||||
//'SUB" + (iSet+1).ToString() + " " + xt.lstName[i] + "',";
|
||||
|
||||
if (xt.lstName[i].CompareTo("No") == 0)
|
||||
continue;
|
||||
else if (xt.lstName[i].CompareTo("UpdateDT") == 0)
|
||||
continue;
|
||||
else if (xt.lstName[i].CompareTo("Revision") == 0)
|
||||
continue;
|
||||
else if (xt.lstName[i].CompareTo("Description") == 0)
|
||||
continue;
|
||||
|
||||
strQueryInfo += strAddModelInfo[i];
|
||||
}
|
||||
|
||||
strSubTable[iSet] = strName + " AS " + strSubAs[iSet] + ",";
|
||||
|
||||
iSet++;
|
||||
}
|
||||
|
||||
strQueryInfo = strQueryInfo.Remove(strQueryInfo.Length - 1, 1);
|
||||
|
||||
strQueryInfo +=
|
||||
" FROM ";
|
||||
|
||||
foreach (string strSubT in strSubTable)
|
||||
{
|
||||
if (strSubT.Length > 0)
|
||||
strQueryInfo += strSubT;
|
||||
}
|
||||
|
||||
strQueryInfo +=
|
||||
" PROD_ModelParent AS B, " +
|
||||
"PROD_ModelChild AS A INNER JOIN PROD_ModelParent C ON C.PrtProdNo = A.PrtProdNo" +
|
||||
" WHERE A.ProdNo = '" + strProdNo + "' AND B.PrtProdNo = A.PrtProdNo ";
|
||||
|
||||
iSet = 0;
|
||||
foreach (string strSubT in strSubTable)
|
||||
{
|
||||
if (strSubT.Length > 0)
|
||||
strQueryInfo += "AND B.PrtProdNo = " + strSubAs[iSet] + ".PrtProdNo ";
|
||||
|
||||
iSet++;
|
||||
}
|
||||
|
||||
strQueryInfo += ";";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
|
||||
public string[] GetProcessPPITableList(int iPos, ServerInfo getServerInfo, XTableInfo getSchemaTableInfo)
|
||||
{
|
||||
//int iGetProcessCode = getServerInfo.ConnectInfo[iPos].Item4;
|
||||
|
||||
string[] strPPITableList = null;
|
||||
|
||||
/*IEnumerable<InfoProcess> queryFindProcessInfo =
|
||||
from Process in getServerInfo.ProcessInfo
|
||||
where Process.nNum == (iPos + 1)
|
||||
select Process;
|
||||
|
||||
foreach (InfoProcess fpi in queryFindProcessInfo)
|
||||
{
|
||||
//Find Process Info
|
||||
strPPITableList = fpi.strPreviousProcessInquiryTableName.Split(',');
|
||||
|
||||
break;
|
||||
}*/
|
||||
|
||||
return strPPITableList;
|
||||
}
|
||||
|
||||
public SqlCommand[] InsertLogData(
|
||||
ref string strOutLogKey,
|
||||
string strSetAddLogKey,
|
||||
Int64 SetNumber,
|
||||
|
||||
string strTestID,
|
||||
int iProcNum,
|
||||
DataSet dsPalletInfo,
|
||||
|
||||
string strFilePath,
|
||||
byte[] ucDataArray,
|
||||
|
||||
ushort usPalletIndex = ushort.MaxValue,
|
||||
string strSetPalletNumber = "",
|
||||
string strSetPalletID = "",
|
||||
string strSetPIndex = "",
|
||||
string strSeProdNo = "",
|
||||
string strSetProdID = "",
|
||||
|
||||
int iSetStatus = 0)
|
||||
{
|
||||
SqlCommand[] cmd = new SqlCommand[2];
|
||||
|
||||
strOutLogKey = string.Empty;
|
||||
strOutLogKey = "";
|
||||
|
||||
string strNullPath = "NULL";
|
||||
byte[] ucNullByte = new byte[1];
|
||||
ucNullByte[0] = 0x01;
|
||||
|
||||
if (dsPalletInfo != null)
|
||||
{
|
||||
bool hasRows = dsPalletInfo.Tables.Cast<DataTable>().Any(table => table.Rows.Count != 0);
|
||||
|
||||
if (hasRows)
|
||||
{
|
||||
string strPalletNumber = string.Empty;
|
||||
string strPalletID = string.Empty;
|
||||
|
||||
string strPIndex = string.Empty;
|
||||
string strProdNo = string.Empty;
|
||||
string strProdID = string.Empty;
|
||||
|
||||
if (usPalletIndex == ushort.MaxValue)
|
||||
{
|
||||
strPalletNumber = strSetPalletNumber;
|
||||
strPalletID = strSetPalletID;
|
||||
|
||||
strPIndex = strSetPIndex;
|
||||
strProdNo = strSeProdNo;
|
||||
strProdID = strSetProdID;
|
||||
}
|
||||
else
|
||||
{
|
||||
int iAccessPos = 0;
|
||||
|
||||
if (usPalletIndex != ushort.MaxValue)
|
||||
iAccessPos = usPalletIndex - 1;
|
||||
|
||||
strPalletNumber = dsPalletInfo.Tables[0].Rows[iAccessPos]["PalletNumber"].ToString();
|
||||
strPalletID = dsPalletInfo.Tables[0].Rows[iAccessPos]["PalletID"].ToString();
|
||||
|
||||
strPIndex = dsPalletInfo.Tables[0].Rows[iAccessPos]["PIndex"].ToString();
|
||||
strProdNo = dsPalletInfo.Tables[0].Rows[iAccessPos]["ProdNo"].ToString();
|
||||
strProdID = dsPalletInfo.Tables[0].Rows[iAccessPos]["ProdID"].ToString();
|
||||
}
|
||||
|
||||
strPalletNumber = strPalletNumber.Trim();
|
||||
strPalletID = strPalletID.Trim();
|
||||
|
||||
strPIndex = strPIndex.Trim();
|
||||
strProdNo = strProdNo.Trim();
|
||||
strProdID = strProdID.Trim();
|
||||
|
||||
cmd[0] = new SqlCommand("INSERT INTO HIST_TestResultData_" + iProcNum.ToString() + " (LogAccessKey, ProcNo, PalletNumber, PalletID, PIndex, ProdNo, ProdID, TestID, LogDataPath, LogData, Status) VALUES (@LogAccessKey, @ProcNo, @PalletNumber, @PalletID, @PIndex, @ProdNo, @ProdID, @TestID, @LogDataPath, @LogData, @Status)");
|
||||
cmd[1] = new SqlCommand("INSERT INTO HIST_TestResultData (LogAccessKey, ProcNo, PalletNumber, PalletID, PIndex, ProdNo, ProdID, TestID, LogDataPath, LogData, Status) VALUES (@LogAccessKey, @ProcNo, @PalletNumber, @PalletID, @PIndex, @ProdNo, @ProdID, @TestID, @LogDataPath, @LogData, @Status)");
|
||||
|
||||
if (strSetAddLogKey.Length == 0)
|
||||
strOutLogKey = SetNumber.ToString() + "-" + iProcNum.ToString();
|
||||
else
|
||||
strOutLogKey = SetNumber.ToString() + "-" + iProcNum.ToString() + "-" + strSetAddLogKey;
|
||||
|
||||
SqlParameter param0 = new SqlParameter("@LogAccessKey", SqlDbType.NVarChar, 64);
|
||||
param0.Value = strOutLogKey;
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
/*
|
||||
* ProcNo : 공정 코드 180 ~ 290
|
||||
*/
|
||||
param0 = new SqlParameter("@ProcNo", SqlDbType.BigInt);
|
||||
param0.Value = iProcNum;
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
param0 = new SqlParameter("@PalletNumber", SqlDbType.NVarChar, 20);
|
||||
param0.Value = strPalletNumber;
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
param0 = new SqlParameter("@PalletID", SqlDbType.NVarChar, 30);
|
||||
param0.Value = strPalletID;
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
param0 = new SqlParameter("@PIndex", SqlDbType.TinyInt);
|
||||
param0.Value = Convert.ToByte(strPIndex);
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
param0 = new SqlParameter("@ProdNo", SqlDbType.NVarChar, 30);
|
||||
param0.Value = strProdNo;
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
param0 = new SqlParameter("@ProdID", SqlDbType.NVarChar, 50);
|
||||
param0.Value = strProdID;
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
/*
|
||||
* TestID 공정 위치별 ID
|
||||
*/
|
||||
param0 = new SqlParameter("@TestID", SqlDbType.NVarChar, 20);
|
||||
param0.Value = strTestID;
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
param0 = new SqlParameter("@LogDataPath", SqlDbType.NVarChar, 256);
|
||||
param0.Value = strFilePath;
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
param0 = new SqlParameter("@LogData", SqlDbType.VarBinary, -1);
|
||||
param0.Value = ucDataArray; // byte[]로 지정함
|
||||
cmd[0].Parameters.Add(param0);
|
||||
|
||||
param0 = new SqlParameter("@Status", SqlDbType.TinyInt);
|
||||
param0.Value = iSetStatus;
|
||||
cmd[0].Parameters.Add(param0);
|
||||
//
|
||||
//
|
||||
SqlParameter param1 = new SqlParameter("@LogAccessKey", SqlDbType.NVarChar, 64);
|
||||
param1.Value = strOutLogKey;
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
/*
|
||||
* ProcNo : 공정 코드 180 ~ 290
|
||||
*/
|
||||
param1 = new SqlParameter("@ProcNo", SqlDbType.BigInt);
|
||||
param1.Value = iProcNum;
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
param1 = new SqlParameter("@PalletNumber", SqlDbType.NChar, 20);
|
||||
param1.Value = strPalletNumber;
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
param1 = new SqlParameter("@PalletID", SqlDbType.NChar, 30);
|
||||
param1.Value = strPalletID;
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
param1 = new SqlParameter("@PIndex", SqlDbType.TinyInt);
|
||||
param1.Value = Convert.ToByte(strPIndex);
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
param1 = new SqlParameter("@ProdNo", SqlDbType.NChar, 30);
|
||||
param1.Value = strProdNo;
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
param1 = new SqlParameter("@ProdID", SqlDbType.NChar, 50);
|
||||
param1.Value = strProdID;
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
/*
|
||||
* TestID 공정 위치별 ID
|
||||
*/
|
||||
param1 = new SqlParameter("@TestID", SqlDbType.NChar, 20);
|
||||
param1.Value = strTestID;
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
param1 = new SqlParameter("@LogDataPath", SqlDbType.NVarChar, 256);
|
||||
param1.Value = strNullPath;
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
param1 = new SqlParameter("@LogData", SqlDbType.VarBinary, -1);
|
||||
param1.Value = ucNullByte; // byte[]로 지정함
|
||||
cmd[1].Parameters.Add(param1);
|
||||
|
||||
param1 = new SqlParameter("@Status", SqlDbType.TinyInt);
|
||||
param1.Value = iSetStatus;
|
||||
cmd[1].Parameters.Add(param1);
|
||||
}
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
public string QueryMakePPIInfo(string strTableName, string strProdNo, string strPalletID)
|
||||
{
|
||||
string strQueryInfo = string.Empty;
|
||||
|
||||
//오늘 부터 10일 이내 데이터만 필요시
|
||||
strQueryInfo = "SELECT A.PalletID, A.PIndex, A.ProdID, A.Result AS RESULT, A.UpdateDT " +
|
||||
"FROM " + strTableName + " AS A " +
|
||||
"INNER JOIN" +
|
||||
"(" +
|
||||
"SELECT MAX(UpdateDT) AS LAST_DATE, B.ProdID " +
|
||||
"FROM " + strTableName + " AS B WHERE ProdID = '" + strProdNo + "' " +
|
||||
"GROUP BY ProdID" +
|
||||
") AS SUB " +
|
||||
"ON A.UpdateDT = SUB.LAST_DATE " +
|
||||
//"AND SUB.LAST_DATE BETWEEN CONVERT(VARCHAR, GETDATE() - 10, 112) AND CONVERT(VARCHAR, GETDATE(), 112) " +
|
||||
"AND A.ProdID = SUB.ProdID " +
|
||||
"AND A.PalletID = '" + strPalletID + "';";
|
||||
/*
|
||||
if (strPalletID.Length > 0 && iPalletIndex > 0)
|
||||
{
|
||||
strQueryInfo = "SELECT A.PalletID, A.PIndex, A.ProdID, A.Result AS RESULT, A.UpdateDT " +
|
||||
"FROM " + strTableName + " AS A " +
|
||||
"INNER JOIN" +
|
||||
"(" +
|
||||
"SELECT MAX(UpdateDT) AS LAST_DATE, B.ProdID " +
|
||||
"FROM " + strTableName + " AS B WHERE ProdID = '" + strProdNo + "' " +
|
||||
"GROUP BY ProdID" +
|
||||
") AS SUB " +
|
||||
"ON A.UpdateDT = SUB.LAST_DATE " +
|
||||
"AND SUB.LAST_DATE BETWEEN CONVERT(VARCHAR, GETDATE() - 15, 112) AND CONVERT(VARCHAR, GETDATE(), 112) " +
|
||||
"AND A.ProdID = SUB.ProdID " +
|
||||
"AND A.PalletID = '" + strPalletID + "';";
|
||||
}
|
||||
else
|
||||
{
|
||||
strQueryInfo = "SELECT A.PalletID, A.PIndex, A.ProdID, A.Result AS RESULT, A.UpdateDT " +
|
||||
"FROM " + strTableName + " AS A " +
|
||||
"INNER JOIN" +
|
||||
"(" +
|
||||
"SELECT MAX(UpdateDT) AS LAST_DATE, B.ProdID " +
|
||||
"FROM " + strTableName + " AS B WHERE ProdID = '" + strProdNo + "' " +
|
||||
"GROUP BY ProdID" +
|
||||
") AS SUB " +
|
||||
"ON A.UpdateDT = SUB.LAST_DATE " +
|
||||
"AND SUB.LAST_DATE BETWEEN CONVERT(VARCHAR, GETDATE() - 15, 112) AND CONVERT(VARCHAR, GETDATE(), 112) " +
|
||||
"AND A.ProdID = SUB.ProdID";
|
||||
}
|
||||
*/
|
||||
|
||||
return strQueryInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,660 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Net;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
|
||||
namespace SystemX.Common.Protocol.SIA
|
||||
{
|
||||
using ParamElement = Tuple<SqlDbType, int, byte, byte>;
|
||||
|
||||
public class HISTTesterSummary
|
||||
{
|
||||
public string StationName { set; get; }
|
||||
public string TestType { set; get; }
|
||||
public string Version { set; get; }
|
||||
public string ProdCode { set; get; }
|
||||
public int TestListFileNo { set; get; }
|
||||
public int TestListVariantNo { set; get; }
|
||||
public string TestListCntID { set; get; }
|
||||
|
||||
public int StepVersion { set; get; }
|
||||
public string Host { set; get; }
|
||||
public string Section { set; get; }
|
||||
public string ProdNoC { set; get; }
|
||||
public string ProdNoP { set; get; }
|
||||
public string TestCode { set; get; }
|
||||
public string TestListFileName { set; get; }
|
||||
public string ProductID { set; get; }
|
||||
public string Result { set; get; }
|
||||
public string Duration { set; get; }
|
||||
public DateTime TestDT { set; get; }
|
||||
}
|
||||
|
||||
public class HISTLogSummary
|
||||
{
|
||||
public Int64 AccessStart { set; get; }
|
||||
public Int64 AccessEnd { set; get; }
|
||||
public Int64 LogNo { set; get; }
|
||||
public int LogCount { set; get; }
|
||||
public string StationName { set; get; }
|
||||
public string TestType { set; get; }
|
||||
public string Version { set; get; }
|
||||
public string ProdCode { set; get; }
|
||||
public int TestListFileNo { set; get; }
|
||||
public int TestListVariantNo { set; get; }
|
||||
public string TestListCntID { set; get; }
|
||||
|
||||
public int StepVersion { set; get; }
|
||||
public string Host { set; get; }
|
||||
public string Section { set; get; }
|
||||
public string ProdNoC { set; get; }
|
||||
public string ProdNoP { set; get; }
|
||||
public string TestCode { set; get; }
|
||||
public string TestListFileName { set; get; }
|
||||
public string ProductID { set; get; }
|
||||
public string Result { set; get; }
|
||||
public string Duration { set; get; }
|
||||
public DateTime TestDT { set; get; }
|
||||
}
|
||||
|
||||
public static class ParamSet
|
||||
{
|
||||
public static Dictionary<string, ParamElement> fParam= new Dictionary<string, ParamElement>();
|
||||
|
||||
public static void TesterSummaryField()
|
||||
{
|
||||
fParam.Clear();
|
||||
fParam = new Dictionary<string, ParamElement>();
|
||||
fParam.Add("StationName", new ParamElement(SqlDbType.NVarChar, 128, 0, 0));
|
||||
fParam.Add("TestType", new ParamElement(SqlDbType.NVarChar, 8, 0, 0));
|
||||
fParam.Add("Version", new ParamElement(SqlDbType.NVarChar, 4, 0, 0));
|
||||
fParam.Add("ProdCode", new ParamElement(SqlDbType.NVarChar, 4, 0, 0));
|
||||
fParam.Add("TestListFileNo", new ParamElement(SqlDbType.Int, 0, 0, 0));
|
||||
fParam.Add("TestListVariantNo", new ParamElement(SqlDbType.Int, 0, 0, 0));
|
||||
fParam.Add("TestListCntID", new ParamElement(SqlDbType.NVarChar, 256, 0, 0));
|
||||
fParam.Add("StepVersion", new ParamElement(SqlDbType.Int, 0, 0, 0));
|
||||
fParam.Add("HostID", new ParamElement(SqlDbType.NVarChar, 64, 0, 0));
|
||||
fParam.Add("Section", new ParamElement(SqlDbType.NVarChar, 64, 0, 0));
|
||||
fParam.Add("ProdNo_C", new ParamElement(SqlDbType.NVarChar, 32, 0, 0));
|
||||
fParam.Add("ProdNo_P", new ParamElement(SqlDbType.NVarChar, 32, 0, 0));
|
||||
fParam.Add("Testcode", new ParamElement(SqlDbType.NVarChar, 16, 0, 0));
|
||||
fParam.Add("TestListFileName", new ParamElement(SqlDbType.NVarChar, 256, 0, 0));
|
||||
fParam.Add("ProductID", new ParamElement(SqlDbType.NVarChar, 64, 0, 0));
|
||||
fParam.Add("Result", new ParamElement(SqlDbType.NVarChar, 16, 0, 0));
|
||||
fParam.Add("Duration", new ParamElement(SqlDbType.NVarChar, 16, 0, 0));
|
||||
fParam.Add("TestDT", new ParamElement(SqlDbType.DateTime2, 7, 0, 0));
|
||||
}
|
||||
|
||||
public static void LogSummaryField()
|
||||
{
|
||||
fParam.Clear();
|
||||
fParam = new Dictionary<string, ParamElement>();
|
||||
fParam.Add("AccessStart", new ParamElement(SqlDbType.BigInt, 0, 0, 0));
|
||||
fParam.Add("AccessEnd", new ParamElement(SqlDbType.BigInt, 0, 0, 0));
|
||||
fParam.Add("LogNo", new ParamElement(SqlDbType.BigInt, 0, 0, 0));
|
||||
fParam.Add("LogCount", new ParamElement(SqlDbType.Int, 0, 0, 0));
|
||||
fParam.Add("StationName", new ParamElement(SqlDbType.NVarChar, 128, 0, 0));
|
||||
fParam.Add("TestType", new ParamElement(SqlDbType.NVarChar, 8, 0, 0));
|
||||
fParam.Add("Version", new ParamElement(SqlDbType.NVarChar, 4, 0, 0));
|
||||
fParam.Add("ProdCode", new ParamElement(SqlDbType.NVarChar, 4, 0, 0));
|
||||
fParam.Add("TestListFileNo", new ParamElement(SqlDbType.Int, 0, 0, 0));
|
||||
fParam.Add("TestListVariantNo", new ParamElement(SqlDbType.Int, 0, 0, 0));
|
||||
fParam.Add("TestListCntID", new ParamElement(SqlDbType.NVarChar, 256, 0, 0));
|
||||
fParam.Add("StepVersion", new ParamElement(SqlDbType.Int, 0, 0, 0));
|
||||
fParam.Add("HostID", new ParamElement(SqlDbType.NVarChar, 64, 0, 0));
|
||||
fParam.Add("Section", new ParamElement(SqlDbType.NVarChar, 64, 0, 0));
|
||||
fParam.Add("ProdNo_C", new ParamElement(SqlDbType.NVarChar, 32, 0, 0));
|
||||
fParam.Add("ProdNo_P", new ParamElement(SqlDbType.NVarChar, 32, 0, 0));
|
||||
fParam.Add("Testcode", new ParamElement(SqlDbType.NVarChar, 16, 0, 0));
|
||||
fParam.Add("TestListFileName", new ParamElement(SqlDbType.NVarChar, 256, 0, 0));
|
||||
fParam.Add("ProductID", new ParamElement(SqlDbType.NVarChar, 64, 0, 0));
|
||||
fParam.Add("Result", new ParamElement(SqlDbType.NVarChar, 16, 0, 0));
|
||||
fParam.Add("Duration", new ParamElement(SqlDbType.NVarChar, 16, 0, 0));
|
||||
fParam.Add("TestDT", new ParamElement(SqlDbType.DateTime2, 7, 0, 0));
|
||||
}
|
||||
|
||||
public static void TestResultField()
|
||||
{
|
||||
fParam.Clear();
|
||||
fParam = new Dictionary<string, ParamElement>();
|
||||
fParam.Add("AccessKey", new ParamElement(SqlDbType.BigInt, 0, 0, 0));
|
||||
fParam.Add("StepID", new ParamElement(SqlDbType.BigInt, 0, 0, 0));
|
||||
fParam.Add("MeasVal", new ParamElement(SqlDbType.Decimal, 0, 15, 5));
|
||||
fParam.Add("MeasValStr", new ParamElement(SqlDbType.NVarChar, 1024, 0, 0));
|
||||
fParam.Add("Message", new ParamElement(SqlDbType.NVarChar, 2048, 0, 0));
|
||||
fParam.Add("GlobalMin", new ParamElement(SqlDbType.NVarChar, 1024, 0, 0));
|
||||
fParam.Add("GlobalMax", new ParamElement(SqlDbType.NVarChar, 1024, 0, 0));
|
||||
fParam.Add("Result", new ParamElement(SqlDbType.NVarChar, 16, 0, 0));
|
||||
fParam.Add("SpentTime", new ParamElement(SqlDbType.NVarChar, 64, 0, 0));
|
||||
fParam.Add("DataDT", new ParamElement(SqlDbType.DateTime2, 7, 0, 0));
|
||||
}
|
||||
|
||||
public static SqlParameter GetMakeSqlParameterInfo(Dictionary<string, ParamElement> refField, string strSetName, object objValue)
|
||||
{
|
||||
if (refField.ContainsKey(strSetName))
|
||||
{
|
||||
SqlParameter param = null;
|
||||
|
||||
if (refField[strSetName].Item2 != 0)
|
||||
param = new SqlParameter("@" + strSetName, refField[strSetName].Item1, refField[strSetName].Item2);
|
||||
else
|
||||
param = new SqlParameter("@" + strSetName, refField[strSetName].Item1);
|
||||
|
||||
if (refField[strSetName].Item1 == SqlDbType.Decimal)
|
||||
{
|
||||
param.Precision = refField[strSetName].Item3;
|
||||
param.Scale = refField[strSetName].Item4;
|
||||
}
|
||||
|
||||
param.Value = objValue;
|
||||
return param;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LogParamInfo
|
||||
{
|
||||
public static readonly int MessageLength = 2048;
|
||||
public static readonly int MessageValLength = 1024;
|
||||
|
||||
public static string STEP = "";
|
||||
public static string POSITION = "";
|
||||
public static string MO = "";
|
||||
public static string FNC_NAME = "";
|
||||
public static string MIN = "";
|
||||
public static string MEASURE = "";
|
||||
public static string MAX = "";
|
||||
public static string DIM = "";
|
||||
public static string CHECK = "";
|
||||
public static string SPENT_TIME = "";
|
||||
public static string INFO = "";
|
||||
|
||||
public static bool GLOBAL_SPEC = false;
|
||||
public static string VRFY_MIN = "";
|
||||
public static string VRFY_MAX = "";
|
||||
}
|
||||
|
||||
public class CustomProtocol_ : BASE_PROTOCOL
|
||||
{
|
||||
public CustomProtocol_() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public CustomProtocol_(ushort usGetCommnad, ushort usGetSubCommand) : base(usGetCommnad, usGetSubCommand)
|
||||
{
|
||||
}
|
||||
|
||||
public CustomProtocol_(PROTOCOL_CODE SET_CODE) : base(SET_CODE)
|
||||
{
|
||||
}
|
||||
|
||||
public string CheckTestListUpdate(string strProdC, string strTestCode, string strTestType, string strVersion, string strProdCode)
|
||||
{
|
||||
StringBuilder sbSetQuery = new StringBuilder();
|
||||
|
||||
/*
|
||||
sbSetQuery.Append("SELECT A.TestListNo, A.ProdNo_C, B.ProdNo_P, B.UpdateDT, D.TestCode, " +
|
||||
"B.TestType, B.Version, B.ProdCode FROM PROD_Release AS A WITH(NOLOCK) ");
|
||||
*/
|
||||
|
||||
sbSetQuery.Append("SELECT A.VariantNo AS 'TestListNo', A.ProdNo_C, B.ProdNo_P, B.UpdateDT, D.TestCode, " +
|
||||
"E.TestType, E.Version, E.ProdCode, B.TestListFileNo, A.VariantNo, E.UpdateDT AS 'TestListFileUpdateDT' FROM PROD_Release AS A WITH(NOLOCK) ");
|
||||
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [PROD_Variant] WITH(NOLOCK)) AS B ");
|
||||
sbSetQuery.Append("ON A.VariantNo = B.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [PROD_Group] WITH(NOLOCK)) AS C ");
|
||||
sbSetQuery.Append("ON B.GroupNo = C.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [STAT_TestCode] WITH(NOLOCK)) AS D ");
|
||||
sbSetQuery.Append("ON A.TestCodeNo = D.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [STOR_TestListFile] WITH(NOLOCK)) AS E ");
|
||||
sbSetQuery.Append("ON B.TestListFileNo = E.No ");
|
||||
|
||||
sbSetQuery.Append("WHERE A.ProdNo_C = '" + strProdC + "' ");
|
||||
if (strTestCode.Length > 0)
|
||||
sbSetQuery.Append("AND D.TestCode = '" + strTestCode + "' ");
|
||||
if (strTestType.Length > 0)
|
||||
sbSetQuery.Append("AND E.TestType = '" + strTestType + "' ");
|
||||
if (strVersion.Length > 0)
|
||||
sbSetQuery.Append("AND E.Version = '" + strVersion + "' ");
|
||||
if (strProdCode.Length > 0)
|
||||
sbSetQuery.Append("AND E.ProdCode = '" + strProdCode + "' ");
|
||||
|
||||
return sbSetQuery.ToString();
|
||||
|
||||
/*
|
||||
string[] strGetTestListFindInfo = new string[3];
|
||||
strGetTestListFindInfo[0] = strTestType;
|
||||
strGetTestListFindInfo[1] = strVersion;
|
||||
strGetTestListFindInfo[2] = strProdCode;
|
||||
|
||||
bool bFirstAppend = false;
|
||||
int iParameterCnt = 0;
|
||||
for (int i = 0; i < strGetTestListFindInfo.Length; i++)
|
||||
{
|
||||
if (strGetTestListFindInfo[i].Length > 0)
|
||||
{
|
||||
iParameterCnt++;
|
||||
|
||||
if (bFirstAppend == false)
|
||||
{
|
||||
bFirstAppend = true;
|
||||
|
||||
sbSetQuery.Append("WHERE ");
|
||||
}
|
||||
|
||||
if (iParameterCnt > 1)
|
||||
sbSetQuery.Append("AND ");
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
sbSetQuery.Append("TestType = '" + strGetTestListFindInfo[i] + "' ");
|
||||
break;
|
||||
case 1:
|
||||
sbSetQuery.Append("Version = '" + strGetTestListFindInfo[i] + "' ");
|
||||
break;
|
||||
case 2:
|
||||
sbSetQuery.Append("ProdCode = '" + strGetTestListFindInfo[i] + "' ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
sbSetQuery.Append(") AS B ");
|
||||
|
||||
sbSetQuery.Append("ON B.No = A.TestListNo ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM PROD_Group AS Y WITH(NOLOCK)) AS C ");
|
||||
sbSetQuery.Append("ON C.No = B.GroupNo ");
|
||||
|
||||
if (strTestCode.Length > 0)
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM STAT_TestCode AS Z WITH(NOLOCK) WHERE Z.TestCode = '" + strTestCode + "') AS D ");
|
||||
else
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM STAT_TestCode AS Z WITH(NOLOCK)) AS D ");
|
||||
|
||||
sbSetQuery.Append("ON A.ProdNo_C = '" + strProdC + "' AND B.No = A.TestListNo AND D.No = A.TestCodeNo;");
|
||||
*/
|
||||
|
||||
return sbSetQuery.ToString();
|
||||
}
|
||||
|
||||
public string QueryFindTestList(PROCESS_PACKET getPaket, bool bJustCheck = false)
|
||||
{
|
||||
StringBuilder sbSetQuery = new StringBuilder();
|
||||
|
||||
/*
|
||||
if (bJustCheck)
|
||||
{
|
||||
sbSetQuery.Append("SELECT A.ProdNo_C, B.ProdNo_P, B.UpdateDT, D.TestCode, D.Gate1, D.Gate2, " +
|
||||
"B.FileName, A.RegUserComment, E.Description, C.GroupName, C.ModelName, " +
|
||||
"A.TestListNo, A.Config, " +
|
||||
"B.TestType, B.Version, B.ProdCode, B.UseTLPosition FROM PROD_Release AS A ");
|
||||
}
|
||||
else
|
||||
{
|
||||
sbSetQuery.Append("SELECT A.ProdNo_C, B.ProdNo_P, B.UpdateDT, D.TestCode, D.Gate1, D.Gate2, " +
|
||||
"B.FileName, A.RegUserComment, E.Description, C.GroupName, C.ModelName, " +
|
||||
"A.TestListNo, A.Config, " +
|
||||
"B.TestType, B.Version, B.ProdCode, B.TestListData, B.UseTLPosition FROM PROD_Release AS A ");
|
||||
}
|
||||
*/
|
||||
|
||||
if (bJustCheck)
|
||||
{
|
||||
sbSetQuery.Append("SELECT A.ProdNo_C, B.ProdNo_P, B.UpdateDT, D.TestCode, D.Gate1, D.Gate2, " +
|
||||
"E.FileName, A.RegUserComment, E.Description, C.GroupName, C.ModelName, " +
|
||||
"A.VariantNo AS 'TestListNo', A.Config, " +
|
||||
"E.TestType, E.Version, E.ProdCode, B.UseTLPosition, B.TestListFileNo, E.UpdateDT AS 'TestListFileUpdateDT', A.VariantNo FROM [PROD_Release] AS A WITH(NOLOCK) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
sbSetQuery.Append("SELECT A.ProdNo_C, B.ProdNo_P, B.UpdateDT, D.TestCode, D.Gate1, D.Gate2, " +
|
||||
"E.FileName, A.RegUserComment, E.Description, C.GroupName, C.ModelName, " +
|
||||
"A.VariantNo AS 'TestListNo', A.Config, " +
|
||||
"E.TestType, E.Version, E.ProdCode, E.TestListData, B.UseTLPosition, B.TestListFileNo, E.UpdateDT AS 'TestListFileUpdateDT', A.VariantNo FROM [PROD_Release] AS A WITH(NOLOCK) ");
|
||||
}
|
||||
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [PROD_Variant] WITH(NOLOCK)) AS B ");
|
||||
sbSetQuery.Append("ON A.VariantNo = B.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [PROD_Group] WITH(NOLOCK)) AS C ");
|
||||
sbSetQuery.Append("ON B.GroupNo = C.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [STAT_TestCode] WITH(NOLOCK)) AS D ");
|
||||
sbSetQuery.Append("ON A.TestCodeNo = D.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [STOR_TestListFile] WITH(NOLOCK)) AS E ");
|
||||
sbSetQuery.Append("ON B.TestListFileNo = E.No ");
|
||||
sbSetQuery.Append("WHERE A.ProdNo_C = '" + getPaket.objProdNo_C[0].Data + "' ");
|
||||
|
||||
if (getPaket.objTestCode[0].Data.Length > 0)
|
||||
sbSetQuery.Append("AND D.TestCode = '" + getPaket.objTestCode[0].Data + "' ");
|
||||
if (getPaket.objTestType[0].Data.Length > 0)
|
||||
sbSetQuery.Append("AND E.TestType = '" + getPaket.objTestType[0].Data + "' ");
|
||||
if (getPaket.objTestListFileVersion[0].Data.Length > 0)
|
||||
sbSetQuery.Append("AND E.Version = '" + getPaket.objTestListFileVersion[0].Data + "' ");
|
||||
if (getPaket.objProductionCode[0].Data.Length > 0)
|
||||
sbSetQuery.Append("AND E.ProdCode = '" + getPaket.objProductionCode[0].Data + "' ");
|
||||
|
||||
return sbSetQuery.ToString();
|
||||
|
||||
/*
|
||||
string[] strGetTestListFindInfo = new string[3];
|
||||
strGetTestListFindInfo[0] = getPaket.objTestType[0].Data;
|
||||
strGetTestListFindInfo[1] = getPaket.objTestListFileVersion[0].Data;
|
||||
strGetTestListFindInfo[2] = getPaket.objProductionCode[0].Data;
|
||||
|
||||
bool bFirstAppend = false;
|
||||
int iParameterCnt = 0;
|
||||
for (int i = 0; i < strGetTestListFindInfo.Length; i++)
|
||||
{
|
||||
if (strGetTestListFindInfo[i].Length > 0)
|
||||
{
|
||||
iParameterCnt++;
|
||||
|
||||
if (bFirstAppend == false)
|
||||
{
|
||||
bFirstAppend = true;
|
||||
|
||||
sbSetQuery.Append("WHERE ");
|
||||
}
|
||||
|
||||
if (iParameterCnt > 1)
|
||||
sbSetQuery.Append("AND ");
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
sbSetQuery.Append("TestType = '" + strGetTestListFindInfo[i] + "' ");
|
||||
break;
|
||||
case 1:
|
||||
sbSetQuery.Append("Version = '" + strGetTestListFindInfo[i] + "' ");
|
||||
break;
|
||||
case 2:
|
||||
sbSetQuery.Append("ProdCode = '" + strGetTestListFindInfo[i] + "' ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public string QuerySelectTestListData(PROCESS_PACKET getPaket, int nLoadPosition)
|
||||
{
|
||||
StringBuilder sbSetQuery = new StringBuilder();
|
||||
|
||||
sbSetQuery.Append("SELECT A.ProdNo_C, B.ProdNo_P, B.UpdateDT, E.UpdateDT AS 'TestListFileUpdateDT', D.TestCode, D.Gate1, D.Gate2, " +
|
||||
"E.FileName, A.RegUserComment, E.Description, C.GroupName, C.ModelName, " +
|
||||
"A.VariantNo, A.VariantNo AS 'TestListNo', A.Config, " +
|
||||
"E.TestType, E.Version, E.ProdCode, ");
|
||||
|
||||
switch (nLoadPosition)
|
||||
{
|
||||
case 1: sbSetQuery.Append("F.TestListData1 AS 'TestListData', "); break;
|
||||
case 2: sbSetQuery.Append("F.TestListData2 AS 'TestListData', "); break;
|
||||
case 3: sbSetQuery.Append("F.TestListData3 AS 'TestListData', "); break;
|
||||
case 4: sbSetQuery.Append("F.TestListData4 AS 'TestListData', "); break;
|
||||
case 5: sbSetQuery.Append("F.TestListData5 AS 'TestListData', "); break;
|
||||
case 6: sbSetQuery.Append("F.TestListData6 AS 'TestListData', "); break;
|
||||
case 7: sbSetQuery.Append("F.TestListData7 AS 'TestListData', "); break;
|
||||
case 8: sbSetQuery.Append("F.TestListData8 AS 'TestListData', "); break;
|
||||
case 9: sbSetQuery.Append("F.TestListData9 AS 'TestListData', "); break;
|
||||
case 10: sbSetQuery.Append("F.TestListData10 AS 'TestListData', "); break;
|
||||
}
|
||||
|
||||
sbSetQuery.Append("B.TestListFileNo, B.UseTLPosition FROM [PROD_Release] AS A WITH(NOLOCK) ");
|
||||
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [PROD_Variant] WITH(NOLOCK)) AS B ");
|
||||
sbSetQuery.Append("ON A.VariantNo = B.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [PROD_Group] WITH(NOLOCK)) AS C ");
|
||||
sbSetQuery.Append("ON B.GroupNo = C.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [STAT_TestCode] WITH(NOLOCK)) AS D ");
|
||||
sbSetQuery.Append("ON A.TestCodeNo = D.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [STOR_TestListFile] WITH(NOLOCK)) AS E ");
|
||||
sbSetQuery.Append("ON B.TestListFileNo = E.No ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM [HIST_TestListFile] WITH(NOLOCK)) AS F ");
|
||||
sbSetQuery.Append("ON B.TestListFileNo = F.TestListFileNo ");
|
||||
sbSetQuery.Append("WHERE A.ProdNo_C = '" + getPaket.objProdNo_C[0].Data + "' ");
|
||||
|
||||
if (getPaket.objTestCode[0].Data.Length > 0)
|
||||
sbSetQuery.Append("AND D.TestCode = '" + getPaket.objTestCode[0].Data + "' ");
|
||||
if (getPaket.objTestType[0].Data.Length > 0)
|
||||
sbSetQuery.Append("AND E.TestType = '" + getPaket.objTestType[0].Data + "' ");
|
||||
if (getPaket.objTestListFileVersion[0].Data.Length > 0)
|
||||
sbSetQuery.Append("AND E.Version = '" + getPaket.objTestListFileVersion[0].Data + "' ");
|
||||
if (getPaket.objProductionCode[0].Data.Length > 0)
|
||||
sbSetQuery.Append("AND E.ProdCode = '" + getPaket.objProductionCode[0].Data + "' ");
|
||||
|
||||
/*
|
||||
string[] strGetTestListFindInfo = new string[3];
|
||||
strGetTestListFindInfo[0] = getPaket.objTestType[0].Data;
|
||||
strGetTestListFindInfo[1] = getPaket.objTestListFileVersion[0].Data;
|
||||
strGetTestListFindInfo[2] = getPaket.objProductionCode[0].Data;
|
||||
|
||||
bool bFirstAppend = false;
|
||||
int iParameterCnt = 0;
|
||||
for (int i = 0; i < strGetTestListFindInfo.Length; i++)
|
||||
{
|
||||
if (strGetTestListFindInfo[i].Length > 0)
|
||||
{
|
||||
iParameterCnt++;
|
||||
|
||||
if (bFirstAppend == false)
|
||||
{
|
||||
bFirstAppend = true;
|
||||
|
||||
sbSetQuery.Append("WHERE ");
|
||||
}
|
||||
|
||||
if (iParameterCnt > 1)
|
||||
sbSetQuery.Append("AND ");
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
sbSetQuery.Append("TestType = '" + strGetTestListFindInfo[i] + "' ");
|
||||
break;
|
||||
case 1:
|
||||
sbSetQuery.Append("Version = '" + strGetTestListFindInfo[i] + "' ");
|
||||
break;
|
||||
case 2:
|
||||
sbSetQuery.Append("ProdCode = '" + strGetTestListFindInfo[i] + "' ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
sbSetQuery.Append(") AS B ");
|
||||
|
||||
sbSetQuery.Append("ON B.No = A.TestListNo ");
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM PROD_Group AS Y) AS C ");
|
||||
sbSetQuery.Append("ON C.No = B.GroupNo ");
|
||||
|
||||
sbSetQuery.Append("INNER JOIN(SELECT* FROM HIST_TestList) AS K ON K.TestListNo = A.TestListNo ");
|
||||
|
||||
if (getPaket.objTestCode[0].Data.Length > 0)
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM STAT_TestCode AS Z WHERE Z.TestCode = '" + getPaket.objTestCode[0].Data + "') AS D ");
|
||||
else
|
||||
sbSetQuery.Append("INNER JOIN(SELECT * FROM STAT_TestCode AS Z) AS D ");
|
||||
|
||||
sbSetQuery.Append("ON A.ProdNo_C = '" + getPaket.objProdNo_C[0].Data + "' AND B.No = A.TestListNo AND D.No = A.TestCodeNo;");
|
||||
*/
|
||||
|
||||
return sbSetQuery.ToString();
|
||||
}
|
||||
|
||||
public SqlCommand LoginInfoSummaryInsert(
|
||||
string strHostID,
|
||||
string strSection,
|
||||
bool bConnectState)
|
||||
{
|
||||
string columns = "TestType,Version,ProdCode,TestListFileNo,TestListVariantNo,StepVersion,HostID,Section,ProdNo_C,ProdNo_P,Testcode,TestListFileName,ProductID,Result,Duration";
|
||||
string values = string.Join(",", columns.Split(',').Select(c => string.Format("@{0}", c)));
|
||||
string sqlCommand = string.Format("INSERT INTO [HIST_TesterSummary] ({0}) VALUES ({1})", columns, values);
|
||||
|
||||
ParamSet.TesterSummaryField();
|
||||
|
||||
SqlCommand cmd = new SqlCommand(sqlCommand);
|
||||
|
||||
SqlParameter[] setParams = new SqlParameter[columns.Split(',').Count()];
|
||||
|
||||
setParams[0] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestType", "-");
|
||||
setParams[1] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Version", "-");
|
||||
setParams[2] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdCode", "-");
|
||||
setParams[3] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListFileNo", -1);
|
||||
setParams[4] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListVariantNo", -1);
|
||||
setParams[5] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "StepVersion", -1);
|
||||
setParams[6] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "HostID", strHostID);
|
||||
setParams[7] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Section", strSection);
|
||||
setParams[8] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdNo_C", "-");
|
||||
setParams[9] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdNo_P", "-");
|
||||
setParams[10] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Testcode", "-");
|
||||
setParams[11] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListFileName", "-");
|
||||
|
||||
if (bConnectState)
|
||||
setParams[12] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProductID", "PowerON");
|
||||
else
|
||||
setParams[12] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProductID", "PowerOFF");
|
||||
|
||||
setParams[13] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Result", "-");
|
||||
setParams[14] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Duration", "-");
|
||||
|
||||
cmd.Parameters.AddRange(setParams);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public SqlCommand QueryTestListInfoSummaryInsert(
|
||||
//Int64 No,
|
||||
string strHostID,
|
||||
string strSection,
|
||||
|
||||
string strTestListCntID,
|
||||
|
||||
int nResultType,
|
||||
|
||||
string strProdNo_C = "-",
|
||||
string strTestType = "-",
|
||||
string strVersion = "-",
|
||||
string strProdCode = "-",
|
||||
string strTestcode = "-",
|
||||
|
||||
int nTestListFileNo = -1,
|
||||
int nTestListVariantNo = -1,
|
||||
string strProdNo_P = "-",
|
||||
string strTestlistFile = "-")
|
||||
{
|
||||
string columns = "TestType,Version,ProdCode,TestListFileNo,TestListVariantNo,TestListCntID,StepVersion,HostID,Section,ProdNo_C,ProdNo_P,Testcode,TestListFileName,ProductID,Result,Duration";
|
||||
string values = string.Join(",", columns.Split(',').Select(c => string.Format("@{0}", c)));
|
||||
string sqlCommand = string.Format("INSERT INTO [HIST_TesterSummary] ({0}) VALUES ({1})", columns, values);
|
||||
|
||||
if (strProdNo_C.Length <= 0) strProdNo_C = "-";
|
||||
if (strTestType.Length <= 0) strTestType = "-";
|
||||
if (strVersion.Length <= 0) strVersion = "-";
|
||||
if (strProdCode.Length <= 0) strProdCode = "-";
|
||||
if (strTestcode.Length <= 0) strTestcode = "-";
|
||||
if (strProdNo_P.Length <= 0) strProdNo_P = "-";
|
||||
if (strTestlistFile.Length <= 0) strTestlistFile = "-";
|
||||
|
||||
ParamSet.TesterSummaryField();
|
||||
|
||||
SqlCommand cmd = new SqlCommand(sqlCommand);
|
||||
SqlParameter[] setParams = new SqlParameter[columns.Split(',').Count()];
|
||||
//setParams[0] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestID", No);
|
||||
setParams[0] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestType", strTestType);
|
||||
setParams[1] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Version", strVersion);
|
||||
setParams[2] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdCode", strProdCode);
|
||||
setParams[3] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListFileNo", nTestListFileNo);
|
||||
setParams[4] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListVariantNo", nTestListVariantNo);
|
||||
setParams[5] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListCntID", strTestListCntID);
|
||||
setParams[6] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "StepVersion", -1);
|
||||
setParams[7] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "HostID", strHostID);
|
||||
setParams[8] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Section", strSection);
|
||||
setParams[9] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdNo_C", strProdNo_C);
|
||||
setParams[10] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdNo_P", strProdNo_P);
|
||||
setParams[11] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Testcode", strTestcode);
|
||||
setParams[12] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListFileName", strTestlistFile);
|
||||
setParams[13] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProductID", "QUERY");
|
||||
|
||||
switch (nResultType)
|
||||
{
|
||||
case 0: setParams[14] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Result", "FAIL"); break;
|
||||
case 1: setParams[14] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Result", "FIND"); break;
|
||||
case 2: setParams[14] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Result", "CHECK"); break;
|
||||
case 3: setParams[14] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Result", "ERROR"); break;
|
||||
default: setParams[14] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Result", "-"); break;
|
||||
}
|
||||
|
||||
setParams[15] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Duration", "-");
|
||||
|
||||
cmd.Parameters.AddRange(setParams);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public SqlCommand LogDataSummaryInsert(HISTLogSummary itemSummary)
|
||||
{
|
||||
string columns = string.Empty;
|
||||
if(itemSummary.TestListCntID == string.Empty)
|
||||
columns = "StationName,TestType,Version,ProdCode,TestListFileNo,TestListVariantNo,StepVersion,HostID,Section,ProdNo_C,ProdNo_P,Testcode,TestListFileName,ProductID,Result,Duration,TestDT";
|
||||
else
|
||||
columns = "StationName,TestType,Version,ProdCode,TestListFileNo,TestListVariantNo,TestListCntID,StepVersion,HostID,Section,ProdNo_C,ProdNo_P,Testcode,TestListFileName,ProductID,Result,Duration,TestDT";
|
||||
|
||||
string values = string.Join(",", columns.Split(',').Select(c => string.Format("@{0}", c)));
|
||||
string sqlCommand = string.Format("INSERT INTO [HIST_LogSummary] ({0}) VALUES ({1})", columns, values);
|
||||
|
||||
ParamSet.LogSummaryField();
|
||||
|
||||
SqlCommand cmd = new SqlCommand(sqlCommand);
|
||||
|
||||
SqlParameter[] setParams = new SqlParameter[columns.Split(',').Count()];
|
||||
|
||||
if (itemSummary.TestListCntID == string.Empty)
|
||||
{
|
||||
setParams[0] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "StationName", itemSummary.StationName);
|
||||
setParams[1] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestType", itemSummary.TestType);
|
||||
setParams[2] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Version", itemSummary.Version);
|
||||
setParams[3] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdCode", itemSummary.ProdCode);
|
||||
setParams[4] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListFileNo", itemSummary.TestListFileNo);
|
||||
setParams[5] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListVariantNo", itemSummary.TestListVariantNo);
|
||||
setParams[6] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "StepVersion", itemSummary.StepVersion);
|
||||
setParams[7] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "HostID", itemSummary.Host);
|
||||
setParams[8] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Section", itemSummary.Section);
|
||||
setParams[9] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdNo_C", itemSummary.ProdNoC);
|
||||
setParams[10] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdNo_P", itemSummary.ProdNoP);
|
||||
setParams[11] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Testcode", itemSummary.TestCode);
|
||||
setParams[12] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListFileName", itemSummary.TestListFileName);
|
||||
setParams[13] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProductID", itemSummary.ProductID);
|
||||
setParams[14] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Result", itemSummary.Result);
|
||||
setParams[15] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Duration", itemSummary.Duration);
|
||||
setParams[16] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestDT", itemSummary.TestDT);
|
||||
}
|
||||
else
|
||||
{
|
||||
setParams[0] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "StationName", itemSummary.StationName);
|
||||
setParams[1] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestType", itemSummary.TestType);
|
||||
setParams[2] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Version", itemSummary.Version);
|
||||
setParams[3] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdCode", itemSummary.ProdCode);
|
||||
setParams[4] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListFileNo", itemSummary.TestListFileNo);
|
||||
setParams[5] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListVariantNo", itemSummary.TestListVariantNo);
|
||||
setParams[6] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListCntID", itemSummary.TestListCntID);
|
||||
setParams[7] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "StepVersion", itemSummary.StepVersion);
|
||||
setParams[8] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "HostID", itemSummary.Host);
|
||||
setParams[9] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Section", itemSummary.Section);
|
||||
setParams[10] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdNo_C", itemSummary.ProdNoC);
|
||||
setParams[11] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProdNo_P", itemSummary.ProdNoP);
|
||||
setParams[12] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Testcode", itemSummary.TestCode);
|
||||
setParams[13] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestListFileName", itemSummary.TestListFileName);
|
||||
setParams[14] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "ProductID", itemSummary.ProductID);
|
||||
setParams[15] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Result", itemSummary.Result);
|
||||
setParams[16] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "Duration", itemSummary.Duration);
|
||||
setParams[17] = ParamSet.GetMakeSqlParameterInfo(ParamSet.fParam, "TestDT", itemSummary.TestDT);
|
||||
}
|
||||
|
||||
cmd.Parameters.AddRange(setParams);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user