private async Task RefreshConnectionState()
        {
            if (SelectedConnection == null)
            {
                return;
            }

            await ExecuteSafe(async t =>
            {
                IsIndetermine = true;
                SelectedConnection.IsLegacy = await UnicornCommandsManager.Execute(new IsLegacyCommand(SelectedConnection, t));
            }, "Connecting to Unicorn...", "Failed to read Unicorn version");
        }
Exemplo n.º 2
0
        private async Task Handshake()
        {
            _connection.IsLegacy = await UnicornCommandsManager.Execute(new IsLegacyCommand(_connection));

            var isSuccess = await UnicornCommandsManager.Execute(new HandshakeCommand(_connection, CancellationToken.None));

            if (isSuccess)
            {
                MessageBox.Show("All good!", "Connection test", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Ooops...Something went wrong.", "Connection test", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        private async Task CheckConfigurationHealth()
        {
            if (SelectedConnection == null || !CheckForConfigurationHealth)
            {
                return;
            }

            SetStatusBarText("Checking configuration status...");
            await RefreshConnectionState();
            await ExecuteSafe(async t =>
            {
                IsIndetermine    = true;
                var healthReport = await UnicornCommandsManager.Execute(new CheckConfigurationHealthCommand(SelectedConnection, SelectedConfigurations, t));
                if (healthReport.Any())
                {
                    _statusReports.Clear();
                    healthReport.ToList().ForEach(r => _statusReports.Add(r));
                }
            }, "Done", "Failed to check configuration status");
        }
 private async void ExecuteReserialize()
 {
     if (SelectedConnection == null)
     {
         MessageBox.Show("Please select connection.", "No connection", MessageBoxButton.OK,
                         MessageBoxImage.Exclamation);
         return;
     }
     await ExecuteSafe(async t =>
     {
         ResetState();
         using (var progressContext = new ProgressContext(StatusBar, "Serializing"))
         {
             var legacySynchronizeCommand = new ReserializeCommand(SelectedConnection,
                                                                   SelectedConfigurations, t, s => _dispatcher.Invoke(() => RefreshStatus(s, progressContext)));
             await UnicornCommandsManager.Execute(legacySynchronizeCommand)
             .ConfigureAwait(false);
         }
     }, $"{SelectedConnection} has been serialized", "Serialization failed").ConfigureAwait(false);
 }
        private async Task RefreshConfiguration()
        {
            if (SelectedConnection == null)
            {
                return;
            }

            SetStatusBarText("Connecting to Unicorn...");
            await RefreshConnectionState();
            await ExecuteSafe(async t =>
            {
                IsIndetermine          = true;
                SelectedConfigurations = string.Empty;
                Configurations.Clear();
                Configurations.Add(DefaultConfiguration);

                var configs = await UnicornCommandsManager.Execute(new ConfigurationsCommand(SelectedConnection, t));
                foreach (var config in configs)
                {
                    Configurations.Add(config);
                }
                SelectedConfigurationIndex = 0;
            }, $"Connected to {SelectedConnection.Name}", $"{SelectedConnection.Name} failed to connect").ConfigureAwait(false);
        }