Kaynağa Gözat

将G客户接口单独分类;对接新接口业务逻辑。

JeffWang 2 yıl önce
ebeveyn
işleme
5b21f219e4

+ 1 - 1
FactoryTool_CShare/BLL/NTFBLL.cs

@@ -35,7 +35,7 @@ namespace MOKA_Factory_Tools.BLL
             _strLastSN = strLastSN;
             DateTime dateNow = DateTime.Now;
             // 通过SN获取MES服务器中记录的ODF、Model、Dissemination信息;            
-            if (CommonMethod.GetMaInfo(strSN, out maInfo, null))
+            if (GMethod.GetMaInfo(strSN, out maInfo, null))
             {
                 // 1.通过SN查询出订单类型;
                 if (nOrderType == 1)    // 量产;

+ 8 - 468
FactoryTool_CShare/Business/CommonMethod.cs

@@ -40,8 +40,6 @@ namespace MOKA_Factory_Tools
 
         private static LoginInput loginInput = new LoginInput();
 
-        private static Dictionary<string,string> LastKaylaOrderInfo = new Dictionary<string,string>();
-
         /// <summary>
         /// 保存登录信息;
         /// </summary>
@@ -211,6 +209,7 @@ namespace MOKA_Factory_Tools
         /// <param name="sqliteConn"></param>
         /// <param name="mid"></param>
         /// <returns></returns>
+        [Obsolete]
         public static bool GetMidInfo(string url, string order, string pcmac, string iptvip, string version, SQLiteConnection sqliteConn, out MidList mid)
         {
             mid = new MidList();
@@ -360,6 +359,7 @@ namespace MOKA_Factory_Tools
         /// <param name="sqliteConn"></param>
         /// <param name="midAddress"></param>
         /// <returns></returns>
+        [Obsolete]
         public static bool GetMidAddress(MidList midInfo, string order, SQLiteConnection sqliteConn, out MidAddress midAddress)
         {
             midAddress = new MidAddress();
@@ -429,6 +429,7 @@ namespace MOKA_Factory_Tools
         /// <param name="sqliteConn"></param>
         /// <param name="midAddress"></param>
         /// <returns></returns>
+        [Obsolete]
         public static bool GetMidAddress2(MidList midInfo, string order, SQLiteConnection sqliteConn, out List<MidAddress> midAddressList)
         {
             midAddressList = new List<MidAddress>();
@@ -561,6 +562,7 @@ namespace MOKA_Factory_Tools
         /// <param name="error"></param>
         /// <param name="md5"></param>
         /// <returns></returns>
+        [Obsolete]
         public static bool GetIDMKeys(string url, string sn, string order, string psn, string firetv_device_code, List<KeyType> key2Write, SQLiteConnection connection, ref KeyInfo keys, out string msg)
         {
             msg = "";
@@ -945,6 +947,7 @@ end:
         /// <param name="order"></param>
         /// <param name="sqliteConn"></param>
         /// <returns></returns>
+        [Obsolete]
         public static bool ReportDownloadStatus(string url, string order, SQLiteConnection sqliteConn)
         {
             HttpHelper http = new HttpHelper();
@@ -1118,6 +1121,7 @@ end:
         /// </summary>
         /// <param name="content"></param>
         /// <returns></returns>
+        [Obsolete]
         public static bool UploadCopyResult(string content, string url, SQLiteConnection sqliteConn, string order, bool repeatupload, string id, int timeout)
         {
             if (timeout < 5000)
@@ -1284,6 +1288,7 @@ end:
         /// </summary>
         /// <param name="copydate">烧录时间</param>
         /// <returns></returns>
+        [Obsolete]
         public static bool UploadPreloadCopyResult(string host, string copydate, string SN, SQLiteConnection localDBNow, SQLiteConnection sqliteConn, bool repeatupload, string id, int timeout)
         {
             string ParseText = "";
@@ -1358,6 +1363,7 @@ end:
         /// <param name="repeatupload"></param>
         /// <param name="id"></param>
         /// <returns></returns>
+        [Obsolete]
         public static bool UploadPreloadCopyResultList(string host, List<PostDateClass> postList, SQLiteConnection localDBNow, SQLiteConnection sqliteConn, bool repeatupload, string id)
         {
             string ParseText = "";
@@ -1943,470 +1949,6 @@ end:
             return true;
         }
 
-        #region G客户相关功能接口
-        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.UTF8,
-                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))
-                {
-                    Log.WriteGetKeyLog("GetMaInfo error:" + desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
-                    return false;
-                }
-            }
-            else
-            {
-                Log.WriteGetKeyLog("GetMaInfo error:" + result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
-                return false;
-            }
-
-            return true;
-        }
-
-        /// <summary>
-        /// 上报数据抄写结果到MES系统中;
-        /// </summary>
-        /// <param name="fsn"></param>
-        /// <param name="dsn"></param>
-        /// <param name="dateTime">抄写时间</param>
-        /// <param name="result">抄写结果</param>
-        /// <param name="msg">如果上报失败,此参数为失败的描述信息</param>
-        /// <returns></returns>
-        public static bool ReportDataBurningResultToMES(string fsn, string dsn, string result, string dateTime, SQLiteConnection errorDBNow, out string msg, out string returnObject)
-        {
-            msg = "";
-            returnObject = "";
-            string strPost = string.Format("{{\"FSN\":\"{0}\",\"DSN\":\"{1}\",\"DataCopy\":\"{2}\",\"UPDATETIME\":\"{3}\"}}", fsn, dsn, result, dateTime);
-            HttpHelper http = new HttpHelper();
-            HttpItem item = new HttpItem()
-            {
-                Encoding = Encoding.UTF8,
-                Method = "post",
-                ContentType = "application/json",
-                KeepAlive = false
-            };
-
-            // 测试地址;
-            item.URL = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/RecordKey";
-            item.Postdata = strPost;
-            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();
-
-                        bool bResult = jObject["Result"].Value<bool>();
-                        msg = jObject["EroMsg"].Value<string>();
-                        if ( jObject["returnObject"] != null )
-                            returnObject = jObject["returnObject"].ToString();
-                        Log.WriteInfoLog("nReportDataBurningResultToMES:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
-                        return bResult;
-                    }
-                }
-                catch (Exception e)
-                {
-                    msg = e.Message;
-                    Log.WriteErrorLog("ReportDataBurningResultToMES Json-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
-                }
-            }
-            else
-            {
-                msg = hResult.StatusDescription;
-                Log.WriteInfoLog("ReportDataBurningResultToMES Http-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
-            }
-            
-            // 没有进行数据库查重:惹数据已添加过,同一次FSN抄写多次失败后导致多条记录。
-            SQLiteHelper.InsertDelayErrorReport(errorDBNow, new object[] { item.URL, item.Postdata });
-
-            return false;
-        }
-
-        /// <summary>
-        /// 上传本地数据库失败的日志,重新上传;
-        /// </summary>
-        /// <param name="url"></param>
-        /// <param name="strPost"></param>
-        /// <param name="mark"></param>
-        /// <returns></returns>
-        public static bool ReportDataBurningResultToMES(string url, string strPost, out bool mark)
-        {
-            // 表示是否上传成功;
-            mark = false;
-            HttpHelper http = new HttpHelper();
-            HttpItem item = new HttpItem()
-            {
-                Encoding = Encoding.UTF8,
-                Method = "post",
-                ContentType = "application/json",
-                KeepAlive = false
-            };
-
-            item.URL = url;
-            item.Postdata = strPost;
-            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();
-
-                        mark = jObject["Result"].Value<bool>();
-                        Log.WriteInfoLog("nReportDataBurningResultToMES:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
-                        return true;
-                    }
-                }
-                catch (Exception)
-                {
-                    Log.WriteErrorLog("ReportDataBurningResultToMES error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
-                    throw;
-                }
-            }
-            else
-            {
-                Log.WriteInfoLog("ReportDataBurningResultToMES error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
-            }
-
-            return false;
-        }
-
-        /// <summary>
-        /// 通过SN获取订单类型
-        /// </summary>
-        /// <param name="sn"></param>
-        /// <returns></returns>
-        public static bool GetOrderTypeFromSN(string sn, out string result, out string msg)
-        {
-            msg = "";
-            result = "";
-            HttpHelper http = new HttpHelper();
-            HttpItem item = new HttpItem()
-            {
-                Encoding = Encoding.UTF8,
-                Method = "post",
-                ContentType = "application/x-www-form-urlencoded",
-                KeepAlive = false
-            };
-
-            // 测试地址;
-            item.URL = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/getOrderProductStatus?sn=" + sn;
-            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();
-
-                        bool bResult = jObject["Result"].Value<bool>();
-                        msg = jObject["EroMsg"].Value<string>();
-                        string returnObject = jObject["returnObject"].ToString();
-
-                        if (bResult)
-                        {
-                            if (returnObject.Contains("量产"))
-                                result = "量产";
-                            else if (returnObject.Contains("试产"))
-                                result = "试产";
-                            else
-                                result = "错误返回";
-                            Log.WriteInfoLog("\r\nIsCuringBOM :\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + hResult.Html);
-                            return true;
-                        }
-
-                        Log.WriteInfoLog("IsCuringBOM error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
-                    }
-                }
-                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;
-        }
-
-        /// <summary>
-        // Section1:本机信息;
-        // Section2:SMES信息;
-        // Section3:实际抄写Key信息;
-        /// </summary>
-        /// <param name="Line"></param>
-        /// <param name="Station"></param>
-        /// <param name="order"></param>
-        /// <param name="sn"></param>
-        /// <param name="StartTime"></param>
-        /// <param name="EndOfTime"></param>
-        /// <param name="returnObject"></param>
-        /// <param name="key"></param>
-        /// <param name="result"></param>
-        /// <returns></returns>
-        public static bool GeneratKaylaData(string Line, string Station, string order, string sn, DateTime StartTime, DateTime EndOfTime, string returnObject, KeyInfo key, bool result)
-        {
-            Dictionary<string, string> localInfo = new Dictionary<string,string>();
-            // 本机信息;
-            localInfo.Add("Item", "Value");
-            localInfo.Add("factory_id_I", "TCL");
-            localInfo.Add("operator_I", Line);
-            localInfo.Add("station_I", Station);
-            localInfo.Add("fixture_id_I", "1_1");
-            localInfo.Add("gui_ver_I", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
-            localInfo.Add("route_check_I", "1");
-
-            // SMES信息;
-            string strLastOrder = ReadProfileString("MOKAFactoryTools", "LastOrder", "");
-            if ( !strLastOrder.Equals(order,StringComparison.OrdinalIgnoreCase) )
-            {
-                // 请求新的订单信息;
-                MaInfo maInfo;
-                if ( !GetMaInfo(sn, out maInfo, null) )
-                {
-                    Log.WriteErrorLog("Kayla GetMaInfo失败");
-                    return false;
-                }
-
-                LastKaylaOrderInfo = new Dictionary<string,string>();
-                if ( maInfo != null )
-                {
-                    LastKaylaOrderInfo.Add("project_name_I", maInfo.project_name_I);
-                    LastKaylaOrderInfo.Add("build_I", maInfo.build_I);
-                    LastKaylaOrderInfo.Add("build_config_I", maInfo.build_config_I);
-                    LastKaylaOrderInfo.Add("diag_ver_I", maInfo.diag_ver_I);
-                    LastKaylaOrderInfo.Add("image_name_ver_I", maInfo.image_name_ver_I);
-                    LastKaylaOrderInfo.Add("soc_type", maInfo.soc_type);
-                    LastKaylaOrderInfo.Add("speaker_vender", maInfo.speaker_vender);
-                    LastKaylaOrderInfo.Add("mic_vender", maInfo.mic_vender);
-                }
-            }
-            Dictionary<string, string> dic = localInfo.Union(LastKaylaOrderInfo).ToDictionary(k=>k.Key, v=>v.Value);
-
-            dic.Add("start_time_I", StartTime.ToString());
-            dic.Add("serial_id_I", key != null ? key.DSN : "");   // DSN;
-            dic.Add("FSN", sn);
-
-            // 耐压值;
-            if (returnObject != null && returnObject.Length > 0 && returnObject.Contains("Hightpot"))
-            {
-                Log.WriteInfoLog(String.Format("returnObjec={0}", returnObject));
-                // 删除头尾[];
-                returnObject = returnObject.Remove(0, 1);
-                returnObject = returnObject.Remove(returnObject.Length - 1, 1);
-
-                JObject jObject = JObject.Parse(returnObject);
-                string hightpot = JSON_SeleteNode(jObject, "Hightpot");
-                int pos = hightpot.LastIndexOf('/');
-                if (pos != -1)
-                {
-                    hightpot = hightpot.Substring(pos+1);
-                    pos = hightpot.IndexOf("mA");
-                    // 使用正规去除数字+小数点以外的字符;
-                    string AC = hightpot.Substring(0, pos + 2);
-                    string DC = hightpot.Substring(pos + 2);
-                    AC = System.Text.RegularExpressions.Regex.Replace(AC, @"[^\d.]*", "");
-                    DC = System.Text.RegularExpressions.Regex.Replace(DC, @"[^\d.]*", "");
-                    dic.Add("AC_I", AC);
-                    dic.Add("DC_R", DC);
-                }
-                else
-                {
-                    dic.Add("AC_I", "");
-                    dic.Add("DC_R", "");
-                }
-            }
-            else
-            {
-                dic.Add("AC_I", "");
-                dic.Add("DC_R", "");
-                Log.WriteErrorLog("获取耐压值结果为空");
-            }
-
-            if ( key != null )
-            {
-                if (key.DID.enable)
-                {
-                    dic.Add("DID", key.DID); // 本身就是字符串;
-                    dic.Add("DID_check", key.DID.result ? "PASS" : "FAIL");
-                }
-
-                if (key.Mac.enable)
-                {
-                    dic.Add("Mac", key.Mac);//keyInfo.Mac.data.Replace("-", ":");
-                    dic.Add("Mac_check", key.Mac.result ? "PASS" : "FAIL");
-                }
-
-                if (key.HDCP.enable)
-                {
-                    dic.Add("HDCP", key.HDCP);
-                    dic.Add("HDCP_check", key.HDCP.result ? "PASS" : "FAIL");
-                }
-
-                if (key.HDCP22.enable)
-                {
-                    dic.Add("HDCP22", key.HDCP22);
-                    dic.Add("HDCP22_check", key.HDCP22.result ? "PASS" : "FAIL");
-                }
-
-                if (key.ESN.enable)
-                {
-                    dic.Add("ESN", key.ESN);
-                    dic.Add("ESN_check", key.ESN.result ? "PASS" : "FAIL");
-                }
-
-                if (key.Widevine.enable)
-                {
-                    dic.Add("Widevine", key.Widevine);
-                    dic.Add("Widevine_check", key.Widevine.result ? "PASS" : "FAIL");
-                }
-
-                if (key.CI_plus.enable)
-                {
-                    dic.Add("CI_plus", key.CI_plus);
-                    dic.Add("CI_plus_check", key.CI_plus.result ? "PASS" : "FAIL");
-                }
-
-                if (key.Attestation.enable)
-                {
-                    dic.Add("Attestation", key.Attestation);
-                    dic.Add("Attestation_check", key.Attestation.result ? "PASS" : "FAIL");
-                }
-
-                if (key.MGK.enable)
-                {
-                    dic.Add("MGK", key.MGK);
-                    dic.Add("MGK_check", key.MGK.result ? "PASS" : "FAIL");
-                }
-
-                if (key.Fairplay.enable)
-                {
-                    dic.Add("Fairplay", key.Fairplay);
-                    dic.Add("Fairplay_check", key.Fairplay.result ? "PASS" : "FAIL");
-                }
-
-                if (key.DSN.enable)
-                {
-                    dic.Add("DSN", key.DSN);
-                    dic.Add("DSN_check", key.DSN.result ? "PASS" : "FAIL");
-                }
-
-                if (key.WiFi_MAC.enable)
-                {
-                    dic.Add("WiFi_MAC", key.WiFi_MAC);
-                    dic.Add("WiFi_MAC_check", key.WiFi_MAC.result ? "PASS" : "FAIL");
-                }
-
-                if (key.BT_MAC.enable)
-                {
-                    dic.Add("BT_MAC", key.BT_MAC);
-                    dic.Add("BT_MAC_check", key.BT_MAC.result ? "PASS" : "FAIL");
-                }
-
-                if (key.LEK.enable)
-                {
-                    dic.Add("LEK", key.LEK);
-                    dic.Add("LEK_check", key.LEK.result ? "PASS" : "FAIL");
-                }
-
-                if (key.PEK.enable)
-                {
-                    dic.Add("PEK", key.PEK);
-                    dic.Add("PEK_check", key.PEK.result ? "PASS" : "FAIL");
-                }
-
-                if (key.Playready.enable)
-                {
-                    dic.Add("Playready", key.Playready);
-                    dic.Add("Playready_check", key.Playready.result ? "PASS" : "FAIL");
-                }
-
-                if (key.Hashkey.enable)
-                {
-                    dic.Add("Hashkey", key.Hashkey);
-                    dic.Add("Hashkey_check", key.Hashkey.result ? "PASS" : "FAIL");
-                }
-
-                if (key.ECP.enable)
-                {
-                    dic.Add("ECP", key.ECP);
-                    dic.Add("ECP_check", key.ECP.result ? "PASS" : "FAIL");
-                }
-
-                if (key.YouTube_KEY.enable)
-                {
-                    dic.Add("YouTube_KEY", key.YouTube_KEY);
-                    dic.Add("YouTube_KEY_check", key.YouTube_KEY.result ? "PASS" : "FAIL");
-                }          
-            }
-
-            dic.Add("cycle_time_I", EndOfTime.Subtract(StartTime).Seconds.ToString());
-            dic.Add("test_result_I", result ? "PASS" : "FAIL");
-
-            try
-            {
-                // 以DSN命名文件;
-                if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory+ "Kayla"))
-                {
-                    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "Kayla");
-                }
-                string savefile = string.Format("{0}Kayla\\{1}.csv", AppDomain.CurrentDomain.BaseDirectory, sn);
-                using (System.IO.StreamWriter file = new System.IO.StreamWriter(savefile, false))
-                {
-                    foreach (KeyValuePair<string, string> kvp in dic)
-                    {
-                        file.WriteLine(string.Format("{0},{1}", kvp.Key, kvp.Value));
-                    }
-                }
-            }
-            catch (Exception ex)
-            {
-                Log.WriteErrorLog(string.Format("保存csv文件失败:{0}", ex.ToString()));
-                return false;
-            }
-
-            StartProcess(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "tcp_send.exe", sn);
-
-            return true;
-        }
-
-        #endregion
-
         #region 小米FireTV功能模块相关接口;
         public static bool GetMIKey(string url, string sn, out MIKey mikey, out string msg)
         {
@@ -3126,6 +2668,4 @@ end:
             }
         }
     }
-
-
 }

+ 481 - 0
FactoryTool_CShare/Business/GMethod.cs

@@ -0,0 +1,481 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using SufeiUtil;
+using SXLibrary;
+using System;
+using System.Collections.Generic;
+using System.Data.SQLite;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MOKA_Factory_Tools
+{
+    internal class GMethod
+    {
+        private static Dictionary<string, string> LastKaylaOrderInfo = new Dictionary<string, string>();
+
+        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.UTF8,
+                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))
+                {
+                    Log.WriteGetKeyLog("GetMaInfo error:" + desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                    return false;
+                }
+            }
+            else
+            {
+                Log.WriteGetKeyLog("GetMaInfo error:" + result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                return false;
+            }
+
+            return true;
+        }
+
+        /// <summary>
+        /// 上报数据抄写结果到MES系统中;
+        /// </summary>
+        /// <param name="fsn"></param>
+        /// <param name="dsn"></param>
+        /// <param name="dateTime">抄写时间</param>
+        /// <param name="result">抄写结果</param>
+        /// <param name="msg">如果上报失败,此参数为失败的描述信息</param>
+        /// <returns></returns>
+        public static bool ReportDataBurningResultToMES(string fsn, string dsn, string result, string dateTime, SQLiteConnection errorDBNow, out string msg, out string returnObject)
+        {
+            msg = "";
+            returnObject = "";
+            string strPost = string.Format("{{\"FSN\":\"{0}\",\"DSN\":\"{1}\",\"DataCopy\":\"{2}\",\"UPDATETIME\":\"{3}\"}}", fsn, dsn, result, dateTime);
+            HttpHelper http = new HttpHelper();
+            HttpItem item = new HttpItem()
+            {
+                Encoding = Encoding.UTF8,
+                Method = "post",
+                ContentType = "application/json",
+                KeepAlive = false
+            };
+
+            // 测试地址;
+            item.URL = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/RecordKey";
+            item.Postdata = strPost;
+            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();
+
+                        bool bResult = jObject["Result"].Value<bool>();
+                        msg = jObject["EroMsg"].Value<string>();
+                        if (jObject["returnObject"] != null)
+                            returnObject = jObject["returnObject"].ToString();
+                        Log.WriteInfoLog("nReportDataBurningResultToMES:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                        return bResult;
+                    }
+                }
+                catch (Exception e)
+                {
+                    msg = e.Message;
+                    Log.WriteErrorLog("ReportDataBurningResultToMES Json-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                }
+            }
+            else
+            {
+                msg = hResult.StatusDescription;
+                Log.WriteInfoLog("ReportDataBurningResultToMES Http-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+            }
+
+            // 没有进行数据库查重:惹数据已添加过,同一次FSN抄写多次失败后导致多条记录。
+            SQLiteHelper.InsertDelayErrorReport(errorDBNow, new object[] { item.URL, item.Postdata });
+
+            return false;
+        }
+
+        /// <summary>
+        /// 上传本地数据库失败的日志,重新上传;
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="strPost"></param>
+        /// <param name="mark"></param>
+        /// <returns></returns>
+        public static bool ReportDataBurningResultToMES(string url, string strPost, out bool mark)
+        {
+            // 表示是否上传成功;
+            mark = false;
+            HttpHelper http = new HttpHelper();
+            HttpItem item = new HttpItem()
+            {
+                Encoding = Encoding.UTF8,
+                Method = "post",
+                ContentType = "application/json",
+                KeepAlive = false
+            };
+
+            item.URL = url;
+            item.Postdata = strPost;
+            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();
+
+                        mark = jObject["Result"].Value<bool>();
+                        Log.WriteInfoLog("nReportDataBurningResultToMES:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                        return true;
+                    }
+                }
+                catch (Exception)
+                {
+                    Log.WriteErrorLog("ReportDataBurningResultToMES error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                    throw;
+                }
+            }
+            else
+            {
+                Log.WriteInfoLog("ReportDataBurningResultToMES error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+            }
+
+            return false;
+        }
+
+        /// <summary>
+        /// 通过SN获取订单类型
+        /// </summary>
+        /// <param name="sn"></param>
+        /// <returns></returns>
+        public static bool GetOrderTypeFromSN(string sn, out string result, out string msg)
+        {
+            msg = "";
+            result = "";
+            HttpHelper http = new HttpHelper();
+            HttpItem item = new HttpItem()
+            {
+                Encoding = Encoding.UTF8,
+                Method = "post",
+                ContentType = "application/x-www-form-urlencoded",
+                KeepAlive = false
+            };
+
+            // 测试地址;
+            item.URL = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/getOrderProductStatus?sn=" + sn;
+            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();
+
+                        bool bResult = jObject["Result"].Value<bool>();
+                        msg = jObject["EroMsg"].Value<string>();
+                        string returnObject = jObject["returnObject"].ToString();
+
+                        if (bResult)
+                        {
+                            if (returnObject.Contains("量产"))
+                                result = "量产";
+                            else if (returnObject.Contains("试产"))
+                                result = "试产";
+                            else
+                                result = "错误返回";
+                            Log.WriteInfoLog("\r\nIsCuringBOM :\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + hResult.Html);
+                            return true;
+                        }
+
+                        Log.WriteInfoLog("IsCuringBOM error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                    }
+                }
+                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;
+        }
+
+        /// <summary>
+        // Section1:本机信息;
+        // Section2:SMES信息;
+        // Section3:实际抄写Key信息;
+        /// </summary>
+        /// <param name="Line"></param>
+        /// <param name="Station"></param>
+        /// <param name="order"></param>
+        /// <param name="sn"></param>
+        /// <param name="StartTime"></param>
+        /// <param name="EndOfTime"></param>
+        /// <param name="returnObject"></param>
+        /// <param name="key"></param>
+        /// <param name="result"></param>
+        /// <returns></returns>
+        public static bool GeneratKaylaData(string Line, string Station, string order, string sn, DateTime StartTime, DateTime EndOfTime, string returnObject, KeyInfo key, bool result)
+        {
+            Dictionary<string, string> localInfo = new Dictionary<string, string>();
+            // 本机信息;
+            localInfo.Add("Item", "Value");
+            localInfo.Add("factory_id_I", "TCL");
+            localInfo.Add("operator_I", Line);
+            localInfo.Add("station_I", Station);
+            localInfo.Add("fixture_id_I", "1_1");
+            localInfo.Add("gui_ver_I", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
+            localInfo.Add("route_check_I", "1");
+
+            // SMES信息;
+            string strLastOrder = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastOrder", "");
+            if (!strLastOrder.Equals(order, StringComparison.OrdinalIgnoreCase))
+            {
+                // 请求新的订单信息;
+                MaInfo maInfo;
+                if (!GetMaInfo(sn, out maInfo, null))
+                {
+                    Log.WriteErrorLog("Kayla GetMaInfo失败");
+                    return false;
+                }
+
+                LastKaylaOrderInfo = new Dictionary<string, string>();
+                if (maInfo != null)
+                {
+                    LastKaylaOrderInfo.Add("project_name_I", maInfo.project_name_I);
+                    LastKaylaOrderInfo.Add("build_I", maInfo.build_I);
+                    LastKaylaOrderInfo.Add("build_config_I", maInfo.build_config_I);
+                    LastKaylaOrderInfo.Add("diag_ver_I", maInfo.diag_ver_I);
+                    LastKaylaOrderInfo.Add("image_name_ver_I", maInfo.image_name_ver_I);
+                    LastKaylaOrderInfo.Add("soc_type", maInfo.soc_type);
+                    LastKaylaOrderInfo.Add("speaker_vender", maInfo.speaker_vender);
+                    LastKaylaOrderInfo.Add("mic_vender", maInfo.mic_vender);
+                }
+            }
+            Dictionary<string, string> dic = localInfo.Union(LastKaylaOrderInfo).ToDictionary(k => k.Key, v => v.Value);
+
+            dic.Add("start_time_I", StartTime.ToString());
+            dic.Add("serial_id_I", key != null ? key.DSN : "");   // DSN;
+            dic.Add("FSN", sn);
+
+            // 耐压值;
+            if (returnObject != null && returnObject.Length > 0 && returnObject.Contains("Hightpot"))
+            {
+                Log.WriteInfoLog(String.Format("returnObjec={0}", returnObject));
+                // 删除头尾[];
+                returnObject = returnObject.Remove(0, 1);
+                returnObject = returnObject.Remove(returnObject.Length - 1, 1);
+
+                JObject jObject = JObject.Parse(returnObject);
+                string hightpot = CommonMethod.JSON_SeleteNode(jObject, "Hightpot");
+                int pos = hightpot.LastIndexOf('/');
+                if (pos != -1)
+                {
+                    hightpot = hightpot.Substring(pos + 1);
+                    pos = hightpot.IndexOf("mA");
+                    // 使用正规去除数字+小数点以外的字符;
+                    string AC = hightpot.Substring(0, pos + 2);
+                    string DC = hightpot.Substring(pos + 2);
+                    AC = System.Text.RegularExpressions.Regex.Replace(AC, @"[^\d.]*", "");
+                    DC = System.Text.RegularExpressions.Regex.Replace(DC, @"[^\d.]*", "");
+                    dic.Add("AC_I", AC);
+                    dic.Add("DC_R", DC);
+                }
+                else
+                {
+                    dic.Add("AC_I", "");
+                    dic.Add("DC_R", "");
+                }
+            }
+            else
+            {
+                dic.Add("AC_I", "");
+                dic.Add("DC_R", "");
+                Log.WriteErrorLog("获取耐压值结果为空");
+            }
+
+            if (key != null)
+            {
+                if (key.DID.enable)
+                {
+                    dic.Add("DID", key.DID); // 本身就是字符串;
+                    dic.Add("DID_check", key.DID.result ? "PASS" : "FAIL");
+                }
+
+                if (key.Mac.enable)
+                {
+                    dic.Add("Mac", key.Mac);//keyInfo.Mac.data.Replace("-", ":");
+                    dic.Add("Mac_check", key.Mac.result ? "PASS" : "FAIL");
+                }
+
+                if (key.HDCP.enable)
+                {
+                    dic.Add("HDCP", key.HDCP);
+                    dic.Add("HDCP_check", key.HDCP.result ? "PASS" : "FAIL");
+                }
+
+                if (key.HDCP22.enable)
+                {
+                    dic.Add("HDCP22", key.HDCP22);
+                    dic.Add("HDCP22_check", key.HDCP22.result ? "PASS" : "FAIL");
+                }
+
+                if (key.ESN.enable)
+                {
+                    dic.Add("ESN", key.ESN);
+                    dic.Add("ESN_check", key.ESN.result ? "PASS" : "FAIL");
+                }
+
+                if (key.Widevine.enable)
+                {
+                    dic.Add("Widevine", key.Widevine);
+                    dic.Add("Widevine_check", key.Widevine.result ? "PASS" : "FAIL");
+                }
+
+                if (key.CI_plus.enable)
+                {
+                    dic.Add("CI_plus", key.CI_plus);
+                    dic.Add("CI_plus_check", key.CI_plus.result ? "PASS" : "FAIL");
+                }
+
+                if (key.Attestation.enable)
+                {
+                    dic.Add("Attestation", key.Attestation);
+                    dic.Add("Attestation_check", key.Attestation.result ? "PASS" : "FAIL");
+                }
+
+                if (key.MGK.enable)
+                {
+                    dic.Add("MGK", key.MGK);
+                    dic.Add("MGK_check", key.MGK.result ? "PASS" : "FAIL");
+                }
+
+                if (key.Fairplay.enable)
+                {
+                    dic.Add("Fairplay", key.Fairplay);
+                    dic.Add("Fairplay_check", key.Fairplay.result ? "PASS" : "FAIL");
+                }
+
+                if (key.DSN.enable)
+                {
+                    dic.Add("DSN", key.DSN);
+                    dic.Add("DSN_check", key.DSN.result ? "PASS" : "FAIL");
+                }
+
+                if (key.WiFi_MAC.enable)
+                {
+                    dic.Add("WiFi_MAC", key.WiFi_MAC);
+                    dic.Add("WiFi_MAC_check", key.WiFi_MAC.result ? "PASS" : "FAIL");
+                }
+
+                if (key.BT_MAC.enable)
+                {
+                    dic.Add("BT_MAC", key.BT_MAC);
+                    dic.Add("BT_MAC_check", key.BT_MAC.result ? "PASS" : "FAIL");
+                }
+
+                if (key.LEK.enable)
+                {
+                    dic.Add("LEK", key.LEK);
+                    dic.Add("LEK_check", key.LEK.result ? "PASS" : "FAIL");
+                }
+
+                if (key.PEK.enable)
+                {
+                    dic.Add("PEK", key.PEK);
+                    dic.Add("PEK_check", key.PEK.result ? "PASS" : "FAIL");
+                }
+
+                if (key.Playready.enable)
+                {
+                    dic.Add("Playready", key.Playready);
+                    dic.Add("Playready_check", key.Playready.result ? "PASS" : "FAIL");
+                }
+
+                if (key.Hashkey.enable)
+                {
+                    dic.Add("Hashkey", key.Hashkey);
+                    dic.Add("Hashkey_check", key.Hashkey.result ? "PASS" : "FAIL");
+                }
+
+                if (key.ECP.enable)
+                {
+                    dic.Add("ECP", key.ECP);
+                    dic.Add("ECP_check", key.ECP.result ? "PASS" : "FAIL");
+                }
+
+                if (key.YouTube_KEY.enable)
+                {
+                    dic.Add("YouTube_KEY", key.YouTube_KEY);
+                    dic.Add("YouTube_KEY_check", key.YouTube_KEY.result ? "PASS" : "FAIL");
+                }
+            }
+
+            dic.Add("cycle_time_I", EndOfTime.Subtract(StartTime).Seconds.ToString());
+            dic.Add("test_result_I", result ? "PASS" : "FAIL");
+
+            try
+            {
+                // 以DSN命名文件;
+                if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "Kayla"))
+                {
+                    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "Kayla");
+                }
+                string savefile = string.Format("{0}Kayla\\{1}.csv", AppDomain.CurrentDomain.BaseDirectory, sn);
+                using (System.IO.StreamWriter file = new System.IO.StreamWriter(savefile, false))
+                {
+                    foreach (KeyValuePair<string, string> kvp in dic)
+                    {
+                        file.WriteLine(string.Format("{0},{1}", kvp.Key, kvp.Value));
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                Log.WriteErrorLog(string.Format("保存csv文件失败:{0}", ex.ToString()));
+                return false;
+            }
+
+            CommonMethod.StartProcess(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "tcp_send.exe", sn);
+
+            return true;
+        }
+
+    }
+}

+ 51 - 45
FactoryTool_CShare/Business/V2Method.cs

@@ -13,7 +13,7 @@ using System.Web;
 using System.Windows.Forms;
 using HttpHelper = SufeiUtil.HttpHelper;
 
-namespace MOKA_Factory_Tools.Business
+namespace MOKA_Factory_Tools
 {
     internal class V2Method
     {
@@ -26,8 +26,8 @@ namespace MOKA_Factory_Tools.Business
             {
                 List<KeyType> key2Write;
                 string msg;
-                KeyInfo keys;
-                bRet = GetMidKey(mid.host, "SN0321-test9999", "TEST_WJF", "20220321APSN9999", "BBB", null, null, out keys, out msg);
+                KeyInfo keys = new KeyInfo();
+                bRet = GetMidKey(mid.host, "SN0321-test9999", "TEST_WJF", "20220321APSN9999", "BBB", null, null, ref keys, out msg);
 
                 List<MidAddress> midlist; 
                 GetOfflineData(mid.host, "TEST_WJF", null, out midlist);
@@ -47,9 +47,9 @@ namespace MOKA_Factory_Tools.Business
                     SetEnable(keys.CI_plus);
                     SetEnable(keys.Playready);
 
-                    ReportOnlineData(mid.host, "TEST_WJF", "SN0321-test9999", false, ref keys, null, out msg);
+                    ReportOnlineData(mid.host, "TEST_WJF", GetReportJson("TEST_WJF", "SN0321-test9999", false, ref keys), null, false, "", 1000);
 
-                    ReportOfflineData(mid.host, "2022-07-18 14:40:42", "SN0321-test9999", null, null, false, "", 1000);
+                    ReportOfflineData(mid.host, "2022-07-18 14:40:42", "SN0321-test9999", null, null, false, "");
                 }
             }
         }
@@ -149,10 +149,9 @@ namespace MOKA_Factory_Tools.Business
             return false;
         }
 
-        public static bool GetMidKey(string url, string sn, string order, string psn, string firetv_device_code, List<KeyType> key2Write, SQLiteConnection connection, out KeyInfo keys, out string msg)
+        public static bool GetMidKey(string url, string sn, string order, string psn, string firetv_device_code, List<KeyType> key2Write, SQLiteConnection connection, ref KeyInfo keys, out string msg)
         {
             msg = "";
-            keys = new KeyInfo();
             string code;
             bool result = false;
 
@@ -467,7 +466,7 @@ namespace MOKA_Factory_Tools.Business
             return result;
         }
 
-        private static string GetReportJson(string order, string sn, bool isNodid, ref KeyInfo keyinfo)
+        public static string GetReportJson(string order, string sn, bool isNodid, ref KeyInfo keyinfo)
         {
             Func<string, string, JObject, bool> AddJsonItem = (name, value, jobj) =>
             {
@@ -556,21 +555,23 @@ namespace MOKA_Factory_Tools.Business
         /// <param name="sqliteConn"></param>
         /// <param name="msg"></param>
         /// <returns></returns>
-        public static bool ReportOnlineData(string url, string order, string sn, bool isNodid, ref KeyInfo keyinfo, SQLiteConnection sqliteConn, out string msg)
+        public static bool ReportOnlineData(string url, string order, string postData, SQLiteConnection sqliteConn, bool repeatupload, string id, int timeout)
         {
-            msg = "";
+            if (timeout < 5000)
+                timeout = 5000;
             HttpHelper http = new HttpHelper();
             HttpItem item = new HttpItem()
             {
                 Encoding = Encoding.UTF8,//编码格式(utf-8,gb2312,gbk)可选项 默认类会自动识别//Encoding = Encoding.Default,
                 Method = "post",
-                Postdata = GetReportJson(order, sn, isNodid, ref keyinfo),
+                Postdata = postData,
                 PostEncoding = Encoding.UTF8,
+                Timeout = timeout,
                 KeepAlive = false
             };
             item.URL = url + "/reportData/report";
             item.ContentType = "application/json;charset=utf-8";
-            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
+            Stopwatch stopwatch = new Stopwatch();
             stopwatch.Start();
             HttpResult result = http.GetHtml(item);
             stopwatch.Stop();
@@ -580,28 +581,36 @@ namespace MOKA_Factory_Tools.Business
             if (result.StatusCode == System.Net.HttpStatusCode.OK)
             {
                 Log.WriteGetKeyLog("\r\nReportOnlineData info\r\nUsing time:" + usingtime + "ms\r\n" + ParseText + "\r\nAddress:" + url + "\r\nPostdata:" + item.Postdata);
+                try
+                {
+                    JObject jObject = JObject.Parse(ParseText);
+                    string msg = jObject["message"].Value<string>();
+                    string code = jObject["code"].Value<string>();
+
+                    if (code == "0")
+                        return true;                   
+                }
+                catch (Exception ex)
+                {
+                    Log.WriteErrorLog("\r\nFail to ReportOnlineData," + ex.Message + ":" + ParseText + "\r\nAddress:" + url + "\r\nPostdata:" + item.Postdata);
+                    CommonMethod.ReportErrormsg("Fail to ReportOnlineData", ex.Message + ":" + ParseText + "\r\nAddress:" + url + "\r\nPostdata:" + item.Postdata, sqliteConn);
+                }
+
+                if (repeatupload)
+                {// 删除记录;
+                    SQLiteHelper.DeleteDelayCopyReport(sqliteConn, id);
+                }
             }
             else
             {
                 Log.WriteErrorLog("\r\nFail to ReportOnlineData:" + result.StatusDescription + result.Html + "\r\nAddress:" + url + "\r\nPostdata:" + item.Postdata);
+                if (!repeatupload)
+                {
+                    if (CommonMethod.HTTPChecker(item.URL))
+                        SQLiteHelper.InsertDelayCopyReport(sqliteConn, new object[] { order, item.URL, item.Postdata });
+                }
                 CommonMethod.ReportErrormsg("Fail to ReportOnlineData", result.StatusDescription + result.Html + "\r\nAddress:" + url + "\r\nPostdata:" + item.Postdata, sqliteConn);
-                return false;
-            }
-
-            try
-            {
-                JObject jObject = JObject.Parse(ParseText);
-                msg = jObject["message"].Value<string>();
-                string code = jObject["code"].Value<string>();
-
-                if (code == "0")
-                    return true;
-            }
-            catch (Exception ex)
-            {
-                Log.WriteErrorLog("\r\nFail to ReportOnlineData," + ex.Message + ":" + ParseText + "\r\nAddress:" + url + "\r\nPostdata:" + item.Postdata);
-                CommonMethod.ReportErrormsg("Fail to ReportOnlineData", ex.Message + ":" + ParseText + "\r\nAddress:" + url + "\r\nPostdata:" + item.Postdata, sqliteConn);
-            }
+            }            
 
             return false;
         }
@@ -619,7 +628,7 @@ namespace MOKA_Factory_Tools.Business
         /// <param name="id"></param>
         /// <param name="timeout"></param>
         /// <returns></returns>
-        public static bool ReportOfflineData(string url, string copydate, string SN, SQLiteConnection localDBNow, SQLiteConnection sqliteConn, bool repeatupload, string id, int timeout)
+        public static bool ReportOfflineData(string url, string copydate, string SN, SQLiteConnection localDBNow, SQLiteConnection sqliteConn, bool repeatupload, string id)
         {
             HttpHelper http = new HttpHelper();
             HttpItem item = new HttpItem()
@@ -770,7 +779,7 @@ namespace MOKA_Factory_Tools.Business
             {
                 Encoding = null,
                 Method = "post",
-                Postdata = string.Format("{{\"orderNumber\":\"{0}\"}}", order),
+                Postdata = string.Format("{{\"ordernum\":\"{0}\"}}", order),
                 KeepAlive = false
             };
 
@@ -778,38 +787,35 @@ namespace MOKA_Factory_Tools.Business
             item.ContentType = "application/json;charset=utf-8";
             HttpResult result = http.GetHtml(item);
             string ParseText = result.Html;
-            if (result.StatusCode == System.Net.HttpStatusCode.OK)
+            if (result.StatusCode != System.Net.HttpStatusCode.OK)
             {
-                //
-            }
-            else
-            {
-                Log.WriteErrorLog("\r\nFail to report download status:" + result.StatusDescription + result.Html + "\r\nAddress:" + url + "/getreportofflinesn.do?" + "\r\nPostdata:" + ("orderNumber =" + order));
-                CommonMethod.ReportErrormsg("Fail to report download status", result.StatusDescription + result.Html + "\r\nAddress:" + url + "/getreportofflinesn.do?" + "\r\nPostdata:" + ("orderNumber =" + order), sqliteConn);
+                Log.WriteErrorLog("\r\nFail to report download status:" + result.StatusDescription + result.Html + "\r\nAddress:" + url + "/offline/getreportofflinesn" + "\r\nPostdata:" + ("ordernum=" + order));
+                CommonMethod.ReportErrormsg("Fail to report download status", result.StatusDescription + result.Html + "\r\nAddress:" + url + "/offline/getreportofflinesn" + "\r\nPostdata:" + ("ordernum=" + order), sqliteConn);
                 return false;
             }
+
             try
             {
                 JObject jObject = JObject.Parse(ParseText);
                 string msg = CommonMethod.JSON_SeleteNode(jObject, "msg");
                 string code = CommonMethod.JSON_SeleteNode(jObject, "code");
   
-                if (code == "0")
-                    return true;
-                else
+                if (code != "0")
                 {
-                    Log.WriteErrorLog("\r\nError report download status,should be 1000:" + result.StatusDescription + result.Html + "\r\nAddress:" + url + "/getreportofflinesn.do?" + "\r\nPostdata:" + ("orderNumber =" + order));
-                    CommonMethod.ReportErrormsg("Error download status code return", result.StatusDescription + result.Html + "\r\nAddress:" + url + "/getreportofflinesn.do?" + "\r\nPostdata:" + ("orderNumber =" + order), sqliteConn);
+                    Log.WriteErrorLog("\r\nError report download status,should be 1000:" + result.StatusDescription + result.Html + "\r\nAddress:" + url + "/offline/getreportofflinesn" + "\r\nPostdata:" + ("ordernum=" + order));
+                    CommonMethod.ReportErrormsg("Error download status code return", result.StatusDescription + result.Html + "\r\nAddress:" + url + "/offline/getreportofflinesn" + "\r\nPostdata:" + ("ordernum=" + order), sqliteConn);
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
-                Log.WriteErrorLog("\r\n" + ex.Message + ":" + result.StatusDescription + result.Html + "\r\nAddress:" + url + "/getreportofflinesn.do?" + "\r\nPostdata:" + ("orderNumber =" + order));
-                CommonMethod.ReportErrormsg("Error parse download status return", result.StatusDescription + result.Html + "\r\nAddress:" + url + "/getreportofflinesn.do?" + "\r\nPostdata:" + ("orderNumber =" + order), sqliteConn);
+                Log.WriteErrorLog("\r\n" + ex.Message + ":" + result.StatusDescription + result.Html + "\r\nAddress:" + url + "/offline/getreportofflinesn" + "\r\nPostdata:" + ("ordernum=" + order));
+                CommonMethod.ReportErrormsg("Error parse download status return", result.StatusDescription + result.Html + "\r\nAddress:" + url + "/offline/getreportofflinesn" + "\r\nPostdata:" + ("ordernum=" + order), sqliteConn);
                 return false;
             }
+
+            return true;
         }
     };
 };

+ 10 - 15
FactoryTool_CShare/Database/SQLiteHelper.cs

@@ -752,8 +752,7 @@ namespace MOKA_Factory_Tools
         {
             postList = new List<PostDateClass>();
             try
-            {
-                
+            {                
                 SQLiteCommand cmd = new SQLiteCommand();
                 SNs = new List<string>();
                 cmd.Connection = sqliteConn;
@@ -777,28 +776,23 @@ namespace MOKA_Factory_Tools
                 Log.WriteErrorLog("\r\nFail to GetEppormData:" + ex.Message);
                 return false;
             }
-
         }
 
-        public static bool GetEppormDataList2(SQLiteConnection sqliteConn, out List<PostDateClass> postList, out List<string> SNs)
+        public static bool GetEppormDataListV2(SQLiteConnection sqliteConn, out List<string> listSN, out List<string> listCopydates)
         {
-            postList = new List<PostDateClass>();
             try
             {
-
+                listSN = new List<string>();
+                listCopydates = new List<string>();
                 SQLiteCommand cmd = new SQLiteCommand();
-                SNs = new List<string>();
                 cmd.Connection = sqliteConn;
-                cmd.CommandText = "select sn,copy_date from keys where report_date is null and copy_date is not null LIMIT 20";
+                cmd.CommandText = "select sn,copydate from keys where report_date is null LIMIT 200";
                 SQLiteDataReader dr = cmd.ExecuteReader();
                 while (dr.Read())
                 {
                     NameValueCollection user = dr.GetValues();
-                    string sn = user.Get("sn");
-                    string copy_date = user.Get("copy_date");
-                    SNs.Add(sn);
-                    postList.Add(new PostDateClass("sn", sn));
-                    postList.Add(new PostDateClass("date", copy_date));                                
+                    listSN.Add(user.Get("sn"));
+                    listCopydates.Add(user.Get("copydate").ToString());
                 }
                 dr.Close();
                 return true;
@@ -806,12 +800,13 @@ namespace MOKA_Factory_Tools
             catch (Exception ex)
             {
                 GC.Collect();
-                SNs = null;
+                listSN = null;
+                listCopydates = null;
                 Log.WriteErrorLog("\r\nFail to GetEppormData:" + ex.Message);
                 return false;
             }
-
         }
+
         public static bool GetEppormDataCount(SQLiteConnection sqliteConn, out string count)
         {
             count = "";

+ 1 - 0
FactoryTool_CShare/MOKA Factory Tools.csproj

@@ -92,6 +92,7 @@
     <Compile Include="BLL\NTFBLL.cs" />
     <Compile Include="Business\CommonMethod.cs" />
     <Compile Include="Business\Countkey.cs" />
+    <Compile Include="Business\GMethod.cs" />
     <Compile Include="Business\SanhuaMethod.cs" />
     <Compile Include="Business\V2Method.cs" />
     <Compile Include="DAL\BaseDAL.cs" />

+ 1 - 1
FactoryTool_CShare/Models/StructList.cs

@@ -211,7 +211,7 @@ namespace MOKA_Factory_Tools
         /// <summary>
         /// 产线工站,抄写工具默认为DataBurning
         /// </summary>
-        public string Station { get; set; } = "DataBurning";
+        public readonly string Station = "DataBurning";
 
         #region 波兰工厂DHA解决方案;
         /// <summary>

+ 16 - 23
FactoryTool_CShare/Views/CreateDBManually.cs

@@ -38,9 +38,9 @@ namespace MOKA_Factory_Tools
             {
                 dbPath = AppDomain.CurrentDomain.BaseDirectory + "\\Keys\\" + Order_Text.Text.Trim() + ".db";
                 order = Order_Text.Text.Trim();
-                if (CommonMethod.GetMidInfo(url, order, TestMode.MAC, "", "", errorDBNow, out midList1))
-                {   
-                    if (CommonMethod.GetMidAddress2(midList1, order, errorDBNow, out List<MidAddress> midAddress2))
+                if (V2Method.GetMidInfo(url, order, TestMode.MAC, errorDBNow, out midList1))
+                {
+                    if (V2Method.GetOfflineData(midList1.host, order, errorDBNow, out List<MidAddress> midAddress2))
                     {
                         foreach(var midAddress1 in midAddress2)
                         {
@@ -57,7 +57,7 @@ namespace MOKA_Factory_Tools
                             ReportDB.Open();
                             if (SQLiteHelper.WholeCheckDownloadStatus(ReportDB, order))
                             {
-                                if (CommonMethod.ReportDownloadStatus(midList1.host, order, errorDBNow))
+                                if (V2Method.ReportDownloadStatus(midList1.host, order, errorDBNow))
                                     MessageBox.Show(LResource.DownloadSuccess);
                                 else
                                     MessageBox.Show(LResource.DownloadReportFail);
@@ -67,11 +67,9 @@ namespace MOKA_Factory_Tools
                     }
                     else
                         MessageBox.Show(LResource.GetMidAdresserror);
-
                 }
                 else
                     MessageBox.Show(LResource.GetMidInfoerror);
-
             }
             else
                 MessageBox.Show("请输入订单号!");
@@ -94,31 +92,26 @@ namespace MOKA_Factory_Tools
                     progressBar1.Value= Convert.ToInt32(count);
                 else
                     goto end;
-                List<string> SNs = new List<string>();
+
                 do
                 {
-                    //int n = 0;
-                    List<PostDateClass> postList = new List<PostDateClass>();
-                    
-                    if (!SQLiteHelper.GetEppormDataList(ReportDB, out postList,out SNs))
-                    {
+                    List<string> listSN;
+                    List<string> listCopydate;
+                    if (!SQLiteHelper.GetEppormDataListV2(ReportDB, out listSN, out listCopydate))
                         goto end;
-                    }
-                    if (SNs.Count==0)
-                    {
+                    
+                    if (listSN.Count == 0)
                         break;
-                    }
-                    if (!CommonMethod.UploadPreloadCopyResultList(midAddress1.host, postList, ReportDB, errorDBNow, false, ""))//
+
+                    if (V2Method.ReportOfflineData(midAddress1.host, string.Join(",", listCopydate.ToArray()), string.Join(",", listSN.ToArray()), ReportDB, errorDBNow, false, ""))
                     {
                         MessageBox.Show("上报异常!");
                         goto end;
+                    } else {
+                        SQLiteHelper.UpdateReportListStatus(ReportDB, listSN);
                     }
-                    else
-                    {
-                        SQLiteHelper.UpdateReportListStatus(ReportDB, SNs);          
-                        
-                    }
-                } while (SNs.Count>0);
+                } while(true);
+
                 MessageBox.Show("上报成功!");
                 result = false;
                 end:

+ 5 - 4
FactoryTool_CShare/Views/Download.cs

@@ -44,7 +44,7 @@ namespace MOKA_Factory_Tools
             skinLabel1.Text = LResource.DownloadKeys;
             this.Text = LResource.Download;
             Control.CheckForIllegalCrossThreadCalls = false;
-            DownloadLink = MidAddress1.purl;//MidAddress1.purl;//http://sz-idmanage.file.qhmoka.com/JsonFile/SanHua/20191105164316042.json
+            DownloadLink = MidAddress1.purl;
             DownloadSize = MidAddress1.psize;
             Ordername = MidAddress1.order;
             packet_md5 = MidAddress1.pmd5;
@@ -152,16 +152,17 @@ namespace MOKA_Factory_Tools
         public byte[] nbytes;//接收缓冲区
         public int nreadsize;//接收字节数
 
-
         public HttpFile(Download form, int thread)
         {
             formm = form;
             threadIndex = thread;
         }
+
         ~HttpFile()
         {
             formm.Dispose();
         }
+
         public int GetThread
         {
             get
@@ -169,6 +170,7 @@ namespace MOKA_Factory_Tools
                 return threadIndex;
             }
         }
+
         public int GetFilesize
         {
             get
@@ -176,6 +178,7 @@ namespace MOKA_Factory_Tools
                 return formm.filesize[threadIndex];
             }
         }
+
         public void ReceiveFile()//线程开始接收文件
         {
             filenamea = formm.filenameList[threadIndex];
@@ -407,6 +410,4 @@ namespace MOKA_Factory_Tools
             }
         }
     }
-
-
 }

+ 9 - 14
FactoryTool_CShare/Views/Main.cs

@@ -254,9 +254,9 @@ namespace MOKA_Factory_Tools
                     else
                     {
                         // 预绑定模式下:没有db数据库时需要下载json包;
-                        if (CommonMethod.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, "", "", ErrorDB, out midList1))
+                        if (V2Method.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out midList1))
                         {
-                            if (CommonMethod.GetMidAddress2(midList1, OrderText.Text.Trim(), ErrorDB, out List<MidAddress> midAddress2))
+                            if (V2Method.GetOfflineData(midList1.host, OrderText.Text.Trim(), ErrorDB, out List<MidAddress> midAddress2))
                             {
                                 WhiteBalanceList WhiteBalanceListNow;
                                 // 如果是抄写EDID,则不获取白平衡数据;
@@ -405,7 +405,7 @@ namespace MOKA_Factory_Tools
                                     }
                                     if (SQLiteHelper.WholeCheckDownloadStatus(LocalDB, OrderText.Text.Trim()))
                                     {
-                                        if (CommonMethod.ReportDownloadStatus(midList1.host, OrderText.Text.Trim(), ErrorDB))
+                                        if (V2Method.ReportDownloadStatus(midList1.host, OrderText.Text.Trim(), ErrorDB))
                                             MessageBox.Show(LResource.DownloadSuccess);
                                         else
                                             MessageBox.Show(LResource.DownloadReportFail);
@@ -428,12 +428,11 @@ namespace MOKA_Factory_Tools
                 }
                 else
                 {
-                    if (CommonMethod.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, "", "", ErrorDB, out midList1))
+                    if (V2Method.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out midList1))
                     {
                         CommonMethod.CheckKeyType(midList1.keytype, cfg_writedone, out key2Write);
                         OperationPanel.key2Write = key2Write;
 
-                        //CommonMethod.UpgradeCheck(UpgradeUrl.Officialurl, midList1.factoryNum, ErrorDB, out UpgradeMsgList1);
                         if (UsinglocalIDCheck.Checked)
                         {
                             midList1.projectid = Custom_ProjectID;
@@ -809,11 +808,6 @@ namespace MOKA_Factory_Tools
                 {
                     SaveJsonConfig("Line", "");
                 }
-
-                if (jObject["Station"] != null)
-                {
-                    functionSetting1.Station = jObject["Station"].Value<string>();
-                }
                 #endregion
 
                 #region 小米FireTV功能模块启用;
@@ -1314,19 +1308,20 @@ namespace MOKA_Factory_Tools
                         string content;
                         string id;
                         if (SQLiteHelper.GetDelayReportData(ErrorDB, out url, out content, out id))
+                        {
                             if (content.Contains("@"))
                             {
                                 string[] data = content.Split('@');
-                                if (CommonMethod.UploadPreloadCopyResult(url, data[1], data[0], LocalDB, ErrorDB, true, id, 30000))
+                                if (V2Method.ReportOfflineData(url, data[1], data[0], LocalDB, ErrorDB, true, id))
                                 {
                                     SQLiteHelper.UpdateReportData(ErrorDB, "CopyDelayReport", "ID", id);
                                 }
                             }
-                            else
-                                if (CommonMethod.UploadCopyResult(content, url, ErrorDB, OrderText.Text.Trim(), true, id, functionSetting1.ReportTimeOut))
+                            else if (V2Method.ReportOnlineData(url, OrderText.Text.Trim(), content, ErrorDB,  true, id, functionSetting1.ReportTimeOut))
                             {
                                 SQLiteHelper.UpdateReportData(ErrorDB, "CopyDelayReport", "ID", id);
                             }
+                        }
                     }
                     catch (Exception ex)
                     {
@@ -1343,7 +1338,7 @@ namespace MOKA_Factory_Tools
                             bool mark = false;
                             if ( url.EndsWith("smes/RecordKey") )
                             {
-                                CommonMethod.ReportDataBurningResultToMES(url, content, out mark);
+                                GMethod.ReportDataBurningResultToMES(url, content, out mark);
                             }
                             else
                             {

+ 15 - 7
FactoryTool_CShare/Views/OperationPanel.cs

@@ -806,7 +806,7 @@ namespace MOKA_Factory_Tools
                     // 根据SN获取订单类型;
                     string strOrderType;
                     string strErrorMsg;
-                    if (!CommonMethod.GetOrderTypeFromSN(SN, out strOrderType, out strErrorMsg))
+                    if (!GMethod.GetOrderTypeFromSN(SN, out strOrderType, out strErrorMsg))
                     {
                         Verify dlg = new Verify("根据SN获取订单类型失败,停止测试!" + "\r\nSN:" + SN);
                         dlg.ShowDialog();
@@ -2180,7 +2180,8 @@ namespace MOKA_Factory_Tools
                 // 部分订单无key,只有Roku信息;
                 if (midListNow.keytype.Count() != 0)
                 {
-                    if (!CommonMethod.GetIDMKeys(midListNow.host, SN, orderNow, psn, devicecode, key2Write, errorDBNow, ref keyInfo, out error))
+                    //if (!CommonMethod.GetIDMKeys(midListNow.host, SN, orderNow, psn, devicecode, key2Write, errorDBNow, ref keyInfo, out error))
+                    if (!V2Method.GetMidKey(midListNow.host, SN, orderNow, psn, devicecode, key2Write, errorDBNow, ref keyInfo, out error))
                     {
                         ErrMsg = string.Format("{0} GetIDMKeys Failed!\r\n{1}", SN, error);
                         Log.WriteErrorLog(ErrMsg);
@@ -4696,7 +4697,8 @@ namespace MOKA_Factory_Tools
                 }
                 //上传抄写状态
                 if (midListNow.host != "LocalPC")
-                    CommonMethod.UploadPreloadCopyResult(MidAddressNow.host, copydate, SN, localDBNow, errorDBNow, false, "", FunctionSettingNow.ReportTimeOut);
+                    //CommonMethod.UploadPreloadCopyResult(MidAddressNow.host, copydate, SN, localDBNow, errorDBNow, false, "", FunctionSettingNow.ReportTimeOut);
+                    V2Method.ReportOfflineData(MidAddressNow.host, copydate, SN, localDBNow, errorDBNow, false, "");
             }
             else if (!CommonMethod.HTTPChecker(midListNow.host))
             {
@@ -4709,8 +4711,11 @@ namespace MOKA_Factory_Tools
             {// 在线抄写;
                 if (WriteDID.Checked)
                 {
-                    if (CommonMethod.UploadCopyResult(keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow, midListNow.host, errorDBNow, orderNow, false, "", FunctionSettingNow.ReportTimeOut))
+                    //if (CommonMethod.UploadCopyResult(keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow, midListNow.host, errorDBNow, orderNow, false, "", FunctionSettingNow.ReportTimeOut))
+                    if (V2Method.ReportOnlineData(midListNow.host, orderNow, V2Method.GetReportJson(orderNow, SN, isNodid:false, ref keyInfo), errorDBNow,  false, "", FunctionSettingNow.ReportTimeOut))
+                    {
                         TestResult = 1;
+                    }
                     else
                     {
                         TestResult = 0;
@@ -4726,8 +4731,11 @@ namespace MOKA_Factory_Tools
                     if (SN.Trim().Length > 0)
                     {
                         keycontent += "nodid=true&";
-                        if (CommonMethod.UploadCopyResult(keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow, midListNow.host, errorDBNow, orderNow, false, "", FunctionSettingNow.ReportTimeOut))
+                        //if (CommonMethod.UploadCopyResult(keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow, midListNow.host, errorDBNow, orderNow, false, "", FunctionSettingNow.ReportTimeOut))
+                        if (V2Method.ReportOnlineData(midListNow.host, orderNow, V2Method.GetReportJson(orderNow, SN, isNodid: true, ref keyInfo), errorDBNow, false, "", FunctionSettingNow.ReportTimeOut))
+                        {
                             TestResult = 1;
+                        }
                         else
                         {
                             TestResult = 0;
@@ -4882,7 +4890,7 @@ namespace MOKA_Factory_Tools
                 { // 上报抄写结果到MES系统中;
                     string strOutMsg;
                     string returnObject;
-                    if (!CommonMethod.ReportDataBurningResultToMES(SN, keyInfo.DSN, (TestResult != 0) ? "Pass" : "Fail", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), errorDBNow, out strOutMsg, out returnObject))
+                    if (!GMethod.ReportDataBurningResultToMES(SN, keyInfo.DSN, (TestResult != 0) ? "Pass" : "Fail", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), errorDBNow, out strOutMsg, out returnObject))
                     {
                         ErrMsg = string.Format("上报抄写结果到MES失败,请紧急处理:{0}", strOutMsg);
                         Log.WriteErrorLog(ErrMsg);
@@ -4891,7 +4899,7 @@ namespace MOKA_Factory_Tools
                     }
 
                     // 将测试结果保存到Kayla要求的csv文件中;
-                    CommonMethod.GeneratKaylaData(FunctionSettingNow.Line, FunctionSettingNow.Station, OrderText.Text, SN, startTime, DateTime.Now, returnObject, keyInfo, TestResult != 0 ? true : false);
+                    GMethod.GeneratKaylaData(FunctionSettingNow.Line, FunctionSettingNow.Station, OrderText.Text, SN, startTime, DateTime.Now, returnObject, keyInfo, TestResult != 0 ? true : false);
                 }
             }
             #endregion