Ejemplo n.º 1
0
 private static StatsPackage GetStatsPackage(DataServicePackage package)
 {
     return new StatsPackage {
         Id = package.Id,
         Version = package.Version,
         DownloadCount = package.DownloadCount,
         // Workaround for the gallery url until it is fixed.
         Url = String.Format("http://nuget.org/List/Packages/{0}/{1}", HttpUtility.UrlPathEncode(package.Id), HttpUtility.UrlPathEncode(package.Version.ToString()))
     };
 }
 private static void Delete(IPackageRepository repo, DataServicePackage package, bool whatIf)
 {
     if (!whatIf)
       {
     repo.RemovePackage(package);
       }
       else
       {
     logger.Info("skipping as whatif is true");
       }
 }
        public static void BackupAndDelete(IPackageRepository repo, string nugetServerUrl, DataServicePackage package, string packageBackupfolder, bool whatIf)
        {
            try
              {
            Backup(nugetServerUrl, package, packageBackupfolder, whatIf);
              }
              catch (Exception ex)
              {
            throw new Exception(string.Format("Backup of package {0} version {1} failed. skipping delete",package.Id,package.Version),ex);
              }

              Delete(repo,package,whatIf);
        }
 private static void Backup(string nugetServerUrl, DataServicePackage package, string packageBackupfolder, bool whatIf)
 {
     var serverUrl = string.Format("{0}/api/v2/package/{1}/{2}", nugetServerUrl, package.Id, package.Version);
       var uri = new Uri(serverUrl);
       logger.Info(string.Format("Downloading package {0} to folder {1} from url {2}",package.Id,packageBackupfolder,uri));
       if (!whatIf)
       {
     var downloader = new PlexPackageDownloader(uri, packageBackupfolder);
     downloader.Download(package);
       }
       else
       {
     logger.Info("skipping as whatif is true");
       }
 }
        public void GetPackageDependenciesRecursive(DataServicePackage package, HashSet<DataServicePackage> dependencies)
        {
            dependencies.Add(package);
              var packagesToReslove = new List<DataServicePackage>();

              foreach (var packageDependencySet in package.DependencySets)
              {
            foreach (var dependency in packageDependencySet.Dependencies)
            {
              var dependecyPackage = (DataServicePackage)_repo.ResolveDependency(dependency, true, true);
              if (dependecyPackage != null && !dependencies.Contains(dependecyPackage))
              {
            packagesToReslove.Add(dependecyPackage);
              }
            }
              }

              foreach (var p in packagesToReslove)
              {
            GetPackageDependenciesRecursive(p, dependencies);
              }
        }
 /// <summary>
 /// Creates a blank DataServicePackage with the required field Id already filled in.
 /// </summary>
 private DataServicePackage CreateTestDataServicePackage()
 {
     DataServicePackage newDataServicePackage = new DataServicePackage()
     {
         Id = "Foo.Bar"
     };
     return newDataServicePackage;
 }