private void masterUpdate_NewVersionFound(string[] newfiles) { try { if (this.InvokeRequired) { this.Invoke(new MasterDataUpdate.NewVersionFoundEventHandler(masterUpdate_NewVersionFound), new object[] { newfiles }); } else { _hasRemindDialog = true; string message = ""; DataView dv = DynamicCtrl.GetOpenFileMenuConfigFile(); if (dv == null) return; Dictionary<string, string> masterFiles = new Dictionary<string, string>(); for (int ix = 0; ix < dv.Table.Rows.Count; ix++) { masterFiles.Add(DataConvert.GetString(dv.Table.Rows[ix]["FileName"]), DataConvert.GetString(dv.Table.Rows[ix]["Caption"])); } StringBuilder sb = new StringBuilder(); for (int ix = 0; ix < newfiles.Length; ix++) { if (String.IsNullOrEmpty(newfiles[ix])) continue; string caption = ""; masterFiles.TryGetValue(newfiles[ix], out caption); sb.Append("{"); sb.Append(caption); sb.Append("}"); if (ix < newfiles.Length - 1) sb.Append(","); } message = sb.ToString(); message = message.Substring(0, message.Length - 1); if (MessageBox.Show(this, "检测到有新的" + message + "\r\n是否下载到本地?", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { // Call the auto update program with the parameter MasterDataUpdate masterUpdate = new MasterDataUpdate(); masterUpdate.DownloadNewMasterDataFiles(newfiles); MessageBox.Show(this, "下载完成!"); } _hasRemindDialog = false; } } catch { //Program.ShowMessageBox("MainForm", ex); } }
private void CheckAndDownloadMasterData(bool IsStartUp, bool IsManually) { Thread updateThread = new Thread(new System.Threading.ThreadStart(delegate { MasterDataUpdate masterUpdate = new MasterDataUpdate(); masterUpdate.LatestVersionConfirmed += new MasterDataUpdate.LatestVersionConfirmedEventHandler(masterUpdate_LatestVersionConfirmed); masterUpdate.NewVersionFound += new MasterDataUpdate.NewVersionFoundEventHandler(masterUpdate_NewVersionFound); masterUpdate.CheckVersion(IsStartUp, IsManually); })); updateThread.IsBackground = true; updateThread.Start(); }