private async void WindowX_Loaded(object sender, RoutedEventArgs e) { #region 初始化 LogHelper.CommLogger.Info("--------------------------------------------------------------------------------"); LogHelper.CommLogger.Info("开始初始化Encrypter"); Params param = null; try { if (!File.Exists(paramsFilePath)) { UpdateProgress(0, "未找到参数文件!"); LogHelper.CommLogger.Error("未找到参数文件!"); return; } //param = JsonMapper.ToObject<Params>(File.ReadAllText(paramsFilePath)); param = JsonHelper.GetFromFile <Params>(paramsFilePath); } catch (Exception ex) { UpdateProgress(0, "解析参数失败!"); LogHelper.CommLogger.Error("解析参数失败!"); return; } LogHelper.CommLogger.Info($"解析参数完成:{JsonHelper.SerializeObject(param)}"); Dictionary <string, string> connStrs = new Dictionary <string, string>(); var dbs = param.database.Replace(';', ';').Split(';'); string path = param.path; int cmd = param.cmd; if (dbs.Length < 1) { return; } for (int i = 0; i < dbs.Length; i++) { dbs[i] = dbs[i].Trim(); connStrs.Add(dbs[i], GetConnStr(dbs[i], param.connStr)); } #endregion EncryptorHelper encrypter = new EncryptorHelper(); try { var command = (EnumCMD)cmd; LogHelper.CommLogger.Info($"开始执行命令:{command}"); if (cmd >= 0 && cmd <= 3) { await encrypter.StartAsync(UpdateProgressSafely, dbs, connStrs, command); } else if (cmd >= 4 && cmd <= 9) { await encrypter.StartAsync(UpdateProgressSafely, path, command, connStrs[dbs[0]]); } } catch (Exception ex) { viewModel.EncryptMessage = ex.Message + ",程序即将退出!"; LogHelper.CommLogger.Error(ex.Message + ",程序即将退出!"); } LogHelper.CommLogger.Info("执行完成,关闭Encrypter"); UpdateProgress(100, "执行完成,关闭Encrypter!"); Thread.Sleep(3 * 1000); OnClose(); }