|
@@ -1,7 +1,7 @@
|
|
|
-using Oracle.ManagedDataAccess.Client;
|
|
|
-using System;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
+using System.Data.OracleClient;
|
|
|
using System.Runtime.InteropServices;
|
|
|
using System.Text;
|
|
|
|
|
@@ -63,7 +63,8 @@ namespace BenQGuru.eMES.DLLService
|
|
|
{
|
|
|
oErrMessage = "";
|
|
|
string[] param = new string[] { "", iResCode, iSN, "", "", "", oErrMessage };
|
|
|
- CallProcedure("CS_CHECKSTEPSNANDMACODE", ref param);
|
|
|
+ string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
|
|
|
+ CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
|
|
|
oErrMessage = param[6];
|
|
|
if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
return true;
|
|
@@ -174,7 +175,8 @@ namespace BenQGuru.eMES.DLLService
|
|
|
string omakeCode = "";
|
|
|
GetRcardMOInfo(iSN, out omakeCode, out oErrMessage);
|
|
|
string[] param = new string[] { iSN, omakeCode, oWIFI, oBT, oCode1, oCode2, oCdoe3, oErrMessage };
|
|
|
- CallProcedure("CS_GETADDRESSBYMAKECODE", ref param);
|
|
|
+ string[] ParamName = new string[] { "v_i_sncode", "v_i_macode", "v_o_mac", "v_o_bt", "v_o_code1", "v_o_code2", "v_o_code3", "v_o_errmsg" };
|
|
|
+ CallProcedure("CS_GETADDRESSBYMAKECODE", ParamName, ref param);
|
|
|
oWIFI = param[2];
|
|
|
oBT = param[3];
|
|
|
oCode1 = param[4];
|
|
@@ -219,7 +221,8 @@ namespace BenQGuru.eMES.DLLService
|
|
|
oID5 = "";
|
|
|
oErrMessage = "";
|
|
|
string[] param = new string[] { iSnCode, "", iIMEI1, iNetCode, oIMEI1, oIMEI2, "", oMEID, oNetCode, oPSN, oID1, oID2, oID3, oErrMessage };
|
|
|
- CallProcedure("CS_GETIMEIORNETCODERANGE", ref param);
|
|
|
+ string[] ParamName = new string[] { "v_i_sncode", "v_i_macode", "v_i_imei", "v_i_netcode", "v_o_imei1", "v_o_imei2", "v_o_imei3", "v_o_meid", "v_o_netcode", "v_o_psn", "v_o_id1", "v_o_id2", "v_o_id3", "v_o_errmsg" };
|
|
|
+ CallProcedure("CS_GETIMEIORNETCODERANGE", ParamName, ref param);
|
|
|
oIMEI1 = param[4];
|
|
|
oIMEI2 = param[5];
|
|
|
oMEID = param[7];
|
|
@@ -347,7 +350,7 @@ namespace BenQGuru.eMES.DLLService
|
|
|
string LineCode = "";
|
|
|
string CurrentStepName = "";
|
|
|
GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
|
|
|
- sql.Clear();
|
|
|
+ sql.Length = 0;
|
|
|
sql.Append("insert into MakeProcess(mp_id,mp_makecode,mp_maid, mp_mscode,mp_sncode,mp_stepcode,mp_stepname,");
|
|
|
sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode,mp_snstatus,mp_sncheckno,mp_snoutboxcode)");
|
|
|
sql.Append("select MakeProcess_seq.nextval, ma_code,ma_id,ms_code,ms_sncode,'" + CurrentStep + "','" + CurrentStepName + "',");
|
|
@@ -372,7 +375,8 @@ namespace BenQGuru.eMES.DLLService
|
|
|
{
|
|
|
oErrorMessage = "";
|
|
|
string[] param = new string[] { iSN, iWIFI, iBT, iCode1, iCode2, iCode3, oErrorMessage };
|
|
|
- CallProcedure("CS_SETADDRESSINFO", ref param);
|
|
|
+ string[] ParamName = new string[] { "v_i_sncode", "v_i_mac", "v_i_bt", "v_i_code1", "v_i_code2", "v_i_code3", "v_o_errmsg" };
|
|
|
+ CallProcedure("CS_SETADDRESSINFO", ParamName, ref param);
|
|
|
oErrorMessage = param[6];
|
|
|
if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
|
|
|
return true;
|
|
@@ -380,7 +384,7 @@ namespace BenQGuru.eMES.DLLService
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- private bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, string iErrCode, out string oErrorMessage)
|
|
|
+ public bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, string iErrCode, out string oErrorMessage)
|
|
|
{
|
|
|
oErrorMessage = "";
|
|
|
string StepCode = getFieldDataByCondition("Makeserial", "ms_stepcode", "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'").ToString();
|
|
@@ -398,13 +402,19 @@ namespace BenQGuru.eMES.DLLService
|
|
|
else
|
|
|
{
|
|
|
string[] BadCode = iErrCode.Split(',');
|
|
|
- sql.Clear();
|
|
|
+ sql.Length = 0;
|
|
|
sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
|
|
|
sql.Append(",mb_sourcecode,mb_badcode,mb_badtable,mb_soncode,mb_status) select makebad_seq.nextval");
|
|
|
sql.Append(",ma_code,ms_code,ms_sncode,'" + iUserCode + "',sysdate,'" + StepCode + "',ms_sourcecode,:bc_code,'',");
|
|
|
sql.Append("sp_soncode,'0' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
|
|
|
sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'");
|
|
|
- BatchInsert(sql.ToString(), new string[] { "bc_code" }, BadCode);
|
|
|
+ List<string> InsertSQL = new List<string>();
|
|
|
+ for (int i = 0; i < BadCode.Length; i++)
|
|
|
+ {
|
|
|
+ sql.ToString().Replace(":bc_code", BadCode[i]);
|
|
|
+ InsertSQL.Add(sql.ToString());
|
|
|
+ }
|
|
|
+ ExecuteSQLTran(InsertSQL.ToArray());
|
|
|
//将不良的序列号的状态码设为3
|
|
|
ExecuteSql("update makeserial set ms_status='3' where ms_sncode=:sncode and ms_makecode=:macode", "update", iSN, iMakeCode);
|
|
|
}
|
|
@@ -448,7 +458,8 @@ namespace BenQGuru.eMES.DLLService
|
|
|
{
|
|
|
oErrorMessage = "";
|
|
|
string[] param = new string[] { iTSN, iSN, iSourceCode, "", iResult, iErrCode, oErrorMessage };
|
|
|
- CallProcedure("CS_DLLSNCHANGE", ref param);
|
|
|
+ string[] ParamName = new string[] { "v_i_tsn", "v_i_sncode", "v_i_sourcecode", "v_i_usercode", "v_i_result", "v_i_errcode", "v_o_errmsg" };
|
|
|
+ CallProcedure("CS_DLLSNCHANGE", ParamName, ref param);
|
|
|
oErrorMessage = param[6];
|
|
|
if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
|
|
|
return true;
|
|
@@ -460,7 +471,8 @@ namespace BenQGuru.eMES.DLLService
|
|
|
{
|
|
|
oErrorMessage = "";
|
|
|
string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, iResult, oErrorMessage };
|
|
|
- CallProcedure("CS_SETSTEPRESULT", ref param);
|
|
|
+ string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_i_result", "v_o_errmsg" };
|
|
|
+ CallProcedure("CS_SETSTEPRESULT", ParamName, ref param);
|
|
|
oErrorMessage = param[5];
|
|
|
if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
|
|
|
return true;
|
|
@@ -488,7 +500,7 @@ namespace BenQGuru.eMES.DLLService
|
|
|
public bool SetTestDetail(string iSN, string iClass, string iSubClass1, string iSubClass2, string iSubClass3, string iMaxValue, string iMinValue, string iActualValue, string iValue1, string iValue2, string iValue3, string iTestResult, string iResCode, out string oErrMessage)
|
|
|
{
|
|
|
oErrMessage = "";
|
|
|
- sql.Clear();
|
|
|
+ sql.Length = 0;
|
|
|
string omakeCode;
|
|
|
GetRcardMOInfo(iSN, out omakeCode, out oErrMessage);
|
|
|
sql.Append("Insert into STEPTESTDETAIL (STD_ID,STD_SN,STD_MAKECODE,STD_CLASS,STD_SUBCLASS1,STD_SUBCLASS2,");
|
|
@@ -522,7 +534,8 @@ namespace BenQGuru.eMES.DLLService
|
|
|
{
|
|
|
oErrMessage = "";
|
|
|
string[] param = new string[] { iSnCode, iIMEI1, "", "", "", "", "", "", "", "", oErrMessage };
|
|
|
- CallProcedure("CS_SETIMEIINFO", ref param);
|
|
|
+ string[] ParamName = new string[] { "v_i_sncode", "v_i_imei1", "v_i_imei2", "v_i_imei3", "v_i_meid", "v_i_netcode", "v_i_psn", "v_i_id1", "v_i_id2", "v_i_id3", "v_o_errmsg" };
|
|
|
+ CallProcedure("CS_SETIMEIINFO", ParamName, ref param);
|
|
|
oErrMessage = param[10];
|
|
|
if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
return true;
|
|
@@ -535,7 +548,8 @@ namespace BenQGuru.eMES.DLLService
|
|
|
oErrMessage = "";
|
|
|
string omakecode = "";
|
|
|
string[] param = new string[] { "", iResCode, iSN, "", omakecode, "", oErrMessage };
|
|
|
- CallProcedure("CS_CHECKSTEPSNANDMACODE", ref param);
|
|
|
+ string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
|
|
|
+ CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
|
|
|
oErrMessage = param[6];
|
|
|
if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
return SetStepFinish(omakecode, iResCode, iSN, iOperator, iResult, "", iErrCode, out oErrMessage);
|
|
@@ -547,7 +561,8 @@ namespace BenQGuru.eMES.DLLService
|
|
|
{
|
|
|
oErrMessage = "";
|
|
|
string[] param = new string[] { iMO, iResCode, iSN, "", "", "", oErrMessage };
|
|
|
- CallProcedure("CS_CHECKSTEPSNANDMACODE", ref param);
|
|
|
+ string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
|
|
|
+ CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
|
|
|
oErrMessage = param[6];
|
|
|
if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
return true;
|
|
@@ -780,7 +795,7 @@ namespace BenQGuru.eMES.DLLService
|
|
|
}
|
|
|
}
|
|
|
for (int i = 0; i < addpar.Length; i++)
|
|
|
- command.Parameters.Add(new OracleParameter(addpar[i].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
|
|
|
+ command.Parameters.Add(new OracleParameter(addpar[i].ToString(), names[i]));
|
|
|
}
|
|
|
switch (Type.ToUpper())
|
|
|
{
|
|
@@ -842,26 +857,45 @@ namespace BenQGuru.eMES.DLLService
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private void BatchInsert(string sql, params object[][] names)
|
|
|
- {
|
|
|
- command = new OracleCommand(sql, connection);
|
|
|
+ /// <summary>
|
|
|
+ /// 出现异常进行回滚的执行方法
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="SQL"></param>
|
|
|
+ private void ExecuteSQLTran(params string[] SQL)
|
|
|
+ {
|
|
|
+ OracleConnection myConnection = new OracleConnection(ConnectionStrings);
|
|
|
+ myConnection.Open();
|
|
|
+ OracleCommand myCommand = myConnection.CreateCommand();
|
|
|
+ OracleTransaction myTrans;
|
|
|
+ // Start a local transaction
|
|
|
+ myTrans = myConnection.BeginTransaction(IsolationLevel.ReadCommitted);
|
|
|
+ // Assign transaction object for a pending local transaction
|
|
|
+ myCommand.Transaction = myTrans;
|
|
|
+
|
|
|
+ command = new OracleCommand();
|
|
|
+ command.Connection = new OracleConnection(ConnectionStrings);
|
|
|
+ command.Connection.Open();
|
|
|
Reconnect(command);
|
|
|
- command.ArrayBindCount = names[1].Length;
|
|
|
- //因为第一个数组保存的是参数的名称,所以循环从1而不是0开始
|
|
|
- //将第一个数组的下标固定为0作为循环添加的参数的名称
|
|
|
- for (int i = 1; i <= names[0].Length; i++)
|
|
|
- {
|
|
|
- command.Parameters.Add(new OracleParameter(names[0][i - 1].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
|
|
|
- }
|
|
|
+ OracleTransaction tx = command.Connection.BeginTransaction(IsolationLevel.ReadCommitted);
|
|
|
+ command.Transaction = tx;
|
|
|
try
|
|
|
{
|
|
|
- command.ExecuteNonQuery();
|
|
|
+ foreach (string sql in SQL)
|
|
|
+ {
|
|
|
+ if (!String.IsNullOrEmpty(sql))
|
|
|
+ {
|
|
|
+ command.CommandText = sql;
|
|
|
+
|
|
|
+ command.ExecuteNonQuery();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tx.Commit();
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ catch (OracleException E)
|
|
|
{
|
|
|
- command.Connection = new OracleConnection(ConnectionStrings);
|
|
|
- command.Connection.Open();
|
|
|
- command.ExecuteNonQuery();
|
|
|
+ tx.Rollback();
|
|
|
+ throw new Exception(E.Message);
|
|
|
}
|
|
|
command.Dispose();
|
|
|
}
|
|
@@ -885,7 +919,7 @@ namespace BenQGuru.eMES.DLLService
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
|
- private void CallProcedure(string ProcedureName, ref string[] param)
|
|
|
+ private void CallProcedure(string ProcedureName, string[] ParamName, ref string[] param)
|
|
|
{
|
|
|
command = new OracleCommand(ProcedureName);
|
|
|
command.Connection = connection;
|
|
@@ -893,7 +927,9 @@ namespace BenQGuru.eMES.DLLService
|
|
|
command.CommandText = ProcedureName;
|
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
|
for (int i = 0; i < param.Length; i++)
|
|
|
- command.Parameters.Add(new OracleParameter(param[i].ToString(), OracleDbType.Varchar2, 200, param[i], ParameterDirection.InputOutput));
|
|
|
+ {
|
|
|
+ command.Parameters.Add(new OracleParameter(ParamName[i], OracleType.VarChar, 200, ParameterDirection.InputOutput, "", DataRowVersion.Default, true, param[i]));
|
|
|
+ }
|
|
|
try
|
|
|
{
|
|
|
command.ExecuteNonQuery();
|
|
@@ -906,6 +942,7 @@ namespace BenQGuru.eMES.DLLService
|
|
|
}
|
|
|
for (int i = 0; i < command.Parameters.Count; i++)
|
|
|
param[i] = command.Parameters[i].Value.ToString();
|
|
|
+ command.Dispose();
|
|
|
}
|
|
|
|
|
|
private string AddField(string[] Fields)
|