| 
					
				 | 
			
			
				@@ -9,6 +9,7 @@ using System.IO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Linq; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Text; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Threading.Tasks; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using System.Windows.Forms; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 namespace MOKA_Factory_Tools 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -22,6 +23,7 @@ namespace MOKA_Factory_Tools 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static string url_MaInfo = "http://smes-prd-app01.tclking.com:9002/SAPService.asmx"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static string url_ReportKey = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/RecordKey"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static string url_getOrderProductStatus = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/getOrderProductStatus?sn="; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private static string url_getMainBoardPSNWithSN = "http://smes-app-prod.tclking.com:9006/api/xm/GetXMTVParts?TVSN="; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         public static void SetMexicanConfig(bool bMexican=false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -524,5 +526,64 @@ namespace MOKA_Factory_Tools 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 根据FSN获取服务器上与之绑定的PSN值; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 这个函数在哪里调用,被谁调用; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 成功怎么处理;失败怎么处理; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public static bool GetMainBoardPSNWithSN(string FSN, out string PSN) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            string msg; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            PSN = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HttpHelper http = new HttpHelper(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HttpItem item = new HttpItem() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Encoding = Encoding.UTF8, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Method = "post", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ContentType = "application/x-www-form-urlencoded", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                KeepAlive = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.URL = url_getMainBoardPSNWithSN + FSN; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HttpResult hResult = http.GetHtml(item); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (hResult.StatusCode == System.Net.HttpStatusCode.OK) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    using (JsonTextReader reader = new JsonTextReader(new StringReader(hResult.Html))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        JObject jObject = (JObject)JToken.ReadFrom(reader); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        reader.Close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        foreach (var ss in jObject["Tvparts"])  //查找某个字段与值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //如果里面的TypeCode为MA(主板),读出他的PSN                   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (ss["PartTypeCode"].Value<string>().Equals("MA", StringComparison.OrdinalIgnoreCase)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                PSN = ss["PartSN"].Value<string>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (PSN == "" || PSN == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            MessageBox.Show("查不到该FSN对应的主板PSN号"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Log.WriteInfoLog("PartSN" + PSN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                catch (Exception e) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    msg = e.Message; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Log.WriteErrorLog("IsCuringBOM Json-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                msg = hResult.StatusDescription; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Log.WriteInfoLog("IsCuringBOM Http-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |