private async void lbxGalleryProjects_ItemClick(object sender, int index) { try { string projectId = lbxGalleryProjects.ClickedItem.Id; List <IPackageSearchMetadata> metadata = new List <IPackageSearchMetadata>(); if (lblGalleryProjects.Text == "Gallery Automations") { metadata.AddRange(await NugetPackageManager.GetPackageMetadata(projectId, _galleryAutomationsSourceUrl, true)); } else if (lblGalleryProjects.Text == "Gallery Samples") { metadata.AddRange(await NugetPackageManager.GetPackageMetadata(projectId, _gallerySamplesSourceUrl, true)); } else if (lblGalleryProjects.Text == "Gallery Templates") { metadata.AddRange(await NugetPackageManager.GetPackageMetadata(projectId, _galleryTemplatesSourceUrl, true)); } string latestVersion = metadata.LastOrDefault().Identity.Version.ToString(); _projectVersions.Clear(); if (lblGalleryProjects.Text == "Gallery Automations") { _projectVersions.AddRange(await NugetPackageManager.GetPackageVersions(projectId, _galleryAutomationsSourceUrl, true)); } else if (lblGalleryProjects.Text == "Gallery Samples") { _projectVersions.AddRange(await NugetPackageManager.GetPackageVersions(projectId, _gallerySamplesSourceUrl, true)); } else if (lblGalleryProjects.Text == "Gallery Templates") { _projectVersions.AddRange(await NugetPackageManager.GetPackageVersions(projectId, _galleryTemplatesSourceUrl, true)); } List <string> versionList = _projectVersions.Select(x => x.ToString()).ToList(); versionList.Reverse(); cbxVersion.Items.Clear(); foreach (var version in versionList) { cbxVersion.Items.Add(version); } _selectedPackageMetaData = metadata; pnlProjectVersion.Show(); pnlProjectDetails.Show(); uiBtnOpen.Enabled = true; cbxVersion.SelectedItem = latestVersion; } catch (Exception) { pnlProjectVersion.Hide(); pnlProjectDetails.Hide(); uiBtnOpen.Enabled = false; } }
private async Task GetCurrentDepencies() { List <string> nugetDirectoryList = Directory.GetDirectories(_packagesPath).ToList(); _projectDependencies.Clear(); foreach (var pair in _projectDependenciesDict) { var dependency = (await NugetPackageManager.GetPackageMetadata(pair.Key, _packagesPath, _includePrerelease)) .Where(x => x.Identity.Version.ToString() == pair.Value).FirstOrDefault(); if (dependency != null && nugetDirectoryList.Where(x => x.EndsWith($"{pair.Key}.{pair.Value}")).FirstOrDefault() != null) { _projectDependencies.Add(dependency); } } }
private async void lbxNugetPackages_ItemClick(object sender, int index) { lblError.Text = ""; try { string projectId = lbxNugetPackages.ClickedItem.Id; List <IPackageSearchMetadata> metadata = new List <IPackageSearchMetadata>(); if (lblPackageCategory.Text == "Project Dependencies") { metadata.AddRange(await NugetPackageManager.GetPackageMetadata(projectId, _packagesPath, _includePrerelease)); } else if (lblPackageCategory.Text == "All Packages") { foreach (DataRow row in _packageSourceDT.Rows) { if (row[0].ToString() == "True") { metadata.AddRange(await NugetPackageManager.GetPackageMetadata(projectId, row[2].ToString(), _includePrerelease)); } } } else { var sourceURL = _packageSourceDT.AsEnumerable().Where(r => r.Field <string>("Enabled") == "True" && r.Field <string>("Package Name") == lblPackageCategory.Text) .Select(r => r.Field <string>("Package Source")).FirstOrDefault(); metadata.AddRange(await NugetPackageManager.GetPackageMetadata(projectId, sourceURL, _includePrerelease)); } string latestVersion = metadata.LastOrDefault().Identity.Version.ToString(); _projectVersions.Clear(); if (lblPackageCategory.Text == "Project Dependencies") { _projectVersions.AddRange(await NugetPackageManager.GetPackageVersions(projectId, _packagesPath, _includePrerelease)); } else if (lblPackageCategory.Text == "All Packages") { foreach (DataRow row in _packageSourceDT.Rows) { if (row[0].ToString() == "True") { _projectVersions.AddRange(await NugetPackageManager.GetPackageVersions(projectId, row[2].ToString(), _includePrerelease)); } } } else { var sourceURL = _packageSourceDT.AsEnumerable().Where(r => r.Field <string>("Enabled") == "True" && r.Field <string>("Package Name") == lblPackageCategory.Text) .Select(r => r.Field <string>("Package Source")).FirstOrDefault(); _projectVersions.AddRange(await NugetPackageManager.GetPackageVersions(projectId, sourceURL, _includePrerelease)); } List <string> versionList = _projectVersions.Select(x => x.ToString()).ToList(); versionList.Reverse(); cbxVersion.Items.Clear(); foreach (var version in versionList) { cbxVersion.Items.Add(version); } _selectedPackageMetaData = metadata; var installedPackage = _projectDependencies.Where(x => x.Identity.Id == projectId).FirstOrDefault(); if (installedPackage != null) { _isInstalled = true; _installedVersion = installedPackage.Identity.Version.ToString(); PopulateProjectDetails(_installedVersion); cbxVersion.SelectedItem = _installedVersion; } else { _isInstalled = false; _installedVersion = ""; PopulateProjectDetails(latestVersion); cbxVersion.SelectedIndex = 0; } pnlProjectVersion.Show(); pnlProjectDetails.Show(); } catch (Exception) { pnlProjectVersion.Hide(); pnlProjectDetails.Hide(); } }