CommonUtil.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
DetectionDataUpload.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
MainForm.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Program.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Properties/AssemblyInfo.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
CommonUtil.cs
@@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using System.Windows; using System.Windows.Forms; using System.Threading; namespace M423project { @@ -46,22 +47,22 @@ private static object lockObj = new object(); private static object logObj = new object(); private static bool uploadDataEnable = true; //private static bool uploadDataEnable = true; public static bool UploadDataEnable { get { lock (lockObj) { return uploadDataEnable; } } set { lock (lockObj) { uploadDataEnable = value; } } } //public static bool UploadDataEnable //{ // get // { // lock (lockObj) { return uploadDataEnable; } // } // set // { // lock (lockObj) // { // uploadDataEnable = value; // } // } //} private static DetectionOption detectionOption = DetectionOption.doProduct; @@ -119,6 +120,10 @@ /// </summary> public static MainForm mainForm { get; set; } public static ManualResetEvent UploadDoneHandle = new ManualResetEvent(true); public static object UploadDataLock = new object(); public static bool UploadDataEnable = true; static CommonUtil() { CurrentDir = Directory.GetCurrentDirectory(); DetectionDataUpload.cs
@@ -23,7 +23,7 @@ { #region 数据上传相关私有成员 private DetectionData detectionData; private Thread uploadDataProcesser; private Thread uploadDataProcesser = null; //private RunCard runCard; private ConfigStruct config; #endregion @@ -43,33 +43,43 @@ /// </summary> public void Start() { if (uploadDataProcesser == null) { uploadDataProcesser = new Thread(Execute); uploadDataProcesser.IsBackground = true; uploadDataProcesser.Start(); } } public void Stop() { if (uploadDataProcesser != null && uploadDataProcesser.IsAlive) { uploadDataProcesser.Abort(); uploadDataProcesser.Join(); } uploadDataProcesser = null; //if (uploadDataProcesser != null && uploadDataProcesser.IsAlive) //{ // uploadDataProcesser.Abort(); // uploadDataProcesser.Join(); //} //uploadDataProcesser = null; } static object uploadLock = new object(); //static object uploadLock = new object(); public void UploadData() { lock (uploadLock) lock (CommonUtil.UploadDataLock) { if (!CommonUtil.UploadDataEnable) return; DataTable dtUpload = detectionData.QueryUnloadData(); if (dtUpload.Rows.Count <= 0) return; if (dtUpload.Rows.Count < 20) { Thread.Sleep(2000); dtUpload = detectionData.QueryUnloadData(); } CommonUtil.UploadDoneHandle.Reset(); // Type runCardClass = asm.GetType("AutoRunCard.RunCard"); // object runCardObj = Activator.CreateInstance(runCardClass); @@ -168,6 +178,7 @@ //} CommonUtil.WriteLog(LogType.Inf, string.Format("检测记录上传结束,共有{0}笔待上传数据,成功上传{1}笔", dtUpload.Rows.Count, uploadCount)); CommonUtil.UploadDoneHandle.Set(); } } @@ -234,11 +245,11 @@ int times = 1200 * 5; while (uploadDataProcesser.IsAlive) { if (!CommonUtil.UploadDataEnable) { Thread.Sleep(20); continue; } //if (!CommonUtil.UploadDataEnable) //{ // Thread.Sleep(20); // continue; //} //UploadData(asm); UploadData(); MainForm.cs
@@ -1075,19 +1075,35 @@ #region 事件 private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { try { Stop(); SaveMeasureTTL(); Task.Factory.StartNew(() => { //Task.Factory.StartNew(() => //{ SpotCheckData data = new SpotCheckData(); data.UpdateLastBreakProductQty(measureResultTTL.ProductQuntity); DownTimeData downTimeData = new DownTimeData(); DownTime downTime = new DownTime() { BeginTime = DateTime.Now, Type = DownTimeType.Closed }; downTimeData.SaveDownTime(downTime); }); //}); MessageHandler.MessageHandlerInstance.Close(); } catch (Exception ex) { Trace.TraceError($"界面关闭异常:{ex.Message}"); } finally { lock (CommonUtil.UploadDataLock) { //CommonUtil.UploadDoneHandle.WaitOne(); CommonUtil.UploadDataEnable = false; System.Environment.Exit(0); } } } private void btnConfig_Click(object sender, EventArgs e) { Program.cs
@@ -28,6 +28,7 @@ { // 程序已经运行,显示提示后退出 MessageBox.Show("应用程序已经运行!"); System.Environment.Exit(0); } } } Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.1.2")] [assembly: AssemblyFileVersion("1.0.1.2")] [assembly: AssemblyVersion("1.0.2.0")] [assembly: AssemblyFileVersion("1.0.2.0")]