225 lines
6.7 KiB
C#
225 lines
6.7 KiB
C#
|
using System;
|
|||
|
using System.Data;
|
|||
|
using static iMESCore.Base.iMESConst;
|
|||
|
using static iMESCore.DataBase.iMESSql;
|
|||
|
using iMESCore.Settings;
|
|||
|
using Microsoft.VisualBasic.CompilerServices;
|
|||
|
using System.Data.Common;
|
|||
|
|
|||
|
namespace udScriptFunction_Customer
|
|||
|
{
|
|||
|
|
|||
|
public class clsScriptFunction : IDisposable
|
|||
|
{
|
|||
|
|
|||
|
// 2007/04/03,sammi.整合modUD.
|
|||
|
private AppSettings objSetting = new AppSettings();
|
|||
|
|
|||
|
private IDbConnection cnnTemp;
|
|||
|
private string strConnectionString; // Connection string
|
|||
|
private string strDataBaseType; // DataBase Type:oracle, mysql, access
|
|||
|
private string strMQType; // MessageQueue Type:TIBCO, MQSeries, MSMQ
|
|||
|
private int intGetMethod = 1; // 0.Simulation, 1.Production
|
|||
|
|
|||
|
private DataTable dtLotAttrib = null;
|
|||
|
private DataTable dtCompAttrib = null;
|
|||
|
private string strLotNo;
|
|||
|
private string strOPNo;
|
|||
|
private string strComponentNo;
|
|||
|
|
|||
|
private string strENGNo;
|
|||
|
private string strENGVersion;
|
|||
|
private string strRecipeNo;
|
|||
|
private string strRecipeVersion;
|
|||
|
private string strPropertyNo;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#region --- Property ---
|
|||
|
public string ConnectionString
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return strConnectionString;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public string DataBaseType
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return strDataBaseType;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public string MQType
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return strMQType;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 當intGetMethod 為 0 時 Function 本身必須自行 Return Value,當 1 時可依實際需求取得實際值
|
|||
|
public int GetMethod
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return intGetMethod;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
intGetMethod = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 部分之Function 需要提供LotNo的屬性
|
|||
|
public string LotNo
|
|||
|
{
|
|||
|
set
|
|||
|
{
|
|||
|
strLotNo = value;
|
|||
|
}
|
|||
|
}
|
|||
|
// 部分之Function 需要提供OPNo的屬性
|
|||
|
public string OPNo
|
|||
|
{
|
|||
|
set
|
|||
|
{
|
|||
|
strOPNo = value;
|
|||
|
}
|
|||
|
}
|
|||
|
// 部分之Function 需要提供OPNo的屬性
|
|||
|
public string ComponentNo
|
|||
|
{
|
|||
|
set
|
|||
|
{
|
|||
|
strComponentNo = value;
|
|||
|
}
|
|||
|
}
|
|||
|
// 部分之Function 需要提供ComponentAttrib
|
|||
|
public DataTable ComponentAttrib
|
|||
|
{
|
|||
|
set
|
|||
|
{
|
|||
|
dtCompAttrib = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 部分之Function 需要提供ComponentAttrib
|
|||
|
public DataTable LotAttrib
|
|||
|
{
|
|||
|
set
|
|||
|
{
|
|||
|
dtLotAttrib = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
// //Initial Object--------------------------------------------------------------------------------------------------------------------------------
|
|||
|
public clsScriptFunction()
|
|||
|
{
|
|||
|
// //Get database type
|
|||
|
strDataBaseType = objSetting.GetDataBaseType();
|
|||
|
// //Get connection string
|
|||
|
strConnectionString = objSetting.GetConnectionString(strDataBaseType);
|
|||
|
// //Get Message Queue Type
|
|||
|
strMQType = objSetting.GetMQType();
|
|||
|
}
|
|||
|
|
|||
|
#region IDisposable Support
|
|||
|
private bool disposedValue; // 偵測多餘的呼叫
|
|||
|
|
|||
|
// IDisposable
|
|||
|
protected virtual void Dispose(bool disposing)
|
|||
|
{
|
|||
|
if (!disposedValue)
|
|||
|
{
|
|||
|
if (disposing)
|
|||
|
{
|
|||
|
// TODO: 處置 Managed 狀態 (Managed 物件)。
|
|||
|
}
|
|||
|
|
|||
|
// 釋放 Unmanaged 資源 (Unmanaged 物件) 並覆寫下方的 Finalize()。
|
|||
|
if (objSetting != null)
|
|||
|
objSetting = null;
|
|||
|
// 將大型欄位設為 null。
|
|||
|
}
|
|||
|
disposedValue = true;
|
|||
|
}
|
|||
|
|
|||
|
// TODO: 只有當上方的 Dispose(disposing As Boolean) 具有要釋放 Unmanaged 資源的程式碼時,才覆寫 Finalize()。
|
|||
|
// Protected Overrides Sub Finalize()
|
|||
|
// ' 請勿變更這個程式碼。請將清除程式碼放在上方的 Dispose(disposing As Boolean) 中。
|
|||
|
// Dispose(False)
|
|||
|
// MyBase.Finalize()
|
|||
|
// End Sub
|
|||
|
|
|||
|
// Visual Basic 加入這個程式碼的目的,在於能正確地實作可處置的模式。
|
|||
|
public void Dispose()
|
|||
|
{
|
|||
|
// 請勿變更這個程式碼。請將清除程式碼放在上方的 Dispose(disposing As Boolean) 中。
|
|||
|
Dispose(true);
|
|||
|
// TODO: 覆寫上列 Finalize() 時,取消下行的註解狀態。
|
|||
|
// GC.SuppressFinalize(Me)
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
// 2018/05/22 OwenLiu, Mantis:0047207 Script Function同時支援標準迭代與個案客製
|
|||
|
// FunctionName 必須以 funSCC_ 作為名稱的前綴字串,才可以正常運作
|
|||
|
//public int funSCC_GetAPPreviousDate()
|
|||
|
//{
|
|||
|
|
|||
|
// int intResult = defInteger;
|
|||
|
// string strFunctionName = System.Reflection.MethodBase.GetCurrentMethod().Name;
|
|||
|
// string strSQL = string.Empty;
|
|||
|
// var datServerTime = DateTime.Now;
|
|||
|
|
|||
|
// try
|
|||
|
// {
|
|||
|
// // Simulation
|
|||
|
// if (intGetMethod == 0)
|
|||
|
// {
|
|||
|
// intResult = 1;
|
|||
|
// return intResult;
|
|||
|
// }
|
|||
|
|
|||
|
// // Production
|
|||
|
// // Create Connection
|
|||
|
// cnnTemp = CreateConnection_None(strConnectionString, strDataBaseType);
|
|||
|
// if (strDataBaseType.ToLower() == "oracle")
|
|||
|
// {
|
|||
|
// strSQL = "SELECT sysdate AS ServerTime FROM dual";
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// strSQL = "SELECT getdate() AS ServerTime";
|
|||
|
// }
|
|||
|
|
|||
|
|
|||
|
// using (DbDataReader drTemp = ExecuteSQLQuery_Reader(strSQL, cnnTemp))
|
|||
|
// {
|
|||
|
// if (drTemp.Read())
|
|||
|
// {
|
|||
|
// datServerTime = Conversions.ToDate(drTemp["ServerTime"]);
|
|||
|
// intResult = Conversions.ToInteger(datServerTime.AddDays(-1).ToString("yyyyMMdd"));
|
|||
|
// }
|
|||
|
// drTemp.Close();
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// throw;
|
|||
|
// }
|
|||
|
// finally
|
|||
|
// {
|
|||
|
// CloseConnection(cnnTemp);
|
|||
|
// }
|
|||
|
|
|||
|
// return intResult;
|
|||
|
|
|||
|
//}
|
|||
|
|
|||
|
}
|
|||
|
}
|