فهرست منبع

调整后台上报线程代码 。

jianfeng1.wang 2 سال پیش
والد
کامیت
0e4208eeb0
1فایلهای تغییر یافته به همراه47 افزوده شده و 45 حذف شده
  1. 47 45
      FactoryTool_CShare/Views/Main.cs

+ 47 - 45
FactoryTool_CShare/Views/Main.cs

@@ -1378,66 +1378,68 @@ namespace MOKA_Factory_Tools
         {
             while (true)
             {
-                if (CommonMethod.HTTPChecker(StructList.CheckServerConnectionUrl))
+                if (!CommonMethod.HTTPChecker(StructList.CheckServerConnectionUrl))
                 {
-                    try
+                    Thread.Sleep(20000);
+                    continue;
+                }
+                
+                try
+                {
+                    string url;
+                    string content;
+                    string id;
+                    if (SQLiteHelper.GetDelayReportData(ErrorDB, out url, out content, out id))
                     {
-                        string url;
-                        string content;
-                        string id;
-                        if (SQLiteHelper.GetDelayReportData(ErrorDB, out url, out content, out id))
+                        if (content.Contains("@"))
                         {
-                            if (content.Contains("@"))
-                            {
-                                string[] data = content.Split('@');
-                                if (V2Method.ReportOfflineData(url, data[1], data[0], LocalDB, ErrorDB, true, id))
-                                {
-                                    SQLiteHelper.UpdateReportData(ErrorDB, "CopyDelayReport", "ID", id);
-                                }
-                            }
-                            else if (V2Method.ReportOnlineData(url, OrderText.Text.Trim(), content, ErrorDB,  true, id, functionSetting1.ReportTimeOut))
+                            string[] data = content.Split('@');
+                            if (V2Method.ReportOfflineData(url, data[1], data[0], LocalDB, ErrorDB, true, id))
                             {
                                 SQLiteHelper.UpdateReportData(ErrorDB, "CopyDelayReport", "ID", id);
                             }
                         }
+                        else if (V2Method.ReportOnlineData(url, OrderText.Text.Trim(), content, ErrorDB,  true, id, functionSetting1.ReportTimeOut))
+                        {
+                            SQLiteHelper.UpdateReportData(ErrorDB, "CopyDelayReport", "ID", id);
+                        }
                     }
-                    catch (Exception ex)
-                    {
-                        Log.WriteErrorLog(ex.Message);
-                    }
+                }
+                catch (Exception ex)
+                {
+                    Log.WriteErrorLog(ex.Message);
+                }
 
-                    try
+                try
+                {
+                    string url;
+                    string content;
+                    string id;
+                    if (SQLiteHelper.GetErrorReportData(ErrorDB, out url, out content, out id))
                     {
-                        string url;
-                        string content;
-                        string id;
-                        if (SQLiteHelper.GetErrorReportData(ErrorDB, out url, out content, out id))
+                        bool mark = false;
+                        if ( url.EndsWith("smes/RecordKey") )
                         {
-                            bool mark = false;
-                            if ( url.EndsWith("smes/RecordKey") )
-                            {
-                                GMethod.ReportDataBurningResultToMES(url, content, out mark);
-                            }
-                            else
-                            {
-                                CommonMethod.ReportErrormsg2(url, content, out mark);
-                            }
-
-                            if (mark)
-                            {
-                                SQLiteHelper.UpdateReportData(ErrorDB, "ErrorReport", "ID", id);
-                            }
+                            GMethod.ReportDataBurningResultToMES(url, content, out mark);
+                        }
+                        else
+                        {
+                            CommonMethod.ReportErrormsg2(url, content, out mark);
                         }
 
+                        if (mark)
+                        {
+                            SQLiteHelper.UpdateReportData(ErrorDB, "ErrorReport", "ID", id);
+                        }
                     }
-                    catch (Exception ex)
-                    {
-                        Log.WriteErrorLog(ex.Message);
-                    }
-                    Thread.Sleep(5000);
                 }
-                else
-                    Thread.Sleep(20000);
+                catch (Exception ex)
+                {
+                    Log.WriteErrorLog(ex.Message);
+                }
+
+                // 频率5秒一次;
+                Thread.Sleep(5000);
             }
         }