Ability to change main WPI (Microsoft) feed url in System Settings.

This commit is contained in:
ruslanht 2013-01-30 17:33:37 +02:00
parent 815519b650
commit 54c8438ece
14 changed files with 122 additions and 1041 deletions

View file

@ -57,8 +57,6 @@ namespace WebsitePanel.Server.Code
private readonly List<string> _feeds;
private string _webPIinstallersFolder;
//private const string MainWpiFeed = "https://www.microsoft.com/web/webpi/3.0/webproductlist.xml";
private const string MainWpiFeed = "https://www.microsoft.com/web/webpi/4.0/WebProductList.xml";
private const string IisChoiceProduct = "StaticContent";
private const string WebMatrixChoiceProduct = "WebMatrix";
private ProductManager _productManager;
@ -79,6 +77,14 @@ namespace WebsitePanel.Server.Code
public WpiHelper(IEnumerable<string> feeds)
{
// check feeds is not empty
if (null == feeds || !feeds.Any())
{
throw new Exception("WpiHelper error: empty feed list in constructor");
}
// by default feeds must contains main MS WPI feed url and Zoo feed url
_feeds = new List<string>();
_feeds.AddRange(feeds);
@ -135,7 +141,6 @@ namespace WebsitePanel.Server.Code
}
#endregion
#region Keywords
public ReadOnlyCollection<Keyword> GetKeywords()
{
@ -158,8 +163,6 @@ namespace WebsitePanel.Server.Code
}
#endregion
#region Products
public List<Product> GetProductsToInstall(string FeedLocation, string keywordId)
{
@ -546,6 +549,7 @@ namespace WebsitePanel.Server.Code
}
#endregion
#endregion Public interface
@ -553,12 +557,6 @@ namespace WebsitePanel.Server.Code
private void Initialize()
{
// insert Main WebPI xml file
if (!_feeds.Contains(MainWpiFeed, StringComparer.OrdinalIgnoreCase))
{
_feeds.Insert(0, MainWpiFeed);
}
// create cache folder if not exists
//_webPIinstallersFolder = Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Microsoft\Web Platform Installer\installers");
_webPIinstallersFolder = Path.Combine(

View file

@ -477,11 +477,7 @@ namespace WebsitePanel.Server
}
static string[] FEEDS = new string[]
{
// "https://www.microsoft.com/web/webpi/3.0/WebProductList.xml",
// "http://www.helicontech.com/zoo/feed/"
};
static private string[] _feeds = new string[]{};
[WebMethod]
public void InitWPIFeeds(string feedUrls)
@ -491,18 +487,18 @@ namespace WebsitePanel.Server
throw new Exception("Empty feed list");
}
string[] newFEEDS = feedUrls.Split(';');
string[] newFeeds = feedUrls.Split(';');
if (newFEEDS.Length == 0)
if (newFeeds.Length == 0)
{
throw new Exception("Empty feed list");
}
if (!ArraysEqual<string>(newFEEDS, FEEDS))
if (!ArraysEqual<string>(newFeeds, _feeds))
{
Log.WriteInfo("InitWPIFeeds - new value: " + feedUrls);
//Feeds settings have been channged
FEEDS = newFEEDS;
_feeds = newFeeds;
wpi = null;
}
@ -604,7 +600,7 @@ namespace WebsitePanel.Server
WPIServiceContract client = new WPIServiceContract();
client.Initialize(FEEDS);
client.Initialize(_feeds);
client.BeginInstallation(products);
@ -795,14 +791,14 @@ namespace WebsitePanel.Server
static WpiHelper wpi = null;
WpiHelper GetWpiFeed()
{
if (FEEDS.Length == 0)
if (_feeds.Length == 0)
{
throw new Exception("Empty feed list");
}
if (null == wpi)
{
wpi = new WpiHelper(FEEDS);
wpi = new WpiHelper(_feeds);
}
return wpi;
}