private void AsyncSqlPuller_StatusChanged(AsyncReplicaOperations.AsyncSQLConnectPuller sender, AsyncStatusChangedEventArgs e) { if (e.NewStatus == RunningStatusEnum.Completed) { if (!pullers.All(x => x.Status == RunningStatusEnum.Completed)) { AsyncSQLConnectPuller puller = pullers.First(x => x.Status == RunningStatusEnum.NotRunning); puller.operatePull(); } else { this.Notify(); } } }
private void RunButton_Click(object sender, RoutedEventArgs e) { TabElement.Items.Clear(); Progress.Value = 0; pullers.Clear(); Global.dataSources = new Dictionary <string, ObservableCollection <PullValue> >(); sqlConnection = new SqlConnection(); timer = new Stopwatch(); try { //var connectSettings = AsyncReplicaOperations.ConnectSettings.getInstance(); if (!runtimeConfig.isValid) { operateManually(); } else { OperateAuto(); } if (pullers.Count > 0) { AsyncSQLConnectPuller puller = pullers.First(x => x.Status == RunningStatusEnum.NotRunning); puller.operatePull(); Progress.IsIndeterminate = true; } } catch (Exception exception) { MessageBox.Show(exception.Message, "Возникла ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } finally { if (sqlConnection.State == System.Data.ConnectionState.Open) { sqlConnection.Close(); } if (timer.IsRunning) { timer.Stop(); } Progress.IsIndeterminate = false; Progress.Value = 0; } }