Ver código fonte

G客户NTF统计功能:
1、GetMaInfo接口
2、GetMaInfoXml接口

sat23 3 anos atrás
pai
commit
40497d3535

+ 45 - 0
SCBC Factory Tools/Business/CommonMethod.cs

@@ -2084,6 +2084,51 @@ namespace MOKA_Factory_Tools
 
             return true;
         }
+
+        #region G客户NTF功能:GetMaInfo
+        public static bool GetMaInfo(string sn, out MaInfo maInfo, SQLiteConnection errorDBNow)
+        {
+            string desc;
+            maInfo = null;
+            string strPost = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
+                            "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
+                            "<soap:Body>"+
+                            "<GetMaInfo xmlns=\"http://tempuri.org/\">"+
+                            "<sn>"+sn+"</sn>"+
+                            "</GetMaInfo>"+
+                            "</soap:Body>"+
+                            "</soap:Envelope>";
+
+            HttpHelper http = new HttpHelper();
+            HttpItem item = new HttpItem()
+            {
+                Encoding = Encoding.Default,
+                Method = "post",
+                ContentType = "text/xml",
+                KeepAlive = false
+            };
+
+            item.URL = "http://smes-prd-app01.tclking.com:9002/SAPService.asmx";
+            item.Postdata = strPost;
+            HttpResult result = http.GetHtml(item);
+            if (result.StatusCode == System.Net.HttpStatusCode.OK)
+            {
+                Log.WriteGetKeyLog("\r\nGetMaInfo :\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
+                if (!Xmlconfig.GetMaInfoXml(result.Html, out maInfo, out desc))
+                {
+                    CommonMethod.ReportErrormsg("GetMaInfo error", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
+                    return false;
+                }
+            }
+            else
+            {
+                CommonMethod.ReportErrormsg("GetMaInfo error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
+                return false;
+            }
+
+            return true;
+        }
+        #endregion
     }
 
     /// <summary>

+ 40 - 1
SCBC Factory Tools/Http/Xmlconfig.cs

@@ -1,6 +1,9 @@
-using System;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
 using System.Xml;
 using WHC.OrderWater.Commons;
+using MOKA_Factory_Tools;
 
 public class Xmlconfig
 {
@@ -350,6 +353,42 @@ public class Xmlconfig
             return false;
         }
     }
+
+    #region G客户NTF统计功能
+    public static bool GetMaInfoXml(string str, out MaInfo maInfo, out string desc)
+    {
+        desc = "";
+        maInfo = null;
+
+        try
+        {
+            XmlDocument doc = new XmlDocument();
+            doc.LoadXml(str);
+            XmlNamespaceManager nsp = new XmlNamespaceManager(doc.NameTable);
+            nsp.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
+            XmlNode node = doc.SelectSingleNode("//soap:Envelope//soap:Body", nsp);
+            if ( node != null)
+            {
+                JObject jObject = JObject.Parse(node.InnerText);
+                if ( jObject["IsSuccess"].Value<bool>() )
+                {
+                    maInfo = JsonConvert.DeserializeObject<MaInfo>(jObject["Msg"].ToString());
+                }
+                else
+                {
+                    return false;
+                }
+            }           
+        }
+        catch (Exception ex)
+        {
+            desc = ex.Message;
+            return false;
+        }
+
+        return true;
+    }
+    #endregion
 }
 
 

+ 12 - 0
SCBC Factory Tools/Models/StructList.cs

@@ -489,4 +489,16 @@ namespace MOKA_Factory_Tools
             }
         }
     }
+
+    #region G客户NTF统计功能
+    public class MaInfo
+    {
+        public string ODF;
+        public string BOM;
+        public string SCREEN;
+        public string SHIPPING;
+        public string SIZE;
+        public string Model;
+    }
+    #endregion
 }