public PackageInfoCollection GetPackageInfoCollection([FromQuery] long from = 0)
        {
            var query = _trustDBService.DB.Packages.AsNoTracking(); // Makes read-only queries faster

            // The package need to be signed and not replaced!
            query = query.Where(p => (p.State & PackageStateType.Signed) > 0 && (p.State & PackageStateType.Replaced) == 0);
            query = query.Where(p => p.File != null);

            if (from > 0)
            {
                query = query.Where(p => p.Created >= from);
            }

            query = query.OrderByDescending(p => p.Created);

            var result = new PackageInfoCollection();

            foreach (var entity in query)
            {
                result.Packages.Add(new PackageInfo {
                    Id = entity.Id, File = entity.File
                });
            }

            return(result);
        }
Exemplo n.º 2
0
        public Task <PackageInfoCollection> GetPackageInfoCollectionAsync(string ipAddress, string scope, long from)
        {
            var info = new PackageInfoCollection();

            info.Packages.Add(new PackageInfo {
                Id = Encoding.UTF8.GetBytes("123"), File = "123"
            });
            return(Task.FromResult(info));
        }
        private static string GetProjectUrlTitle(PackageInfoCollection packageInfo)
        {
            if (!Uri.TryCreate(packageInfo?.ProjectUrl, UriKind.Absolute, out var uri))
            {
                return("Project Site");
            }

            if (uri.Host == "dev.azure.com")
            {
                return("Azure DevOps");
            }

            return(uri.Host);
        }
Exemplo n.º 4
0
        private void AddPackages(PackageInfoCollection infoCollection)
        {
            foreach (var packageInfo in infoCollection.Packages)
            {
                if (packageCache.ContainsKey(packageInfo.Id))
                {
                    continue;
                }

                if (_trustDBService.DoPackageExistAsync(packageInfo.Id).GetAwaiter().GetResult())
                {
                    continue;
                }

                // Get Package
                var package = _mediator.SendAndWait(new FetchPackageCommand(packageInfo.File));
                if (ValidatePackage(packageInfo, package))
                {
                    // Now add the package to the system, the graph should automatically be updated as well.
                    var result = _mediator.Send(new AddPackageCommand(package)).GetAwaiter().GetResult();
                    packageCache[packageInfo.Id] = packageInfo;
                }
            }
        }
 public async Task OnGet(string packageId, string packageVersion = null)
 {
     PackageInfo = await _metadataService.GetPackageInfo(packageId, packageVersion);
 }