Browse Source

修复NTF类获取LastSN时,LastSN已在外部变更为当前SN,导致更新无效的Bug.

sat23 3 years ago
parent
commit
98179acf41
2 changed files with 12 additions and 14 deletions
  1. 7 7
      BLL/NTFBLL.cs
  2. 5 7
      Views/OperationPanel.cs

+ 7 - 7
BLL/NTFBLL.cs

@@ -15,6 +15,7 @@ namespace MOKA_Factory_Tools.BLL
         /// ""=异常,OncePass,NTF,ReadFial
         /// </summary>
         public string ResultType = "";
+        private string _strLastSN = "";
         protected readonly DAL_AMResult dalAMResult = new DAL_AMResult();
         protected readonly DAL_AMYields dalAMYields = new DAL_AMYields();
         protected readonly DAL_AMResult_TR dalAMResultTR = new DAL_AMResult_TR();
@@ -28,9 +29,10 @@ namespace MOKA_Factory_Tools.BLL
         /// <param name="bResult">抄写结果:成功或失败</param>
         /// <param name="strErrMsg">抄写失败时的描述</param>
         /// <returns></returns>
-        public bool SetDataBuringResult(string strLine, string strStation, string strSN, string strDSN, bool bResult, int nOrderType, string strErrMsg = "")
+        public bool SetDataBuringResult(string strLine, string strStation, string strSN, string strDSN, bool bResult, string strLastSN, int nOrderType, string strErrMsg = "")
         {
             MaInfo maInfo;
+            _strLastSN = strLastSN;
             DateTime dateNow = DateTime.Now;
             // 通过SN获取MES服务器中记录的ODF、Model、Dissemination信息;            
             if (CommonMethod.GetMaInfo(strSN, out maInfo, null))
@@ -159,11 +161,10 @@ namespace MOKA_Factory_Tools.BLL
         public bool UpdateAMResults(AMResult model, bool TestResult, string strErrMsg)
         {
             // 先获取ReDo="0"的记录;
-            string strLastSN = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastGSN", "");
             AMResult redo0Model = dalAMResult.GetModel(string.Format("Station='{0}' and SN='{1}' and ReDo='{2}'", model.Station, model.SN, "0"));
-            if (strLastSN == model.SN)
+            if (_strLastSN == model.SN)
             {// 连续抄写数据,更新ReDo="0"的记录;
-                Log.WriteInfoLog(string.Format("上一次SN={0} 与当前SN={1} 相同,只更新数据", strLastSN, model.SN));
+                Log.WriteInfoLog(string.Format("上一次SN={0} 与当前SN={1} 相同,只更新数据", _strLastSN, model.SN));
                 if (!UpdateReDo0AMResult(redo0Model, TestResult, strErrMsg))
                 {
                     // 更新失败;
@@ -395,11 +396,10 @@ namespace MOKA_Factory_Tools.BLL
         public bool UpdateAMResults(AMResult_TR model, bool TestResult, string strErrMsg)
         {
             // 先获取ReDo="0"的记录;
-            string strLastSN = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastGSN", "");
             AMResult_TR redo0Model = dalAMResultTR.GetModel(string.Format("Station='{0}' and SN='{1}' and ReDo='{2}'", model.Station, model.SN, "0"));
-            if (strLastSN == model.SN)
+            if (_strLastSN == model.SN)
             {// 连接抄写数据,更新ReDo="0"的记录;
-                Log.WriteInfoLog(string.Format("上一次SN={0} 与当前SN={1} 相同,只更新数据", strLastSN, model.SN));
+                Log.WriteInfoLog(string.Format("上一次SN={0} 与当前SN={1} 相同,只更新数据", _strLastSN, model.SN));
                 if (!UpdateReDo0AMResult(redo0Model, TestResult, strErrMsg))
                 {
                     // 更新失败;

+ 5 - 7
Views/OperationPanel.cs

@@ -4682,17 +4682,15 @@ namespace MOKA_Factory_Tools
             if (CommonMethod.GetLoginAccout().Equals("Huizhou", StringComparison.OrdinalIgnoreCase))
             {
                 string strLastResult = "";
-                StringBuilder strValue = new StringBuilder(256);
-                // 获取上一次的SN号;
-                CommonMethod.GetProfileString("MOKAFactoryTools", "LastGSN", "", strValue, 256);
-                if (strValue.ToString().Equals(SN, StringComparison.OrdinalIgnoreCase))
+                string strLastSN = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastGSN", "");
+                if (strLastSN.Equals(SN, StringComparison.OrdinalIgnoreCase))
                 {
                     if (TestResult == 0)
                     {
                         int lastCount = 0;
                         // 更新连续测试中累计失败的次数
-                        CommonMethod.GetProfileString("MOKAFactoryTools", "GFailCount", "0", strValue, 256);
-                        int.TryParse(strValue.ToString(), out lastCount);
+                        string strFailCount = CommonMethod.ReadProfileString("MOKAFactoryTools", "GFailCount", "0");
+                        int.TryParse(strFailCount, out lastCount);
                         CommonMethod.WriteProfileString("MOKAFactoryTools", "GFailCount", (++lastCount).ToString());
 
                         if (lastCount >= 2)
@@ -4726,7 +4724,7 @@ namespace MOKA_Factory_Tools
                     TestResult = 2;
                 }
 
-                if (!ntfBLL.SetDataBuringResult(FunctionSettingNow.Line, FunctionSettingNow.Station, SN, keyInfo.DSN, TestResult == 0 ? false : true, nOrderType, TestResult == 0 ? ErrMsg : ""))
+                if (!ntfBLL.SetDataBuringResult(FunctionSettingNow.Line, FunctionSettingNow.Station, SN, keyInfo.DSN, TestResult == 0 ? false : true, strLastSN, nOrderType, TestResult == 0 ? ErrMsg : ""))
                 {
                     //ntf失败,也需要提示;
                     ErrMsg = string.Format("统计NTF失败:{0}", SN);