WPI: load only main (Microsoft) feed if other feeds loading failed
This commit is contained in:
parent
54c8438ece
commit
fc7eeb0df6
2 changed files with 79 additions and 17 deletions
|
@ -55,7 +55,7 @@ namespace WebsitePanel.Server.Code
|
||||||
|
|
||||||
#region private fields
|
#region private fields
|
||||||
|
|
||||||
private readonly List<string> _feeds;
|
private List<string> _feeds;
|
||||||
private string _webPIinstallersFolder;
|
private string _webPIinstallersFolder;
|
||||||
private const string IisChoiceProduct = "StaticContent";
|
private const string IisChoiceProduct = "StaticContent";
|
||||||
private const string WebMatrixChoiceProduct = "WebMatrix";
|
private const string WebMatrixChoiceProduct = "WebMatrix";
|
||||||
|
@ -568,15 +568,66 @@ namespace WebsitePanel.Server.Code
|
||||||
Directory.CreateDirectory(_webPIinstallersFolder);
|
Directory.CreateDirectory(_webPIinstallersFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load feeds
|
LoadFeeds();
|
||||||
|
|
||||||
|
WriteLog(string.Format("{0} products loaded", _productManager.Products.Count));
|
||||||
|
|
||||||
|
//LogDebugInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadFeeds()
|
||||||
|
{
|
||||||
|
if (null == _feeds || !_feeds.Any())
|
||||||
|
{
|
||||||
|
throw new Exception("WpiHelper: no feeds provided");
|
||||||
|
}
|
||||||
|
|
||||||
_productManager = new ProductManager();
|
_productManager = new ProductManager();
|
||||||
|
|
||||||
|
if (TryLoadFeeds())
|
||||||
|
{
|
||||||
|
// ok, all feeds loaded
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// feed loading failed
|
||||||
|
|
||||||
|
if (_feeds.Count > 1)
|
||||||
|
{
|
||||||
|
// exclude feeds except first (default microsoft feed)
|
||||||
|
_feeds = new List<string> {_feeds[0]};
|
||||||
|
|
||||||
|
// re-create product manager
|
||||||
|
_productManager = new ProductManager();
|
||||||
|
if (TryLoadFeeds())
|
||||||
|
{
|
||||||
|
// loaded first (default) feed only
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception(string.Format("WpiHelper: download all feeds failed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception(string.Format("WpiHelper: download all feeds failed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryLoadFeeds()
|
||||||
|
{
|
||||||
|
string loadingFeed = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
foreach (string feed in _feeds)
|
foreach (string feed in _feeds)
|
||||||
{
|
{
|
||||||
|
loadingFeed = feed;
|
||||||
WriteLog(string.Format("Loading feed {0}", feed));
|
WriteLog(string.Format("Loading feed {0}", feed));
|
||||||
if (feed.StartsWith("https://www.microsoft.com", StringComparison.OrdinalIgnoreCase))
|
if (feed.IndexOf("microsoft.com", StringComparison.OrdinalIgnoreCase) > 0)
|
||||||
{
|
{
|
||||||
|
// it is internal Microsoft feed
|
||||||
_productManager.Load(new Uri(feed), true, true, true, _webPIinstallersFolder);
|
_productManager.Load(new Uri(feed), true, true, true, _webPIinstallersFolder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -584,10 +635,20 @@ namespace WebsitePanel.Server.Code
|
||||||
_productManager.LoadExternalFile(new Uri(feed));
|
_productManager.LoadExternalFile(new Uri(feed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(loadingFeed))
|
||||||
|
{
|
||||||
|
// error occured on loading this feed
|
||||||
|
// log this
|
||||||
|
WriteLog(string.Format("Feed {0} loading error: {1}", loadingFeed, ex));
|
||||||
|
|
||||||
WriteLog(string.Format("{0} products loaded", _productManager.Products.Count));
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//LogDebugInfo();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Language GetLanguage(string languageId)
|
private Language GetLanguage(string languageId)
|
||||||
|
|
|
@ -32,6 +32,7 @@ ul.WPIKeywordList {
|
||||||
ul.WPIKeywordList>li {
|
ul.WPIKeywordList>li {
|
||||||
padding: .4em .4em;
|
padding: .4em .4em;
|
||||||
margin-right: .4em;
|
margin-right: .4em;
|
||||||
|
line-height: 2em;
|
||||||
display: inline;
|
display: inline;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue