commit version
This commit is contained in:
@ -19,11 +19,13 @@ namespace isnd.Services
|
||||
public class PackageManager : IPackageManager
|
||||
{
|
||||
ApplicationDbContext dbContext;
|
||||
public PackageManager(ApplicationDbContext dbContext, IOptions<IsndSettings> pmConfigOptions)
|
||||
public PackageManager(ApplicationDbContext dbContext,
|
||||
IOptions<IsndSettings> siteConfigOptionsOptions)
|
||||
{
|
||||
this.dbContext = dbContext;
|
||||
CurrentCatalogIndex = GetCatalogIndex();
|
||||
this.pmConfigOptions = pmConfigOptions.Value;
|
||||
pmConfigOptions = siteConfigOptionsOptions.Value;
|
||||
extApiUrl = pmConfigOptions.ExternalUrl + "/package";
|
||||
}
|
||||
|
||||
|
||||
@ -138,8 +140,10 @@ namespace isnd.Services
|
||||
}
|
||||
|
||||
public static CatalogIndex CurrentCatalogIndex { get; protected set; }
|
||||
public static List<Page> CurrentCatalogPages { get; protected set; }
|
||||
|
||||
private IsndSettings pmConfigOptions;
|
||||
private string extApiUrl;
|
||||
|
||||
public virtual CatalogIndex GetCatalogIndex()
|
||||
{
|
||||
@ -151,7 +155,59 @@ namespace isnd.Services
|
||||
}
|
||||
void LoadCatalogFromDb()
|
||||
{
|
||||
dbContext.Commits.OrderBy(c => c.TimeStamp);
|
||||
int i=0;
|
||||
int p=0;
|
||||
var oldIndex = CurrentCatalogIndex;
|
||||
var oldPages = CurrentCatalogPages;
|
||||
CurrentCatalogIndex = new CatalogIndex
|
||||
{
|
||||
|
||||
};
|
||||
CurrentCatalogPages = new List<Page>();
|
||||
|
||||
var scope = dbContext.Commits.OrderBy(c => c.TimeStamp);
|
||||
Commit last = null;
|
||||
PageRef pageRef = null;
|
||||
Page page = null;
|
||||
i=pmConfigOptions.CatalogPageLen;
|
||||
foreach (var commit in scope)
|
||||
{
|
||||
if (i >= this.pmConfigOptions.CatalogPageLen)
|
||||
{
|
||||
page = new Page{
|
||||
Parent = pmConfigOptions.ExternalUrl + "/package",
|
||||
CommitId = commit.CommitId,
|
||||
CommitTimeStamp = commit.CommitTimeStamp,
|
||||
Id = this.pmConfigOptions.ExternalUrl + "/package/index-" + p++
|
||||
|
||||
};
|
||||
CurrentCatalogPages.Add(page);
|
||||
pageRef = new PageRef{
|
||||
Id = page.Id
|
||||
};
|
||||
CurrentCatalogIndex.Items.Add(pageRef);
|
||||
i = 0;
|
||||
}
|
||||
PackageRef packageref = new PackageRef
|
||||
{
|
||||
CommitId = commit.Id.ToString(),
|
||||
Id = commit.PackageVersionId,
|
||||
|
||||
|
||||
CommitTimeStamp = commit.CommitTimeStamp,
|
||||
RefType = commit.Action == PackageAction.PublishPackage ?
|
||||
"nuget:PackageDetails" : "nuget:PackageDelete"
|
||||
};
|
||||
|
||||
page.Items.Add(packageref);
|
||||
last = commit;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (last!=null)
|
||||
{
|
||||
CurrentCatalogIndex.CommitId = last.CommitId;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@ -182,35 +238,35 @@ namespace isnd.Services
|
||||
public IEnumerable<Resource> GetResources(IUnleash unleashClient)
|
||||
{
|
||||
var res = new List<Resource>();
|
||||
if (unleashClient.IsEnabled("pkg-push"))
|
||||
if (unleashClient.IsEnabled("pkg-push", true))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
id = "package",
|
||||
id = extApiUrl,
|
||||
type = "PackagePublish/2.0.0",
|
||||
comment = "Package Publish service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-get"))
|
||||
if (unleashClient.IsEnabled("pkg-get", false))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
id = "package",
|
||||
id = extApiUrl,
|
||||
type = "PackageBaseAddress/3.0.0",
|
||||
comment = "Package Base Address service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-autocomplete"))
|
||||
if (unleashClient.IsEnabled("pkg-autocomplete", false))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
id = "package",
|
||||
id = extApiUrl,
|
||||
type = "SearchAutocompleteService/3.5.0",
|
||||
comment = "Auto complete service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-search"))
|
||||
if (unleashClient.IsEnabled("pkg-search", false))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
id = "package",
|
||||
id = extApiUrl,
|
||||
type = "SearchQueryService/3.5.0",
|
||||
comment = "Search Query service"
|
||||
});
|
||||
|
Reference in New Issue
Block a user