Helicon Zoo Web Engines

This commit is contained in:
Virtuworks 2013-03-10 10:58:39 -04:00
parent 983d091670
commit 4768b07c92
50 changed files with 4389 additions and 36 deletions

View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,399 @@
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="HeliconZoo_Settings.ascx.cs" Inherits="HeliconZoo_Settings" %>
<%@ Register Src="../UserControls/PopupHeader.ascx" TagName="PopupHeader" TagPrefix="wsp" %>
<%@ Import Namespace="WebsitePanel.Portal.ProviderControls" %>
<%@ Import Namespace="WebsitePanel.Server" %>
<style>
p.description {
margin: 4px 0 10px 0;
color: #666;
}
table.EnginesTable th {
vertical-align: top;
text-align: left;
color: #000;
font-weight: normal;
}
span.ValidationMessageBlock {
display: block !important;
}
#EngineEnvs INPUT.NormalTextBox {
font-family: Consolas, Courier New, monospace;
}
.AspNet-GridView td {
padding: 3px 3px 5px 3px;
}
.AspNet-GridView-Alternate {
background-color: #f2f2f2;
}
</style>
<fieldset>
<legend>
<span>Hosting Packages</span>
</legend>
<asp:GridView runat="server" ID="HostingPackagesGrid"
AutoGenerateColumns="False"
EmptyDataText="Hosting Packages not found. Please check Web Platform Installer settings in System settings."
EnableViewState="True"
ShowHeader="False"
OnRowCommand="HostingPackagesGrid_OnRowCommand"
>
<Columns>
<asp:TemplateField ItemStyle-Wrap="false" HeaderText="gvWPILogo" ItemStyle-Width="10%" >
<ItemTemplate>
<asp:Image ID="icoLogo" runat="server" SkinID="Dvd48" src='<%# Eval("Logo") %>' Width="48" Height="48" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Wrap="true" HeaderText="gvServicesName" ItemStyle-Width="80%">
<ItemTemplate>
<h2 class="ProductTitle Huge"><%# Eval("Title")%></h2>
<p class="ProductSummary"><%# Eval("Summary") %></p>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Wrap="false" HeaderText="gvInstall" ItemStyle-Width="10%">
<ItemStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="LabelInstalled" runat="server" Text="installed" Visible='<%# Eval("IsInstalled") %>'></asp:Label>
<asp:Button ID="btnAdd" runat="server"
CssClass='Button1'
Visible = '<%# !(bool)Eval("IsInstalled") %>'
Text = '<%# AddUpgradeRemoveText( (WPIProduct)Container.DataItem ) %>'
CommandArgument='<%# Container.DataItemIndex %>'
CommandName="WpiAdd"
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Panel runat="server" ID="HostingPackagesInstallButtonsPanel">
<div class="FormFooter">
<asp:Button ID="btnInstall" Text="Install" runat="server" onclick="btnInstall_Click" CssClass="Button1" Enabled="False" />
</div>
</asp:Panel>
<asp:Panel runat="server" ID="HostingPackagesErrorsPanel" Visible="False">
<h3 class="Header ErrorText">Unable to load Hosting Package list with exception:</h3>
<asp:Label runat="server" ID="HostingPackagesLoadingError"></asp:Label>
</asp:Panel>
</fieldset>
<fieldset>
<legend>
<span>Helicon Zoo engine quotas settings</span>
</legend>
<div class="FormBody">
<asp:CheckBox runat="server" ID="QuotasEnabled" Text="Enable Quotas"/>
</div>
</fieldset>
<asp:Panel runat="server" ID="EnginesPanel">
<fieldset>
<legend>
<span>Engines management</span>
</legend>
<div class="FormButtonsBar">
<asp:Button runat="server" ID="ButtonAddEngine" CssClass="Button2" Text="Add engine" OnClick="ButtonAddEngine_Click" />
</div>
<asp:UpdatePanel runat="server" ID="EngineForm" Visible="False">
<ContentTemplate>
<fieldset>
<legend>
<asp:Label runat="server" CssClass="NormalBold" Text="Engine settings"></asp:Label>
</legend>
<table width="100%" cellpadding="4" class="EnginesTable">
<tr>
<th width="160px">
<span>Name</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EngineName" runat="server" CssClass="NormalTextBox" Width="666px"></asp:TextBox>
<asp:RequiredFieldValidator runat="server"
ControlToValidate="EngineName"
ErrorMessage="Engine name can not be empty"
CssClass="ValidationMessageBlock"
EnableViewState="True"
></asp:RequiredFieldValidator>
<p class="description">Id for the engine</p>
</td>
</tr>
<tr>
<th>
<span>Friendly name</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EngineFriendlyName" runat="server" CssClass="NormalTextBox" Width="666px"></asp:TextBox>
<asp:RequiredFieldValidator runat="server"
ControlToValidate="EngineFriendlyName"
ErrorMessage="Engine friendly name can not be empty"
CssClass="ValidationMessageBlock"
></asp:RequiredFieldValidator>
<p class="description">Frendly engine name</p>
</td>
</tr>
<tr>
<th>
<span>Full path to executable</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EngineFullPath" runat="server" CssClass="NormalTextBox" Width="666px"></asp:TextBox>
<asp:RequiredFieldValidator runat="server"
ControlToValidate="EngineFullPath"
ErrorMessage="Path to executable can not be empty"
CssClass="ValidationMessageBlock"
></asp:RequiredFieldValidator>
<p class="description">Path to a worker executable file</p>
</td>
</tr>
<tr>
<th>
<span>Executable`s arguments</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EngineArguments" runat="server" CssClass="NormalTextBox" Width="666px"></asp:TextBox>
<p class="description">Set of arguments to be passed to a worker on a call, can include special environment variables</p>
</td>
</tr>
<tr>
<th>
<span>Transport</span>
</th>
<td class="Normal" valign="top">
<asp:DropDownList runat="server" ID="EngineTransport"></asp:DropDownList>
</td>
</tr>
<tr>
<th>
<span>Protocol</span>
</th>
<td class="Normal" valign="top">
<asp:DropDownList runat="server" ID="EngineProtocol"></asp:DropDownList>
</td>
</tr>
<tr>
<th>
<span>Lower port</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EnginePortLower" runat="server" CssClass="NormalTextBox" Width="150px"></asp:TextBox>
<asp:RangeValidator runat="server"
ControlToValidate="EnginePortLower"
MinimumValue="1" MaximumValue="65535"
ErrorMessage="Out of range"
CssClass="ValidationMessage"
></asp:RangeValidator>
<p class="description">Specifies lower automatic port range bound for TCP transport, default = 49152</p>
</td>
</tr>
<tr>
<th>
<span>Upper port</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EnginePortUpper" runat="server" CssClass="NormalTextBox" Width="150px"></asp:TextBox>
<asp:RangeValidator runat="server"
ControlToValidate="EnginePortUpper"
MinimumValue="1" MaximumValue="65535"
ErrorMessage="Out of range"
CssClass="ValidationMessage"
></asp:RangeValidator>
<p class="description">Specifies upper automatic port range bound for TCP transport, default = 65535</p>
</td>
</tr>
<tr>
<th>
<span>Minimum instances</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EngineMinInstances" runat="server" CssClass="NormalTextBox" Width="150px"></asp:TextBox>
<asp:RegularExpressionValidator runat="server"
ControlToValidate="EngineMinInstances"
ValidationExpression="\d*"
ErrorMessage="Out of range"
CssClass="ValidationMessage"
></asp:RegularExpressionValidator>
<p class="description">Minimum number of worker instances</p>
</td>
</tr>
<tr>
<th>
<span>Maximum instances</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EngineMaxInstances" runat="server" CssClass="NormalTextBox" Width="150px"></asp:TextBox>
<asp:RegularExpressionValidator runat="server"
ControlToValidate="EngineMaxInstances"
ValidationExpression="\d*"
ErrorMessage="Out of range"
CssClass="ValidationMessage"
></asp:RegularExpressionValidator>
<p class="description">Maximum number of instances of worker processes to start under high load. Default value of 0 means start as many instances as there are cores.</p>
</td>
</tr>
<tr>
<th>
<span>Time limit</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EngineTimeLimit" runat="server" CssClass="NormalTextBox" Width="150px"></asp:TextBox>
<asp:RegularExpressionValidator runat="server"
ControlToValidate="EngineTimeLimit"
ValidationExpression="\d*"
ErrorMessage="Out of range"
CssClass="ValidationMessage"
></asp:RegularExpressionValidator>
<p class="description">Restart the worker after it has worked for specific amount of time (minutes), default = 0 (infinite)</p>
</td>
</tr>
<tr>
<th>
<span>Graceful Shutdown Timeout</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EngineGracefulShutdownTimeout" runat="server" CssClass="NormalTextBox" Width="150px"></asp:TextBox>
<asp:RegularExpressionValidator runat="server"
ControlToValidate="EngineGracefulShutdownTimeout"
ValidationExpression="\d*"
ErrorMessage="Out of range"
CssClass="ValidationMessage"
></asp:RegularExpressionValidator>
<p class="description">XXXXXXXXXXXXXXXXXXX</p>
</td>
</tr>
<tr>
<th>
<span>Memory limit</span>
</th>
<td class="Normal" valign="top">
<asp:TextBox ID="EngineMemoryLimit" runat="server" CssClass="NormalTextBox" Width="150px"></asp:TextBox>
<asp:RegularExpressionValidator runat="server"
ControlToValidate="EngineMemoryLimit"
ValidationExpression="\d*"
ErrorMessage="Out of range"
CssClass="ValidationMessage"
></asp:RegularExpressionValidator>
<p class="description">Restart the worker if it has consumed specific amount of memory (megabytes), default = 0 (unlimited)</p>
</td>
</tr>
<tr>
<th>
<span>Environment variables</span>
</th>
<td class="Normal" valign="top">
<table id="EngineEnvs">
<tr>
<th>Key</th>
<th>Value</th>
</tr>
<tr>
<td><asp:TextBox ID="EnvKey1" runat="server" CssClass="NormalTextBox" Width="240px"></asp:TextBox></td>
<td><asp:TextBox ID="EnvValue1" runat="server" CssClass="NormalTextBox" Width="440px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="EnvKey2" runat="server" CssClass="NormalTextBox" Width="240px"></asp:TextBox></td>
<td><asp:TextBox ID="EnvValue2" runat="server" CssClass="NormalTextBox" Width="440px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="EnvKey3" runat="server" CssClass="NormalTextBox" Width="240px"></asp:TextBox></td>
<td><asp:TextBox ID="EnvValue3" runat="server" CssClass="NormalTextBox" Width="440px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="EnvKey4" runat="server" CssClass="NormalTextBox" Width="240px"></asp:TextBox></td>
<td><asp:TextBox ID="EnvValue4" runat="server" CssClass="NormalTextBox" Width="440px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="EnvKey5" runat="server" CssClass="NormalTextBox" Width="240px"></asp:TextBox></td>
<td><asp:TextBox ID="EnvValue5" runat="server" CssClass="NormalTextBox" Width="440px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="EnvKey6" runat="server" CssClass="NormalTextBox" Width="240px"></asp:TextBox></td>
<td><asp:TextBox ID="EnvValue6" runat="server" CssClass="NormalTextBox" Width="440px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="EnvKey7" runat="server" CssClass="NormalTextBox" Width="240px"></asp:TextBox></td>
<td><asp:TextBox ID="EnvValue7" runat="server" CssClass="NormalTextBox" Width="440px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="EnvKey8" runat="server" CssClass="NormalTextBox" Width="240px"></asp:TextBox></td>
<td><asp:TextBox ID="EnvValue8" runat="server" CssClass="NormalTextBox" Width="440px"></asp:TextBox></td>
</tr>
</table>
</td>
</tr>
</table>
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
<br/>
<asp:Panel runat="server" ID="EngineFormButtons" Visible="False">
<div class="FormButtonsBar">
<asp:Button runat="server" ID="ButtonSaveEngine" Text="Save" CssClass="Button2" OnClick="ButtonSaveEngine_Click"></asp:Button>
&nbsp;
<asp:Button runat="server" ID="ButtonCancelEngineForm" Text="Cancel" CssClass="Button2" OnClick="ButtonCancelEngineForm_Click"></asp:Button>
</div>
</asp:Panel>
<asp:GridView runat="server" ID="EngineGrid"
AutoGenerateColumns="False"
EmptyDataText="Engines not found. Please reinstall Helicon Zoo."
EnableViewState="True"
ShowHeader="False"
OnRowCommand="EngineGrid_OnRowCommand"
>
<Columns>
<asp:TemplateField runat="server" ItemStyle-Width="75%">
<ItemTemplate>
<span runat="server" class="NormalBold"><%# Eval("displayName")%></span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField runat="server" ItemStyle-Width="25%">
<ItemTemplate>
<asp:Button ID="ButtonEditEngine" runat="server"
CssClass='Button1'
Text = 'Edit'
CommandArgument='<%# Eval("name") %>'
CommandName="EngineEdit"
/>
<asp:Button ID="ButtonDeleteEngine" runat="server"
CssClass='Button1'
Text="Delete"
CommandArgument='<%# Eval("name") %>'
CommandName="EngineDelete"
Visible='<%# (bool)Eval("isUserEngine") %>'
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</fieldset>
</asp:Panel>

View file

@ -0,0 +1,426 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebsitePanel.Portal;
using WebsitePanel.Providers.HeliconZoo;
using WebsitePanel.Server;
public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServiceProviderSettings
{
private class EnvBoxPair
{
public TextBox Name;
public TextBox Value;
public EnvBoxPair(TextBox name, TextBox value)
{
Name = name;
Value = value;
}
}
private EnvBoxPair[] _envBoxsPair;
protected void Page_Load(object sender, EventArgs e)
{
_envBoxsPair = new EnvBoxPair[]
{
new EnvBoxPair(EnvKey1, EnvValue1),
new EnvBoxPair(EnvKey2, EnvValue2),
new EnvBoxPair(EnvKey3, EnvValue3),
new EnvBoxPair(EnvKey4, EnvValue4),
new EnvBoxPair(EnvKey5, EnvValue5),
new EnvBoxPair(EnvKey6, EnvValue6),
new EnvBoxPair(EnvKey7, EnvValue7),
new EnvBoxPair(EnvKey8, EnvValue8),
};
if (!IsPostBack)
{
BindHostingPackages();
EngineTransport.Items.Clear();
EngineTransport.Items.AddRange(
new ListItem[]
{
new ListItem("Named pipe", "namedpipe"),
new ListItem("TCP", "tcp"),
}
);
EngineProtocol.Items.Clear();
EngineProtocol.Items.AddRange(
new ListItem[]
{
new ListItem("FastCGI", "fastcgi"),
new ListItem("HTTP", "http"),
}
);
BindEngines();
}
}
private void BindHostingPackages()
{
// TODO: try...catch?
WPIProduct[] products = null;
try
{
products = GetHostingPackages();
}
catch(Exception e)
{
HostingPackagesGrid.Visible = false;
HostingPackagesInstallButtonsPanel.Visible = false;
HostingPackagesErrorsPanel.Visible = true;
if (e.InnerException != null)
{
e = e.InnerException;
}
HostingPackagesLoadingError.Text = e.Message;
}
HostingPackagesGrid.DataSource = products;
HostingPackagesGrid.DataBind();
}
private void BindEngines()
{
// get all engines from IIS
HeliconZooEngine[] engineList = ES.Services.HeliconZoo.GetEngines(PanelRequest.ServiceId);
if (null != engineList && engineList.Length > 0)
{
// convert list to dict
Dictionary<string, HeliconZooEngine> enginesDict = new Dictionary<string, HeliconZooEngine>();
foreach (HeliconZooEngine engine in engineList)
{
enginesDict[engine.name] = engine;
}
// save engines in view state
ViewState["HeliconZooEngines"] = enginesDict;
// bind to grid
EngineGrid.DataSource = engineList;
EngineGrid.DataBind();
// bind 'Enable quotas' checkbox
bool enabled = ES.Services.HeliconZoo.IsEnginesEnabled(PanelRequest.ServiceId);
QuotasEnabled.Checked = !enabled;
}
else
{
EnginesPanel.Visible = false;
}
}
private void RebindEngines()
{
Dictionary<string, HeliconZooEngine> engines = GetEngines();
EngineGrid.DataSource = engines.Values;
EngineGrid.DataBind();
}
public void BindSettings(StringDictionary settings)
{
}
public void SaveSettings(StringDictionary settings)
{
// save engines
ES.Services.HeliconZoo.SetEngines(PanelRequest.ServiceId, new List<HeliconZooEngine>(GetEngines().Values).ToArray());
// save switcher
ES.Services.HeliconZoo.SwithEnginesEnabled(PanelRequest.ServiceId, !QuotasEnabled.Checked);
}
protected void ClearEngineForm()
{
EngineName.Text = string.Empty;
EngineFriendlyName.Text = string.Empty;
EngineFullPath.Text = string.Empty;
EngineArguments.Text = string.Empty;
EngineProtocol.SelectedIndex = 0;
EngineTransport.SelectedIndex = 0;
foreach (EnvBoxPair envBoxPair in _envBoxsPair)
{
envBoxPair.Name.Text = string.Empty;
envBoxPair.Value.Text = string.Empty;
}
}
protected void ShowEngineForm()
{
EngineForm.Visible = true;
EngineFormButtons.Visible = true;
}
protected void HideEngineForm()
{
EngineForm.Visible = false;
EngineFormButtons.Visible = false;
}
protected void ButtonAddEngine_Click(object sender, EventArgs e)
{
ClearEngineForm();
ShowEngineForm();
}
protected void ButtonSaveEngine_Click(object sender, EventArgs e)
{
HeliconZooEngine engine = EngineFromForm();
HeliconZooEngine savedEngine = FindEngineByName(engine.name);
Dictionary<string, HeliconZooEngine> engines = GetEngines();
// new user engine or update existing
engines[engine.name] = engine;
ClearEngineForm();
HideEngineForm();
// rebind grid
RebindEngines();
}
public static long ParseLong(string s, long deflt)
{
long result;
if (!long.TryParse(s, out result))
{
result = deflt;
}
return result;
}
private HeliconZooEngine EngineFromForm()
{
HeliconZooEngine engine = new HeliconZooEngine()
{
name = EngineName.Text.Trim(),
displayName = EngineFriendlyName.Text.Trim(),
arguments = EngineArguments.Text.Trim(),
fullPath = EngineFullPath.Text.Trim(),
transport = EngineTransport.SelectedValue,
protocol = EngineProtocol.SelectedValue,
portLower = ParseLong(EnginePortLower.Text, -1),
portUpper = ParseLong(EnginePortUpper.Text, -1),
minInstances = ParseLong(EngineMinInstances.Text, -1),
maxInstances = ParseLong(EngineMaxInstances.Text, -1),
timeLimit = ParseLong(EngineTimeLimit.Text, -1),
gracefulShutdownTimeout = ParseLong(EngineGracefulShutdownTimeout.Text, -1),
memoryLimit = ParseLong(EngineMemoryLimit.Text, -1),
isUserEngine = true
};
// envs
List<HeliconZooEnv> tempEnvList = new List<HeliconZooEnv>();
for (int i = 0; i < _envBoxsPair.Length; i++)
{
EnvBoxPair pair = _envBoxsPair[i];
if (!string.IsNullOrEmpty(pair.Name.Text.Trim()) && !string.IsNullOrEmpty(pair.Value.Text.Trim()))
{
tempEnvList.Add(new HeliconZooEnv(){Name = pair.Name.Text.Trim(), Value = pair.Value.Text.Trim()});
}
}
engine.environmentVariables = tempEnvList.ToArray();
return engine;
}
protected void ButtonCancelEngineForm_Click(object sender, EventArgs e)
{
ClearEngineForm();
HideEngineForm();
}
protected void EngineGrid_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EngineEdit")
{
HeliconZooEngine engine = FindEngineByName((string)e.CommandArgument);
if (null != engine)
{
BindEngineForm(engine);
ShowEngineForm();
}
}
if (e.CommandName == "EngineDisable")
{
HeliconZooEngine engine = FindEngineByName((string)e.CommandArgument);
if (null != engine)
{
engine.disabled = !engine.disabled;
RebindEngines();
}
}
if (e.CommandName == "EngineDelete")
{
HeliconZooEngine engine = FindEngineByName((string)e.CommandArgument);
if (null != engine)
{
Dictionary<string, HeliconZooEngine> engines = GetEngines();
engines.Remove(engine.name);
RebindEngines();
}
}
}
public static string ToStringClearDeafult(long l)
{
if (-1 == l)
{
return string.Empty;
}
return l.ToString(CultureInfo.InvariantCulture);
}
private void BindEngineForm(HeliconZooEngine engine)
{
EngineName.Text = engine.name;
EngineFriendlyName.Text = engine.displayName;
EngineFullPath.Text = engine.fullPath;
EngineArguments.Text = engine.arguments;
EngineTransport.Text = engine.transport.ToLower();
EngineProtocol.Text = engine.protocol.ToLower();
EnginePortLower.Text = ToStringClearDeafult(engine.portLower);
EnginePortUpper.Text = ToStringClearDeafult(engine.portUpper);
EngineMinInstances.Text = ToStringClearDeafult(engine.minInstances);
EngineMaxInstances.Text = ToStringClearDeafult(engine.maxInstances);
EngineTimeLimit.Text = ToStringClearDeafult(engine.timeLimit);
EngineGracefulShutdownTimeout.Text = ToStringClearDeafult(engine.gracefulShutdownTimeout);
EngineMemoryLimit.Text = ToStringClearDeafult(engine.memoryLimit);
for (int i = 0; i < engine.environmentVariables.Length && i < _envBoxsPair.Length; i++)
{
HeliconZooEnv env = engine.environmentVariables[i];
_envBoxsPair[i].Name.Text = env.Name;
_envBoxsPair[i].Value.Text = env.Value;
}
}
private Dictionary<string, HeliconZooEngine> GetEngines()
{
return ViewState["HeliconZooEngines"] as Dictionary<string, HeliconZooEngine>;
}
private HeliconZooEngine FindEngineByName(string engineName)
{
Dictionary<string, HeliconZooEngine> engines = GetEngines();
if (null != engines)
{
if (engines.ContainsKey(engineName))
{
return engines[engineName];
}
}
return null;
}
protected void HostingPackagesGrid_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
ArrayList wpiProductsForInstall = GetProductsToInstallList();
int productIndex = int.Parse((string)e.CommandArgument);
WPIProduct wpiProduct = GetHostingPackages()[productIndex];
if (null != wpiProduct)
{
if (e.CommandName == "WpiAdd")
{
wpiProductsForInstall = GetProductsToInstallList();
wpiProductsForInstall.Add(wpiProduct.ProductId);
SetProductsToInstallList(wpiProductsForInstall);
((Button)e.CommandSource).Text = AddUpgradeRemoveText(wpiProduct); ;
((Button)e.CommandSource).CommandName = "WpiRemove";
}
if (e.CommandName == "WpiRemove")
{
wpiProductsForInstall = GetProductsToInstallList();
wpiProductsForInstall.Remove(wpiProduct.ProductId);
SetProductsToInstallList(wpiProductsForInstall);
((Button)e.CommandSource).Text = AddUpgradeRemoveText(wpiProduct);
((Button)e.CommandSource).CommandName = "WpiAdd";
}
btnInstall.Enabled = wpiProductsForInstall.Count > 0;
}
}
private ArrayList GetProductsToInstallList()
{
if (ViewState["wpiProductsForInstall"] != null)
{
return (ArrayList)ViewState["wpiProductsForInstall"];
}
return new ArrayList();
}
private void SetProductsToInstallList(ArrayList wpiProductsForInstall)
{
ViewState["wpiProductsForInstall"] = wpiProductsForInstall;
}
private WPIProduct[] GetHostingPackages()
{
if (ViewState["HeliconZooHostingPackages"] == null)
{
ViewState["HeliconZooHostingPackages"] = RequestHostingPackages();
}
return (WPIProduct[])ViewState["HeliconZooHostingPackages"];
}
private static WPIProduct[] RequestHostingPackages()
{
return ES.Services.Servers.GetWPIProducts(PanelRequest.ServerId, null, "ZooPackage");
}
protected string AddUpgradeRemoveText(WPIProduct wpiProduct)
{
if (GetProductsToInstallList().Contains(wpiProduct.ProductId))
{
return "- cancel";
}
else
{
return wpiProduct.IsUpgrade ? "+ upgrade" : "+ add";
}
}
protected void btnInstall_Click(object sender, EventArgs e)
{
ArrayList wpiProductsForInstall = GetProductsToInstallList();
List<string> qsParts = new List<string>();
qsParts.Add("pid=Servers");
qsParts.Add("ctl=edit_platforminstaller");
qsParts.Add("mid=" + Request.QueryString["mid"]);
qsParts.Add("ServerID=" + Request.QueryString["ServerID"]);
qsParts.Add("WPIProduct=" + string.Join(",", wpiProductsForInstall.ToArray()));
qsParts.Add("ReturnUrl=" + Server.UrlEncode(Request.RawUrl));
string installUrl = "Default.aspx?" + String.Join("&", qsParts.ToArray());
Response.Redirect(installUrl);
}
}

View file

@ -0,0 +1,419 @@
// 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.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class HeliconZoo_Settings {
/// <summary>
/// HostingPackagesGrid 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 HostingPackagesGrid;
/// <summary>
/// HostingPackagesInstallButtonsPanel 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 HostingPackagesInstallButtonsPanel;
/// <summary>
/// btnInstall 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.Button btnInstall;
/// <summary>
/// HostingPackagesErrorsPanel 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 HostingPackagesErrorsPanel;
/// <summary>
/// HostingPackagesLoadingError 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 HostingPackagesLoadingError;
/// <summary>
/// QuotasEnabled 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.CheckBox QuotasEnabled;
/// <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>
/// ButtonAddEngine 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.Button ButtonAddEngine;
/// <summary>
/// EngineForm control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.UpdatePanel EngineForm;
/// <summary>
/// EngineName 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.TextBox EngineName;
/// <summary>
/// EngineFriendlyName 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.TextBox EngineFriendlyName;
/// <summary>
/// EngineFullPath 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.TextBox EngineFullPath;
/// <summary>
/// EngineArguments 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.TextBox EngineArguments;
/// <summary>
/// EngineTransport 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.DropDownList EngineTransport;
/// <summary>
/// EngineProtocol 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.DropDownList EngineProtocol;
/// <summary>
/// EnginePortLower 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.TextBox EnginePortLower;
/// <summary>
/// EnginePortUpper 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.TextBox EnginePortUpper;
/// <summary>
/// EngineMinInstances 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.TextBox EngineMinInstances;
/// <summary>
/// EngineMaxInstances 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.TextBox EngineMaxInstances;
/// <summary>
/// EngineTimeLimit 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.TextBox EngineTimeLimit;
/// <summary>
/// EngineGracefulShutdownTimeout 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.TextBox EngineGracefulShutdownTimeout;
/// <summary>
/// EngineMemoryLimit 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.TextBox EngineMemoryLimit;
/// <summary>
/// EnvKey1 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.TextBox EnvKey1;
/// <summary>
/// EnvValue1 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.TextBox EnvValue1;
/// <summary>
/// EnvKey2 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.TextBox EnvKey2;
/// <summary>
/// EnvValue2 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.TextBox EnvValue2;
/// <summary>
/// EnvKey3 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.TextBox EnvKey3;
/// <summary>
/// EnvValue3 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.TextBox EnvValue3;
/// <summary>
/// EnvKey4 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.TextBox EnvKey4;
/// <summary>
/// EnvValue4 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.TextBox EnvValue4;
/// <summary>
/// EnvKey5 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.TextBox EnvKey5;
/// <summary>
/// EnvValue5 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.TextBox EnvValue5;
/// <summary>
/// EnvKey6 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.TextBox EnvKey6;
/// <summary>
/// EnvValue6 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.TextBox EnvValue6;
/// <summary>
/// EnvKey7 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.TextBox EnvKey7;
/// <summary>
/// EnvValue7 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.TextBox EnvValue7;
/// <summary>
/// EnvKey8 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.TextBox EnvKey8;
/// <summary>
/// EnvValue8 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.TextBox EnvValue8;
/// <summary>
/// EngineFormButtons 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 EngineFormButtons;
/// <summary>
/// ButtonSaveEngine 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.Button ButtonSaveEngine;
/// <summary>
/// ButtonCancelEngineForm 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.Button ButtonCancelEngineForm;
/// <summary>
/// EngineGrid 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 EngineGrid;
}