/// <summary> /// 保存信息到配置文件 /// </summary> public static void Save() { Dictionary <string, string> paramItem = m_dicParams["系统参数"] as Dictionary <string, string>; m_dbPlatformServiceConnectionString = m_dbPlatformServiceConnectionString.Replace(paramItem["数据库服务器地址"], m_dataServerIP); paramItem["数据库服务器地址"] = m_dataServerIP; m_xmlParams.SaveParams(m_dicParams, false); }
/// <summary> /// 升级文件线程 /// </summary> private void UpgradeFileThread() { try { if (!Directory.Exists(m_tempPath)) { Directory.CreateDirectory(m_tempPath); } for (int i = 0; i < m_upgradeFile.Count; i++) { if (listViewFileList.InvokeRequired) { listViewFileList.Invoke(new UpgradeFileHandle(this.ShowUpgradeStatus), new object[] { "正在更新...", i }); } Sys_AutoUpgrade upgradeInfo = m_upgradeManagement.GetUpgradeInfo(m_upgradeFile[i].序号); string tempFile = string.Format("{0}~dki390v{1}{2}.tmp", m_tempPath, DateTime.Now.ToString("hhmmss"), DateTime.Now.Millisecond); using (FileStream outStream = new FileStream(tempFile, FileMode.Create)) { outStream.Write(upgradeInfo.文件内容.ToArray(), 0, upgradeInfo.文件内容.Length); outStream.Close(); } if (!File.Exists(tempFile)) { throw new Exception(string.Format("无法创建临时文件, 更新 {0} 文件失败...", m_upgradeFile[i].文件名称)); } PlatformManagement.ZipService.UnZipFile(tempFile, m_filePath, m_upgradeFile[i].文件名称, "pwd123!"); Thread.Sleep(160); if (listViewFileList.InvokeRequired) { listViewFileList.Invoke(new UpgradeFileHandle(this.ShowUpgradeStatus), new object[] { "更新完毕...", i }); } File.Delete(tempFile); Thread.Sleep(100); } //2017-07-07,夏石友 修改 m_xmlParams.SaveParams(m_dicUpdateSystem, true); } catch (Exception exce) { m_error = true; lblFindNewVersion.Invoke(new UpgradeMessageHandle(this.ShowUpgradePrompt), new object[] { exce.Message, Color.Red }); Thread.Sleep(3000); lblFindNewVersion.Invoke(new UpgradeMessageHandle(this.ShowUpgradePrompt), new object[] { "更新失败,系统终止,请联系系统管理员", Color.Red }); Thread.Sleep(3000); } finally { lblFindNewVersion.Invoke(new ExitHandle(this.Exit)); // 删除临时文件夹 Directory.Delete(m_tempPath, true); //2017-07-07,夏石友 修改 //m_xmlParams.SaveParams(m_dicUpdateSystem, true); } }