Commit Contribution from Helicon

Includes:

- complete re-write of Web Application Gallery
- Addition of Web PI Installer in Server module
This commit is contained in:
omara_vworks 2012-07-19 13:16:33 -04:00
parent 3b81883a25
commit a2beec7fe4
80 changed files with 9236 additions and 1762 deletions

View file

@ -39,6 +39,7 @@ using WebsitePanel.Server;
using WebsitePanel.Providers;
using WebsitePanel.Providers.OS;
using OS = WebsitePanel.Providers.OS;
using System.Collections;
namespace WebsitePanel.EnterpriseServer
{
@ -406,6 +407,67 @@ namespace WebsitePanel.EnterpriseServer
}
#endregion
#region Web Platform Installer
public static void InitWPIFeeds(int serverId, string feedUrls)
{
GetServerService(serverId).InitWPIFeeds(feedUrls);
}
public static WPITab[] GetWPITabs(int serverId)
{
return GetServerService(serverId).GetWPITabs();
}
public static WPIKeyword[] GetWPIKeywords(int serverId)
{
return GetServerService(serverId).GetWPIKeywords();
}
public static WPIProduct[] GetWPIProducts(int serverId, string tabId, string keywordId)
{
return GetServerService(serverId).GetWPIProducts(tabId, keywordId);
}
public static WPIProduct[] GetWPIProductsFiltered(int serverId, string keywordId)
{
return GetServerService(serverId).GetWPIProductsFiltered(keywordId);
}
public static WPIProduct[] GetWPIProductsWithDependencies(int serverId, string[] products)
{
return GetServerService(serverId).GetWPIProductsWithDependencies(products);
}
public static void InstallWPIProducts(int serverId, string[] products)
{
GetServerService(serverId).InstallWPIProducts(products);
}
public static void CancelInstallWPIProducts(int serverId)
{
GetServerService(serverId).CancelInstallWPIProducts();
}
public static string GetWPIStatus(int serverId)
{
return GetServerService(serverId).GetWPIStatus();
}
public static string WpiGetLogFileDirectory(int serverId)
{
return GetServerService(serverId).WpiGetLogFileDirectory();
}
public static SettingPair[] WpiGetLogsInDirectory(int serverId, string Path)
{
return GetServerService(serverId).WpiGetLogsInDirectory(Path);
}
#endregion
#region Event Viewer
public static string[] GetLogNames(int serverId)
{
@ -684,6 +746,7 @@ namespace WebsitePanel.EnterpriseServer
return 0;
}
#endregion
}
}

View file

@ -62,6 +62,88 @@ namespace WebsitePanel.EnterpriseServer
public const string GET_GALLERY_CATEGORIES_TASK = "GET_GALLERY_CATEGORIES_TASK";
#endregion
private static string[] getFeedsFromSettings(int packageId)
{
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Web);
return getFeedsFromSettingsByServiceId(serviceId);
}
private static string[] getFeedsFromSettingsByServiceId(int serviceId)
{
StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId);
List<string> arFeeds = new List<string>();
if (Utils.ParseBool(serviceSettings["FeedEnableMicrosoft"], true))
{
arFeeds.Add("https://www.microsoft.com/web/webpi/3.0/WebProductList.xml");
}
if (Utils.ParseBool(serviceSettings["FeedEnableHelicon"], true))
{
arFeeds.Add("http://www.helicontech.com/zoo/feed/wsp");
}
string additionalFeeds = serviceSettings["FeedUrls"];
if (!string.IsNullOrEmpty(additionalFeeds))
{
arFeeds.AddRange(additionalFeeds.Split(';'));
}
return arFeeds.ToArray();
}
public static void InitFeedsByServiceId(int UserId, int serviceId)
{
string[] feeds = getFeedsFromSettingsByServiceId(serviceId);
WebServer webServer = WebServerController.GetWebServer(serviceId);
webServer.InitFeeds(UserId, feeds);
}
public static void InitFeeds(int UserId, int packageId)
{
string[] feeds = getFeedsFromSettings(packageId);
// Set feeds
WebServer webServer = GetAssociatedWebServer(packageId);
webServer.InitFeeds(UserId, feeds);
}
public static void SetResourceLanguage(int packageId, string resourceLanguage)
{
GetAssociatedWebServer(packageId).SetResourceLanguage(SecurityContext.User.UserId,resourceLanguage);
}
public static GalleryLanguagesResult GetGalleryLanguages(int packageId)
{
GalleryLanguagesResult result;
try
{
WebServer webServer = GetAssociatedWebServer(packageId);
result = webServer.GetGalleryLanguages(SecurityContext.User.UserId);
if (!result.IsSuccess)
return Error<GalleryLanguagesResult>(result, GalleryErrors.GetLanguagesError);
}
catch (Exception ex)
{
return Error<GalleryLanguagesResult>(GalleryErrors.GetLanguagesError, ex.Message);
}
finally
{
}
//
return result;
}
public static GalleryCategoriesResult GetGalleryCategories(int packageId)
{
GalleryCategoriesResult result;
@ -77,7 +159,7 @@ namespace WebsitePanel.EnterpriseServer
return Error<GalleryCategoriesResult>(GalleryErrors.MsDeployIsNotInstalled);
// get categories
result = webServer.GetGalleryCategories();
result = webServer.GetGalleryCategories(SecurityContext.User.UserId);
if (!result.IsSuccess)
return Error<GalleryCategoriesResult>(result, GalleryErrors.GetCategoriesError);
@ -114,7 +196,7 @@ namespace WebsitePanel.EnterpriseServer
return Error<GalleryApplicationsResult>(GalleryErrors.MsDeployIsNotInstalled);
// get applications
result = webServer.GetGalleryApplications(String.Empty);
result = webServer.GetGalleryApplications(SecurityContext.User.UserId,String.Empty);
if (!result.IsSuccess)
return Error<GalleryApplicationsResult>(result, GalleryErrors.GetApplicationsError);
@ -132,7 +214,7 @@ namespace WebsitePanel.EnterpriseServer
return result;
}
public static GalleryApplicationsResult GetGalleryApplications(int packageId, string categoryId)
public static GalleryApplicationsResult GetGalleryApplications(int packageId, string categoryId)
{
GalleryApplicationsResult result;
//
@ -146,7 +228,7 @@ namespace WebsitePanel.EnterpriseServer
return Error<GalleryApplicationsResult>(GalleryErrors.MsDeployIsNotInstalled);
// get applications
result = webServer.GetGalleryApplications(categoryId);
result = webServer.GetGalleryApplications(SecurityContext.User.UserId,categoryId);
if (!result.IsSuccess)
return Error<GalleryApplicationsResult>(result, GalleryErrors.GetApplicationsError);
@ -189,20 +271,8 @@ namespace WebsitePanel.EnterpriseServer
// || MatchMenaltoGalleryApp(x, appsFilter.ToArray())));
{
int userId = SecurityContext.User.UserId;
//
SecurityContext.SetThreadSupervisorPrincipal();
//
string[] filteredApps = GetServiceAppsCatalogFilter(packageId);
//
if (filteredApps != null)
{
result.Value = new List<GalleryApplication>(Array.FindAll(result.Value.ToArray(),
x => !Array.Exists(filteredApps,
z => z.Equals(x.Id, StringComparison.InvariantCultureIgnoreCase))));
}
//
SecurityContext.SetThreadPrincipal(userId);
FilterResultApplications(packageId, result);
}
}
catch (Exception ex)
@ -218,6 +288,61 @@ namespace WebsitePanel.EnterpriseServer
return result;
}
private static void FilterResultApplications(int packageId, GalleryApplicationsResult result)
{
int userId = SecurityContext.User.UserId;
//
SecurityContext.SetThreadSupervisorPrincipal();
//
string[] filteredApps = GetServiceAppsCatalogFilter(packageId);
//
if (filteredApps != null)
{
result.Value = new List<GalleryApplication>(Array.FindAll(result.Value.ToArray(),
x => !Array.Exists(filteredApps,
z => z.Equals(x.Id, StringComparison.InvariantCultureIgnoreCase))));
}
//
SecurityContext.SetThreadPrincipal(userId);
}
public static GalleryApplicationsResult GetGalleryApplicationsFiltered(int packageId, string pattern)
{
GalleryApplicationsResult result;
//
try
{
TaskManager.StartTask(TASK_MANAGER_SOURCE, GET_GALLERY_APPS_TASK);
// check if WAG is installed
WebServer webServer = GetAssociatedWebServer(packageId);
if (!webServer.IsMsDeployInstalled())
return Error<GalleryApplicationsResult>(GalleryErrors.MsDeployIsNotInstalled);
// get applications
result = webServer.GetGalleryApplicationsFiltered(SecurityContext.User.UserId,pattern);
FilterResultApplications(packageId, result);
if (!result.IsSuccess)
return Error<GalleryApplicationsResult>(result, GalleryErrors.GetApplicationsError);
}
catch (Exception ex)
{
TaskManager.WriteError(ex);
return Error<GalleryApplicationsResult>(GalleryErrors.GeneralError, ex.Message);
}
finally
{
TaskManager.CompleteTask();
}
//
return result;
}
internal static bool MatchParticularAppDependency(Dependency dependency, string[] dependencyIds)
{
List<Dependency> nested = null;
@ -311,7 +436,7 @@ namespace WebsitePanel.EnterpriseServer
return Error<GalleryApplicationResult>(GalleryErrors.MsDeployIsNotInstalled);
// get application details
result = webServer.GetGalleryApplication(applicationId);
result = webServer.GetGalleryApplication(SecurityContext.User.UserId,applicationId);
if (!result.IsSuccess)
return Error<GalleryApplicationResult>(result, GalleryErrors.GetApplicationError);
@ -396,7 +521,7 @@ namespace WebsitePanel.EnterpriseServer
return Error<DeploymentParametersResult>(GalleryErrors.MsDeployIsNotInstalled);
// get parameters
result = webServer.GetGalleryApplicationParameters(webAppId);
result = webServer.GetGalleryApplicationParameters(SecurityContext.User.UserId,webAppId);
if (!result.IsSuccess)
return Error<DeploymentParametersResult>(result, GalleryErrors.GetApplicationParametersError);
@ -414,9 +539,10 @@ namespace WebsitePanel.EnterpriseServer
return result;
}
public static StringResultObject Install(int packageId, string webAppId, string siteName, string virtualDir, List<DeploymentParameter> parameters)
public static StringResultObject Install(int packageId, string webAppId, string siteName, string virtualDir, List<DeploymentParameter> parameters, string languageId )
{
StringResultObject result = new StringResultObject();
int originalUserId = SecurityContext.User.UserId;
try
{
@ -455,7 +581,7 @@ namespace WebsitePanel.EnterpriseServer
return Error<StringResultObject>(GalleryErrors.WebSiteNotFound, siteName);
// get application pack details
GalleryApplicationResult app = webServer.GetGalleryApplication(webAppId);
GalleryApplicationResult app = webServer.GetGalleryApplication(SecurityContext.User.UserId,webAppId);
if (!app.IsSuccess)
return Error<StringResultObject>(app, GalleryErrors.GeneralError);
if (app.Value == null)
@ -643,7 +769,7 @@ namespace WebsitePanel.EnterpriseServer
}
// install application
result = webServer.InstallGalleryApplication(webAppId, parameters.ToArray());
result = webServer.InstallGalleryApplication(originalUserId, webAppId, parameters.ToArray(), languageId);
#region Rollback in case of failure
// Rollback - remove resources have been created previously
@ -665,12 +791,25 @@ namespace WebsitePanel.EnterpriseServer
#region Update Web Application settings
WebVirtualDirectory iisApp = null;
if(String.IsNullOrEmpty(virtualDir))
// load web site
iisApp = WebServerController.GetWebSite(packageId, siteName);
else
// load virtual directory
iisApp = WebServerController.GetVirtualDirectory(webSite.Id, virtualDir);
if (String.IsNullOrEmpty(virtualDir))
// load web site
iisApp = WebServerController.GetWebSite(packageId, siteName);
else
{
try
{
// load virtual directory
iisApp = WebServerController.GetVirtualDirectory(webSite.Id, virtualDir);
}
catch (Exception ex)
{
throw new Exception(
string.Format(
"{0} on WebServerController.GetVirtualDirectory(\"{1}\", \"{2}\")",
ex.GetType(), webSite.Id, virtualDir),
ex);
}
}
// put correct extensions
if ((app.Value.WellKnownDependencies & GalleryApplicationWellKnownDependency.AspNet20) == GalleryApplicationWellKnownDependency.AspNet20)
@ -714,7 +853,10 @@ namespace WebsitePanel.EnterpriseServer
TaskManager.WriteError(ex);
// exit with error code
return Error<StringResultObject>(GalleryErrors.GeneralError);
//return Error<StringResultObject>(GalleryErrors.GeneralError);
result.AddError(GalleryErrors.GeneralError, ex);
return result;
}
finally
{
@ -746,11 +888,11 @@ namespace WebsitePanel.EnterpriseServer
if (!webServer.IsMsDeployInstalled())
return Error<GalleryWebAppStatus>(GalleryErrors.MsDeployIsNotInstalled);
//
GalleryWebAppStatus appStatus = webServer.GetGalleryApplicationStatus(webAppId);
GalleryWebAppStatus appStatus = webServer.GetGalleryApplicationStatus(SecurityContext.User.UserId,webAppId);
//
if (appStatus == GalleryWebAppStatus.NotDownloaded)
{
GalleryApplicationResult appResult = webServer.GetGalleryApplication(webAppId);
GalleryApplicationResult appResult = webServer.GetGalleryApplication(SecurityContext.User.UserId,webAppId);
// Start app download in new thread
WebAppGalleryAsyncWorker async = new WebAppGalleryAsyncWorker();
async.GalleryApp = appResult.Value;
@ -897,7 +1039,7 @@ namespace WebsitePanel.EnterpriseServer
//
TaskManager.Write("Application package download has been started");
//
GalleryWebAppStatus appStatus = webServer.DownloadGalleryApplication(WebAppId);
GalleryWebAppStatus appStatus = webServer.DownloadGalleryApplication(SecurityContext.User.UserId,WebAppId);
//
if (appStatus == GalleryWebAppStatus.Failed)
{

View file

@ -41,6 +41,7 @@ using Microsoft.Web.Services3;
using WebsitePanel.Providers.DNS;
using WebsitePanel.Server;
using WebsitePanel.Providers.ResultObjects;
using WebsitePanel.Providers;
namespace WebsitePanel.EnterpriseServer
{
@ -663,6 +664,108 @@ namespace WebsitePanel.EnterpriseServer
}
#endregion
#region Web Platform Installer
[WebMethod]
public void InitWPIFeeds(int serverId)
{
var wpiSettings = SystemController.GetSystemSettings(SystemSettings.WPI_SETTINGS);
List<string> arFeeds = new List<string>();
if (Utils.ParseBool(wpiSettings["FeedEnableMicrosoft"] ,true))
{
arFeeds.Add( "https://www.microsoft.com/web/webpi/3.0/WebProductList.xml" );
}
if (Utils.ParseBool(wpiSettings["FeedEnableHelicon"] ,true))
{
arFeeds.Add( "http://www.helicontech.com/zoo/feed/wsp" );
}
string additionalFeeds = wpiSettings["FeedUrls"];
if (!string.IsNullOrEmpty(additionalFeeds))
{
arFeeds.AddRange(additionalFeeds.Split(';'));
}
OperatingSystemController.InitWPIFeeds(serverId, string.Join(";", arFeeds));
}
[WebMethod]
public WPITab[] GetWPITabs(int serverId)
{
InitWPIFeeds(serverId);
return OperatingSystemController.GetWPITabs(serverId);
}
[WebMethod]
public WPIKeyword[] GetWPIKeywords(int serverId)
{
InitWPIFeeds(serverId);
return OperatingSystemController.GetWPIKeywords(serverId);
}
[WebMethod]
public WPIProduct[] GetWPIProducts(int serverId, string tabId, string keywordId)
{
InitWPIFeeds(serverId);
return OperatingSystemController.GetWPIProducts(serverId, tabId, keywordId);
}
[WebMethod]
public WPIProduct[] GetWPIProductsFiltered(int serverId, string keywordId)
{
InitWPIFeeds(serverId);
return OperatingSystemController.GetWPIProductsFiltered(serverId, keywordId);
}
[WebMethod]
public WPIProduct[] GetWPIProductsWithDependencies(int serverId, string[] products)
{
InitWPIFeeds(serverId);
return OperatingSystemController.GetWPIProductsWithDependencies(serverId, products);
}
[WebMethod]
public void InstallWPIProducts(int serverId, string[] products)
{
InitWPIFeeds(serverId);
OperatingSystemController.InstallWPIProducts(serverId, products);
}
[WebMethod]
public void CancelInstallWPIProducts(int serviceId)
{
OperatingSystemController.CancelInstallWPIProducts(serviceId);
}
[WebMethod]
public string GetWPIStatus(int serverId)
{
return OperatingSystemController.GetWPIStatus(serverId);
}
[WebMethod]
public string WpiGetLogFileDirectory(int serverId)
{
return OperatingSystemController.WpiGetLogFileDirectory(serverId);
}
[WebMethod]
public SettingPair[] WpiGetLogsInDirectory(int serverId, string Path)
{
return OperatingSystemController.WpiGetLogsInDirectory(serverId, Path);
}
#endregion
#region Windows Services
[WebMethod]
public WindowsService[] GetWindowsServices(int serverId)

View file

@ -43,45 +43,81 @@ namespace WebsitePanel.EnterpriseServer
[System.ComponentModel.ToolboxItem(false)]
public class esWebApplicationGallery : System.Web.Services.WebService
{
[WebMethod]
public void InitFeeds(int packageId)
{
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
}
[WebMethod]
public void SetResourceLanguage(int packageId, string resourceLanguage)
{
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
WebAppGalleryController.SetResourceLanguage(packageId, resourceLanguage);
}
[WebMethod]
public GalleryLanguagesResult GetGalleryLanguages(int packageId)
{
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
return WebAppGalleryController.GetGalleryLanguages(packageId);
}
[WebMethod]
public GalleryApplicationsResult GetGalleryApplicationsByServiceId(int serviceId)
{
WebAppGalleryController.InitFeedsByServiceId(SecurityContext.User.UserId, serviceId);
return WebAppGalleryController.GetGalleryApplicationsByServiceId(serviceId);
}
[WebMethod]
public GalleryApplicationsResult GetGalleryApplications(int packageId, string categoryId)
{
return WebAppGalleryController.GetGalleryApplications(packageId, categoryId);
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
return WebAppGalleryController.GetGalleryApplications(packageId, categoryId);
}
[WebMethod]
public GalleryApplicationsResult GetGalleryApplicationsFiltered(int packageId, string pattern)
{
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
return WebAppGalleryController.GetGalleryApplicationsFiltered(packageId, pattern);
}
[WebMethod]
public GalleryCategoriesResult GetGalleryCategories(int packageId)
{
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
return WebAppGalleryController.GetGalleryCategories(packageId);
}
[WebMethod]
public GalleryApplicationResult GetGalleryApplicationDetails(int packageId, string applicationId)
{
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
return WebAppGalleryController.GetGalleryApplicationDetails(packageId, applicationId);
}
[WebMethod]
public DeploymentParametersResult GetGalleryApplicationParams(int packageId, string applicationId)
{
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
return WebAppGalleryController.GetGalleryApplicationParams(packageId, applicationId);
}
[WebMethod]
public StringResultObject Install(int packageId, string webAppId, string siteName, string virtualDir, List<DeploymentParameter> parameters)
public StringResultObject Install(int packageId, string webAppId, string siteName, string virtualDir, List<DeploymentParameter> parameters, string languageId)
{
return WebAppGalleryController.Install(packageId, webAppId, siteName, virtualDir, parameters);
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
return WebAppGalleryController.Install(packageId, webAppId, siteName, virtualDir, parameters, languageId);
}
[WebMethod(Description="Returns Web Application Gallery application status, such as Downloaded, Downloading, Failed or NotDownloaded. Throws an ApplicationException if WAG module is not available on the target server.")]
public GalleryWebAppStatus GetGalleryApplicationStatus(int packageId, string webAppId)
{
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
return WebAppGalleryController.GetGalleryApplicationStatus(packageId, webAppId);
}
}