Эх сурвалжийг харах

三华抄写MES修改:使用配置文件启动对接三华MES的功能。

jianfeng1.wang 2 жил өмнө
parent
commit
0613b932ba

+ 5 - 0
FactoryTool_CShare/Models/StructList.cs

@@ -265,6 +265,11 @@ namespace MOKA_Factory_Tools
         /// 是否启用墨西哥IDM局域网接口;
         /// </summary>
         public bool Mexican_IDM { get; set; } = false;
+
+        /// <summary>
+        /// 是否使用三华MES对接;
+        /// </summary>
+        public bool EnableSanhuaMES { get; set; } = false;
     }
 
     public enum KEY_FROM

+ 14 - 4
FactoryTool_CShare/Views/Login.cs

@@ -30,6 +30,8 @@ namespace MOKA_Factory_Tools
 
         string ErrorDBPath = AppDomain.CurrentDomain.BaseDirectory + "\\Error.db";
         SQLiteConnection ErrorDB = null;
+        private bool EnableSanhuaMES { get; set; } = false;
+
         public login()
         {
             InitializeComponent();
@@ -178,12 +180,15 @@ namespace MOKA_Factory_Tools
             CommonMethod.SaveLoginInfo(AccountText.Text, PwdText.Text);
 
             #region 三华MES登录数据
-            if (CommonMethod.GetLoginAccout().Equals("Sanhua", StringComparison.OrdinalIgnoreCase))
+            if (EnableSanhuaMES)
             {
-                SanhuaMES sanhuaMES = new SanhuaMES();
-                if (sanhuaMES.ShowDialog() != DialogResult.OK)
+                if (CommonMethod.GetLoginAccout().Equals("Sanhua", StringComparison.OrdinalIgnoreCase))
                 {
-                    return;
+                    SanhuaMES sanhuaMES = new SanhuaMES();
+                    if (sanhuaMES.ShowDialog() != DialogResult.OK)
+                    {
+                        return;
+                    }
                 }
             }
             #endregion
@@ -294,6 +299,11 @@ namespace MOKA_Factory_Tools
                         SanhuaMethod.sanhuaLoginInfo.resourceCode = jObject["SanhuaLoginInfo"]["resourceCode"].Value<string>();
                         SanhuaMethod.sanhuaLoginInfo.jigEdtion = jObject["SanhuaLoginInfo"]["jigEdtion"].Value<string>();
                     }
+
+                    if (jObject["EnableSanhuaMES"] != null )
+                    {
+                        EnableSanhuaMES = jObject["EnableSanhuaMES"].Value<bool>();
+                    }
                     #endregion
                 }
             }            

+ 1 - 0
FactoryTool_CShare/Views/Main.cs

@@ -740,6 +740,7 @@ namespace MOKA_Factory_Tools
 
                 functionSetting1.LeaveFactory = jObject["LeaveFactory"] == null ? false : jObject["LeaveFactory"].Value<bool>();
                 functionSetting1.SNDoubleTips = jObject["SNDoubleTips"] == null ? false : jObject["SNDoubleTips"].Value<bool>();
+                functionSetting1.EnableSanhuaMES = jObject["EnableSanhuaMES"] == null ? false : jObject["EnableSanhuaMES"].Value<bool>();
 
                 #region 是否启用墨西哥抄写
                 if (CommonMethod.GetLoginAccout().Equals("Mexico", StringComparison.OrdinalIgnoreCase) )

+ 29 - 20
FactoryTool_CShare/Views/OperationPanel.cs

@@ -898,16 +898,19 @@ namespace MOKA_Factory_Tools
                 #endregion
 
 #if !SIMULATION && !OD_VER
-                if (CommonMethod.GetLoginAccout().Equals("Sanhua", StringComparison.OrdinalIgnoreCase))
+                if (FunctionSettingNow.EnableSanhuaMES)
                 {
-                    string message = string.Empty;
-                    if ( !SanhuaMethod.ProductRouteCheck(SN, out message) )
+                    if (CommonMethod.GetLoginAccout().Equals("Sanhua", StringComparison.OrdinalIgnoreCase))
                     {
-                        Verify dlg = new Verify(string.Format("{0} ProductRouteCheck faild: {1} ", SN, message));
-                        dlg.ShowDialog();
-                        SNText.Enabled = true;
-                        SNText.Text = "";
-                        return;
+                        string message = string.Empty;
+                        if (!SanhuaMethod.ProductRouteCheck(SN, out message))
+                        {
+                            Verify dlg = new Verify(string.Format("{0} ProductRouteCheck faild: {1} ", SN, message));
+                            dlg.ShowDialog();
+                            SNText.Enabled = true;
+                            SNText.Text = "";
+                            return;
+                        }
                     }
                 }
 #endif
@@ -5038,24 +5041,30 @@ namespace MOKA_Factory_Tools
             {// 只有抄写成功,才输出ACASID;
                 CommonMethod.ExportSNACASID(orderNow, SN, strACASID);
 
-                if (!SanhuaMethod.UploadIdcData(SN, strACASID, out error))
+                if (FunctionSettingNow.EnableSanhuaMES)
                 {
-                    TestResult = 0;
-                    ErrMsg = string.Format("{0}  UploadIdcData fail! {1}", SN, error);
-                    Log.WriteErrorLog(ErrMsg);
-                    goto end;
+                    if (!SanhuaMethod.UploadIdcData(SN, strACASID, out error))
+                    {
+                        TestResult = 0;
+                        ErrMsg = string.Format("{0}  UploadIdcData fail! {1}", SN, error);
+                        Log.WriteErrorLog(ErrMsg);
+                        goto end;
+                    }
                 }
             }
 
-            if (CommonMethod.GetLoginAccout().Equals("Sanhua", StringComparison.OrdinalIgnoreCase))
+            if (FunctionSettingNow.EnableSanhuaMES)
             {
-                // 由于抄写成功才会输出ACASID,所以result参数在此固定为OK/PASS
-                if (!SanhuaMethod.ProductMoveNext(SN, "OK", "", out error))
+                if (CommonMethod.GetLoginAccout().Equals("Sanhua", StringComparison.OrdinalIgnoreCase))
                 {
-                    TestResult = 0;
-                    ErrMsg = string.Format("{0}  ProductMoveNext fail! {1}", SN, error);
-                    Log.WriteErrorLog(ErrMsg);
-                    goto end;
+                    // 由于抄写成功才会输出ACASID,所以result参数在此固定为OK/PASS
+                    if (!SanhuaMethod.ProductMoveNext(SN, "OK", "", out error))
+                    {
+                        TestResult = 0;
+                        ErrMsg = string.Format("{0}  ProductMoveNext fail! {1}", SN, error);
+                        Log.WriteErrorLog(ErrMsg);
+                        goto end;
+                    }
                 }
             }