private void btnProceed_OnClick(object sender, EventArgs e) { if (string.IsNullOrEmpty(OutputFolderPath) || string.IsNullOrEmpty(InputFilePath)) { MessageBox.Show("Выберите папку и файл!"); return; } ConfigHelper.UpdateConfigValues(OutputFolderPath, InputFilePath); try { //todo: proceed input file and generate tree structure var helper = new PortfolioHelper(InputFilePath, OutputFolderPath, string.Empty); helper.Proceed(); } catch (Exception ex) { _logger.Error("Proceed failed", ex); throw; } }
private void ProceedApplication() { Model.ProceedStatuses.Clear(); ConfigHelper.UpdateConfigValues(Model.OutputFolder, Model.InputFile, Model.CompletedFolder); var helper = new PortfolioHelper(Model.InputFile, Model.OutputFolder, Model.CompletedFolder); var worker = new BackgroundWorker {WorkerReportsProgress = true}; worker.DoWork += (o, ea) => { _logger.Info("Proceed Started"); Application.Current.Dispatcher.Invoke(new Action(() => Model.ProceedStatuses.Add("Запуск"))); Model.IsProceedEnabled = false; helper.Proceed(worker); }; worker.ProgressChanged += (o, ea) => { _logger.Info(ea.UserState.ToString()); Model.ProceedStatuses.Add(ea.UserState.ToString()); }; worker.RunWorkerCompleted += (o, ea) => { if (ea.Error != null) { _logger.Error("error", ea.Error); Model.ProceedStatuses.Add("Ошибка"); } else { _logger.Info("Proceed Ended"); Model.ProceedStatuses.Add("Завершено"); } Model.IsProceedEnabled = true; CommandManager.InvalidateRequerySuggested(); }; worker.RunWorkerAsync(); }