Pārlūkot izejas kodu

增加了日志,增加了Smes DSN上报数据修改

chenjiangqun 2 gadi atpakaļ
vecāks
revīzija
405b146959

+ 4 - 1
FactoryTool_CShare/DAL/BaseDAL.cs

@@ -1,6 +1,7 @@
 using MOKA_Factory_Tools.Database;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Converters;
+using SXLibrary;
 using System;
 using System.Collections;
 using System.Collections.Concurrent;
@@ -297,7 +298,9 @@ namespace MOKA_Factory_Tools.DAL
         /// <returns></returns>
         public bool Add(object model, string overlookFieldList = "ID")
         {
+           
             CommandInfo comdInfo = this.GetAddCommandInfo(model, overlookFieldList);
+                
             int rows = DbHelper.ExecuteSQL(cps.ConnectionString, comdInfo.CommandText, (SqlParameter[])comdInfo.Parameters);
             if (rows > 0)
             {
@@ -306,7 +309,7 @@ namespace MOKA_Factory_Tools.DAL
             else
             {
                 return false;
-            }
+            }                     
         }
 
         /// <summary>

+ 3 - 1
FactoryTool_CShare/Database/DbHelper.cs

@@ -557,6 +557,7 @@ namespace MOKA_Factory_Tools.Database
                 }
                 catch (System.Data.SqlClient.SqlException ex)
                 {
+                    Log.WriteErrorLog($"错误:{ex.Message},SQL={strSQL}");
                     throw new Exception(ex.Message);
                 }
                 return ds;
@@ -813,7 +814,8 @@ namespace MOKA_Factory_Tools.Database
                     }
                     catch (System.Data.SqlClient.SqlException e)
                     {
-                        throw e;
+                        Log.WriteErrorLog(string.Format("{0}{1}",e.Message, SQLString));
+                        return -1;
                     }
                 }
             }

+ 1 - 1
FactoryTool_CShare/Views/OperationPanel.cs

@@ -5346,7 +5346,7 @@ namespace MOKA_Factory_Tools
                 { // 上报抄写结果到MES系统中;
                     string strOutMsg;
                     string returnObject;
-                    if (!GMethod.ReportDataBurningResultToMES(SN, keyInfo.DSN, (TestResult != 0) ? "Pass" : "Fail", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), errorDBNow, out strOutMsg, out returnObject))
+                    if (!GMethod.ReportDataBurningResultToMES(SN, FunctionSettingNow.UserDSNFromSmes ? GetSmesDSN : keyInfo.DSN, (TestResult != 0) ? "Pass" : "Fail", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), errorDBNow, out strOutMsg, out returnObject))
                     {
                         ErrMsg = string.Format("上报抄写结果到MES失败,请紧急处理:{0}", strOutMsg);
                         Log.WriteErrorLog(ErrMsg);