private void btnLoadData_Click(object sender, RoutedEventArgs e) { Task.Factory.StartNew(() => { ImportToDataBase importing = new ImportToDataBase(ExcelData); importing.SetProgress += GetProgress; importing.WriteMessageToConsole += AddUser_WriteMessageToConsole; importing.LoadIntoKoks(); this.Dispatcher.Invoke(new Action(() => this.progress.Value = 0)); }); }
private void BtnConfigSqlInser_Click(object sender, RoutedEventArgs e) { // Сформировать SQL-скрипт на вставку в KOKS. if (ExcelData.Rows.Count < 1) { MessageBox.Show("Пожалуйста, выберите Excel файл.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Куда сохраняем выбираем. string pathToSave = String.Empty; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "Выберите путь для сохранения ..."; saveFileDialog.Filter = "SQL file (*.sql)|*.sql|Text file (*.txt)|*.txt|C# file (*.cs)|*.cs"; if (saveFileDialog.ShowDialog() == true) { pathToSave = saveFileDialog.FileName; } else { return; } Task.Factory.StartNew(() => { ImportToDataBase import = new ImportToDataBase(ExcelData); import.SetProgress += GetProgress; import.WriteMessageToConsole += AddUser_WriteMessageToConsole; import.LoadIntoFile(pathToSave); this.Dispatcher.Invoke(new Action(() => this.progress.Value = 0)); }); }