public static Package ConvertToPackage(Version version) { var metadataWrapper = new MetadataWrapper(version.Metadata); var package = new Package { Id = version.Project, Version = version.Name, Title = metadataWrapper["Title"], Authors = metadataWrapper["Authors"], Copyright = metadataWrapper["Copyrights"], Description = metadataWrapper["Description"], IconUrl = metadataWrapper["IconUrl"], LicenseUrl = metadataWrapper["LicenseUrl"], ProjectUrl = metadataWrapper["ProjectUrl"], ReleaseNotes = metadataWrapper["RequireLicenseAcceptance"], RequireLicenseAcceptance = (metadataWrapper["LicenseUrl"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase), Summary = metadataWrapper["Summary"], Tags = metadataWrapper["Tags"], Dependencies = metadataWrapper["Dependencies"], PackageHash = metadataWrapper["PackageHash"] ?? version.PackageHash, PackageHashAlgorithm = metadataWrapper["PackageHashAlgorithm"] ?? "SHA512", PackageSize = int.Parse(metadataWrapper["PackageSize"] ?? "-1"), DownloadCount = int.Parse(metadataWrapper["DownloadCount"] ?? "0"), LastUpdated = DateTime.UtcNow, Published = DateTime.UtcNow, IsLatestVersion = (metadataWrapper["IsLatestVersion"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase), IsAbsoluteLatestVersion = (metadataWrapper["IsLatestVersion"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase), }; return(package); }
public static Package ConvertToPackage(Version version) { var metadataWrapper = new MetadataWrapper(version.Metadata); var package = new Package { Id = version.Project, Version = version.Name, Title = metadataWrapper["Title"], Authors = metadataWrapper["Authors"], Copyright = metadataWrapper["Copyrights"], Description = metadataWrapper["Description"], IconUrl = metadataWrapper["IconUrl"], LicenseUrl = metadataWrapper["LicenseUrl"], ProjectUrl = metadataWrapper["ProjectUrl"], ReleaseNotes = metadataWrapper["RequireLicenseAcceptance"], RequireLicenseAcceptance = (metadataWrapper["LicenseUrl"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase), Summary = metadataWrapper["Summary"], Tags = metadataWrapper["Tags"], Dependencies = metadataWrapper["Dependencies"], PackageHash = metadataWrapper["PackageHash"] ?? version.PackageHash, PackageHashAlgorithm = metadataWrapper["PackageHashAlgorithm"] ?? "SHA512", PackageSize = int.Parse(metadataWrapper["PackageSize"] ?? "-1"), DownloadCount = int.Parse(metadataWrapper["DownloadCount"] ?? "0"), LastUpdated = DateTime.UtcNow, Published = DateTime.UtcNow, IsLatestVersion = (metadataWrapper["IsLatestVersion"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase), IsAbsoluteLatestVersion = (metadataWrapper["IsLatestVersion"] ?? "").Equals("true", StringComparison.OrdinalIgnoreCase), }; return package; }
private string GetPackagePathFromVersion(Version version, string packageFormat) { // ReSharper disable ReplaceWithSingleCallToFirstOrDefault return(GetPackageNameCandidates(version, packageFormat) .Select(name => Path.Combine(version.Project, version.Name, name)) .Where(candidate => File.Exists(Path.Combine(configuration.DataPath, candidate))) .FirstOrDefault()); // ReSharper restore ReplaceWithSingleCallToFirstOrDefault }
public string Download(Caller caller, string company, string repository, string projectName, string versionName, string contentType) { var container = new Version { Company = company, Repository = repository, Project = projectName, Name = versionName }; using (var session = backendFactory.Create(caller)) return(session.GetPackageLink(ref container, contentType)); }
private string GetPackagePathFromVersion(Version version, string packageFormat) { // ReSharper disable ReplaceWithSingleCallToFirstOrDefault return GetPackageNameCandidates(version, packageFormat) .Select(name => Path.Combine(version.Project, version.Name, name)) .Where(candidate => File.Exists(Path.Combine(configuration.DataPath, candidate))) .FirstOrDefault(); // ReSharper restore ReplaceWithSingleCallToFirstOrDefault }
private IEnumerable <string> GetPackageNameCandidates(Version version, string packageFormat) { if (packageFormat != null) { return new[] { GetPackageName(packageFormat, version.Project, version.Name) } } ; return(new[] { GetPackageName("NuGet", version.Project, version.Name) }); }
private IEnumerable<string> GetPackageNameCandidates(Version version, string packageFormat) { if (packageFormat != null) return new[] { GetPackageName(packageFormat, version.Project, version.Name) }; return new[] { GetPackageName("NuGet", version.Project, version.Name), GetPackageName("OpenWrap", version.Project, version.Name) }; }
public virtual void DeleteVersion(Version version) { service.DeleteVersion(caller, version); }
public virtual void CreateVersion(Version version) { service.CreateVersion(caller, ref version); }
public virtual void UpdateVersion(Version version) { service.UpdateVersion(caller, ref version); }
public virtual void DeleteVersion(Version version) { throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name); }
public static Version ConvertToVersion(IPackage package) { var version = new Version { Project = package.Id, Name = package.Version.ToString(), }; var metadata = new List <MetadataEntry>(); var metadataWrapper = new MetadataWrapper(metadata); if (!package.Authors.IsEmpty()) { metadataWrapper["Authors"] = String.Join(",", package.Authors); } if (!string.IsNullOrEmpty(package.Copyright)) { metadataWrapper["Copyrights"] = package.Copyright; } if (!string.IsNullOrEmpty(package.Description)) { metadataWrapper["Description"] = package.Description; } if (package.IconUrl != null) { metadataWrapper["IconUrl"] = package.IconUrl.ToString(); } if (!string.IsNullOrEmpty(package.Language)) { metadataWrapper["Language"] = package.Language; } if (package.LicenseUrl != null) { metadataWrapper["LicenseUrl"] = package.LicenseUrl.ToString(); } if (!package.Owners.IsEmpty()) { metadataWrapper["Owners"] = String.Join(",", package.Owners); } if (package.ProjectUrl != null) { metadataWrapper["ProjectUrl"] = package.ProjectUrl.ToString(); } if (!string.IsNullOrEmpty(package.ReleaseNotes)) { metadataWrapper["ReleaseNotes"] = package.ReleaseNotes; } metadataWrapper["RequireLicenseAcceptance"] = package.RequireLicenseAcceptance.ToString(); if (!string.IsNullOrEmpty(package.Summary)) { metadataWrapper["Summary"] = package.Summary; } if (!string.IsNullOrEmpty(package.Tags)) { metadataWrapper["Tags"] = package.Tags; } if (package.DependencySets.SelectMany(ConvertDependencySetToStrings).Any()) { metadataWrapper["Dependencies"] = String.Join("|", package.DependencySets.SelectMany(ConvertDependencySetToStrings)); } if (!string.IsNullOrEmpty(package.Title)) { metadataWrapper["Title"] = package.Title; } using (var stream = package.GetStream()) { metadataWrapper["PackageSize"] = stream.Length.ToString(); metadataWrapper["PackageHashAlgorithm"] = "SHA512"; stream.Seek(0, SeekOrigin.Begin); using (var hasher = new SHA512Managed()) metadataWrapper["PackageHash"] = Convert.ToBase64String(hasher.ComputeHash(stream)); } metadataWrapper["DownloadCount"] = "000000"; metadataWrapper["CreatedDate"] = DateTime.UtcNow.ToString("s"); version.Metadata = metadata.ToArray(); return(version); }
public virtual Version SetVersionHidden(ref Version version, bool hidden) { throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name); }
public UploadReport UploadPackage(PackageProject package, string packageFormat, byte[] packageData, byte[] symbolPackageData) { //TODO: quick and dirty try { var version = new Version {Company = caller.Company, Repository = package.Repository, Project = package.Name, Name = package.Version.Name}; CreateVersion(version); PushPackage(ref version, packageData, package); CreateJob(symbolPackageData, package); return new UploadReport { Summary = "OK" }; } catch(Exception e) { return new UploadReport { Summary = "Error", Exception = e.ToString(), }; } }
public Compilation[] GetCompilationList(ref Version version) { throw new NotImplementedException(); }
public virtual void SetVersionPermissions(User targetUser, Version version, Permission permission) { throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name); }
public virtual void SetVersionPermissions(User targetUser, Version version, Permission permission) { service.SetVersionPermissions(caller, targetUser, version, permission); }
public virtual string GetPackageLink(ref Version version, string contentType) { return service.GetPackageLink(caller, ref version, contentType); }
public string GetPackageLink(ref Version version, string contentType) { return configuration.RemotePath + '/' + GetPackagePathFromVersion(version, null).Replace(Path.DirectorySeparatorChar, '/'); }
public virtual string GetPackageLink(ref Version version, string contentType) { throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name); }
public virtual void PushPackage(ref Version version, byte[] package, PackageProject packageProject) { throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name); }
public virtual Version SetVersionHidden(ref Version version, bool hidden) { return service.SetVersionHidden(caller, ref version, hidden); }
public virtual VersionPermission[] GetVersionPermissions(Version version) { throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name); }
public virtual VersionPermission[] GetVersionPermissions(Version version) { return service.GetVersionPermissions(caller, version); }
public virtual Compilation[] GetCompilationList(ref Version version) { throw new NotImplementedException("Not implemented: " + MethodBase.GetCurrentMethod().Name); }
public virtual Compilation[] GetCompilationList(ref Version version) { return service.GetCompilationList(caller, ref version); }
public static Version ConvertToVersion(Stream stream) { var package = new ZipPackage(stream); stream = package.GetStream(); var version = new Version { Project = package.Id, Name = package.Version.ToString(), }; var metadata = new List<MetadataEntry>(); var metadataWrapper = new MetadataWrapper(metadata); if (!package.Authors.IsEmpty()) metadataWrapper["Authors"] = String.Join(",", package.Authors); if (!string.IsNullOrEmpty(package.Copyright)) metadataWrapper["Copyrights"] = package.Copyright; if (!string.IsNullOrEmpty(package.Description)) metadataWrapper["Description"] = package.Description; if (package.IconUrl != null) metadataWrapper["IconUrl"] = package.IconUrl.ToString(); if (!string.IsNullOrEmpty(package.Language)) metadataWrapper["Language"] = package.Language; if (package.LicenseUrl != null) metadataWrapper["LicenseUrl"] = package.LicenseUrl.ToString(); if (!package.Owners.IsEmpty()) metadataWrapper["Owners"] = String.Join(",", package.Owners); if (package.ProjectUrl != null) metadataWrapper["ProjectUrl"] = package.ProjectUrl.ToString(); if (!string.IsNullOrEmpty(package.ReleaseNotes)) metadataWrapper["ReleaseNotes"] = package.ReleaseNotes; metadataWrapper["RequireLicenseAcceptance"] = package.RequireLicenseAcceptance.ToString(); if (!string.IsNullOrEmpty(package.Summary)) metadataWrapper["Summary"] = package.Summary; if (!string.IsNullOrEmpty(package.Tags)) metadataWrapper["Tags"] = package.Tags; if (package.DependencySets.SelectMany(ConvertDependencySetToStrings).Any()) metadataWrapper["Dependencies"] = String.Join("|", package.DependencySets.SelectMany(ConvertDependencySetToStrings)); if (!string.IsNullOrEmpty(package.Title)) metadataWrapper["Title"] = package.Title; metadataWrapper["PackageSize"] = stream.Length.ToString(); metadataWrapper["PackageHashAlgorithm"] = "SHA512"; stream.Seek(0, SeekOrigin.Begin); using (var hasher = new SHA512Managed()) metadataWrapper["PackageHash"] = Convert.ToBase64String(hasher.ComputeHash(stream)); metadataWrapper["DownloadCount"] = "000000"; metadataWrapper["CreatedDate"] = DateTime.UtcNow.ToString("s"); version.Metadata = metadata.ToArray(); return version; }
public void CreateVersion(Version version) { }
public void SetVersionHidden(ref Version version, bool hidden) { throw new NotImplementedException(); }
public string GetPackageLink(ref Version version, string contentType) { return(configuration.RemotePath + '/' + GetPackagePathFromVersion(version, null).Replace(Path.DirectorySeparatorChar, '/')); }