private void OnIdeStartupComplete()
        {
            this.dteEvents.OnStartupComplete -= OnIdeStartupComplete;
            var settings = this.GetMefService <ISonarLintSettings>();

            if (settings.IsActivateMoreEnabled && daemon.IsInstalled)
            {
                if (!daemon.IsRunning)
                {
                    daemon.Start();
                }
            }
            else if (settings.IsActivateMoreEnabled)
            {
                // User already agreed to have the daemon installed, so directly start download
                new SonarLintDaemonInstaller(settings, daemon).Show();
            }
            else if (!settings.SkipActivateMoreDialog)
            {
                var result = new SonarLintDaemonSplashscreen(settings).ShowDialog();
                if (result == true)
                {
                    new SonarLintDaemonInstaller(settings, daemon).Show();
                }
            }
        }
        private void DownloadCompleted(object sender, AsyncCompletedEventArgs e)
        {
            try
            {
                daemon.DownloadProgressChanged -= DownloadProgressChanged;
                daemon.DownloadCompleted       -= DownloadCompleted;

                if (e.Error != null)
                {
                    var ex      = e.Error;
                    var message = string.Format($"Failed to activate support of additional languages: {ex.Message}");
                    MessageBox.Show(message, "Error", MessageBoxButton.OK);
                    Debug.WriteLine(message + "\n" + ex.StackTrace);
                    Close();
                    return;
                }

                if (!canceled)
                {
                    ProgressBar.Visibility      = Visibility.Collapsed;
                    CompletedMessage.Visibility = Visibility.Visible;

                    daemon.Start();
                    settings.IsActivateMoreEnabled = true;
                    callback?.DynamicInvoke();
                }

                OkButton.IsEnabled = true;
                OkButton.Focus();
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger.WriteLine(Strings.ERROR_InstallingDaemon, ex);
            }
        }
        private async System.Threading.Tasks.Task InitAsync()
        {
            ILogger logger = null;

            try
            {
                logger = await this.GetMefServiceAsync <ILogger>();

                logger.WriteLine(Resources.Strings.Daemon_Initializing);

                daemon = await this.GetMefServiceAsync <ISonarLintDaemon>();

                var settings = await this.GetMefServiceAsync <ISonarLintSettings>();

                LegacyInstallationCleanup.CleanupDaemonFiles(logger);

                if (daemon.IsInstalled)
                {
                    if (settings.IsActivateMoreEnabled && !daemon.IsRunning)
                    {
                        daemon.Start();
                    }
                }
                else
                {
                    if (settings.IsActivateMoreEnabled)
                    {
                        // User already agreed to have the daemon installed, so directly start download
                        await JoinableTaskFactory.SwitchToMainThreadAsync();

                        new SonarLintDaemonInstaller(settings, daemon, logger).Show();
                    }
                    else if (!settings.SkipActivateMoreDialog)
                    {
                        await JoinableTaskFactory.SwitchToMainThreadAsync();

                        var result = new SonarLintDaemonSplashscreen(settings).ShowDialog();
                        if (result == true)
                        {
                            new SonarLintDaemonInstaller(settings, daemon, logger).Show();
                        }
                    }
                }
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger?.WriteLine(Resources.Strings.ERROR_InitializingDaemon, ex);
            }
            logger?.WriteLine(Resources.Strings.Daemon_InitializationComplete);
        }
 public void Execute()
 {
     // Note: called on the UI thread so an unhandled exception will crash VS.
     // However, the only excecution path to this point should be from our tagger which
     // should handle any exceptions.
     if (!daemonInstaller.IsInstalled())
     {
         daemonInstaller.InstallationCompleted += HandleInstallCompleted;
         daemonInstaller.Install();
     }
     else
     {
         if (!daemon.IsRunning)
         {
             daemon.Ready += HandleDaemonReady;
             daemon.Start();
         }
         else
         {
             MakeRequest();
         }
     }
 }
        private void OnActivateMoreClicked(object sender, RoutedEventArgs e)
        {
            if (!daemon.IsInstalled)
            {
                new SonarLintDaemonInstaller(settings, daemon).Show(UpdateActiveMoreControls);
                return;
            }

            if (!daemon.IsRunning)
            {
                daemon.Start();
            }
            settings.IsActivateMoreEnabled = true;

            UpdateActiveMoreControls();
        }
Example #6
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            if (settings.IsActivateMoreEnabled && daemon.IsInstalled)
            {
                if (!daemon.IsRunning)
                {
                    daemon.Start();
                }
            }
            else if (!SkipActivateMoreDialog())
            {
                LaunchActivateMoreDialog();
            }
        }
Example #7
0
        private async System.Threading.Tasks.Task Init()
        {
            try
            {
                this.daemon = await this.GetMefServiceAsync <ISonarLintDaemon>();

                var settings = await this.GetMefServiceAsync <ISonarLintSettings>();

                var logger = await this.GetMefServiceAsync <ILogger>();

                LegacyInstallationCleanup.CleanupDaemonFiles(logger);

                if (settings.IsActivateMoreEnabled && daemon.IsInstalled)
                {
                    if (!daemon.IsRunning)
                    {
                        daemon.Start();
                    }
                }
                else if (settings.IsActivateMoreEnabled)
                {
                    // User already agreed to have the daemon installed, so directly start download
                    await JoinableTaskFactory.SwitchToMainThreadAsync();

                    new SonarLintDaemonInstaller(settings, daemon).Show();
                }
                else if (!settings.SkipActivateMoreDialog)
                {
                    await JoinableTaskFactory.SwitchToMainThreadAsync();

                    var result = new SonarLintDaemonSplashscreen(settings).ShowDialog();
                    if (result == true)
                    {
                        new SonarLintDaemonInstaller(settings, daemon).Show();
                    }
                }
            }
            catch (Exception)
            {
                // Log this
            }
        }
Example #8
0
        private void OnActivateMoreClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!daemon.IsInstalled)
                {
                    new SonarLintDaemonInstaller(settings, daemon, logger).Show(UpdateActiveMoreControls);
                    return;
                }

                if (!daemon.IsRunning)
                {
                    daemon.Start();
                }
                settings.IsActivateMoreEnabled = true;

                UpdateActiveMoreControls();
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger.WriteLine(Strings.ERROR_ConfiguringDaemon, ex);
            }
        }