Parcourir la source

登录失败时返回原始登录窗口。

JeffWang il y a 3 ans
Parent
commit
dfa8d82a12

+ 4 - 4
FactoryTool_CShare/Business/SanhuaMethod.cs

@@ -17,7 +17,7 @@ namespace MOKA_Factory_Tools
         public static bool CheckLogin(string url)
         {
             HttpHelper http = new HttpHelper();
-            HttpItem item = new HttpItem() {URL = url, Encoding = Encoding.UTF8,Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false};
+            HttpItem item = new HttpItem() {URL = url + "api/MESTestCollect/CheckLogin", Encoding = Encoding.UTF8,Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false};
             item.ContentType = "application/json;charset=utf-8";
             item.Postdata = string.Format("{{\"password\":\"{0}\",\"resourceCode\":\"{1}\",\"staffCode\":\"{2}\"}}", sanhuaLoginInfo.staffCode, sanhuaLoginInfo.password, sanhuaLoginInfo.resourceCode);
             HttpResult result = http.GetHtml(item);
@@ -45,7 +45,7 @@ namespace MOKA_Factory_Tools
         public static bool ProductRouteCheck(string url, string productSN)
         {
             HttpHelper http = new HttpHelper();
-            HttpItem item = new HttpItem() { URL = url, Encoding = Encoding.UTF8, Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false };
+            HttpItem item = new HttpItem() { URL = url + "api/MESTestCollect/ProductRouteCheck", Encoding = Encoding.UTF8, Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false };
             item.ContentType = "application/json;charset=utf-8";
             item.Postdata = string.Format("{{\"jigEdition\":\"{0}\",\"resourceCode\":\"{1}\",\"staffCode\":\"{2}\",\"productSN\":\"{3}\"}}", 
                 sanhuaLoginInfo.jigEdtion, sanhuaLoginInfo.resourceCode, sanhuaLoginInfo.staffCode, productSN);
@@ -74,7 +74,7 @@ namespace MOKA_Factory_Tools
         public static bool UploadIdcData(string url, string productSN, string acasId)
         {
             HttpHelper http = new HttpHelper();
-            HttpItem item = new HttpItem() { URL = url, Encoding = Encoding.UTF8, Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false };
+            HttpItem item = new HttpItem() { URL = url + "api/MESTestCollect/UploadIdcData", Encoding = Encoding.UTF8, Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false };
             item.ContentType = "application/json;charset=utf-8";
             item.Postdata = string.Format("{{\"jigEdition\":\"{0}\",\"resourceCode\":\"{1}\",\"staffCode\":\"{2}\",\"productSN\":\"{3}\",\"attr\":\"{{\"ACASID\",\"{4}\"}}\"}}",
                 sanhuaLoginInfo.jigEdtion, sanhuaLoginInfo.resourceCode, sanhuaLoginInfo.staffCode, productSN, acasId);
@@ -103,7 +103,7 @@ namespace MOKA_Factory_Tools
         public static bool ProductMoveNext(string url, string productSN, string result, string defectCode)
         {
             HttpHelper http = new HttpHelper();
-            HttpItem item = new HttpItem() { URL = url, Encoding = Encoding.UTF8, Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false };
+            HttpItem item = new HttpItem() { URL = url + "api/MESTestCollect/ProductMoveNext", Encoding = Encoding.UTF8, Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false };
             item.ContentType = "application/json;charset=utf-8";
             item.Postdata = string.Format("{{\"jigEdition\":\"{0}\",\"resourceCode\":\"{1}\",\"staffCode\":\"{2}\",\"productSN\":\"{3}\",\"defectCode\":\"{4}\",\"result\":\"{5}\"}}",
                 sanhuaLoginInfo.jigEdtion, sanhuaLoginInfo.resourceCode, sanhuaLoginInfo.staffCode, productSN, defectCode, result);

+ 1 - 0
FactoryTool_CShare/Views/SanhuaMES.Designer.cs

@@ -312,6 +312,7 @@
             // 
             this.Btn_MES_Login.BackColor = System.Drawing.Color.Transparent;
             this.Btn_MES_Login.ControlState = CCWin.SkinClass.ControlState.Normal;
+            this.Btn_MES_Login.DialogResult = System.Windows.Forms.DialogResult.OK;
             this.Btn_MES_Login.DownBack = null;
             this.Btn_MES_Login.Location = new System.Drawing.Point(131, 367);
             this.Btn_MES_Login.MouseBack = null;

+ 15 - 0
FactoryTool_CShare/Views/SanhuaMES.cs

@@ -38,7 +38,22 @@ namespace MOKA_Factory_Tools
             SanhuaMethod.sanhuaLoginInfo.password = Text_MES_Password.Text;
             SanhuaMethod.sanhuaLoginInfo.jigEdtion = Text_JigEdtion.Text;
 
+            if ( SanhuaMethod.sanhuaLoginInfo.url.EndsWith("/") )
+            {
+                SanhuaMethod.sanhuaLoginInfo.url = SanhuaMethod.sanhuaLoginInfo.url.Replace("/", "");
+            }
+
             SaveLoginInfo();
+
+            if ( SanhuaMethod.CheckLogin(SanhuaMethod.sanhuaLoginInfo.url) )
+            {
+                DialogResult = DialogResult.OK;
+            }
+            else
+            {
+                MessageBox.Show("登录失败,原因请查看日志");
+                DialogResult = DialogResult.Cancel;
+            }
         }
 
         private void SaveLoginInfo()