WPI: Check if the WebDeploy is installed

WPI: Check if download is completed successfully
WPI: LoadUserProfile on Windows 2003
This commit is contained in:
Sergey 2012-10-25 13:10:11 +03:00
parent 47ba8449ad
commit b19350e64d
6 changed files with 103 additions and 76 deletions

View file

@ -156,7 +156,10 @@ namespace WebsitePanel.EnterpriseServer
WebServer webServer = GetAssociatedWebServer(packageId); WebServer webServer = GetAssociatedWebServer(packageId);
if (!webServer.IsMsDeployInstalled()) if (!webServer.IsMsDeployInstalled())
{
TaskManager.WriteError("MsDeploy is not installed");
return Error<GalleryCategoriesResult>(GalleryErrors.MsDeployIsNotInstalled); return Error<GalleryCategoriesResult>(GalleryErrors.MsDeployIsNotInstalled);
}
// get categories // get categories
result = webServer.GetGalleryCategories(SecurityContext.User.UserId); result = webServer.GetGalleryCategories(SecurityContext.User.UserId);

View file

@ -238,6 +238,7 @@ namespace WebsitePanel.Providers.WebAppGallery
NotDownloaded, NotDownloaded,
Downloaded, Downloaded,
Downloading, Downloading,
UnauthorizedAccessException,
Failed Failed
} }

View file

@ -3396,7 +3396,8 @@ namespace WebsitePanel.Providers.Web
virtual public bool CheckLoadUserProfile() virtual public bool CheckLoadUserProfile()
{ {
throw new NotImplementedException("LoadUserProfile option valid only on IIS7 or higer"); //throw new NotImplementedException("LoadUserProfile option valid only on IIS7 or higer");
return false;
} }
virtual public void EnableLoadUserProfile() virtual public void EnableLoadUserProfile()
@ -3421,20 +3422,28 @@ namespace WebsitePanel.Providers.Web
public bool IsMsDeployInstalled() public bool IsMsDeployInstalled()
{ {
// project has reference to Microsoft.Web.Deployment, so // TO-DO: Implement Web Deploy detection (x64/x86)
return true; var isInstalled = false;
/* //
try try
{ {
Assembly.Load(MS_DEPLOY_ASSEMBLY_NAME); var msdeployRegKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3");
return true; //
var keyValue = msdeployRegKey.GetValue("Install");
// We have found the required key in the registry hive
if (keyValue != null && keyValue.Equals(1))
{
isInstalled = true;
}
} }
catch catch (Exception ex)
{ {
// type could not be instantiated Log.WriteError("Could not retrieve Web Deploy key from the registry", ex);
return false;
} }
*/ //
return isInstalled;
} }
public GalleryLanguagesResult GetGalleryLanguages(int UserId) public GalleryLanguagesResult GetGalleryLanguages(int UserId)
@ -3551,6 +3560,11 @@ namespace WebsitePanel.Providers.Web
return module.DownloadAppAndGetStatus(UserId, id); return module.DownloadAppAndGetStatus(UserId, id);
} }
catch (UnauthorizedAccessException ex)
{
Log.WriteError(ex);
return GalleryWebAppStatus.UnauthorizedAccessException;
}
catch (Exception ex) catch (Exception ex)
{ {
Log.WriteError(ex); Log.WriteError(ex);

View file

@ -245,21 +245,21 @@ namespace WebsitePanel.Server.Code
foreach (string productId in productIdsToInstall) foreach (string productId in productIdsToInstall)
{ {
Log(string.Format("Product {0} to be installed", productId)); WriteLog(string.Format("Product {0} to be installed", productId));
Product product = _productManager.GetProduct(productId); Product product = _productManager.GetProduct(productId);
if (null == product) if (null == product)
{ {
Log(string.Format("Product {0} not found", productId)); WriteLog(string.Format("Product {0} not found", productId));
continue; continue;
} }
if (product.IsInstalled(true)) if (product.IsInstalled(true))
{ {
Log(string.Format("Product {0} is installed", product.Title)); WriteLog(string.Format("Product {0} is installed", product.Title));
} }
else else
{ {
Log(string.Format("Adding product {0}", product.Title)); WriteLog(string.Format("Adding product {0}", product.Title));
productsToInstall.Add(product); productsToInstall.Add(product);
} }
@ -279,21 +279,21 @@ namespace WebsitePanel.Server.Code
foreach (string productId in updatedProductIdsToInstall) foreach (string productId in updatedProductIdsToInstall)
{ {
Log(string.Format("Product {0} to be installed", productId)); WriteLog(string.Format("Product {0} to be installed", productId));
Product product = _productManager.GetProduct(productId); Product product = _productManager.GetProduct(productId);
if (null == product) if (null == product)
{ {
Log(string.Format("Product {0} not found", productId)); WriteLog(string.Format("Product {0} not found", productId));
continue; continue;
} }
if (product.IsInstalled(true)) if (product.IsInstalled(true))
{ {
Log(string.Format("Product {0} is installed", product.Title)); WriteLog(string.Format("Product {0} is installed", product.Title));
} }
else else
{ {
Log(string.Format("Adding product {0} with dependencies", product.Title)); WriteLog(string.Format("Adding product {0} with dependencies", product.Title));
// search and add dependencies but skip webmatrix/iisexpress branches // search and add dependencies but skip webmatrix/iisexpress branches
AddProductWithDependencies(product, productsToInstall, WebMatrixChoiceProduct); AddProductWithDependencies(product, productsToInstall, WebMatrixChoiceProduct);
} }
@ -358,8 +358,15 @@ namespace WebsitePanel.Server.Code
string failureReason; string failureReason;
if (!_installManager.DownloadInstallerFile(installerContext, out failureReason)) if (!_installManager.DownloadInstallerFile(installerContext, out failureReason))
{ {
Log(string.Format("DownloadInstallerFile '{0}' failed: {1}", WriteLog(string.Format("DownloadInstallerFile '{0}' failed: {1}",
installerContext.Installer.InstallerFile.InstallerUrl, failureReason)); installerContext.Installer.InstallerFile.InstallerUrl, failureReason));
throw new Exception(
string.Format("Can't install {0} DownloadInstallerFile '{1}' failed: {2}",
installerContext.ProductName,
installerContext.Installer.InstallerFile.InstallerUrl,
failureReason)
);
} }
} }
} }
@ -368,10 +375,8 @@ namespace WebsitePanel.Server.Code
{ {
// Start installation // Start installation
_installCompleted = false; _installCompleted = false;
Log("_installManager.StartInstallation()");
_installManager.StartInstallation(); _installManager.StartInstallation();
Log("_installManager.StartInstallation() done");
while (!_installCompleted) while (!_installCompleted)
{ {
Thread.Sleep(100); Thread.Sleep(100);
@ -385,7 +390,7 @@ namespace WebsitePanel.Server.Code
} }
else else
{ {
Log("Nothing to install"); //Log("Nothing to install");
} }
} }
@ -514,13 +519,14 @@ namespace WebsitePanel.Server.Code
RemoveUnusedProviders(appInstaller.MSDeployPackage, dbTag); RemoveUnusedProviders(appInstaller.MSDeployPackage, dbTag);
_installCompleted = false; _installCompleted = false;
Log("_installManager.StartApplicationInstallation()");
_installManager.StartApplicationInstallation(); _installManager.StartApplicationInstallation();
while (!_installCompleted) while (!_installCompleted)
{ {
Thread.Sleep(1000); Thread.Sleep(1000);
} }
Log("_installManager.StartApplicationInstallation() _installCompleted");
WriteLog("InstallApplication complete");
//save logs //save logs
SaveLogDirectory(); SaveLogDirectory();
@ -564,7 +570,7 @@ namespace WebsitePanel.Server.Code
foreach (string feed in _feeds) foreach (string feed in _feeds)
{ {
Log(string.Format("Loading {0}", feed)); WriteLog(string.Format("Loading feed {0}", feed));
if (feed.StartsWith("https://www.microsoft.com", StringComparison.OrdinalIgnoreCase)) if (feed.StartsWith("https://www.microsoft.com", StringComparison.OrdinalIgnoreCase))
{ {
_productManager.Load(new Uri(feed), true, true, true, _webPIinstallersFolder); _productManager.Load(new Uri(feed), true, true, true, _webPIinstallersFolder);
@ -575,9 +581,9 @@ namespace WebsitePanel.Server.Code
} }
} }
Log(string.Format("{0} products loaded", _productManager.Products.Count)); WriteLog(string.Format("{0} products loaded", _productManager.Products.Count));
LogDebugInfo(); //LogDebugInfo();
} }
private Language GetLanguage(string languageId) private Language GetLanguage(string languageId)
@ -606,52 +612,49 @@ namespace WebsitePanel.Server.Code
return installersToUse; return installersToUse;
} }
private void LogDebugInfo()
//private void LogDebugInfo()
//{
// StringBuilder sb = new StringBuilder();
// sb.Append("Products: ");
// sb.Append("Tabs: ").AppendLine();
// foreach (Tab tab in _productManager.Tabs)
// {
// sb.AppendFormat("\t{0}, FromCustomFeed = {1}", tab.Name, tab.FromCustomFeed).AppendLine();
// foreach (string f in tab.FeedList)
// {
// sb.AppendFormat("\t\t{0}", f).AppendLine();
// }
// sb.AppendLine();
// }
// sb.AppendLine();
// sb.Append("Keywords: ").AppendLine().Append("\t");
// foreach (Keyword keyword in _productManager.Keywords)
// {
// sb.Append(keyword.Id).Append(",");
// }
// sb.AppendLine();
// sb.Append("Languages: ").AppendLine().Append("\t");
// foreach (Language language in _productManager.Languages)
// {
// sb.Append(language.Name).Append(",");
// }
// sb.AppendLine();
// Log(sb.ToString());
//}
private static void WriteLog(string message)
{ {
StringBuilder sb = new StringBuilder();
sb.Append("Products: ");
sb.Append("Tabs: ").AppendLine();
foreach (Tab tab in _productManager.Tabs)
{
sb.AppendFormat("\t{0}, FromCustomFeed = {1}", tab.Name, tab.FromCustomFeed).AppendLine();
foreach (string f in tab.FeedList)
{
sb.AppendFormat("\t\t{0}", f).AppendLine();
}
sb.AppendLine();
}
sb.AppendLine();
sb.Append("Keywords: ").AppendLine().Append("\t");
foreach (Keyword keyword in _productManager.Keywords)
{
sb.Append(keyword.Id).Append(",");
}
sb.AppendLine();
sb.Append("Languages: ").AppendLine().Append("\t");
foreach (Language language in _productManager.Languages)
{
sb.Append(language.Name).Append(",");
}
sb.AppendLine();
Log(sb.ToString());
}
private static void Log(string message)
{
//#if DEBUG
Debug.WriteLine(string.Format("[{0}] WpiHelper: {1}", Process.GetCurrentProcess().Id, message)); Debug.WriteLine(string.Format("[{0}] WpiHelper: {1}", Process.GetCurrentProcess().Id, message));
Console.WriteLine(message);
//#endif
} }
private void InstallManager_InstallCompleted(object sender, EventArgs e) private void InstallManager_InstallCompleted(object sender, EventArgs e)
{ {
Log("Installation completed");
if (null != _installManager) if (null != _installManager)
{ {
/* /*
@ -670,11 +673,11 @@ namespace WebsitePanel.Server.Code
private void InstallManager_InstallerStatusUpdated(object sender, InstallStatusEventArgs e) private void InstallManager_InstallerStatusUpdated(object sender, InstallStatusEventArgs e)
{ {
Log(string.Format("{0}: {1}. {2} Progress: {3}", //Log(string.Format("{0}: {1}. {2} Progress: {3}",
e.InstallerContext.ProductName, // e.InstallerContext.ProductName,
e.InstallerContext.InstallationState, // e.InstallerContext.InstallationState,
e.InstallerContext.ReturnCode.DetailedInformation, // e.InstallerContext.ReturnCode.DetailedInformation,
e.ProgressValue)); // e.ProgressValue));
} }
private static void AddProductWithDependencies(Product product, List<Product> productsToInstall, string skipProduct) private static void AddProductWithDependencies(Product product, List<Product> productsToInstall, string skipProduct)
@ -691,7 +694,7 @@ namespace WebsitePanel.Server.Code
{ {
if (string.Equals(dependency.ProductId, skipProduct, StringComparison.OrdinalIgnoreCase)) if (string.Equals(dependency.ProductId, skipProduct, StringComparison.OrdinalIgnoreCase))
{ {
Log(string.Format("Product {0} is iis express dependency, skip it", dependency.Title)); //Log(string.Format("Product {0} is iis express dependency, skip it", dependency.Title));
continue; continue;
} }
@ -702,13 +705,10 @@ namespace WebsitePanel.Server.Code
private void SaveLogDirectory() private void SaveLogDirectory()
{ {
Log("SaveLogDirectory");
foreach (InstallerContext ctx in _installManager.InstallerContexts) foreach (InstallerContext ctx in _installManager.InstallerContexts)
{ {
Log(ctx.LogFileDirectory);
_LogFileDirectory = ctx.LogFileDirectory; _LogFileDirectory = ctx.LogFileDirectory;
break; break;
} }
} }

View file

@ -4627,6 +4627,9 @@
<data name="Error.GALLERY_APP_DOWNLOAD_FAILED" xml:space="preserve"> <data name="Error.GALLERY_APP_DOWNLOAD_FAILED" xml:space="preserve">
<value>We apologize for the inconvenience but the application download has been failed. Please contact your service provider to correct the issue.</value> <value>We apologize for the inconvenience but the application download has been failed. Please contact your service provider to correct the issue.</value>
</data> </data>
<data name="Error.GALLERY_APP_UNAUTHORIZEDACCESSEXCEPTION" xml:space="preserve">
<value>We apologize for the inconvenience but the application download has been failed. Access is denied. Check WebSitePanel event log.</value>
</data>
<data name="Error.WAG_NOT_AVAILABLE" xml:space="preserve"> <data name="Error.WAG_NOT_AVAILABLE" xml:space="preserve">
<value>Web Application Gallery module is unavailable:</value> <value>Web Application Gallery module is unavailable:</value>
</data> </data>

View file

@ -100,6 +100,12 @@ namespace WebsitePanel.Portal
ShowErrorMessage("GALLERY_APP_DOWNLOAD_FAILED"); ShowErrorMessage("GALLERY_APP_DOWNLOAD_FAILED");
isSuccess = false; isSuccess = false;
break; break;
case GalleryWebAppStatus.UnauthorizedAccessException:
ShowErrorMessage("GALLERY_APP_UNAUTHORIZEDACCESSEXCEPTION");
isSuccess = false;
break;
} }
} }
catch(Exception ex) catch(Exception ex)