Browse Source

接口代码更新

章政 7 years ago
parent
commit
6e32ea1655
2 changed files with 96 additions and 37 deletions
  1. 95 36
      UAS_MesInterface/MESHelper.cs
  2. 1 1
      UAS_MesInterface/UAS_MesDllService(3.5).csproj

+ 95 - 36
UAS_MesInterface/MESHelper.cs

@@ -25,7 +25,6 @@ namespace BenQGuru.eMES.DLLService
         bool SetMobileData(string iTSN, string iSN, string iSourceCode, string iMPKind, string iResult, string iErrCode, string flag, out string oErrorMessage);
         bool SetPcbaData(string iSN, string iResCode, string iOperator, string iResult, string iErrCode, out string oErrMessage);
         bool GoMo(string iMO, string iSN, string iResCode, out string oErrMessage);
-        int Add(int a, int b);
     }
 
     [Guid("41EAB546-6EF4-464A-895A-9C34013A5D8C")]
@@ -39,15 +38,15 @@ namespace BenQGuru.eMES.DLLService
         //用于存放批量执行的SQL
         List<string> sqls = new List<string>();
         //系统默认的的连接字符串
-        private string ConnectionStrings = "Password=select!#%*(;User ID=MES_TEST;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=117.25.180.218)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        private string ConnectionStrings = "Password=select!#%*(;User ID=MES_TEST;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.230.200)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         //用户选择的数据库的连接字符串
-        private OracleConnection connection = new OracleConnection("Password=select!#%*(;User ID=MES_TEST;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=117.25.180.218)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));");
+        private OracleConnection connection;
         //用户选择的数据库的连接字符串
         private OracleCommand command = null;
 
         public MESHelper()
         {
-
+            connection = new OracleConnection(ConnectionStrings);
         }
 
         /// <summary>
@@ -59,6 +58,11 @@ namespace BenQGuru.eMES.DLLService
         /// <returns></returns>
         public bool CheckRoutePassed(string iSN, string iResCode, out string oErrMessage)
         {
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
             oErrMessage = "";
             string[] param = new string[] { "", iResCode, iSN, "", "", "", oErrMessage };
             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" };
@@ -101,6 +105,11 @@ namespace BenQGuru.eMES.DLLService
         public bool CheckUserAndResourcePassed(string iUserCode, string iResCode, string iPassWord, out string oErrMessage)
         {
             oErrMessage = "";
+            if (iUserCode == "" || iPassWord == "" || iResCode == "")
+            {
+                oErrMessage = "用户名,密码,岗位资源必须填写";
+                return false;
+            }
             if (CheckUserLogin(iUserCode, iPassWord, out oErrMessage))
             {
                 string SQL = "select em_code,em_type,em_name from employee where em_code=:UserName ";
@@ -169,6 +178,11 @@ namespace BenQGuru.eMES.DLLService
             oCode1 = "";
             oCode2 = "";
             oCdoe3 = "";
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
             oErrMessage = "";
             string omakeCode = "";
             GetRcardMOInfo(iSN, out omakeCode, out oErrMessage);
@@ -191,7 +205,7 @@ namespace BenQGuru.eMES.DLLService
         /// 输入的 SN 号查找在制品是否有 IMEI 信息存在,如果存在则将 IMEI 信息传出,如果没有则在该工单下未使用的 IMEI 中随机分配一组
         /// 如果iIMEI1、iNetCode不为空,则分别作为获取的附件加条件。
         /// </summary>
-        /// <param name="iSnCode"></param>
+        /// <param name="iSN"></param>
         /// <param name="iIMEI1"></param>
         /// <param name="iNetCode"></param>
         /// <param name="oIMEI1"></param>
@@ -205,7 +219,7 @@ namespace BenQGuru.eMES.DLLService
         /// <param name="oID3"></param>
         /// <param name="oErrMessage"></param>
         /// <returns></returns>
-        public bool GetMEIOrNetCodeRange(string iSnCode, string iIMEI1, string iNetCode, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrMessage)
+        public bool GetMEIOrNetCodeRange(string iSN, string iIMEI1, string iNetCode, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrMessage)
         {
             oIMEI1 = "";
             oIMEI2 = "";
@@ -217,8 +231,13 @@ namespace BenQGuru.eMES.DLLService
             oID3 = "";
             oID4 = "";
             oID5 = "";
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
             oErrMessage = "";
-            string[] param = new string[] { iSnCode, "", iIMEI1, iNetCode, oIMEI1, oIMEI2, "", oMEID, oNetCode, oPSN, oID1, oID2, oID3, oErrMessage };
+            string[] param = new string[] { iSN, "", iIMEI1, iNetCode, oIMEI1, oIMEI2, "", oMEID, oNetCode, oPSN, oID1, oID2, oID3, oErrMessage };
             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];
@@ -247,6 +266,11 @@ namespace BenQGuru.eMES.DLLService
         {
             //取MakeProcess表中的执行记录ID最大的一个工单的号码
             oMoCode = "";
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
             oErrMessage = "";
             string ms_id = getFieldDataByCondition("MakeSerial", "max(ms_id) ms_id", "ms_sncode='" + iSN + "' or ms_firstsn in (select firstsn from makesnrelation where sn='" + iSN + "')").ToString();
             oMoCode = getFieldDataByCondition("MakeSerial", "ms_makecode", "ms_id='" + ms_id + "'").ToString();
@@ -279,9 +303,9 @@ namespace BenQGuru.eMES.DLLService
         /// <param name="oID3"></param>
         /// <param name="oID4"></param>
         /// <param name="oID5"></param>
-        /// <param name="oErrorMessage"></param>
+        /// <param name="oErrMessage"></param>
         /// <returns></returns>
-        public bool GetMobileAllInfo(string iSN, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCode3, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrorMessage)
+        public bool GetMobileAllInfo(string iSN, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCode3, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrMessage)
         {
             oBT = "";
             oMEID = "";
@@ -298,6 +322,11 @@ namespace BenQGuru.eMES.DLLService
             oID3 = "";
             oID4 = "";
             oID5 = "";
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
             //通过序列号获取最近操作的工单号
             string ms_id = getFieldDataByCondition("makeserial", "ms_id", "ms_sncode='" + iSN + "'").ToString();
             if (ms_id != "")
@@ -318,18 +347,18 @@ namespace BenQGuru.eMES.DLLService
                     oID1 = dt.Rows[0]["ms_othid3"].ToString();
                     oID2 = dt.Rows[0]["ms_othid3"].ToString();
                     oID3 = dt.Rows[0]["ms_othid3"].ToString();
-                    oErrorMessage = "";
+                    oErrMessage = "";
                     return true;
                 }
                 else
                 {
-                    oErrorMessage = "序列号" + iSN + "不存在";
+                    oErrMessage = "序列号" + iSN + "不存在";
                     return false;
                 }
             }
             else
             {
-                oErrorMessage = "序列号" + iSN + "不存在";
+                oErrMessage = "序列号" + iSN + "不存在";
                 return false;
             }
         }
@@ -367,24 +396,34 @@ namespace BenQGuru.eMES.DLLService
         /// <param name="iCode1"></param>
         /// <param name="iCode2"></param>
         /// <param name="iCode3"></param>
-        /// <param name="oErrorMessage"></param>
+        /// <param name="oErrMessage"></param>
         /// <returns></returns>
-        public bool SetAddressInfo(string iSN, string iWIFI, string iBT, string iCode1, string iCode2, string iCode3, out string oErrorMessage)
+        public bool SetAddressInfo(string iSN, string iWIFI, string iBT, string iCode1, string iCode2, string iCode3, out string oErrMessage)
         {
-            oErrorMessage = "";
-            string[] param = new string[] { iSN, iWIFI, iBT, iCode1, iCode2, iCode3, oErrorMessage };
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
+            oErrMessage = "";
+            string[] param = new string[] { iSN, iWIFI, iBT, iCode1, iCode2, iCode3, oErrMessage };
             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")
+            oErrMessage = param[6];
+            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
                 return true;
             else
                 return false;
         }
 
-        public 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 oErrMessage)
         {
-            oErrorMessage = "";
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
+            oErrMessage = "";
             string StepCode = getFieldDataByCondition("Makeserial", "ms_stepcode", "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'").ToString();
             string CurrentStep = GetStepCodeBySource(iSourceCode);
             switch (iResult)
@@ -394,7 +433,7 @@ namespace BenQGuru.eMES.DLLService
                 case "NG":
                     if (iErrCode == "")
                     {
-                        oErrorMessage = "测试结果为NG时必须传递不良代码";
+                        oErrMessage = "测试结果为NG时必须传递不良代码";
                         return false;
                     }
                     else
@@ -413,11 +452,11 @@ namespace BenQGuru.eMES.DLLService
                         }
                         ExecuteSQLTran(InsertSQL.ToArray());
                         //将不良的序列号的状态码设为3
-                        ExecuteSql("update makeserial set ms_status='3' where ms_sncode=:sncode and ms_makecode=:macode", "update", iSN, iMakeCode);
+                        ExecuteSql("update makeserial set ms_status='3' where ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'", "update");
                     }
                     break;
                 default:
-                    oErrorMessage = "测试结果必须为NG或者OK";
+                    oErrMessage = "测试结果必须为NG或者OK";
                     return false;
             }
             //不良采集为良品是更新
@@ -437,7 +476,7 @@ namespace BenQGuru.eMES.DLLService
                     }
                 }
             }
-            return CS_SetFinish(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrorMessage);
+            return CS_SetFinish(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrMessage);
         }
 
         /// <summary>
@@ -464,14 +503,19 @@ namespace BenQGuru.eMES.DLLService
                 return false;
         }
 
-        private bool CS_SetFinish(string iMakeCode, string iSourceCode, string iSN, string iUserCode, string iResult, out string oErrorMessage)
+        private bool CS_SetFinish(string iMakeCode, string iSourceCode, string iSN, string iUserCode, string iResult, out string oErrMessage)
         {
-            oErrorMessage = "";
-            string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, iResult, oErrorMessage };
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
+            oErrMessage = "";
+            string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, iResult, oErrMessage };
             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")
+            oErrMessage = param[5];
+            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
                 return true;
             else
                 return false;
@@ -496,6 +540,11 @@ namespace BenQGuru.eMES.DLLService
         /// <returns></returns>
         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)
         {
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
             oErrMessage = "";
             sql.Length = 0;
             string omakeCode;
@@ -527,10 +576,15 @@ namespace BenQGuru.eMES.DLLService
         /// <param name="iID3"></param>
         /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public bool SetIMEIInfo(string iSnCode, string iIMEI1, out string oErrMessage)
+        public bool SetIMEIInfo(string iSN, string iIMEI1, out string oErrMessage)
         {
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
             oErrMessage = "";
-            string[] param = new string[] { iSnCode, iIMEI1, "", "", "", "", "", "", "", "", oErrMessage };
+            string[] param = new string[] { iSN, iIMEI1, "", "", "", "", "", "", "", "", oErrMessage };
             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];
@@ -542,6 +596,11 @@ namespace BenQGuru.eMES.DLLService
 
         public bool SetPcbaData(string iSN, string iResCode, string iOperator, string iResult, string iErrCode, out string oErrMessage)
         {
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
             oErrMessage = "";
             string omakecode = "";
             string[] param = new string[] { "", iResCode, iSN, "", omakecode, "", oErrMessage };
@@ -557,6 +616,11 @@ namespace BenQGuru.eMES.DLLService
 
         public bool GoMo(string iMO, string iSN, string iResCode, out string oErrMessage)
         {
+            if (iSN == "")
+            {
+                oErrMessage = "SN不能为空";
+                return false;
+            }
             oErrMessage = "";
             string[] param = new string[] { iMO, iResCode, iSN, "", "", "", oErrMessage };
             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" };
@@ -960,10 +1024,5 @@ namespace BenQGuru.eMES.DLLService
                 cmd.Connection.Open();
             }
         }
-
-        public int Add(int a, int b)
-        {
-            return a + b;
-        }
     }
 }

+ 1 - 1
UAS_MesInterface/UAS_MesDllService(3.5).csproj

@@ -9,7 +9,7 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>BenQGuru.eMES.DLLService</RootNamespace>
     <AssemblyName>BenQGuru.eMES.DLLService</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <TargetFrameworkProfile />
   </PropertyGroup>