private void btnTestConnection_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var hubSettings = new HubSettings()
                {
                    ServerUrl = txtHubServerUrl.Text,
                    Username  = txtHubUsername.Text,
                    Password  = txtHubPassword.Password,
                    Timeout   = txtHubTimeout.Text,

                    ProxyHost     = txtProxyHost.Text,
                    ProxyPort     = txtProxyPort.Text,
                    ProxyUsername = txtProxyUsername.Text,
                    ProxyPassword = txtProxyPassword.Password
                };

                if (hubSettings.HasSettings())
                {
                    var client = Authenticate.EstablishHubSession(hubSettings);

                    MessageBox.Show(client != null
                        ? Properties.Resources.MessageConnectionSuccessful
                        : Properties.Resources.MessageConnectionUnsuccessful);
                }
                else
                {
                    MessageBox.Show(Properties.Resources.MesageNoHubSettings);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Properties.Resources.MessageError);
                TaskManager.AddError(Properties.Resources.PaneTitle + ": " + ex.ToString());
            }
        }
        private async Task <bool> GetPackagesAndRiskInformation(IEnumerable <Project> projects)
        {
            var status = false;
            await Task.Run(() =>
            {
                var hubSettings = new HubSettings()
                {
                    ServerUrl     = _package.HubServerUrl,
                    Username      = _package.HubUsername,
                    Password      = _package.HubPassword,
                    Timeout       = _package.HubTimeout,
                    ProxyHost     = _package.ProxyHost,
                    ProxyPort     = _package.ProxyPort,
                    ProxyUsername = _package.ProxyUsername,
                    ProxyPassword = _package.ProxyPassword
                };

                if (!_installerServices.GetInstalledPackages().Any())
                {
                    return;
                }
                if (!hubSettings.HasSettings())
                {
                    _riskAnalysisStatus = Properties.Resources.MesageNoHubSettings;
                    status = false;
                }
                else
                {
                    var client = Authenticate.EstablishHubSession(hubSettings);

                    if (client == null)
                    {
                        _riskAnalysisStatus = Properties.Resources.MessageConnectionUnsuccessful;
                        status = false;
                    }
                    else
                    {
                        String version       = HubVersion.GetHubVersionNumberString(client);
                        bool hubLessThanFour = int.Parse(version.Split('.')[0]) < 4;
                        _packagesList.Clear();
                        _validProjectsList.Clear();

                        _validProjectsList.Add(Properties.Resources.ItemAll);

                        foreach (var project in projects)
                        {
                            List <IVsPackageMetadata> packages = null;

                            try
                            {
                                packages = _installerServices.GetInstalledPackages(project).ToList();
                                _validProjectsList.Add(project.Name);
                            }
                            catch { continue; }

                            var projectPath = project.Properties;

                            foreach (var package in packages)
                            {
                                var index =
                                    _packagesList.FindIndex(
                                        item => (item.Package == package.Id) && (item.Version == package.VersionString));

                                if (index < 0)
                                {
                                    _packagesList.Add(new NuGetPackageViewModel.NuGetPackage
                                    {
                                        Forge     = Properties.Resources.Forge,
                                        Package   = package.Id,
                                        Version   = package.VersionString,
                                        VsProject = project.Name
                                    });
                                }
                                else
                                {
                                    _packagesList[index].VsProject = _packagesList[index].VsProject + "|" + project.Name;
                                }
                            }
                        }

                        foreach (var item in _packagesList)
                        {
                            try
                            {
                                ProcessItem(item, client, hubLessThanFour);
                            } catch (Exception e)
                            {
                                _riskAnalysisStatus = e.Message;
                                status = false;
                            }
                        }

                        if (_packagesList.Count > 0)
                        {
                            _packagesList = _packagesList.OrderBy(x => x.PackageStatus).ThenBy(y => y.Package).ToList();
                        }

                        _validProjectsList.Sort();

                        status = true;
                        Task.Run(() => CollectData.CallHome(client, hubSettings.ServerUrl, _dte.Version));
                    }
                }
            });

            return(status);
        }