Update ZooModule

This commit is contained in:
sergey 2013-06-05 15:56:16 +03:00
parent b94f63db56
commit 14febde12b
3 changed files with 83 additions and 13 deletions

View file

@ -360,20 +360,50 @@ namespace WebsitePanel.Server
{ {
foreach (WPIProduct product in products) foreach (WPIProduct product in products)
{ {
string installedHostingPackageVersion = GetInstalledHostingPackageVersion(product.ProductId); string hostingPackageName = product.ProductId;
if (!string.IsNullOrEmpty(installedHostingPackageVersion) && string.Compare(product.Version, installedHostingPackageVersion, StringComparison.OrdinalIgnoreCase) > 0) CheckProductForUpdate(hostingPackageName, product);
{
product.IsUpgrade = true;
}
} }
} }
private string GetInstalledHostingPackageVersion(string productId) private void CheckProductForUpdate(string hostingPackageName, WPIProduct product)
{ {
string installedVersion = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Helicon\\Zoo", productId+"Version", string.Empty) as string; string installedHostingPackageVersion = GetInstalledHostingPackageVersion(hostingPackageName);
if (!string.IsNullOrEmpty(installedHostingPackageVersion))
{
//6
//3.0.90.383
if (CompareVersions(product.Version, installedHostingPackageVersion) > 0)
{
product.IsUpgrade = true;
product.IsInstalled = false;
}
}
}
private decimal CompareVersions(string newVersion, string oldVersion)
{
try
{
var version1 = new Version(newVersion);
var version2 = new Version(oldVersion);
return version1.CompareTo(version2);
}
catch (ArgumentException)
{
return String.Compare(newVersion,oldVersion, StringComparison.Ordinal);
}
}
private string GetInstalledHostingPackageVersion(string hostingPackageName)
{
string installedVersion = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Helicon\\Zoo", hostingPackageName + "Version", string.Empty) as string;
if (string.IsNullOrEmpty(installedVersion)) if (string.IsNullOrEmpty(installedVersion))
{ {
installedVersion = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Helicon\\Zoo", productId + "Version", string.Empty) as string; installedVersion = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Helicon\\Zoo", hostingPackageName + "Version", string.Empty) as string;
} }
return installedVersion; return installedVersion;
@ -491,6 +521,12 @@ namespace WebsitePanel.Server
Product product = wpi.GetWPIProductById(productdId); Product product = wpi.GetWPIProductById(productdId);
WPIProduct wpiProduct = ProductToWPIProduct(product); WPIProduct wpiProduct = ProductToWPIProduct(product);
if (wpiProduct.ProductId == "HeliconZooModule")
{
/*null string = HeliconZooModule in registry*/
CheckProductForUpdate("", wpiProduct);
}
Log.WriteEnd("GetWPIProductById"); Log.WriteEnd("GetWPIProductById");
return wpiProduct; return wpiProduct;
} }

View file

@ -68,7 +68,7 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
private void BindHostingPackages() private void BindHostingPackages()
{ {
// TODO: try...catch?
WPIProduct[] products = null; WPIProduct[] products = null;
try try
{ {
@ -92,6 +92,12 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
private void BindEngines() private void BindEngines()
{ {
WPIProduct zooModule = ES.Services.Servers.GetWPIProductById(PanelRequest.ServerId, "HeliconZooModule");
if (!zooModule.IsInstalled || zooModule.IsUpgrade)
{
HostModule.ShowWarningMessage("Zoo Module is not installed or out-of-date. To proceed press 'Add' or 'Update' next to Helicon Zoo Module below, then press 'Install'.");
}
// get all engines from IIS // get all engines from IIS
HeliconZooEngine[] engineList = ES.Services.HeliconZoo.GetEngines(PanelRequest.ServiceId); HeliconZooEngine[] engineList = ES.Services.HeliconZoo.GetEngines(PanelRequest.ServiceId);

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
@ -32,7 +33,19 @@ namespace WebsitePanel.Portal
ViewState["WebSitePackageId"] = site.PackageId; ViewState["WebSitePackageId"] = site.PackageId;
BindEngines(site); BindEngines(site);
try
{
BindInstalledApplications(); BindInstalledApplications();
}
catch (Exception ex)
{
lblConsole.Text = "Zoo Module is not installed. Please ask your system administrator to install Zoo on the server to Configuration\\Server\\Web Application Engines.";
lblConsole.ForeColor = Color.Red;
lblConsole.Font.Size = 16;
return; // Exit
}
BindApplications(); BindApplications();
} }
@ -77,17 +90,27 @@ namespace WebsitePanel.Portal
private void BindInstalledApplications() private void BindInstalledApplications()
{ {
ViewState["IsZooEnabled"] = false;
var installedApplications = ES.Services.WebServers.GetZooApplications(PanelRequest.ItemID);
ViewState["IsZooEnabled"] = true;
if ((bool) ViewState["IsZooWebConsoleEnabled"]) if ((bool) ViewState["IsZooWebConsoleEnabled"])
{ {
gvInstalledApplications.DataSource = ES.Services.WebServers.GetZooApplications(PanelRequest.ItemID); gvInstalledApplications.DataSource = installedApplications;
gvInstalledApplications.DataBind(); gvInstalledApplications.DataBind();
} }
else else
{ {
gvInstalledApplications.Visible = false; HideInstalledApplications();
lblConsole.Visible = false; }
} }
private void HideInstalledApplications()
{
gvInstalledApplications.Visible = false;
lblConsole.Visible = false;
} }
private void BindApplications() private void BindApplications()
@ -164,6 +187,11 @@ namespace WebsitePanel.Portal
private void UpdatedAllowedEngines() private void UpdatedAllowedEngines()
{ {
if (!(bool) ViewState["IsZooEnabled"])
{
return; // exit;
}
List<ShortHeliconZooEngine> allowedEngines = (List<ShortHeliconZooEngine>)ViewState["AllowedEngines"]; List<ShortHeliconZooEngine> allowedEngines = (List<ShortHeliconZooEngine>)ViewState["AllowedEngines"];
string[] enabledEngineNames = (string[])ViewState["EnabledEnginesNames"]; string[] enabledEngineNames = (string[])ViewState["EnabledEnginesNames"];