Commit Contribution from Helicon

Includes:

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

View file

@ -0,0 +1,65 @@
// 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.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WebsitePanel.Server.WPIService")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WebsitePanel.Server.WPIService")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("aed34aef-8940-48e0-9183-f2522efd7d28")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,68 @@
// 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.Diagnostics;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Threading;
namespace WebsitePanel.Server.WPIService
{
class Server
{
static Mutex mutex = null;
static void Main(string[] args)
{
bool onlyInstance = false;
mutex = new Mutex(false, "Global\\{5DE133EC-49AE-4AE4-99BE-0F0A0BB5719E}", out onlyInstance);
if (!mutex.WaitOne(0, false)) //if (!onlyInstance)
{
Console.WriteLine("The service is already running.");
return;
}
TcpChannel ch = new TcpChannel(WPIServiceContract.PORT);
ChannelServices.RegisterChannel(ch, true);
WPIService wpiService = new WPIService();
RemotingServices.Marshal(wpiService, "WPIServiceContract");
Console.WriteLine("The service is running.");
while (!wpiService.IsFinished)
{
Thread.Sleep(2000);
}
Console.WriteLine("The service is finished.");
}
}
}

View file

@ -0,0 +1,247 @@
// 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.Collections.Generic;
using System.Text;
using System.Threading;
using Microsoft.Web.PlatformInstaller;
using WebsitePanel.Server.Code;
namespace WebsitePanel.Server.WPIService
{
// Define a service contract.
//[ServiceContract(Namespace = "http://Helicon.Zoo.WPIService")]
//public interface IWPIService
//{
// // [OperationContract]
// void Initialize(string[] feeds);
// //[OperationContract]
// void BeginInstallation(string[] productsToInstall);
// //[OperationContract]
// string GetStatus();
// string GetLogs();
//}
enum EWPIServiceStatus
{
Initialised,
Installation,
InstallationComplete,
InstallationError
}
// Service class which implements the service contract.
//[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
class WPIService : WPIServiceContract
{
private WpiHelper _wpiHelper;
private string[] _productsToInstall;
private EWPIServiceStatus _installationStatus;
private string _statusMessage = "preparing...";
private Thread _installerThread;
private object _lock = new object();
public bool IsFinished { get; private set; }
#region IWPIService contract
public override string Ping()
{
return "OK";
}
public override void Initialize(string[] feeds)
{
lock (_lock)
{
if (_installationStatus == EWPIServiceStatus.Installation)
{
throw new Exception("Invalid state, already in Installation process");
}
_installationStatus = EWPIServiceStatus.Initialised;
if (_wpiHelper == null)
{
_wpiHelper = new WpiHelper(feeds);
Console.WriteLine("_wpiHelper initialized");
}
}
}
public override void BeginInstallation(string[] productsToInstall)
{
lock (_lock)
{
if (_installationStatus != EWPIServiceStatus.Initialised)
{
throw new Exception("Invalid state, expected EWPIServiceStatus.Initialised. now: " + _installationStatus);
}
_installationStatus = EWPIServiceStatus.Installation;
_statusMessage = "Preparing for install";
_productsToInstall = new string[productsToInstall.Length];
productsToInstall.CopyTo(_productsToInstall,0);
_installerThread = new Thread(new ThreadStart(InternalBeginInstallation));
_installerThread.Start();
}
}
public override string GetStatus()
{
lock(_lock)
{
string result = this._statusMessage;
//Allow exit from app, if finished
IsInstallationProceed();
return result;
}
}
public override string GetLogFileDirectory()
{
lock (_lock)
{
return null != _wpiHelper ? _wpiHelper.GetLogFileDirectory() : null;
}
}
#endregion
#region private implementaion
private bool IsInstallationProceed()
{
if (_installationStatus == EWPIServiceStatus.InstallationComplete)
{
IsFinished = true;
return false;
}
else if (_installationStatus == EWPIServiceStatus.InstallationError)
{
IsFinished = true;
return false;
}
return true;
}
private void InternalBeginInstallation()
{
_wpiHelper.InstallProducts(
_productsToInstall,
WpiHelper.DeafultLanguage,
InstallStatusUpdatedHandler,
InstallCompleteHandler
);
lock (_lock)
{
_installationStatus = EWPIServiceStatus.InstallationComplete;
}
}
private void InstallCompleteHandler(object sender, EventArgs eventArgs)
{
lock(_lock)
{
_installationStatus = EWPIServiceStatus.InstallationComplete;
}
}
private void InstallStatusUpdatedHandler(object sender, InstallStatusEventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0}: ", e.InstallerContext.ProductName);
switch (e.InstallerContext.InstallationState)
{
case InstallationState.Waiting:
sb.Append("please wait...").AppendLine();
break;
case InstallationState.Downloading:
sb.Append("downloading").AppendLine();
if (e.ProgressValue > 0)
{
sb.AppendFormat("{0} of {1} Kb downloaded", e.ProgressValue,
e.InstallerContext.Installer.InstallerFile.FileSize);
sb.AppendLine();
}
break;
case InstallationState.Downloaded:
sb.Append("downloaded").AppendLine();
break;
case InstallationState.DownloadFailed:
sb.AppendFormat("download failed").AppendLine();
sb.AppendLine(e.InstallerContext.InstallStateDetails);
break;
case InstallationState.DependencyFailed:
sb.AppendFormat("dependency failed").AppendLine();
sb.AppendLine(e.InstallerContext.InstallStateDetails);
sb.AppendFormat("{0}: {1}", e.InstallerContext.ReturnCode.Status, e.InstallerContext.ReturnCode.DetailedInformation).AppendLine();
break;
case InstallationState.Installing:
sb.Append("installing").AppendLine();
break;
case InstallationState.InstallCompleted:
sb.Append("install completed").AppendLine();
break;
case InstallationState.Canceled:
sb.AppendFormat("canceled").AppendLine();
sb.AppendLine(e.InstallerContext.InstallStateDetails);
sb.AppendFormat("{0}: {1}", e.InstallerContext.ReturnCode.Status, e.InstallerContext.ReturnCode.DetailedInformation).AppendLine();
break;
default:
throw new ArgumentOutOfRangeException();
}
lock (_lock)
{
_statusMessage = sb.ToString();
}
}
#endregion
}
}

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DD9E57D5-797F-4420-AF1A-23CEA2F310E0}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebsitePanel.Server.WPIService</RootNamespace>
<AssemblyName>WebsitePanel.Server.WPIService</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.Deployment, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Web.Deployment.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.PlatformInstaller, Version=3.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Lib\Microsoft.Web.PlatformInstaller.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\WebsitePanel.Server\Code\WPIHelper.cs">
<Link>WPIHelper.cs</Link>
</Compile>
<Compile Include="Server.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WPIService.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebsitePanel.Server.WPIServiceContract\WebsitePanel.Server.WPIServiceContract.csproj">
<Project>{736FA0F0-ECA3-416E-B299-85CC425FFF44}</Project>
<Name>WebsitePanel.Server.WPIServiceContract</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>