Added identifier and fetch time product listings; Added persistence to AdafruitShop.
Implemented in AdafruitShop. AdafruitShop Product listing data now persisted. AdafruitShop configuration now persisted.
This commit is contained in:
@@ -68,16 +68,15 @@ namespace Props.Services.Modules
|
||||
{
|
||||
ProductListingInfo productListingInfo =
|
||||
(from info in dbContext.ProductListingInfos
|
||||
where info.ProductUrl.Equals(productListing.URL)
|
||||
where info.ProductListingIdentifier.Equals(productListing.Identifier)
|
||||
select info).SingleOrDefault() ?? new ProductListingInfo();
|
||||
if (productListingInfo.Hits == 0)
|
||||
{
|
||||
dbContext.Add(productListingInfo);
|
||||
}
|
||||
productListingInfo.ShopName = shopName;
|
||||
productListingInfo.ProductName = productListing.Name;
|
||||
productListingInfo.ProductUrl = productListing.URL;
|
||||
productListingInfo.LastUpdated = DateTime.UtcNow;
|
||||
productListingInfo.ProductListing = productListing;
|
||||
productListingInfo.ProductListingIdentifier = productListing.Identifier;
|
||||
productListingInfo.Hits += 1;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
@@ -55,7 +55,6 @@ namespace Props.Services.Modules
|
||||
|
||||
public void LoadShops()
|
||||
{
|
||||
// TODO: Figure out how to best call this.
|
||||
string shopsDir = options.ModulesDir;
|
||||
string shopRegex = options.ShopRegex;
|
||||
bool recursiveLoad = options.RecursiveLoad;
|
||||
@@ -87,7 +86,8 @@ namespace Props.Services.Modules
|
||||
IShop shop = Activator.CreateInstance(type) as IShop;
|
||||
if (shop != null)
|
||||
{
|
||||
DirectoryInfo dataDir = Directory.CreateDirectory(Path.Combine(options.ModuleDataDir, file));
|
||||
DirectoryInfo dataDir = Directory.CreateDirectory(Path.Combine(options.ModuleDataDir, file.Substring(file.IndexOf(Path.DirectorySeparatorChar) + 1)));
|
||||
logger.LogDebug("Checking data directory for \"{0}\" at \"{1}\"", Path.GetFileName(file), dataDir.FullName);
|
||||
shop.Initialize(dataDir.FullName, loggerFactory);
|
||||
success += 1;
|
||||
if (!shops.TryAdd(shop.ShopName, shop))
|
||||
@@ -105,8 +105,6 @@ namespace Props.Services.Modules
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.LogDebug("Waiting for all shops to finish asynchronous initialization.");
|
||||
logger.LogDebug("All shops finished asynchronous initialization.");
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
@@ -117,7 +115,7 @@ namespace Props.Services.Modules
|
||||
{
|
||||
foreach (string shopName in shops.Keys)
|
||||
{
|
||||
// TODO: Get shop data to persist.
|
||||
shops[shopName].SaveData().AsTask().Wait();
|
||||
shops[shopName].Dispose();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user