This commit is contained in:
Ruslan Keba 2013-09-13 12:41:54 +03:00
commit 8d06b1c1cf
31 changed files with 8030 additions and 679 deletions

View file

@ -29,19 +29,18 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.5456
// Runtime Version:2.0.50727.5466
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using WebsitePanel.Providers.HeliconZoo;
//
// This source code was auto-generated by wsdl, Version=2.0.50727.42.
//
using WebsitePanel.Providers.HeliconZoo;
namespace WebsitePanel.EnterpriseServer {
using System.Xml.Serialization;
using System.Web.Services;
@ -72,9 +71,13 @@ namespace WebsitePanel.EnterpriseServer {
private System.Threading.SendOrPostCallback SetEnabledEnginesForSiteOperationCompleted;
private System.Threading.SendOrPostCallback IsWebCosoleEnabledOperationCompleted;
private System.Threading.SendOrPostCallback SetWebCosoleEnabledOperationCompleted;
/// <remarks/>
public esHeliconZoo() {
this.Url = "http://localhost:9005/esHeliconZoo.asmx";
this.Url = "http://localhost:9002/esHeliconZoo.asmx";
}
/// <remarks/>
@ -98,6 +101,12 @@ namespace WebsitePanel.EnterpriseServer {
/// <remarks/>
public event SetEnabledEnginesForSiteCompletedEventHandler SetEnabledEnginesForSiteCompleted;
/// <remarks/>
public event IsWebCosoleEnabledCompletedEventHandler IsWebCosoleEnabledCompleted;
/// <remarks/>
public event SetWebCosoleEnabledCompletedEventHandler SetWebCosoleEnabledCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetEngines", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public HeliconZooEngine[] GetEngines(int serviceId) {
@ -395,6 +404,89 @@ namespace WebsitePanel.EnterpriseServer {
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/IsWebCosoleEnabled", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public bool IsWebCosoleEnabled(int serviceId) {
object[] results = this.Invoke("IsWebCosoleEnabled", new object[] {
serviceId});
return ((bool)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginIsWebCosoleEnabled(int serviceId, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("IsWebCosoleEnabled", new object[] {
serviceId}, callback, asyncState);
}
/// <remarks/>
public bool EndIsWebCosoleEnabled(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((bool)(results[0]));
}
/// <remarks/>
public void IsWebCosoleEnabledAsync(int serviceId) {
this.IsWebCosoleEnabledAsync(serviceId, null);
}
/// <remarks/>
public void IsWebCosoleEnabledAsync(int serviceId, object userState) {
if ((this.IsWebCosoleEnabledOperationCompleted == null)) {
this.IsWebCosoleEnabledOperationCompleted = new System.Threading.SendOrPostCallback(this.OnIsWebCosoleEnabledOperationCompleted);
}
this.InvokeAsync("IsWebCosoleEnabled", new object[] {
serviceId}, this.IsWebCosoleEnabledOperationCompleted, userState);
}
private void OnIsWebCosoleEnabledOperationCompleted(object arg) {
if ((this.IsWebCosoleEnabledCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.IsWebCosoleEnabledCompleted(this, new IsWebCosoleEnabledCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SetWebCosoleEnabled", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void SetWebCosoleEnabled(int serviceId, bool enabled) {
this.Invoke("SetWebCosoleEnabled", new object[] {
serviceId,
enabled});
}
/// <remarks/>
public System.IAsyncResult BeginSetWebCosoleEnabled(int serviceId, bool enabled, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("SetWebCosoleEnabled", new object[] {
serviceId,
enabled}, callback, asyncState);
}
/// <remarks/>
public void EndSetWebCosoleEnabled(System.IAsyncResult asyncResult) {
this.EndInvoke(asyncResult);
}
/// <remarks/>
public void SetWebCosoleEnabledAsync(int serviceId, bool enabled) {
this.SetWebCosoleEnabledAsync(serviceId, enabled, null);
}
/// <remarks/>
public void SetWebCosoleEnabledAsync(int serviceId, bool enabled, object userState) {
if ((this.SetWebCosoleEnabledOperationCompleted == null)) {
this.SetWebCosoleEnabledOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetWebCosoleEnabledOperationCompleted);
}
this.InvokeAsync("SetWebCosoleEnabled", new object[] {
serviceId,
enabled}, this.SetWebCosoleEnabledOperationCompleted, userState);
}
private void OnSetWebCosoleEnabledOperationCompleted(object arg) {
if ((this.SetWebCosoleEnabledCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.SetWebCosoleEnabledCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
@ -516,4 +608,34 @@ namespace WebsitePanel.EnterpriseServer {
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void SetEnabledEnginesForSiteCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void IsWebCosoleEnabledCompletedEventHandler(object sender, IsWebCosoleEnabledCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class IsWebCosoleEnabledCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal IsWebCosoleEnabledCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <remarks/>
public bool Result {
get {
this.RaiseExceptionIfNecessary();
return ((bool)(this.results[0]));
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void SetWebCosoleEnabledCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
}

View file

@ -85,6 +85,8 @@ namespace WebsitePanel.EnterpriseServer
allowedEngines.Add( new ShortHeliconZooEngine(){
Name = (string)reader["QuotaName"],
DisplayName= (string)reader["QuotaDescription"],
Enabled = true
});
}
@ -120,6 +122,21 @@ namespace WebsitePanel.EnterpriseServer
}
public static bool IsWebCosoleEnabled(int serviceId)
{
HeliconZoo zooServer = new HeliconZoo();
ServiceProviderProxy.Init(zooServer, serviceId);
return zooServer.IsWebCosoleEnabled();
}
public static void SetWebCosoleEnabled(int serviceId, bool enabled)
{
HeliconZoo zooServer = new HeliconZoo();
ServiceProviderProxy.Init(zooServer, serviceId);
zooServer.SetWebCosoleEnabled(enabled);
}
#region private helpers
private static void UpdateQuotas(int serviceId, HeliconZooEngine[] userEngines)
{
@ -183,7 +200,7 @@ namespace WebsitePanel.EnterpriseServer
DataProvider.AddHeliconZooQuota(groupId, quotaId,
HeliconZooQuotaPrefix+engine.name,
engine.displayName,
order++);
existingQuotas.Count + order++);
}
}

View file

@ -0,0 +1,822 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.IO;
using System.Data;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using WebsitePanel.Server;
using WebsitePanel.Providers;
using WebsitePanel.Providers.OS;
using OS = WebsitePanel.Providers.OS;
using System.Collections;
namespace WebsitePanel.EnterpriseServer
{
public class OperatingSystemController : IImportController, IBackupController
{
private const int FILE_BUFFER_LENGTH = 5000000; // ~5MB
private static OS.OperatingSystem GetOS(int serviceId)
{
OS.OperatingSystem os = new OS.OperatingSystem();
ServiceProviderProxy.Init(os, serviceId);
return os;
}
#region ODBC DSNs
public static DataSet GetRawOdbcSourcesPaged(int packageId,
string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
return PackageController.GetRawPackageItemsPaged(packageId, ResourceGroups.Os, typeof(SystemDSN),
true, filterColumn, filterValue, sortColumn, startRow, maximumRows);
}
public static List<SystemDSN> GetOdbcSources(int packageId, bool recursive)
{
List<ServiceProviderItem> items = PackageController.GetPackageItemsByType(
packageId, ResourceGroups.Os, typeof(SystemDSN), recursive);
return items.ConvertAll<SystemDSN>(
new Converter<ServiceProviderItem, SystemDSN>(ConvertItemToSystemDSN));
}
private static SystemDSN ConvertItemToSystemDSN(ServiceProviderItem item)
{
return (SystemDSN)item;
}
public static string[] GetInstalledOdbcDrivers(int packageId)
{
// load service item
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);
OS.OperatingSystem os = GetOS(serviceId);
return os.GetInstalledOdbcDrivers();
}
public static SystemDSN GetOdbcSource(int itemId)
{
// load meta item
SystemDSN item = (SystemDSN)PackageController.GetPackageItem(itemId);
// load service item
OS.OperatingSystem os = GetOS(item.ServiceId);
SystemDSN dsn = os.GetDSN(item.Name);
// add common properties
dsn.Id = item.Id;
dsn.PackageId = item.PackageId;
dsn.ServiceId = item.ServiceId;
if(dsn.Driver == "MsAccess" || dsn.Driver == "Excel" || dsn.Driver == "Text")
dsn.DatabaseName = FilesController.GetVirtualPackagePath(item.PackageId, dsn.DatabaseName);
return dsn;
}
public static int AddOdbcSource(SystemDSN item)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
if (accountCheck < 0) return accountCheck;
// check package
int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
if (packageCheck < 0) return packageCheck;
// check quota
QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.OS_ODBC);
if (quota.QuotaExhausted)
return BusinessErrorCodes.ERROR_OS_DSN_RESOURCE_QUOTA_LIMIT;
// check if mail resource is available
int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.Os);
if (serviceId == 0)
return BusinessErrorCodes.ERROR_OS_RESOURCE_UNAVAILABLE;
// check package items
if (PackageController.GetPackageItemByName(item.PackageId, item.Name, typeof(SystemDSN)) != null)
return BusinessErrorCodes.ERROR_OS_DSN_PACKAGE_ITEM_EXISTS;
// place log record
TaskManager.StartTask("ODBC_DSN", "ADD", item.Name);
try
{
// check service items
OS.OperatingSystem os = GetOS(serviceId);
if (os.GetDSN(item.Name) != null)
return BusinessErrorCodes.ERROR_OS_DSN_SERVICE_ITEM_EXISTS;
string[] dbNameParts = item.DatabaseName.Split('|');
string groupName = null;
if (dbNameParts.Length > 1)
{
item.DatabaseName = dbNameParts[0];
groupName = dbNameParts[1];
}
// get database server address
item.DatabaseServer = GetDatabaseServerName(groupName, item.PackageId);
if (item.Driver == "MsAccess" || item.Driver == "Excel" || item.Driver == "Text")
item.DatabaseName = FilesController.GetFullPackagePath(item.PackageId, item.DatabaseName);
// add service item
os.CreateDSN(item);
// save item
item.DatabasePassword = CryptoUtils.Encrypt(item.DatabasePassword);
item.ServiceId = serviceId;
int itemId = PackageController.AddPackageItem(item);
TaskManager.ItemId = itemId;
return itemId;
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
}
public static int UpdateOdbcSource(SystemDSN item)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
if (accountCheck < 0) return accountCheck;
// load original meta item
SystemDSN origItem = (SystemDSN)PackageController.GetPackageItem(item.Id);
if (origItem == null)
return BusinessErrorCodes.ERROR_OS_DSN_PACKAGE_ITEM_NOT_FOUND;
// check package
int packageCheck = SecurityContext.CheckPackage(origItem.PackageId, DemandPackage.IsActive);
if (packageCheck < 0) return packageCheck;
// place log record
TaskManager.StartTask("ODBC_DSN", "UPDATE", origItem.Name);
TaskManager.ItemId = item.Id;
try
{
// get service
OS.OperatingSystem os = GetOS(origItem.ServiceId);
// password
item.Driver = origItem.Driver;
item.Name = origItem.Name;
if (item.DatabasePassword == "")
item.DatabasePassword = CryptoUtils.Decrypt(origItem.DatabasePassword);
string[] dbNameParts = item.DatabaseName.Split('|');
string groupName = null;
if (dbNameParts.Length > 1)
{
item.DatabaseName = dbNameParts[0];
groupName = dbNameParts[1];
}
// get database server address
item.DatabaseServer = GetDatabaseServerName(groupName, item.PackageId);
if (item.Driver == "MsAccess" || item.Driver == "Excel" || item.Driver == "Text")
item.DatabaseName = FilesController.GetFullPackagePath(origItem.PackageId, item.DatabaseName);
// update service item
os.UpdateDSN(item);
// update meta item
if (item.DatabasePassword != "")
{
item.DatabasePassword = CryptoUtils.Encrypt(item.DatabasePassword);
PackageController.UpdatePackageItem(item);
}
return 0;
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
}
private static string GetDatabaseServerName(string groupName, int packageId)
{
int sqlServiceId = PackageController.GetPackageServiceId(packageId, groupName);
if (sqlServiceId > 0)
{
StringDictionary sqlSettings = ServerController.GetServiceSettings(sqlServiceId);
return sqlSettings["ExternalAddress"];
}
return "";
}
public static int DeleteOdbcSource(int itemId)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo);
if (accountCheck < 0) return accountCheck;
// load original meta item
SystemDSN origItem = (SystemDSN)PackageController.GetPackageItem(itemId);
if (origItem == null)
return BusinessErrorCodes.ERROR_OS_DSN_PACKAGE_ITEM_NOT_FOUND;
// place log record
TaskManager.StartTask("ODBC_DSN", "DELETE", origItem.Name);
TaskManager.ItemId = itemId;
try
{
// get service
OS.OperatingSystem os = GetOS(origItem.ServiceId);
// delete service item
os.DeleteDSN(origItem.Name);
// delete meta item
PackageController.DeletePackageItem(origItem.Id);
return 0;
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
}
#endregion
private static WindowsServer GetServerService(int serverId)
{
WindowsServer winServer = new WindowsServer();
ServiceProviderProxy.ServerInit(winServer, serverId);
return winServer;
}
#region Terminal Services Sessions
public static TerminalSession[] GetTerminalServicesSessions(int serverId)
{
return GetServerService(serverId).GetTerminalServicesSessions();
}
public static int CloseTerminalServicesSession(int serverId, int sessionId)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin
| DemandAccount.IsActive);
if (accountCheck < 0) return accountCheck;
// load server info
ServerInfo server = ServerController.GetServerById(serverId);
// place log record
TaskManager.StartTask("SERVER", "RESET_TERMINAL_SESSION", sessionId);
TaskManager.ItemId = serverId;
try
{
GetServerService(serverId).CloseTerminalServicesSession(sessionId);
return 0;
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
}
#endregion
#region Windows Processes
public static WindowsProcess[] GetWindowsProcesses(int serverId)
{
return GetServerService(serverId).GetWindowsProcesses();
}
public static int TerminateWindowsProcess(int serverId, int pid)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin
| DemandAccount.IsActive);
if (accountCheck < 0) return accountCheck;
// load server info
ServerInfo server = ServerController.GetServerById(serverId);
// place log record
TaskManager.StartTask("SERVER", "TERMINATE_SYSTEM_PROCESS", pid);
TaskManager.ItemId = serverId;
try
{
GetServerService(serverId).TerminateWindowsProcess(pid);
return 0;
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
}
#endregion
#region Windows Services
public static WindowsService[] GetWindowsServices(int serverId)
{
return GetServerService(serverId).GetWindowsServices();
}
public static int ChangeWindowsServiceStatus(int serverId, string id, WindowsServiceStatus status)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin
| DemandAccount.IsActive);
if (accountCheck < 0) return accountCheck;
// load server info
ServerInfo server = ServerController.GetServerById(serverId);
// place log record
TaskManager.StartTask("SERVER", "CHANGE_WINDOWS_SERVICE_STATUS", id);
TaskManager.ItemId = serverId;
TaskManager.WriteParameter("New Status", status);
try
{
GetServerService(serverId).ChangeWindowsServiceStatus(id, status);
return 0;
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
}
// Check If FSRM Role services were installed
public static bool CheckFileServicesInstallation(int serviceId)
{
OS.OperatingSystem os = GetOS(serviceId);
return os.CheckFileServicesInstallation();
}
#endregion
#region Web Platform Installer
public static bool CheckLoadUserProfile(int serverId)
{
int serviceId = getWebServiceId(serverId);
if (serviceId != -1)
{
return WebServerController.GetWebServer(serviceId).CheckLoadUserProfile();
}
return false;
}
private static int getWebServiceId(int serverId)
{
DataSet dsServices = ServerController.GetRawServicesByServerId(serverId);
int webGroup = -1;
if (dsServices.Tables.Count < 1) return -1;
foreach (DataRow r in dsServices.Tables[0].Rows)
{
if (r["GroupName"].ToString() == "Web")
{
webGroup = (int)r["GroupID"];
break;
}
}
if (webGroup == -1) return -1;
foreach (DataRow r in dsServices.Tables[1].Rows)
{
if ((int)r["GroupID"] == webGroup)
{
return (int)r["ServiceID"];
}
}
return -1;
}
public static void EnableLoadUserProfile(int serverId)
{
int serviceId = getWebServiceId(serverId);
if (serviceId != -1)
{
WebServerController.GetWebServer(serviceId).EnableLoadUserProfile();
}
}
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 GetWPIProductById(int serverId, string productdId)
{
return GetServerService(serverId).GetWPIProductById(productdId);
}
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)
{
return GetServerService(serverId).GetLogNames();
}
public static SystemLogEntry[] GetLogEntries(int serverId, string logName)
{
return GetServerService(serverId).GetLogEntries(logName);
}
public static SystemLogEntriesPaged GetLogEntriesPaged(int serverId, string logName, int startRow, int maximumRows)
{
return GetServerService(serverId).GetLogEntriesPaged(logName, startRow, maximumRows);
}
public static int ClearLog(int serverId, string logName)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin
| DemandAccount.IsActive);
if (accountCheck < 0) return accountCheck;
TaskManager.StartTask("SERVER", "CLEAR_EVENT_LOG", logName);
TaskManager.ItemId = serverId;
try
{
GetServerService(serverId).ClearLog(logName);
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
return 0;
}
#endregion
#region Server Reboot
public static int RebootSystem(int serverId)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin
| DemandAccount.IsActive);
if (accountCheck < 0) return accountCheck;
// load server info
ServerInfo server = ServerController.GetServerById(serverId);
// place log record
TaskManager.StartTask("SERVER", "REBOOT");
TaskManager.ItemId = serverId;
try
{
GetServerService(serverId).RebootSystem();
return 0;
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
}
#endregion
#region IImportController Members
public List<string> GetImportableItems(int packageId, int itemTypeId, Type itemType,
ResourceGroupInfo group)
{
List<string> items = new List<string>();
// get service id
int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);
if (serviceId == 0)
return items;
OS.OperatingSystem os = GetOS(serviceId);
if (itemType == typeof(SystemDSN))
items.AddRange(os.GetDSNNames());
return items;
}
public void ImportItem(int packageId, int itemTypeId, Type itemType,
ResourceGroupInfo group, string itemName)
{
// get service id
int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);
if (serviceId == 0)
return;
if (itemType == typeof(SystemDSN))
{
// save DSN info
SystemDSN dsn = new SystemDSN();
dsn.Name = itemName;
dsn.ServiceId = serviceId;
dsn.PackageId = packageId;
PackageController.AddPackageItem(dsn);
}
}
#endregion
#region IBackupController Members
public int BackupItem(string tempFolder, System.Xml.XmlWriter writer, ServiceProviderItem item, ResourceGroupInfo group)
{
if (item is HomeFolder)
{
// backup home folder files
string backupName = String.Format("SpaceFiles_{0}_{1}.zip",
item.Id, DateTime.Now.Ticks);
// get the list of remote files
List<SystemFile> files = FilesController.GetFiles(item.PackageId, "\\", true);
string[] zipFiles = new string[files.Count];
for(int i = 0; i < zipFiles.Length; i++)
zipFiles[i] = files[i].Name;
// zip remote files
FilesController.ZipFiles(item.PackageId, zipFiles, backupName);
// download zipped file
string localBackupPath = Path.Combine(tempFolder, backupName);
byte[] buffer = null;
FileStream stream = new FileStream(localBackupPath, FileMode.Create, FileAccess.Write);
int offset = 0;
long length = 0;
do
{
// read remote content
buffer = FilesController.GetFileBinaryChunk(item.PackageId, backupName, offset, FILE_BUFFER_LENGTH);
// write remote content
stream.Write(buffer, 0, buffer.Length);
length += buffer.Length;
offset += FILE_BUFFER_LENGTH;
}
while (buffer.Length == FILE_BUFFER_LENGTH);
stream.Close();
// delete zipped file
if (FilesController.FileExists(item.PackageId, backupName))
FilesController.DeleteFiles(item.PackageId, new string[] { backupName });
// add file pointer
BackupController.WriteFileElement(writer, "SpaceFiles", backupName, length);
// store meta item
XmlSerializer serializer = new XmlSerializer(typeof(HomeFolder));
serializer.Serialize(writer, item);
}
else if (item is SystemDSN)
{
// backup ODBC DSN
OS.OperatingSystem os = GetOS(item.ServiceId);
// read DSN info
SystemDSN itemDsn = item as SystemDSN;
SystemDSN dsn = os.GetDSN(item.Name);
dsn.DatabasePassword = itemDsn.DatabasePassword;
XmlSerializer serializer = new XmlSerializer(typeof(SystemDSN));
serializer.Serialize(writer, dsn);
}
return 0;
}
public int RestoreItem(string tempFolder, System.Xml.XmlNode itemNode, int itemId, Type itemType, string itemName, int packageId, int serviceId, ResourceGroupInfo group)
{
if (itemType == typeof(HomeFolder))
{
OS.OperatingSystem os = GetOS(serviceId);
// extract meta item
XmlSerializer serializer = new XmlSerializer(typeof(HomeFolder));
HomeFolder homeFolder = (HomeFolder)serializer.Deserialize(
new XmlNodeReader(itemNode.SelectSingleNode("HomeFolder")));
// create home folder if required
if (!os.DirectoryExists(homeFolder.Name))
{
os.CreatePackageFolder(homeFolder.Name);
}
// copy database backup to remote server
XmlNode fileNode = itemNode.SelectSingleNode("File[@name='SpaceFiles']");
string backupFileName = fileNode.Attributes["path"].Value;
long backupFileLength = Int64.Parse(fileNode.Attributes["size"].Value);
string localBackupFilePath = Path.Combine(tempFolder, backupFileName);
if (new FileInfo(localBackupFilePath).Length != backupFileLength)
return -3;
FileStream stream = new FileStream(localBackupFilePath, FileMode.Open, FileAccess.Read);
byte[] buffer = new byte[FILE_BUFFER_LENGTH];
int readBytes = 0;
long length = 0;
string remoteBackupPath = Path.Combine(homeFolder.Name, backupFileName);
do
{
// read package file
readBytes = stream.Read(buffer, 0, FILE_BUFFER_LENGTH);
length += readBytes;
if (readBytes < FILE_BUFFER_LENGTH)
// resize buffer
Array.Resize<byte>(ref buffer, readBytes);
// write remote backup file
os.AppendFileBinaryContent(remoteBackupPath, buffer);
}
while (readBytes == FILE_BUFFER_LENGTH);
stream.Close();
// unzip files
os.UnzipFiles(remoteBackupPath, homeFolder.Name);
// delete archive
if (os.FileExists(remoteBackupPath))
os.DeleteFile(remoteBackupPath);
// add meta-item if required
if (PackageController.GetPackageItemByName(packageId, itemName, typeof(HomeFolder)) == null)
{
homeFolder.PackageId = packageId;
homeFolder.ServiceId = serviceId;
PackageController.AddPackageItem(homeFolder);
}
}
else if (itemType == typeof(SystemDSN))
{
OS.OperatingSystem os = GetOS(serviceId);
// extract meta item
XmlSerializer serializer = new XmlSerializer(typeof(SystemDSN));
SystemDSN dsn = (SystemDSN)serializer.Deserialize(
new XmlNodeReader(itemNode.SelectSingleNode("SystemDSN")));
// create DSN if required
if (os.GetDSN(itemName) == null)
{
dsn.DatabasePassword = CryptoUtils.Decrypt(dsn.DatabasePassword);
os.CreateDSN(dsn);
// restore password
dsn.DatabasePassword = CryptoUtils.Encrypt(dsn.DatabasePassword);
}
// add meta-item if required
if (PackageController.GetPackageItemByName(packageId, itemName, typeof(SystemDSN)) == null)
{
dsn.PackageId = packageId;
dsn.ServiceId = serviceId;
PackageController.AddPackageItem(dsn);
}
}
return 0;
}
#endregion
}
}

View file

@ -97,5 +97,17 @@ namespace WebsitePanel.EnterpriseServer
{
HeliconZooController.SetEnabledEnginesForSite(siteId, packageId, engines);
}
[WebMethod]
public bool IsWebCosoleEnabled(int serviceId)
{
return HeliconZooController.IsWebCosoleEnabled(serviceId);
}
[WebMethod]
public void SetWebCosoleEnabled(int serviceId, bool enabled)
{
HeliconZooController.SetWebCosoleEnabled(serviceId, enabled);
}
}
}

View file

@ -752,6 +752,12 @@ namespace WebsitePanel.EnterpriseServer
return OperatingSystemController.GetWPIProductsFiltered(serverId, keywordId);
}
[WebMethod]
public WPIProduct GetWPIProductById(int serverId, string productdId)
{
InitWPIFeeds(serverId);
return OperatingSystemController.GetWPIProductById(serverId, productdId);
}
[WebMethod]
public WPIProduct[] GetWPIProductsWithDependencies(int serverId, string[] products)

View file

@ -79,6 +79,14 @@ namespace WebsitePanel.EnterpriseServer
return WebAppGalleryController.GetGalleryApplications(packageId, categoryId);
}
[WebMethod]
public GalleryApplicationsResult GetInstaledApplications(int packageId, string categoryId)
{
WebAppGalleryController.InitFeeds(SecurityContext.User.UserId, packageId);
return WebAppGalleryController.GetGalleryApplications(packageId, categoryId);
}
[WebMethod]
public GalleryApplicationsResult GetGalleryApplicationsFiltered(int packageId, string pattern)
{

View file

@ -443,6 +443,8 @@ namespace WebsitePanel.EnterpriseServer
#endregion
#region Helicon Ape Users
[WebMethod]
public HtaccessUser[] GetHeliconApeUsers(int siteItemId)
@ -495,6 +497,38 @@ namespace WebsitePanel.EnterpriseServer
}
#endregion
#region Helicon Zoo
[WebMethod]
public List<WebVirtualDirectory> GetZooApplications(int siteItemId)
{
return WebServerController.GetZooApplications(siteItemId);
}
[WebMethod]
public StringResultObject SetZooEnvironmentVariable(int siteItemId, string appName, string envName, string envValue)
{
return WebServerController.SetZooEnvironmentVariable(siteItemId, appName, envName, envValue);
}
[WebMethod]
public StringResultObject SetZooConsoleEnabled(int siteItemId, string appName)
{
return WebServerController.SetZooConsoleEnabled(siteItemId, appName);
}
[WebMethod]
public StringResultObject SetZooConsoleDisabled(int siteItemId, string appName)
{
return WebServerController.SetZooConsoleDisabled(siteItemId, appName);
}
#endregion
#region WebManagement Access

View file

@ -92,5 +92,7 @@ namespace WebsitePanel.Providers.HeliconZoo
void SwithEnginesEnabled(bool enabled);
string[] GetEnabledEnginesForSite(string siteId);
void SetEnabledEnginesForSite(string siteId, string[] engineNames);
bool IsWebCosoleEnabled();
void SetWebCosoleEnabled(bool enabled);
}
}

View file

@ -121,6 +121,12 @@ namespace WebsitePanel.Providers.Web
void UpdateHeliconApeGroup(string siteId, WebGroup group);
void DeleteHeliconApeGroup(string siteId, string groupName);
// Helicon Zoo
WebVirtualDirectory[] GetZooApplications(string siteId);
StringResultObject SetZooEnvironmentVariable(string siteId, string appName, string envName, string envValue);
StringResultObject SetZooConsoleEnabled(string siteId, string appName);
StringResultObject SetZooConsoleDisabled(string siteId, string appName);
// web app gallery
bool CheckLoadUserProfile();

View file

@ -78,6 +78,7 @@ namespace WebsitePanel.Providers.Web
private bool redirectPermanent;
private bool sharePointInstalled;
private bool iis7;
private string consoleUrl;
public string AnonymousUsername
{
@ -264,6 +265,12 @@ namespace WebsitePanel.Providers.Web
set { this.iis7 = value; }
}
public string ConsoleUrl
{
get { return consoleUrl; }
set { consoleUrl = value; }
}
#region Web Deploy Publishing Properties
/// <summary>
/// Gets or sets Web Deploy publishing account name

View file

@ -95,11 +95,15 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
{
if ((string)switchboardElement.GetAttributeValue("name") == "*")
{
switchboardDisabledDefault = !(bool)switchboardElement.GetAttributeValue("enabled");
bool isEnabled = GetSwitchBoardValue(switchboardElement);
switchboardDisabledDefault = !isEnabled ;
break;
}
}
//main engines
foreach (ConfigurationElement item in enginesCollection)
{
HeliconZooEngine newItem = ConvertElementToHeliconZooEngine(item);
@ -107,6 +111,9 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
result.Add(newItem);
}
//userEngines
ConfigurationElement userEngines = heliconZooServer.GetChildElement("userEngines");
ConfigurationElementCollection userEnginesCollection = userEngines.GetCollection();
foreach (ConfigurationElement item in userEnginesCollection)
@ -127,13 +134,25 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
}
//Web console
HeliconZooEngine webConsole = new HeliconZooEngine
{
displayName = "Web console",
name = "console"
};
result.Add(webConsole);
foreach (ConfigurationElement switchboardElement in switchboardCollection)
{
HeliconZooEngine item = Collection_GetHeliconZooEngineByName(result, (string)switchboardElement.GetAttributeValue("name"));
if (item != null)
{
item.disabled = !(bool)switchboardElement.GetAttributeValue("enabled");
bool isEnabled = GetSwitchBoardValue(switchboardElement);
item.disabled = !isEnabled;
}
else
{
@ -149,6 +168,17 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
return result.ToArray();
}
private bool GetSwitchBoardValue(ConfigurationElement switchboardElement)
{
return (0 == String.Compare((string)switchboardElement.GetAttributeValue("value"),
"Enabled", StringComparison.OrdinalIgnoreCase));
}
private void SetSwitchBoardValue(ConfigurationElement switchboardElement, bool enabled)
{
switchboardElement.SetAttributeValue("value", enabled ? "Enabled" : "Disabled");
}
HeliconZooEngine Collection_GetHeliconZooEngineByName(List<HeliconZooEngine> collection, string name)
{
foreach (HeliconZooEngine r in collection)
@ -184,14 +214,6 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
switchboardCollection.Clear();
//Disable all engines, by default for WSP
/*
ConfigurationElement disableAll = switchboardCollection.CreateElement();
disableAll.SetAttributeValue("name", "*");
disableAll.SetAttributeValue("enabled", "false");
switchboardCollection.Add(disableAll);
*/
foreach(HeliconZooEngine item in userEngines)
{
@ -202,12 +224,7 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
enginesCollection.Add(engine);
}
/*
ConfigurationElement disable = switchboardCollection.CreateElement();
disable.SetAttributeValue("name", item.name );
disable.SetAttributeValue("enabled", item.disabled? "false": "true" );
switchboardCollection.Add(disable);
*/
}
srvman.CommitChanges();
@ -233,7 +250,7 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
{
if ((string) switchboardElement.GetAttributeValue("name") == "*")
{
isEnginesEnabled = (bool) switchboardElement.GetAttributeValue("enabled");
isEnginesEnabled = GetSwitchBoardValue(switchboardElement);
break;
}
}
@ -258,7 +275,7 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
{
if ((string)switchboardElement.GetAttributeValue("name") == "*")
{
switchboardElement.SetAttributeValue("enabled", enabled ? "true" : "false");
switchboardElement.SetAttributeValue("value", enabled ? "Enabed" : "Disabled");
wildCardFound = true;
break;
}
@ -268,7 +285,7 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
{
ConfigurationElement element = switchboardCollection.CreateElement();
element.SetAttributeValue("name", "*");
element.SetAttributeValue("enabled", enabled ? "true" : "false");
SetSwitchBoardValue(element, enabled);
switchboardCollection.Add(element);
}
@ -305,8 +322,9 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
foreach (ConfigurationElement element in switchboardCollection)
{
string enabled = element.GetAttributeValue("enabled").ToString();
if (string.Equals(enabled, "true", StringComparison.OrdinalIgnoreCase))
bool isEnabled = GetSwitchBoardValue(element);
if (isEnabled)
{
engines.Add(element.GetAttributeValue("name").ToString());
}
@ -334,14 +352,14 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
ConfigurationElement elementDisableAll = switchboardCollection.CreateElement();
elementDisableAll.SetAttributeValue("name", "*");
elementDisableAll.SetAttributeValue("enabled", "false");
SetSwitchBoardValue(elementDisableAll, false);
switchboardCollection.Add(elementDisableAll);
foreach (string engineName in engineNames)
{
ConfigurationElement element = switchboardCollection.CreateElement();
element.SetAttributeValue("name", engineName);
element.SetAttributeValue("enabled", "true");
SetSwitchBoardValue(element, true);
switchboardCollection.Add(element);
}
@ -352,6 +370,72 @@ namespace WebsitePanel.Providers.Web.HeliconZoo
}
public bool IsWebCosoleEnabled()
{
bool isEnginesEnabled = true;
using (var srvman = new ServerManager())
{
Configuration appConfig = srvman.GetApplicationHostConfiguration();
ConfigurationSection heliconZooServer = appConfig.GetSection("system.webServer/heliconZooServer");
//switchboard
ConfigurationElement switchboard = heliconZooServer.GetChildElement("switchboard");
ConfigurationElementCollection switchboardCollection = switchboard.GetCollection();
foreach (ConfigurationElement switchboardElement in switchboardCollection)
{
if ((string)switchboardElement.GetAttributeValue("name") == "console")
{
isEnginesEnabled = GetSwitchBoardValue(switchboardElement);
break;
}
}
}
return isEnginesEnabled;
}
public void SetWebCosoleEnabled(bool enabled)
{
using (var srvman = new ServerManager())
{
Configuration appConfig = srvman.GetApplicationHostConfiguration();
ConfigurationSection heliconZooServer = appConfig.GetSection("system.webServer/heliconZooServer");
ConfigurationElement switchboard = heliconZooServer.GetChildElement("switchboard");
ConfigurationElementCollection switchboardCollection = switchboard.GetCollection();
bool found = false;
foreach (ConfigurationElement switchboardElement in switchboardCollection)
{
if ((string)switchboardElement.GetAttributeValue("name") == "console")
{
SetSwitchBoardValue(switchboardElement, enabled);
found = true;
break;
}
}
if (!found)
{
ConfigurationElement element = switchboardCollection.CreateElement();
element.SetAttributeValue("name", "console");
SetSwitchBoardValue(element, enabled);
switchboardCollection.Add(element);
}
srvman.CommitChanges();
}
}
#region private methods
private void ConvertHeliconZooEngineToElement(HeliconZooEngine item, ConfigurationElement engine)

View file

@ -1563,12 +1563,18 @@ namespace WebsitePanel.Providers.Web
/// <returns>virtual directories that belong to site with supplied id.</returns>
public override WebVirtualDirectory[] GetVirtualDirectories(string siteId)
{
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
return GetVirtualDirectories(srvman, siteId);
}
}
private WebVirtualDirectory[] GetVirtualDirectories(ServerManager srvman, string siteId)
{
// get all virt dirs
@ -1938,7 +1944,6 @@ namespace WebsitePanel.Providers.Web
if (!string.IsNullOrEmpty(siteId))
{
// Check the web site app pool in integrated pipeline mode
WebSite webSite = null;
webSite = webObjectsSvc.GetWebSiteFromIIS(srvman, siteId);
if (webSite == null)
@ -2585,11 +2590,90 @@ namespace WebsitePanel.Providers.Web
return;
}
#endregion
#region Helicon Zoo
public override WebVirtualDirectory[] GetZooApplications(string siteId)
{
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
return webObjectsSvc.GetZooApplications(srvman, siteId);
}
}
public override StringResultObject SetZooEnvironmentVariable(string siteId, string appName, string envName, string envValue)
{
StringResultObject result = new StringResultObject();
try
{
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
webObjectsSvc.SetZooEnvironmentVariable(srvman, siteId, appName, envName, envValue);
}
result.IsSuccess = true;
}
catch (Exception e)
{
result.AddError("Exception", e);
}
return result;
}
public override StringResultObject SetZooConsoleEnabled(string siteId, string appName)
{
StringResultObject result = new StringResultObject();
try
{
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
webObjectsSvc.SetZooConsoleEnabled(srvman, siteId, appName);
}
result.IsSuccess = true;
}
catch (Exception e)
{
result.AddError("Exception", e);
}
return result;
}
public override StringResultObject SetZooConsoleDisabled(string siteId, string appName)
{
StringResultObject result = new StringResultObject();
try
{
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
webObjectsSvc.SetZooConsoleDisabled(srvman, siteId, appName);
}
result.IsSuccess = true;
}
catch (Exception e)
{
result.AddError("Exception", e);
}
return result;
}
#endregion
#region Secured Helicon Ape Users
public static string GeneratePasswordHash(HtaccessUser user)
public static string GeneratePasswordHash(HtaccessUser user)
{
if (HtaccessFolder.AUTH_TYPE_BASIC == user.AuthType)
{

View file

@ -26,6 +26,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace WebsitePanel.Providers.Web.Iis.WebObjects
{
using System;
@ -661,6 +665,137 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
return vdirs.ToArray();
}
public WebVirtualDirectory[] GetZooApplications(ServerManager srvman, string siteId)
{
if (!SiteExists(srvman, siteId))
return new WebVirtualDirectory[] { };
var vdirs = new List<WebVirtualDirectory>();
var iisObject = srvman.Sites[siteId];
//
foreach (var item in iisObject.Applications)
{
try
{
Configuration cfg = item.GetWebConfiguration();
string location = siteId + ConfigurationUtility.GetQualifiedVirtualPath(item.Path);
ConfigurationSection section = cfg.GetSection("system.webServer/heliconZoo", location);
if (section.GetCollection().Count > 0)
{
WebVirtualDirectory vdir = new WebVirtualDirectory
{
Name = ConfigurationUtility.GetNonQualifiedVirtualPath(item.Path),
ContentPath = item.VirtualDirectories[0].PhysicalPath
};
ConfigurationElement zooAppElement = section.GetCollection()[0];
ConfigurationElementCollection envColl = zooAppElement.GetChildElement("environmentVariables").GetCollection();
foreach (ConfigurationElement env in envColl)
{
if ((string) env.GetAttributeValue("name") == "CONSOLE_URL")
{
vdir.ConsoleUrl = ConfigurationUtility.GetQualifiedVirtualPath(item.Path);
if (!vdir.ConsoleUrl.EndsWith("/"))
{
vdir.ConsoleUrl += "/";
}
vdir.ConsoleUrl += (string)env.GetAttributeValue("value");
}
}
vdirs.Add(vdir);
}
}
catch (Exception)
{
//there is no zoo
throw;
}
}
//
return vdirs.ToArray();
}
public void SetZooConsoleEnabled(ServerManager srvman, string siteId, string appName)
{
Random random = new Random((int) DateTime.Now.Ticks);
byte[] bytes = new byte[8];
random.NextBytes(bytes);
string consoleUrl = "console_" + Convert.ToBase64String(bytes);
SetZooEnvironmentVariable(srvman, siteId, appName, "CONSOLE_URL", consoleUrl);
}
public void SetZooConsoleDisabled(ServerManager srvman, string siteId, string appName)
{
SetZooEnvironmentVariable(srvman, siteId, appName, "CONSOLE_URL", null);
}
public void SetZooEnvironmentVariable(ServerManager srvman, string siteId, string appName, string envName, string envValue)
{
if (!SiteExists(srvman, siteId))
return;
var iisObject = srvman.Sites[siteId];
//
foreach (var item in iisObject.Applications)
{
if (appName == ConfigurationUtility.GetNonQualifiedVirtualPath(item.Path))
{
Configuration cfg = item.GetWebConfiguration();
ConfigurationSection section = cfg.GetSection("system.webServer/heliconZoo");
ConfigurationElement zooAppElement = section.GetCollection()[0];
ConfigurationElementCollection envColl = zooAppElement.GetChildElement("environmentVariables").GetCollection();
//remove all CONSOLE_URLs
for (int i = 0; i < envColl.Count; )
{
if (String.Compare(envColl[i].GetAttributeValue("name").ToString(), envName, StringComparison.OrdinalIgnoreCase) == 0)
{
envColl.RemoveAt(i);
}
else
{
++i;
}
}
// do not set empty value
if (!string.IsNullOrEmpty(envValue))
{
ConfigurationElement el = envColl.CreateElement();
el.SetAttributeValue("name", envName);
el.SetAttributeValue("value", envValue);
envColl.Add(el);
}
srvman.CommitChanges();
}
}
}
public WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName)
{
//
@ -737,4 +872,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
}
}
}
}

View file

@ -2455,10 +2455,37 @@ namespace WebsitePanel.Providers.Web
throw new NotImplementedException();
}
#endregion
#region Private Helper Methods
protected string GetVirtualDirectoryPath(string siteId, string directoryName)
#endregion
#region Helicon Zoo
public virtual WebVirtualDirectory[] GetZooApplications(string siteId)
{
return new WebVirtualDirectory[] { };
}
public virtual StringResultObject SetZooEnvironmentVariable(string siteId, string appName, string envName, string envValue)
{
//pass
return new StringResultObject();
}
public virtual StringResultObject SetZooConsoleEnabled(string siteId, string appName)
{
return new StringResultObject();
}
public virtual StringResultObject SetZooConsoleDisabled(string siteId, string appName)
{
return new StringResultObject();
}
#endregion
#region Private Helper Methods
protected string GetVirtualDirectoryPath(string siteId, string directoryName)
{
string path = siteId + "/ROOT";
if (!String.IsNullOrEmpty(directoryName))

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.5456
// Runtime Version:2.0.50727.5466
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -41,6 +41,10 @@ namespace WebsitePanel.Providers.HeliconZoo {
private System.Threading.SendOrPostCallback SetEnabledEnginesForSiteOperationCompleted;
private System.Threading.SendOrPostCallback IsWebCosoleEnabledOperationCompleted;
private System.Threading.SendOrPostCallback SetWebCosoleEnabledOperationCompleted;
/// <remarks/>
public HeliconZoo() {
this.Url = "http://localhost:9003/HeliconZoo.asmx";
@ -64,6 +68,12 @@ namespace WebsitePanel.Providers.HeliconZoo {
/// <remarks/>
public event SetEnabledEnginesForSiteCompletedEventHandler SetEnabledEnginesForSiteCompleted;
/// <remarks/>
public event IsWebCosoleEnabledCompletedEventHandler IsWebCosoleEnabledCompleted;
/// <remarks/>
public event SetWebCosoleEnabledCompletedEventHandler SetWebCosoleEnabledCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetEngines", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
@ -307,6 +317,85 @@ namespace WebsitePanel.Providers.HeliconZoo {
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/IsWebCosoleEnabled", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public bool IsWebCosoleEnabled() {
object[] results = this.Invoke("IsWebCosoleEnabled", new object[0]);
return ((bool)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginIsWebCosoleEnabled(System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("IsWebCosoleEnabled", new object[0], callback, asyncState);
}
/// <remarks/>
public bool EndIsWebCosoleEnabled(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((bool)(results[0]));
}
/// <remarks/>
public void IsWebCosoleEnabledAsync() {
this.IsWebCosoleEnabledAsync(null);
}
/// <remarks/>
public void IsWebCosoleEnabledAsync(object userState) {
if ((this.IsWebCosoleEnabledOperationCompleted == null)) {
this.IsWebCosoleEnabledOperationCompleted = new System.Threading.SendOrPostCallback(this.OnIsWebCosoleEnabledOperationCompleted);
}
this.InvokeAsync("IsWebCosoleEnabled", new object[0], this.IsWebCosoleEnabledOperationCompleted, userState);
}
private void OnIsWebCosoleEnabledOperationCompleted(object arg) {
if ((this.IsWebCosoleEnabledCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.IsWebCosoleEnabledCompleted(this, new IsWebCosoleEnabledCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/SetWebCosoleEnabled", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void SetWebCosoleEnabled(bool enabled) {
this.Invoke("SetWebCosoleEnabled", new object[] {
enabled});
}
/// <remarks/>
public System.IAsyncResult BeginSetWebCosoleEnabled(bool enabled, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("SetWebCosoleEnabled", new object[] {
enabled}, callback, asyncState);
}
/// <remarks/>
public void EndSetWebCosoleEnabled(System.IAsyncResult asyncResult) {
this.EndInvoke(asyncResult);
}
/// <remarks/>
public void SetWebCosoleEnabledAsync(bool enabled) {
this.SetWebCosoleEnabledAsync(enabled, null);
}
/// <remarks/>
public void SetWebCosoleEnabledAsync(bool enabled, object userState) {
if ((this.SetWebCosoleEnabledOperationCompleted == null)) {
this.SetWebCosoleEnabledOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetWebCosoleEnabledOperationCompleted);
}
this.InvokeAsync("SetWebCosoleEnabled", new object[] {
enabled}, this.SetWebCosoleEnabledOperationCompleted, userState);
}
private void OnSetWebCosoleEnabledOperationCompleted(object arg) {
if ((this.SetWebCosoleEnabledCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.SetWebCosoleEnabledCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
@ -402,4 +491,34 @@ namespace WebsitePanel.Providers.HeliconZoo {
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void SetEnabledEnginesForSiteCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void IsWebCosoleEnabledCompletedEventHandler(object sender, IsWebCosoleEnabledCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class IsWebCosoleEnabledCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal IsWebCosoleEnabledCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <remarks/>
public bool Result {
get {
this.RaiseExceptionIfNecessary();
return ((bool)(this.results[0]));
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void SetWebCosoleEnabledCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
}

View file

@ -26,10 +26,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.42
// Runtime Version:2.0.50727.5466
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -39,8 +40,7 @@
//
// This source code was auto-generated by wsdl, Version=2.0.50727.42.
//
namespace WebsitePanel.Server
{
namespace WebsitePanel.Server {
using System.Diagnostics;
using System.Web.Services;
using System.ComponentModel;
@ -73,6 +73,8 @@ namespace WebsitePanel.Server
private System.Threading.SendOrPostCallback GetWPIProductsFilteredOperationCompleted;
private System.Threading.SendOrPostCallback GetWPIProductByIdOperationCompleted;
private System.Threading.SendOrPostCallback GetWPITabsOperationCompleted;
private System.Threading.SendOrPostCallback InitWPIFeedsOperationCompleted;
@ -132,6 +134,9 @@ namespace WebsitePanel.Server
/// <remarks/>
public event GetWPIProductsFilteredCompletedEventHandler GetWPIProductsFilteredCompleted;
/// <remarks/>
public event GetWPIProductByIdCompletedEventHandler GetWPIProductByIdCompleted;
/// <remarks/>
public event GetWPITabsCompletedEventHandler GetWPITabsCompleted;
@ -496,6 +501,47 @@ namespace WebsitePanel.Server
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetWPIProductById", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public WPIProduct GetWPIProductById(string productdId) {
object[] results = this.Invoke("GetWPIProductById", new object[] {
productdId});
return ((WPIProduct)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginGetWPIProductById(string productdId, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("GetWPIProductById", new object[] {
productdId}, callback, asyncState);
}
/// <remarks/>
public WPIProduct EndGetWPIProductById(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((WPIProduct)(results[0]));
}
/// <remarks/>
public void GetWPIProductByIdAsync(string productdId) {
this.GetWPIProductByIdAsync(productdId, null);
}
/// <remarks/>
public void GetWPIProductByIdAsync(string productdId, object userState) {
if ((this.GetWPIProductByIdOperationCompleted == null)) {
this.GetWPIProductByIdOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetWPIProductByIdOperationCompleted);
}
this.InvokeAsync("GetWPIProductById", new object[] {
productdId}, this.GetWPIProductByIdOperationCompleted, userState);
}
private void OnGetWPIProductByIdOperationCompleted(object arg) {
if ((this.GetWPIProductByIdCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.GetWPIProductByIdCompleted(this, new GetWPIProductByIdCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetWPITabs", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public WPITab[] GetWPITabs() {
@ -1237,6 +1283,32 @@ namespace WebsitePanel.Server
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void GetWPIProductByIdCompletedEventHandler(object sender, GetWPIProductByIdCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class GetWPIProductByIdCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal GetWPIProductByIdCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <remarks/>
public WPIProduct Result {
get {
this.RaiseExceptionIfNecessary();
return ((WPIProduct)(this.results[0]));
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void GetWPITabsCompletedEventHandler(object sender, GetWPITabsCompletedEventArgs e);

View file

@ -267,6 +267,20 @@ namespace WebsitePanel.Server.Code
return products;
}
public Product GetWPIProductById(string productId)
{
foreach (Product product in _productManager.Products)
{
if (0 == String.Compare(product.ProductId, productId, StringComparison.OrdinalIgnoreCase))
{
return product;
}
}
return null; //not found
}
public List<Product> GetProductsToInstall(IEnumerable<string> productIdsToInstall)
{
List<Product> productsToInstall = new List<Product>();
@ -582,7 +596,6 @@ namespace WebsitePanel.Server.Code
private void Initialize()
{
// create cache folder if not exists
//_webPIinstallersFolder = Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Microsoft\Web Platform Installer\installers");
_webPIinstallersFolder = Path.Combine(
Environment.ExpandEnvironmentVariables("%SystemRoot%"),
"Temp\\zoo.wpi\\AppData\\Local\\Microsoft\\Web Platform Installer\\installers");

View file

@ -101,5 +101,17 @@ namespace WebsitePanel.Server
{
ZooProvider.SetEnabledEnginesForSite(siteId, engineNames);
}
[WebMethod, SoapHeader("settings")]
public bool IsWebCosoleEnabled()
{
return ZooProvider.IsWebCosoleEnabled();
}
[WebMethod, SoapHeader("settings")]
public void SetWebCosoleEnabled(bool enabled)
{
ZooProvider.SetWebCosoleEnabled(enabled);
}
}
}

View file

@ -1093,6 +1093,82 @@ namespace WebsitePanel.Server
throw;
}
}
#endregion
#region Helicon Zoo
[WebMethod, SoapHeader("settings")]
public WebVirtualDirectory[] GetZooApplications(string siteId)
{
try
{
Log.WriteStart("'{0}' GetZooApplications", ProviderSettings.ProviderName);
WebVirtualDirectory[] result = WebProvider.GetZooApplications(siteId);
Log.WriteEnd("'{0}' GetZooApplications", ProviderSettings.ProviderName);
return result;
}
catch (Exception ex)
{
Log.WriteError(String.Format("'{0}' GetZooApplications", ProviderSettings.ProviderName), ex);
throw;
}
}
[WebMethod, SoapHeader("settings")]
public StringResultObject SetZooEnvironmentVariable(string siteId, string appName, string envName, string envValue)
{
try
{
Log.WriteStart("'{0}' SetZooEnvironmentVariable", ProviderSettings.ProviderName);
StringResultObject result = WebProvider.SetZooEnvironmentVariable(siteId, appName, envName, envValue);
Log.WriteEnd("'{0}' SetZooEnvironmentVariable", ProviderSettings.ProviderName);
return result;
}
catch (Exception ex)
{
Log.WriteError(String.Format("'{0}' SetZooEnvironmentVariable", ProviderSettings.ProviderName), ex);
throw;
}
}
[WebMethod, SoapHeader("settings")]
public StringResultObject SetZooConsoleEnabled(string siteId, string appName)
{
try
{
Log.WriteStart("'{0}' SetZooConsoleEnabled", ProviderSettings.ProviderName);
StringResultObject result = WebProvider.SetZooConsoleEnabled(siteId, appName);
Log.WriteEnd("'{0}' SetZooConsoleEnabled", ProviderSettings.ProviderName);
return result;
}
catch (Exception ex)
{
Log.WriteError(String.Format("'{0}' SetZooConsoleEnabled", ProviderSettings.ProviderName), ex);
throw;
}
}
[WebMethod, SoapHeader("settings")]
public StringResultObject SetZooConsoleDisabled(string siteId, string appName)
{
try
{
Log.WriteStart("'{0}' SetZooConsoleDisabled", ProviderSettings.ProviderName);
StringResultObject result = WebProvider.SetZooConsoleDisabled(siteId, appName);
Log.WriteEnd("'{0}' SetZooConsoleDisabled", ProviderSettings.ProviderName);
return result;
}
catch (Exception ex)
{
Log.WriteError(String.Format("'{0}' SetZooConsoleDisabled", ProviderSettings.ProviderName), ex);
throw;
}
}
#endregion
#region Web Application Gallery

View file

@ -360,20 +360,50 @@ namespace WebsitePanel.Server
{
foreach (WPIProduct product in products)
{
string installedHostingPackageVersion = GetInstalledHostingPackageVersion(product.ProductId);
if (!string.IsNullOrEmpty(installedHostingPackageVersion) && string.Compare(product.Version, installedHostingPackageVersion, StringComparison.OrdinalIgnoreCase) > 0)
{
product.IsUpgrade = true;
}
string hostingPackageName = product.ProductId;
CheckProductForUpdate(hostingPackageName, product);
}
}
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))
{
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;
@ -480,6 +510,33 @@ namespace WebsitePanel.Server
}
}
[WebMethod]
public WPIProduct GetWPIProductById(string productdId)
{
try
{
Log.WriteStart("GetWPIProductById");
WpiHelper wpi = GetWpiFeed();
Product product = wpi.GetWPIProductById(productdId);
WPIProduct wpiProduct = ProductToWPIProduct(product);
if (wpiProduct.ProductId == "HeliconZooModule")
{
/*null string = HeliconZooModule in registry*/
CheckProductForUpdate("", wpiProduct);
}
Log.WriteEnd("GetWPIProductById");
return wpiProduct;
}
catch (Exception ex)
{
Log.WriteError("GetWPIProductById", ex);
throw;
}
}
[WebMethod]
public WPITab[] GetWPITabs()
{

View file

@ -123,4 +123,18 @@
<data name="SelectWebEngine.Text" xml:space="preserve">
<value>Select web application engine to set up</value>
</data>
<data name="gvInstalledApplicationsEnableConsole.Header" xml:space="preserve">
<value>Web console</value>
</data>
<data name="btnEnable.Text" xml:space="preserve">
<value>Enable</value>
</data>
<data name="btnDisable.Text" xml:space="preserve">
<value>Disable</value>
</data>
<data name="EnableWebConsole.Text" xml:space="preserve">
<value>Enable web console</value>
</data>
</root>

View file

@ -89,10 +89,12 @@ span.ValidationMessageBlock {
<fieldset>
<legend>
<span>Helicon Zoo engine quotas settings</span>
<span>Helicon Zoo settings</span>
</legend>
<div class="FormBody">
<asp:CheckBox runat="server" ID="QuotasEnabled" Text="Enable Quotas"/>
<asp:CheckBox runat="server" ID="QuotasEnabled" Text="Enable hosting plan controls for web engines."/>
<br />
<asp:CheckBox runat="server" ID="WebCosoleEnabled" Text="Enable web console."/>
</div>
</fieldset>

View file

@ -68,7 +68,7 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
private void BindHostingPackages()
{
// TODO: try...catch?
WPIProduct[] products = null;
try
{
@ -92,6 +92,12 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
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
HeliconZooEngine[] engineList = ES.Services.HeliconZoo.GetEngines(PanelRequest.ServiceId);
@ -114,6 +120,8 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
// bind 'Enable quotas' checkbox
bool enabled = ES.Services.HeliconZoo.IsEnginesEnabled(PanelRequest.ServiceId);
QuotasEnabled.Checked = !enabled;
WebCosoleEnabled.Checked = ES.Services.HeliconZoo.IsWebCosoleEnabled(PanelRequest.ServiceId);
}
else
{
@ -139,6 +147,8 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
// save switcher
ES.Services.HeliconZoo.SwithEnginesEnabled(PanelRequest.ServiceId, !QuotasEnabled.Checked);
ES.Services.HeliconZoo.SetWebCosoleEnabled(PanelRequest.ServiceId, WebCosoleEnabled.Checked);
}
protected void ClearEngineForm()
@ -390,7 +400,15 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
private static WPIProduct[] RequestHostingPackages()
{
return ES.Services.Servers.GetWPIProducts(PanelRequest.ServerId, null, "ZooPackage");
List<WPIProduct> result = new List<WPIProduct>();
result.Add(ES.Services.Servers.GetWPIProductById(PanelRequest.ServerId, "HeliconZooModule"));
result.AddRange(ES.Services.Servers.GetWPIProducts(PanelRequest.ServerId, null, "ZooPackage"));
return result.ToArray();
}
protected string AddUpgradeRemoveText(WPIProduct wpiProduct)

View file

@ -1,32 +1,4 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
@ -84,6 +56,15 @@ public partial class HeliconZoo_Settings {
/// </remarks>
protected global::System.Web.UI.WebControls.Label HostingPackagesLoadingError;
/// <summary>
/// EnginesPanel control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel EnginesPanel;
/// <summary>
/// QuotasEnabled control.
/// </summary>
@ -94,13 +75,13 @@ public partial class HeliconZoo_Settings {
protected global::System.Web.UI.WebControls.CheckBox QuotasEnabled;
/// <summary>
/// EnginesPanel control.
/// WebCosoleEnabled control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel EnginesPanel;
protected global::System.Web.UI.WebControls.CheckBox WebCosoleEnabled;
/// <summary>
/// ButtonAddEngine control.

View file

@ -28,12 +28,72 @@
--%>
<p>
<asp:Label runat="server" meta:resourcekey="SelectWebEngine" CssClass="NormalBold"></asp:Label>
<asp:Label ID="lblConsole" runat="server" meta:resourcekey="EnableWebConsole" CssClass="NormalBold"></asp:Label>
</p>
<br />
<%--<asp:GridView id="gvInstalledApplications" runat="server" AutoGenerateColumns="True" AllowPaging="true"
ShowHeader="false" CssSelectorClass="LightGridView" EmptyDataText="gvInstalledApplications.Empty"
>
</asp:GridView>--%>
<asp:GridView ID="gvInstalledApplications" runat="server"
EnableViewState="True" AutoGenerateColumns="false"
ShowHeader="true" CssSelectorClass="NormalGridView"
EmptyDataText="gvVirtualDirectories"
onrowcommand="gvInstalledApplications_RowCommand">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name">
<ItemStyle Width="60%" />
</asp:BoundField>
<asp:TemplateField HeaderText="gvInstalledApplicationsEnableConsole">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Button ID="btnEnable" runat="server"
Text='<%# GetLocalizedString("btnEnable.Text") %>' CssClass="Button1"
CommandArgument='<%# Eval("Name") %>'
CommandName="EnableConsole"
Visible= '<%# IsNullOrEmpty( (string)Eval("ConsoleUrl")) %>'
/>
<asp:Button ID="btnDisable" runat="server"
Text='<%# GetLocalizedString("btnDisable.Text") %>' CssClass="Button1"
CommandArgument='<%# Eval("Name") %>'
CommandName="DisableConsole"
Visible= '<%# !IsNullOrEmpty( (string)Eval("ConsoleUrl")) %>'
/>
&nbsp;&nbsp;
<asp:hyperlink
CssClass="MediumBold"
NavigateUrl='<%# GetConsoleFullUrl((string)Eval("ConsoleUrl")) %>'
runat="server"
ID="lnkAppDetails"
ToolTip='<%# Eval("ConsoleUrl") %>'
Target="_blank"
Visible= '<%# !IsNullOrEmpty( (string)Eval("ConsoleUrl")) %>'>
Open console
</asp:hyperlink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<p>
<asp:Label runat="server" meta:resourcekey="SelectWebEngine" CssClass="NormalBold"></asp:Label>
</p>
<br />
<asp:GridView id="gvApplications" runat="server" AutoGenerateColumns="False" AllowPaging="true"
ShowHeader="false" CssSelectorClass="LightGridView" EmptyDataText="gvApplications" OnRowCommand="gvApplications_RowCommand"
ShowHeader="false" CssSelectorClass="LightGridView" EmptyDataText="There are no applications" OnRowCommand="gvApplications_RowCommand"
OnPageIndexChanging="gvApplications_PageIndexChanging">
<Columns>
<asp:TemplateField HeaderText="gvApplicationsApplication">

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Web;
@ -32,6 +33,19 @@ namespace WebsitePanel.Portal
ViewState["WebSitePackageId"] = site.PackageId;
BindEngines(site);
try
{
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();
}
@ -42,12 +56,17 @@ namespace WebsitePanel.Portal
ES.Services.HeliconZoo.GetAllowedHeliconZooQuotasForPackage(site.PackageId);
Array.Sort(allowedEngineArray, new ShortHeliconZooEngineComparer());
// get enabled engines for this site
// get enabled engines for this site from applicationHost.config
string[] enabledEngineNames = ES.Services.HeliconZoo.GetEnabledEnginesForSite(site.SiteId, site.PackageId);
ViewState["EnabledEnginesNames"] = enabledEngineNames;
//EnabledEnginesList.DataSource = enabledEngineNames;
//EnabledEnginesList.DataBind();
//console allowed in applicationHost.config
ViewState["IsZooWebConsoleEnabled"] = enabledEngineNames.Contains("console", StringComparer.OrdinalIgnoreCase);
List<ShortHeliconZooEngine> allowedEngines = new List<ShortHeliconZooEngine>(allowedEngineArray);
@ -55,18 +74,51 @@ namespace WebsitePanel.Portal
foreach (ShortHeliconZooEngine engine in allowedEngines)
{
engine.Name = engine.Name.Replace("HeliconZoo.", "");
engine.Enabled = enabledEngineNames.Contains(engine.Name, StringComparer.OrdinalIgnoreCase);
//engine.Enabled = enabledEngineNames.Contains(engine.Name, StringComparer.OrdinalIgnoreCase);
if (engine.Name == "console")
{
//console allowed in hosting plan
ViewState["IsZooWebConsoleEnabled"] = engine.Enabled;
}
}
ViewState["AllowedEngines"] = allowedEngines;
//AllowedEnginesList.DataSource = allowedEngines;
//AllowedEnginesList.DataBind();
}
private void BindInstalledApplications()
{
ViewState["IsZooEnabled"] = false;
var installedApplications = ES.Services.WebServers.GetZooApplications(PanelRequest.ItemID);
ViewState["IsZooEnabled"] = true;
if ((bool) ViewState["IsZooWebConsoleEnabled"])
{
gvInstalledApplications.DataSource = installedApplications;
gvInstalledApplications.DataBind();
}
else
{
HideInstalledApplications();
}
}
private void HideInstalledApplications()
{
gvInstalledApplications.Visible = false;
lblConsole.Visible = false;
}
private void BindApplications()
{
WebAppGalleryHelpers helper = new WebAppGalleryHelpers();
GalleryApplicationsResult result = helper.GetGalleryApplications("ZooTemplate", PanelSecurity.PackageId);
List<GalleryApplication> applications = result.Value as List<GalleryApplication>;
@ -77,19 +129,34 @@ namespace WebsitePanel.Portal
{
foreach (GalleryApplication application in applications)
{
foreach (string keyword in application.Keywords)
{
bool appAlreadyAdded = false;
if (keyword.StartsWith("ZooEngine", StringComparison.OrdinalIgnoreCase))
{
string appEngine = keyword.Substring("ZooEngine".Length);
foreach (ShortHeliconZooEngine engine in allowedEngines)
{
if (!engine.Enabled)
{
continue; //skip
}
if (string.Equals(appEngine, engine.KeywordedName, StringComparison.OrdinalIgnoreCase))
{
filteredApplications.Add(application);
appAlreadyAdded = true;
break;
}
}
if (appAlreadyAdded)
{
break;
}
}
}
}
@ -120,6 +187,11 @@ namespace WebsitePanel.Portal
private void UpdatedAllowedEngines()
{
if (!(bool) ViewState["IsZooEnabled"])
{
return; // exit;
}
List<ShortHeliconZooEngine> allowedEngines = (List<ShortHeliconZooEngine>)ViewState["AllowedEngines"];
string[] enabledEngineNames = (string[])ViewState["EnabledEnginesNames"];
@ -195,5 +267,44 @@ namespace WebsitePanel.Portal
return "~/Default.aspx?" + String.Join("&", url.ToArray());
}
protected void gvInstalledApplications_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EnableConsole")
{
UpdatedAllowedEngines();
string appName = e.CommandArgument.ToString();
ES.Services.WebServers.SetZooConsoleEnabled(PanelRequest.ItemID, appName);
BindInstalledApplications();
}
if (e.CommandName == "DisableConsole")
{
UpdatedAllowedEngines();
string appName = e.CommandArgument.ToString();
ES.Services.WebServers.SetZooConsoleDisabled(PanelRequest.ItemID, appName);
BindInstalledApplications();
}
}
protected bool IsNullOrEmpty(string value)
{
return string.IsNullOrEmpty(value);
}
protected string GetConsoleFullUrl(string consoleUrl)
{
WebSite site = ES.Services.WebServers.GetWebSite(PanelRequest.ItemID);
return "http://" + site.Name + consoleUrl;
}
}
}

View file

@ -26,6 +26,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -40,6 +41,24 @@ namespace WebsitePanel.Portal {
public partial class WebSitesHeliconZooControl {
/// <summary>
/// lblConsole control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblConsole;
/// <summary>
/// gvInstalledApplications control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvInstalledApplications;
/// <summary>
/// gvApplications control.
/// </summary>