From 2ae1a69422dd50cef56d34f614c9ec19e7f22064 Mon Sep 17 00:00:00 2001 From: chenjiangqun Date: Wed, 13 May 2026 14:09:38 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9C=AA=E9=80=89=E6=8B=A9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=A6=81=E6=AD=A2=E5=8D=87=E7=BA=A7=202.=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=203.=E6=96=87=E4=BB=B6=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=A6=81=E6=AD=A2=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WinISP/FormISP_MSI.cs | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs index e17f7b8..aacfc56 100644 --- a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs @@ -168,6 +168,7 @@ namespace WinISP } #endif TopMost = true; + btnAuto.Enabled = false; Connect(); _lastNumOfMonitors = _numberOfMonitors; Application.Idle += Application_Idle; @@ -486,6 +487,7 @@ namespace WinISP frmISP.WriteLog("btnLoadFile_Click exception: " + ex.GetType().Name + ": " + ex.Message, "debug"); MessageBox.Show(this, "加载文件失败: " + ex.GetType().Name + "\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); SetStatusMsg("Could not read file from disk.", true); + btnAuto.Enabled = false; } if (_binFilePath == String.Empty) @@ -504,10 +506,12 @@ namespace WinISP { SetStatusMsg(verifyErr, true); SetStatusMsg("Please select a F/W file."); + btnAuto.Enabled = false; } else { SetStatusMsg("BIN loaded. Ready to upgrade."); + btnAuto.Enabled = true; } } } @@ -643,7 +647,7 @@ namespace WinISP //if (IsConnect) { //WriteLog("IsConnect = true", "debug"); - btnAuto.Enabled = true; + btnAuto.Enabled = !String.IsNullOrEmpty(_binFilePath); if (String.IsNullOrEmpty(_binFilePath)) SetStatusMsg("Please select a F/W file."); else @@ -1623,7 +1627,7 @@ namespace WinISP { // BIN has a version but monitor version is unreadable – treat as mismatch. frmISP.WriteLog("ValidateMonitorVsBin: effVer is empty, cannot verify FW version.", "debug"); - errMsg = "FWVersion not match" ; + errMsg = "FW Version not match." ; return false; } string normalizedMonVer = NormalizeFwVersionForCompare(effVer); @@ -1631,7 +1635,7 @@ namespace WinISP frmISP.WriteLog("ValidateMonitorVsBin: normalizedMonVer=" + normalizedMonVer + " normalizedBinVer=" + normalizedBinVer, "debug"); if (!string.Equals(normalizedMonVer, normalizedBinVer, StringComparison.OrdinalIgnoreCase)) { - errMsg = "FWVersion not match"; + errMsg = "FW Version not match."; return false; } } @@ -1692,6 +1696,7 @@ namespace WinISP if (!ValidateMonitorVsBin(out checkErr)) { SetStatusMsg(checkErr, true); + btnAuto.Enabled = false; return; } prbProgress.Maximum = flashSectorInfo.Count; @@ -1745,6 +1750,7 @@ namespace WinISP { SetStatusMsg(verifyErr, true); SetISPStatus(false); + btnAuto.Enabled = false; return; } @@ -2105,14 +2111,26 @@ namespace WinISP System.IO.Directory.CreateDirectory(resultFolder); string path = resultFolder + (fileName == "" ? "" : fileName + "_") + DateTime.Now.ToString("yyyy-MM-dd") + ".log"; - if (_logWriter == null || _logPath != path) + try { - if (_logWriter != null) { _logWriter.Flush(); _logWriter.Close(); } - _logPath = path; - _logWriter = new System.IO.StreamWriter(path, append: true); + if (_logWriter == null || _logPath != path) + { + if (_logWriter != null) + { + _logWriter.Flush(); + _logWriter.Close(); + } + _logPath = path; + var stream = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); + _logWriter = new System.IO.StreamWriter(stream); + } + _logWriter.WriteLine(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss.fff: ") + str); + _logWriter.Flush(); + } + catch (IOException) + { + // Ignore logging failures caused by file locks. } - _logWriter.WriteLine(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss.fff: ") + str); - _logWriter.Flush(); } public static Byte[] InitBinaryFile(String filepath)