private bool UpdateInfo(ArrayList WinId) { try { if (WinId == null || WinId.Count == 0) { return(false); } string sQuery = ""; string Server_Ver = ""; string Client_Ver = null; if (Server_Info() == false) { Label1.Visible = true; Label1.Text = "服务器连接超时,请检查"; return(false); } else { for (int i = 0; i < WinId.Count; i++) { sQuery = "{call PKG_MAIN.P_FIND_VER('" + WinId[i] + "')}"; Server_Ver = GeneralCommon.Gf_CodeFind(sQuery); //Client Version Client_Ver = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\" + RegLocation + @"\VERSION\").GetValue(WinId[i].ToString(), "0.0.0").ToString(); if (Server_Ver != Client_Ver | !System.IO.File.Exists(sExePath + WinId[i])) { return(true); } } return(true); } } catch //(System.Exception e) { return(false); } }
//============================================================================================== // Procedure Name : DownLoad_File // Description : 下载所有更新文件 //============================================================================================== private bool DownLoad_File(ArrayList WinId) { //return true; bool functionReturnValue = false; if (MainMenu_Check()) { if (MessageBox.Show("检验室程序正在运行,是否要关闭?关闭前请保存当前操作以免丢失数据。", "更新提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { Process[] myProcess = null; myProcess = Process.GetProcessesByName(ProcessesName); foreach (Process myPro in myProcess) { myPro.Kill(); } } else { return(true);; } } if (WinId == null) { return(true); } string sQuery = null; int i = 0; string Client_Ver = null; string Server_Ver = null; FILE_SIZE = 0; functionReturnValue = false; try { //check ftp server info if (string.IsNullOrEmpty(sServerIP) | string.IsNullOrEmpty(sServerID) | string.IsNullOrEmpty(sServerPWD) | string.IsNullOrEmpty(sServerPATH)) // { GeneralCommon.Gp_MsgBoxDisplay("FTP服务器信息不存在...!!", "W"); return(false); } Cursor.Current = Cursors.WaitCursor; Application.DoEvents(); //check download folder if (!System.IO.Directory.Exists(sExePath)) { System.IO.Directory.CreateDirectory(sExePath); } this.pic_Close.Visible = false; Label1.Visible = true; Label1.Text = "程序更新中,请勿关闭"; for (i = 0; i < WinId.Count; i++) { //Server Version sQuery = "{call PKG_MAIN.P_FIND_VER('" + WinId[i] + "')}"; Server_Ver = GeneralCommon.Gf_CodeFind(sQuery); //Client Version Client_Ver = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\" + RegLocation + @"\VERSION\").GetValue(WinId[i].ToString(), "0.0.0").ToString();// Interaction.GetSetting("CYEDM", "VERSION", WinId[i], "0.0.0"); if (Server_Ver != Client_Ver | !System.IO.File.Exists(sExePath + WinId[i])) { //Client File Delete if (System.IO.File.Exists(sExePath + WinId[i])) { System.IO.File.Delete(sExePath + WinId[i]); } int point = WinId[i].ToString().LastIndexOf(@"\"); string spath = sExePath; string sysname = ""; if (point > 0) { spath = sExePath + WinId[i].ToString().Substring(0, point); if (System.IO.Directory.Exists(spath) == false) { System.IO.Directory.CreateDirectory(spath);// FileSystem.MkDir(spath); } sysname = WinId[i].ToString().Substring(point + 1); } FTPClient ftp = new FTPClient(sServerIP, sServerPATH, sServerID, sServerPWD, sServerPORT); if (ftp.Get(WinId[i].ToString(), sExePath, WinId[i].ToString())) { Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\" + RegLocation + @"\VERSION\").SetValue(WinId[i].ToString(), Server_Ver); } else { GeneralCommon.Gp_MsgBoxDisplay("下载文件出错 : " + ftp.strReply); GeneralCommon.Gp_LogData(WinId[i].ToString() + " " + ftp.strReply); } } } PrgDown.Visible = false; pic_Close.Visible = true; Label1.Visible = false; functionReturnValue = true; Cursor.Current = Cursors.Default; Application.DoEvents(); } catch (Exception ex) { PrgDown.Visible = false; GeneralCommon.Gp_MsgBoxDisplay("下载文件 Error : " + ex.Message); Cursor.Current = Cursors.Default; Application.DoEvents(); } return(functionReturnValue); }