Merge with Omar

This commit is contained in:
feodor_fitsner 2012-03-05 15:17:46 -08:00
commit 094c838d85
235 changed files with 6289 additions and 2962 deletions

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.235
// Runtime Version:4.0.30319.239
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -15,8 +15,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Outercurve Foundation")]
[assembly: AssemblyCopyright("Copyright © 2011 Outercurve Foundation.")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.38")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyVersion("1.2.1.0")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]

View file

@ -1,7 +1,7 @@
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.235
' Runtime Version:4.0.30319.239
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
@ -17,7 +17,7 @@ Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Outercurve Foundation"), _
Assembly: AssemblyCopyright("Copyright © 2011 Outercurve Foundation."), _
Assembly: AssemblyVersion("1.2.0.0"), _
Assembly: AssemblyFileVersion("1.2.0.38"), _
Assembly: AssemblyInformationalVersion("1.2.0")>
Assembly: AssemblyVersion("1.2.1.0"), _
Assembly: AssemblyFileVersion("1.2.1.0"), _
Assembly: AssemblyInformationalVersion("1.2.1")>

View file

@ -29,8 +29,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Products.Hosti
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Products.HostingPlan", "WebsitePanel.Products.HostingPlan\WebsitePanel.Products.HostingPlan.csproj", "{65FEDD1B-379C-413D-84D8-20E6C29C645D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Plugins.Directi", "WebsitePanel.Registrars.Directi\WebsitePanel.Plugins.Directi.csproj", "{823D6FA5-F84F-4E50-9091-040C256955A5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Plugins.Enom", "WebsitePanel.Registrars.Enom\WebsitePanel.Plugins.Enom.csproj", "{39A6F585-4A27-4AAA-A43F-858FC32ADF98}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Common.Utils", "WebsitePanel.Common.Utils\WebsitePanel.Common.Utils.csproj", "{53D22D35-4013-415F-BA09-F67A0DBBB0C1}"
@ -81,10 +79,6 @@ Global
{338F816B-BEB4-4F18-9EA1-2EFD35DBA65B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65FEDD1B-379C-413D-84D8-20E6C29C645D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65FEDD1B-379C-413D-84D8-20E6C29C645D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{823D6FA5-F84F-4E50-9091-040C256955A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{823D6FA5-F84F-4E50-9091-040C256955A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{823D6FA5-F84F-4E50-9091-040C256955A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{823D6FA5-F84F-4E50-9091-040C256955A5}.Release|Any CPU.Build.0 = Release|Any CPU
{39A6F585-4A27-4AAA-A43F-858FC32ADF98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39A6F585-4A27-4AAA-A43F-858FC32ADF98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39A6F585-4A27-4AAA-A43F-858FC32ADF98}.Release|Any CPU.ActiveCfg = Release|Any CPU

View file

@ -5,11 +5,11 @@
</configSections>
<!-- Connection strings -->
<connectionStrings>
<add name="EnterpriseServer" connectionString="${installer.connectionstring}" providerName="System.Data.SqlClient"/>
<add name="EnterpriseServer" connectionString="Server=(local)\SQLExpress;Database=WebsitePanel;uid=WebsitePanel;pwd=Password12" providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<!-- Encryption util settings -->
<add key="WebsitePanel.CryptoKey" value="${installer.cryptokey}"/>
<add key="WebsitePanel.CryptoKey" value="1234567890"/>
<!-- A1D4KDHUE83NKHddF -->
<add key="WebsitePanel.EncryptionEnabled" value="true"/>
<!-- Web Applications -->

View file

@ -47,7 +47,6 @@ namespace WebsitePanel.Providers.Web
private string siteId;
private string siteIPAddress;
private int siteIPAddressId;
private string logsPath;
private string dataPath;
private ServerBinding[] bindings;
private bool frontPageAvailable;

View file

@ -17,7 +17,7 @@
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>

View file

@ -56,7 +56,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="SDNSAPI">
<HintPath>..\..\..\..\..\WebsitePanel.bak\WebsitePanel\Branches\1.2.0\Lib\References\SimpleDNS\SDNSAPI.dll</HintPath>
<HintPath>..\..\Lib\References\SimpleDNS\SDNSAPI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />

View file

@ -1,4 +1,4 @@
// Copyright (c) 2010, SMB SAAS Systems Inc.
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -11,7 +11,7 @@
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the SMB SAAS Systems Inc. nor the names of its
// - 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.
//

View file

@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebsitePanel.Providers.ExchangeHostedEdition</RootNamespace>
<AssemblyName>WebsitePanel.Providers.ExchangeHostedEdition</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>

View file

@ -80,31 +80,31 @@
</Reference>
<Reference Include="Microsoft.Exchange.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\Microsoft.Exchange.Common.dll</HintPath>
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Exchange.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Exchange.Data, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\Microsoft.Exchange.Data.dll</HintPath>
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Exchange.Data.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Exchange.Data.Directory, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\Microsoft.Exchange.Data.Directory.dll</HintPath>
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Exchange.Data.Directory.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Exchange.Data.Storage, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\Microsoft.Exchange.Data.Storage.dll</HintPath>
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Exchange.Data.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Exchange.Diagnostics, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\Microsoft.Exchange.Diagnostics.dll</HintPath>
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Exchange.Diagnostics.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Exchange.Extensibility.Internal, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\Microsoft.Exchange.Extensibility.Internal.dll</HintPath>
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Exchange.Extensibility.Internal.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Exchange.Net, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\Microsoft.Exchange.Net.dll</HintPath>
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Exchange.Net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SharePoint">
<HintPath>..\..\Lib\References\Microsoft\Microsoft.SharePoint.dll</HintPath>
@ -123,14 +123,6 @@
<Reference Include="System.Web" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Xml" />
<Reference Include="WebsitePanel.Providers.Base, Version=1.2.0.0, Culture=neutral, PublicKeyToken=da8782a6fc4d0081, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\bin\WebsitePanel.Providers.Base.dll</HintPath>
</Reference>
<Reference Include="WebsitePanel.Server.Utils, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\bin\WebsitePanel.Server.Utils.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\VersionInfo.cs">
@ -173,6 +165,16 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebsitePanel.Providers.Base\WebsitePanel.Providers.Base.csproj">
<Project>{684C932A-6C75-46AC-A327-F3689D89EB42}</Project>
<Name>WebsitePanel.Providers.Base</Name>
</ProjectReference>
<ProjectReference Include="..\WebsitePanel.Server.Utils\WebsitePanel.Server.Utils.csproj">
<Project>{E91E52F3-9555-4D00-B577-2B1DBDD87CA7}</Project>
<Name>WebsitePanel.Server.Utils</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- 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.

View file

@ -1,4 +1,32 @@
using System;
// Copyright (c) 2011, 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.Linq;
using System.Text;

View file

@ -27,7 +27,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

View file

@ -1,4 +1,32 @@
using System;
// Copyright (c) 2011, 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.Linq;
using System.Text;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2010, SMB SAAS Systems Inc.
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -11,7 +11,7 @@
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the SMB SAAS Systems Inc. nor the names of its
// - 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.
//

View file

@ -27,7 +27,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

View file

@ -908,7 +908,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
steps.AppendLine("VM created");
}
}
catch (System.TimeoutException ex)
catch (System.TimeoutException)
{
vmTemplate.ProvisioningStatus = VirtualMachineProvisioningStatus.InProgress;
}
@ -1064,38 +1064,32 @@ namespace WebsitePanel.Providers.VirtualizationForPC
{
List<Virtualization.VirtualNetworkInfo> result = new List<Virtualization.VirtualNetworkInfo>();
try
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
{
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
VirtualizationForPC.SVMMService.VirtualNetworkInfo[] networks = client.GetVirtualNetworkByHost(hostInfo);
foreach (var item in networks)
{
VirtualizationForPC.SVMMService.VirtualNetworkInfo[] networks = client.GetVirtualNetworkByHost(hostInfo);
foreach (var item in networks)
{
result.Add(
new Virtualization.VirtualNetworkInfo
{
BoundToVMHost = item.BoundToVMHost,
DefaultGatewayAddress = item.DefaultGatewayAddress,
Description = item.Description,
DNSServers = item.DNSServers,
EnablingIPAddress = item.EnablingIPAddress,
HighlyAvailable = item.HighlyAvailable,
HostBoundVlanId = item.HostBoundVlanId,
Id = item.Id,
Name = item.Name,
NetworkAddress = item.NetworkAddress,
NetworkMask = item.NetworkMask,
Tag = item.Tag,
VMHost = item.VMHost.ComputerName,
VMHostId = item.VMHostId,
WINServers = item.WINServers
});
}
result.Add(
new Virtualization.VirtualNetworkInfo
{
BoundToVMHost = item.BoundToVMHost,
DefaultGatewayAddress = item.DefaultGatewayAddress,
Description = item.Description,
DNSServers = item.DNSServers,
EnablingIPAddress = item.EnablingIPAddress,
HighlyAvailable = item.HighlyAvailable,
HostBoundVlanId = item.HostBoundVlanId,
Id = item.Id,
Name = item.Name,
NetworkAddress = item.NetworkAddress,
NetworkMask = item.NetworkMask,
Tag = item.Tag,
VMHost = item.VMHost.ComputerName,
VMHostId = item.VMHostId,
WINServers = item.WINServers
});
}
}
catch (Exception ex)
{
}
return result.ToArray();
@ -1287,35 +1281,29 @@ namespace WebsitePanel.Providers.VirtualizationForPC
List<VirtualMachineSnapshot> ret = new List<VirtualMachineSnapshot>();
try
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
{
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
{
VMCheckpointInfo[] chkPtnList = client.GetVirtualMachineByName(vmId).VMCheckpoints;
VMCheckpointInfo[] chkPtnList = client.GetVirtualMachineByName(vmId).VMCheckpoints;
if (chkPtnList != null)
if (chkPtnList != null)
{
foreach (VMCheckpointInfo curr in chkPtnList)
{
foreach (VMCheckpointInfo curr in chkPtnList)
ret.Add(new VirtualMachineSnapshot()
{
ret.Add(new VirtualMachineSnapshot()
{
Created = curr.AddedTime
,
Id = curr.Id.ToString()
,
Name = curr.Name
,
CheckPointId = curr.CheckpointID
,
ParentId = curr.ParentCheckpointID
});
}
Created = curr.AddedTime
,
Id = curr.Id.ToString()
,
Name = curr.Name
,
CheckPointId = curr.CheckpointID
,
ParentId = curr.ParentCheckpointID
});
}
}
}
catch (Exception e)
{
}
return ret;
}
@ -1338,7 +1326,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
client.NewVirtualMachineCheckpoint(vm.Id, String.Format("{0} - {1}", vm.Name, DateTime.Now), String.Empty);
}
}
catch (TimeoutException ext)
catch (TimeoutException)
{
ret.ReturnValue = ReturnCode.JobStarted;
}
@ -1368,7 +1356,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
client.RestoreVirtualMachineCheckpoint(snapshotId);
}
}
catch (TimeoutException ext)
catch (TimeoutException)
{
error = true;
ret.ReturnValue = ReturnCode.JobStarted;
@ -1856,25 +1844,19 @@ namespace WebsitePanel.Providers.VirtualizationForPC
public WSPVirtualMachineManagementServiceClient GetVMMSClient()
{
WSPVirtualMachineManagementServiceClient ret;
try
if (!String.IsNullOrWhiteSpace(SCVMMServer)
&& !String.IsNullOrWhiteSpace(SCVMMPrincipalName))
{
if (!String.IsNullOrWhiteSpace(SCVMMServer)
&& !String.IsNullOrWhiteSpace(SCVMMPrincipalName))
{
EndpointAddress endPointAddress = GetEndPointAddress(SCVMMServer, SCVMMPrincipalName);
EndpointAddress endPointAddress = GetEndPointAddress(SCVMMServer, SCVMMPrincipalName);
ret = new WSPVirtualMachineManagementServiceClient(new WSHttpBinding("WSHttpBinding_IVirtualMachineManagementService"), endPointAddress);
ret = new WSPVirtualMachineManagementServiceClient(new WSHttpBinding("WSHttpBinding_IVirtualMachineManagementService"), endPointAddress);
VersionInfo ver = new VersionInfo();
}
else
{
throw new Exception("SCVMMServer or SCVMMPrincipalName is empty");
}
VersionInfo ver = new VersionInfo();
}
catch (Exception ex)
else
{
throw;
throw new Exception("SCVMMServer or SCVMMPrincipalName is empty");
}
return ret;
@ -1884,23 +1866,16 @@ namespace WebsitePanel.Providers.VirtualizationForPC
{
WSPMonitoringServiceClient ret;
try
if (!String.IsNullOrWhiteSpace(SCOMServer)
&& !String.IsNullOrWhiteSpace(SCOMPrincipalName))
{
if (!String.IsNullOrWhiteSpace(SCOMServer)
&& !String.IsNullOrWhiteSpace(SCOMPrincipalName))
{
EndpointAddress endPointAddress = GetEndPointAddress(SCOMServer, SCOMPrincipalName);
EndpointAddress endPointAddress = GetEndPointAddress(SCOMServer, SCOMPrincipalName);
ret = new WSPMonitoringServiceClient(new WSHttpBinding("WSHttpBinding_IMonitoringService"), endPointAddress);
}
else
{
throw new Exception("MonitoringServer or MonitoringPrincipalName is empty");
}
ret = new WSPMonitoringServiceClient(new WSHttpBinding("WSHttpBinding_IMonitoringService"), endPointAddress);
}
catch (Exception ex)
else
{
throw;
throw new Exception("MonitoringServer or MonitoringPrincipalName is empty");
}
return ret;

View file

@ -49,10 +49,6 @@
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.XML" />
<Reference Include="WebsitePanel.Providers.Base, Version=1.1.0.0, Culture=neutral, PublicKeyToken=da8782a6fc4d0081, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\WebsitePanel.Server\bin\WebsitePanel.Providers.Base.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\VersionInfo.cs">
@ -165,6 +161,10 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebsitePanel.Providers.Base\WebsitePanel.Providers.Base.csproj">
<Project>{684C932A-6C75-46AC-A327-F3689D89EB42}</Project>
<Name>WebsitePanel.Providers.Base</Name>
</ProjectReference>
<ProjectReference Include="..\WebsitePanel.Server.Utils\WebsitePanel.Server.Utils.csproj">
<Project>{E91E52F3-9555-4D00-B577-2B1DBDD87CA7}</Project>
<Name>WebsitePanel.Server.Utils</Name>

View file

@ -41,23 +41,20 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
public const string UserNameAttribute = "userName";
public const string PasswordAttribute = "password";
public PropertyBag GetAuthenticationSettings(string siteId)
public PropertyBag GetAuthenticationSettings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{
var config = srvman.GetApplicationHostConfiguration();
//
var section = config.GetSection(Constants.AnonymousAuthenticationSection, siteId);
//
PropertyBag bag = new PropertyBag();
//
bag[AuthenticationGlobals.AnonymousAuthenticationUserName] = Convert.ToString(section.GetAttributeValue(UserNameAttribute));
bag[AuthenticationGlobals.AnonymousAuthenticationPassword] = Convert.ToString(section.GetAttributeValue(PasswordAttribute));
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
//
return bag;
}
var config = srvman.GetApplicationHostConfiguration();
//
var section = config.GetSection(Constants.AnonymousAuthenticationSection, siteId);
//
PropertyBag bag = new PropertyBag();
//
bag[AuthenticationGlobals.AnonymousAuthenticationUserName] = Convert.ToString(section.GetAttributeValue(UserNameAttribute));
bag[AuthenticationGlobals.AnonymousAuthenticationPassword] = Convert.ToString(section.GetAttributeValue(PasswordAttribute));
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
//
return bag;
}
public void SetAuthenticationSettings(string virtualPath, string userName,

View file

@ -37,16 +37,13 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
{
public const string EnabledAttribute = "enabled";
public void GetAuthenticationSettings(WebVirtualDirectory virtualDir)
public void GetAuthenticationSettings(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
{
var config = srvman.GetApplicationHostConfiguration();
//
var section = config.GetSection(Constants.BasicAuthenticationSection, virtualDir.FullQualifiedPath);
//
virtualDir.EnableBasicAuthentication = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
}
var config = srvman.GetApplicationHostConfiguration();
//
var section = config.GetSection(Constants.BasicAuthenticationSection, virtualDir.FullQualifiedPath);
//
virtualDir.EnableBasicAuthentication = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
}
public void SetAuthenticationSettings(WebVirtualDirectory virtualDir)

View file

@ -37,20 +37,15 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
{
public const string EnabledAttribute = "enabled";
public PropertyBag GetAuthenticationSettings(string siteId)
public PropertyBag GetAuthenticationSettings(ServerManager srvman, string siteId)
{
PropertyBag bag = new PropertyBag();
//
using (var srvman = GetServerManager())
{
var config = srvman.GetApplicationHostConfiguration();
//
var section = config.GetSection(Constants.WindowsAuthenticationSection, siteId);
//
bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
}
//
var config = srvman.GetApplicationHostConfiguration();
//
var section = config.GetSection(Constants.WindowsAuthenticationSection, siteId);
//
bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
return bag;
}

View file

@ -40,20 +40,17 @@ namespace WebsitePanel.Providers.Web.Iis.ClassicAsp
public const string SectionName = "system.webServer/asp";
public const string EnableParentPathsAttribute = "enableParentPaths";
public PropertyBag GetClassicAspSettings(string siteId)
public PropertyBag GetClassicAspSettings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{
var config = srvman.GetApplicationHostConfiguration();
//
var aspSection = config.GetSection(SectionName, siteId);
//
PropertyBag bag = new PropertyBag();
//
bag[ClassicAspGlobals.EnableParentPaths] = Convert.ToBoolean(aspSection.GetAttributeValue(EnableParentPathsAttribute));
//
return bag;
}
var config = srvman.GetApplicationHostConfiguration();
//
var aspSection = config.GetSection(SectionName, siteId);
//
PropertyBag bag = new PropertyBag();
//
bag[ClassicAspGlobals.EnableParentPaths] = Convert.ToBoolean(aspSection.GetAttributeValue(EnableParentPathsAttribute));
//
return bag;
}
public void SetClassicAspSettings(WebVirtualDirectory virtualDir)

View file

@ -31,12 +31,14 @@ namespace WebsitePanel.Providers.Web.Iis.Common
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using Microsoft.Web.Administration;
using Microsoft.Web.Management.Server;
public abstract class ConfigurationModuleService
{
private const string ServerManagerContextKey = "ServerManagerContextKey";
/// <summary>
/// We'll use it in the future to implement management of web farm with shared configuration enabled
/// </summary>

View file

@ -43,31 +43,28 @@ namespace WebsitePanel.Providers.Web.Iis.DefaultDocuments
{
public const string ValueAttribute = "value";
public string GetDefaultDocumentSettings(string siteId)
public string GetDefaultDocumentSettings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
// Load web site configuration
var config = srvman.GetWebConfiguration(siteId);
// Load corresponding section
var section = config.GetSection(Constants.DefaultDocumentsSection);
//
var filesCollection = section.GetCollection("files");
// Build default documents
var defaultDocs = new List<String>();
//
foreach (var item in filesCollection)
{
// Load web site configuration
var config = srvman.GetWebConfiguration(siteId);
// Load corresponding section
var section = config.GetSection(Constants.DefaultDocumentsSection);
var item2Get = GetDefaultDocument(item);
//
var filesCollection = section.GetCollection("files");
// Build default documents
var defaultDocs = new List<String>();
if (String.IsNullOrEmpty(item2Get))
continue;
//
foreach (var item in filesCollection)
{
var item2Get = GetDefaultDocument(item);
//
if (String.IsNullOrEmpty(item2Get))
continue;
//
defaultDocs.Add(item2Get);
}
//
return String.Join(",", defaultDocs.ToArray());
defaultDocs.Add(item2Get);
}
//
return String.Join(",", defaultDocs.ToArray());
}
public void SetDefaultDocumentsEnabled(string siteId, bool enabled)

View file

@ -35,20 +35,17 @@ namespace WebsitePanel.Providers.Web.Iis.DirectoryBrowse
internal sealed class DirectoryBrowseModuleService : ConfigurationModuleService
{
public PropertyBag GetDirectoryBrowseSettings(string siteId)
public PropertyBag GetDirectoryBrowseSettings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{
var config = srvman.GetWebConfiguration(siteId);
//
DirectoryBrowseSection directoryBrowseSection = (DirectoryBrowseSection)config.GetSection(Constants.DirectoryBrowseSection, typeof(DirectoryBrowseSection));
//
PropertyBag bag = new PropertyBag();
bag[DirectoryBrowseGlobals.Enabled] = directoryBrowseSection.Enabled;
bag[DirectoryBrowseGlobals.ShowFlags] = (int)directoryBrowseSection.ShowFlags;
bag[DirectoryBrowseGlobals.ReadOnly] = directoryBrowseSection.IsLocked;
return bag;
}
var config = srvman.GetWebConfiguration(siteId);
//
DirectoryBrowseSection directoryBrowseSection = (DirectoryBrowseSection)config.GetSection(Constants.DirectoryBrowseSection, typeof(DirectoryBrowseSection));
//
PropertyBag bag = new PropertyBag();
bag[DirectoryBrowseGlobals.Enabled] = directoryBrowseSection.Enabled;
bag[DirectoryBrowseGlobals.ShowFlags] = (int)directoryBrowseSection.ShowFlags;
bag[DirectoryBrowseGlobals.ReadOnly] = directoryBrowseSection.IsLocked;
return bag;
}
public void SetDirectoryBrowseEnabled(string siteId, bool enabled)

View file

@ -58,36 +58,33 @@ using System.Collections.Specialized;
{ Constants.AspNet40x64PathSetting, @"\Framework64\v4.0.30128\aspnet_isapi.dll" }
};
public SettingPair[] GetISAPIExtensionsInstalled()
public SettingPair[] GetISAPIExtensionsInstalled(ServerManager srvman)
{
List<SettingPair> settings = new List<SettingPair>();
//
using (var srvman = GetServerManager())
var config = srvman.GetApplicationHostConfiguration();
//
var section = config.GetSection(Constants.IsapiCgiRestrictionSection);
//
foreach (var item in section.GetCollection())
{
var config = srvman.GetApplicationHostConfiguration();
var isapiModulePath = Convert.ToString(item.GetAttributeValue(PathAttribute));
//
var section = config.GetSection(Constants.IsapiCgiRestrictionSection);
//
foreach (var item in section.GetCollection())
for (int i = 0; i < ISAPI_MODULES.Keys.Count; i++)
{
var isapiModulePath = Convert.ToString(item.GetAttributeValue(PathAttribute));
var pathExt = ISAPI_MODULES.Get(i);
//
for (int i = 0; i < ISAPI_MODULES.Keys.Count; i++)
if (isapiModulePath.EndsWith(pathExt))
{
var pathExt = ISAPI_MODULES.Get(i);
//
if (isapiModulePath.EndsWith(pathExt))
settings.Add(new SettingPair
{
settings.Add(new SettingPair
{
// Retrieve key name
Name = ISAPI_MODULES.GetKey(i),
// Evaluate ISAPI module path
Value = isapiModulePath
});
//
break;
}
// Retrieve key name
Name = ISAPI_MODULES.GetKey(i),
// Evaluate ISAPI module path
Value = isapiModulePath
});
//
break;
}
}
}

View file

@ -87,45 +87,22 @@ namespace WebsitePanel.Providers.Web.Handlers
}
}
public void SetHandlersAccessPolicy(string fqPath, HandlerAccessPolicy policy)
public void SetHandlersAccessPolicy(ServerManager srvman, string fqPath, HandlerAccessPolicy policy)
{
var config = srvman.GetWebConfiguration(fqPath);
//
using (var srvman = GetServerManager())
{
var config = srvman.GetWebConfiguration(fqPath);
//
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
//
section.AccessPolicy = policy;
//
srvman.CommitChanges();
}
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
//
section.AccessPolicy = policy;
}
public HandlerAccessPolicy GetHandlersAccessPolicy(string fqPath)
public HandlerAccessPolicy GetHandlersAccessPolicy(ServerManager srvman, string fqPath)
{
var config = srvman.GetWebConfiguration(fqPath);
//
using (var srvman = GetServerManager())
{
var config = srvman.GetWebConfiguration(fqPath);
//
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
//
return section.AccessPolicy;
}
}
internal ConfigurationElementCollection GetHandlers(WebVirtualDirectory virtualDir)
{
//
using (var srvman = GetServerManager())
{
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
//
var section = config.GetSection(Constants.HandlersSection);
//
return section.GetCollection();
}
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
//
return section.AccessPolicy;
}
/// <summary>
@ -141,16 +118,16 @@ namespace WebsitePanel.Providers.Web.Handlers
if (String.IsNullOrEmpty(processor))
return;
// This section helps to overcome "legacy" issues
using (var srvman = GetServerManager())
{
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
//
var handlersSection = config.GetSection(Constants.HandlersSection);
// Do a complete section cleanup
handlersSection.RevertToParent();
//
srvman.CommitChanges();
}
//using (var srvman = GetServerManager())
//{
// var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
// //
// var handlersSection = config.GetSection(Constants.HandlersSection);
// // Do a complete section cleanup
// handlersSection.RevertToParent();
// //
// srvman.CommitChanges();
//}
//
using (var srvman = GetServerManager())
{

View file

@ -44,23 +44,20 @@ namespace WebsitePanel.Providers.Web.HttpRedirect
public const string DestinationAttribute = "destination";
public const string HttpResponseStatusAttribute = "httpResponseStatus";
public void LoadHttpRedirectSettings(WebVirtualDirectory virtualDir)
public void GetHttpRedirectSettings(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
{
// Load web site configuration
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
// Load corresponding section
var section = config.GetSection(Constants.HttpRedirectSection);
//
if (!Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute)))
return;
//
virtualDir.RedirectExactUrl = Convert.ToBoolean(section.GetAttributeValue(ExactDestinationAttribute));
virtualDir.RedirectDirectoryBelow = Convert.ToBoolean(section.GetAttributeValue(ChildOnlyAttribute));
virtualDir.HttpRedirect = Convert.ToString(section.GetAttributeValue(DestinationAttribute));
virtualDir.RedirectPermanent = String.Equals("301", Convert.ToString(section.GetAttributeValue(HttpResponseStatusAttribute)));
}
// Load web site configuration
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
// Load corresponding section
var section = config.GetSection(Constants.HttpRedirectSection);
//
if (!Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute)))
return;
//
virtualDir.RedirectExactUrl = Convert.ToBoolean(section.GetAttributeValue(ExactDestinationAttribute));
virtualDir.RedirectDirectoryBelow = Convert.ToBoolean(section.GetAttributeValue(ChildOnlyAttribute));
virtualDir.HttpRedirect = Convert.ToString(section.GetAttributeValue(DestinationAttribute));
virtualDir.RedirectPermanent = String.Equals("301", Convert.ToString(section.GetAttributeValue(HttpResponseStatusAttribute)));
}
public void SetHttpRedirectSettings(WebVirtualDirectory virtualDir)

File diff suppressed because it is too large Load diff

View file

@ -44,28 +44,25 @@ namespace WebsitePanel.Providers.Web.MimeTypes
/// Loads available mime maps into supplied virtual iisDirObject description.
/// </summary>
/// <param name="vdir">Virtual iisDirObject description.</param>
public void GetMimeMaps(WebVirtualDirectory virtualDir)
public void GetMimeMaps(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
//
var section = config.GetSection(Constants.StaticContentSection);
//
var mappings = new List<MimeMap>();
//
foreach (var item in section.GetCollection())
{
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
var item2Get = GetMimeMap(item);
//
var section = config.GetSection(Constants.StaticContentSection);
if (item2Get == null)
continue;
//
var mappings = new List<MimeMap>();
//
foreach (var item in section.GetCollection())
{
var item2Get = GetMimeMap(item);
//
if (item2Get == null)
continue;
//
mappings.Add(item2Get);
}
//
virtualDir.MimeMaps = mappings.ToArray();
mappings.Add(item2Get);
}
//
virtualDir.MimeMaps = mappings.ToArray();
}
/// <summary>

View file

@ -53,8 +53,7 @@ namespace WebsitePanel.Providers.Web.Iis
CX500DistinguishedName dn = new CX500DistinguishedName();
CX509Enrollment enroll = new CX509Enrollment();
CObjectIds objectIds = new CObjectIds();
CObjectId clientObjectId = new CObjectId();
CObjectId serverObjectId = new CObjectId();
CObjectId objectId = new CObjectId();
CX509ExtensionKeyUsage extensionKeyUsage = new CX509ExtensionKeyUsage();
CX509ExtensionEnhancedKeyUsage x509ExtensionEnhancedKeyUsage = new CX509ExtensionEnhancedKeyUsage();
@ -66,11 +65,14 @@ namespace WebsitePanel.Providers.Web.Iis
csPs.Add(csp);
// Provide key container name, key length and key spec to the private key object
//objPrivateKey.ContainerName = "AlejaCMa";
privateKey.Length = cert.CSRLength;
privateKey.KeySpec = X509KeySpec.XCN_AT_SIGNATURE;
privateKey.KeySpec = X509KeySpec.XCN_AT_KEYEXCHANGE;
privateKey.KeyUsage = X509PrivateKeyUsageFlags.XCN_NCRYPT_ALLOW_ALL_USAGES;
privateKey.ExportPolicy = X509PrivateKeyExportFlags.XCN_NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG | X509PrivateKeyExportFlags.XCN_NCRYPT_ALLOW_EXPORT_FLAG;
privateKey.ExportPolicy =
X509PrivateKeyExportFlags.XCN_NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG
| X509PrivateKeyExportFlags.XCN_NCRYPT_ALLOW_ARCHIVING_FLAG
| X509PrivateKeyExportFlags.XCN_NCRYPT_ALLOW_PLAINTEXT_ARCHIVING_FLAG
| X509PrivateKeyExportFlags.XCN_NCRYPT_ALLOW_EXPORT_FLAG;
privateKey.MachineContext = true;
// Provide the CSP collection object (in this case containing only 1 CSP object)
@ -97,10 +99,9 @@ namespace WebsitePanel.Providers.Web.Iis
pkcs10.X509Extensions.Add((CX509Extension)extensionKeyUsage);
// Enhanced Key Usage Extension
clientObjectId.InitializeFromValue("1.3.6.1.5.5.7.3.2");
objectIds.Add(clientObjectId);
serverObjectId.InitializeFromValue("1.3.6.1.5.5.7.3.1");
objectIds.Add(serverObjectId);
objectId.InitializeFromName(CERTENROLLLib.CERTENROLL_OBJECTID.XCN_OID_PKIX_KP_SERVER_AUTH);
objectIds.Add(objectId);
x509ExtensionEnhancedKeyUsage.InitializeEncode(objectIds);
pkcs10.X509Extensions.Add((CX509Extension)x509ExtensionEnhancedKeyUsage);
@ -108,6 +109,9 @@ namespace WebsitePanel.Providers.Web.Iis
string request = String.Format(@"CN={0}, O={1}, OU={2}, L={3}, S={4}, C={5}", cert.Hostname, cert.Organisation, cert.OrganisationUnit, cert.City, cert.State, cert.Country);
dn.Encode(request, X500NameFlags.XCN_CERT_NAME_STR_NONE);
// enable SMIME capabilities
pkcs10.SmimeCapabilities = true;
// Assing the subject name by using the Distinguished Name object initialized above
pkcs10.Subject = dn;
@ -335,7 +339,7 @@ namespace WebsitePanel.Providers.Web.Iis
public void AddBinding(SSLCertificate certificate, WebSite website)
{
using (ServerManager sm = GetServerManager())
using (ServerManager srvman = GetServerManager())
{
// Not sure why do we need to work with X.509 store here, so commented it out and lets see what happens
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
@ -344,7 +348,7 @@ namespace WebsitePanel.Providers.Web.Iis
List<ServerBinding> bindings = new List<ServerBinding>();
// Retrieve existing site bindings to figure out what do we have here
WebObjectsModuleService webObjSvc = new WebObjectsModuleService();
bindings.AddRange(webObjSvc.GetSiteBindings(website.SiteId));
bindings.AddRange(webObjSvc.GetSiteBindings(srvman, website.SiteId));
// Look for dedicated ip
bool dedicatedIp = bindings.Exists(binding => String.IsNullOrEmpty(binding.Host) && binding.IP != "*");
//
@ -353,11 +357,11 @@ namespace WebsitePanel.Providers.Web.Iis
bindingInformation = dedicatedIp ? string.Format("{0}:443:", website.SiteIPAddress)
: string.Format("{0}:443:{1}", website.SiteIPAddress, certificate.Hostname);
//
sm.Sites[website.SiteId].Bindings.Add(bindingInformation, certificate.Hash, store.Name);
srvman.Sites[website.SiteId].Bindings.Add(bindingInformation, certificate.Hash, store.Name);
//
store.Close();
//
sm.CommitChanges();
srvman.CommitChanges();
}
}

View file

@ -49,31 +49,27 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public const string ResponseModeAttribute = "responseMode";
public const string PrefixLanguageFilePath = "prefixLanguageFilePath";
public void GetCustomErrors(WebVirtualDirectory virtualDir)
public void GetCustomErrors(ServerManager srvman, WebVirtualDirectory virtualDir)
{
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
//
using (var srvman = GetServerManager())
var httpErrorsSection = config.GetSection(Constants.HttpErrorsSection);
//
var errorsCollection = httpErrorsSection.GetCollection();
//
var errors = new List<HttpError>();
//
foreach (var item in errorsCollection)
{
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
var item2Get = GetHttpError(item, virtualDir);
//
var httpErrorsSection = config.GetSection(Constants.HttpErrorsSection);
if (item2Get == null)
continue;
//
var errorsCollection = httpErrorsSection.GetCollection();
//
var errors = new List<HttpError>();
//
foreach (var item in errorsCollection)
{
var item2Get = GetHttpError(item, virtualDir);
//
if (item2Get == null)
continue;
//
errors.Add(item2Get);
}
//
virtualDir.HttpErrors = errors.ToArray();
errors.Add(item2Get);
}
//
virtualDir.HttpErrors = errors.ToArray();
}
public void SetCustomErrors(WebVirtualDirectory virtualDir)

View file

@ -40,33 +40,30 @@ namespace WebsitePanel.Providers.Web.WebObjects
public const string NameAttribute = "name";
public const string ValueAttribute = "value";
public void GetCustomHttpHeaders(WebVirtualDirectory virtualDir)
public void GetCustomHttpHeaders(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
var config = srvman.GetApplicationHostConfiguration();
//
var httpProtocolSection = config.GetSection(Constants.HttpProtocolSection, virtualDir.FullQualifiedPath);
//
if (httpProtocolSection == null)
return;
//
var headersCollection = httpProtocolSection.GetCollection("customHeaders");
//
var headers = new List<HttpHeader>();
//
foreach (var item in headersCollection)
{
var config = srvman.GetApplicationHostConfiguration();
var item2Get = GetCustomHttpHeader(item);
//
var httpProtocolSection = config.GetSection(Constants.HttpProtocolSection, virtualDir.FullQualifiedPath);
if (item2Get == null)
continue;
//
if (httpProtocolSection == null)
return;
//
var headersCollection = httpProtocolSection.GetCollection("customHeaders");
//
var headers = new List<HttpHeader>();
//
foreach (var item in headersCollection)
{
var item2Get = GetCustomHttpHeader(item);
//
if (item2Get == null)
continue;
//
headers.Add(item2Get);
}
//
virtualDir.HttpHeaders = headers.ToArray();
headers.Add(item2Get);
}
//
virtualDir.HttpHeaders = headers.ToArray();
}
public void SetCustomHttpHeaders(WebVirtualDirectory virtualDir)

View file

@ -133,7 +133,7 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
//
if (virtualDir.DedicatedApplicationPool)
{
var appPool = GetApplicationPool(virtualDir);
var appPool = GetApplicationPool(srvman, virtualDir);
vdir.UserName = appPool.ProcessModel.UserName;
vdir.Password = appPool.ProcessModel.Password;
}
@ -150,20 +150,17 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
}
}
public ApplicationPool GetApplicationPool(WebVirtualDirectory virtualDir)
public ApplicationPool GetApplicationPool(ServerManager srvman, WebVirtualDirectory virtualDir)
{
if (virtualDir == null)
throw new ArgumentNullException("vdir");
// read app pool
using (var srvman = GetServerManager())
{
var appPool = srvman.ApplicationPools[virtualDir.ApplicationPool];
//
if (appPool == null)
throw new ApplicationException("ApplicationPoolNotFound");
//
return appPool;
}
var appPool = srvman.ApplicationPools[virtualDir.ApplicationPool];
//
if (appPool == null)
throw new ApplicationException("ApplicationPoolNotFound");
//
return appPool;
}
public void CreateApplicationPool(string appPoolName, string appPoolUsername,
@ -324,126 +321,105 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
}
}
public ServerState GetSiteState(string siteId)
public ServerState GetSiteState(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
// ensure website exists
if (srvman.Sites[siteId] == null)
return ServerState.Unknown;
//
var siteState = ServerState.Unknown;
//
switch (srvman.Sites[siteId].State)
{
// ensure website exists
if (srvman.Sites[siteId] == null)
return ServerState.Unknown;
//
var siteState = ServerState.Unknown;
//
switch (srvman.Sites[siteId].State)
{
case ObjectState.Started:
siteState = ServerState.Started;
break;
case ObjectState.Starting:
siteState = ServerState.Starting;
break;
case ObjectState.Stopped:
siteState = ServerState.Stopped;
break;
case ObjectState.Stopping:
siteState = ServerState.Stopping;
break;
}
//
return siteState;
case ObjectState.Started:
siteState = ServerState.Started;
break;
case ObjectState.Starting:
siteState = ServerState.Starting;
break;
case ObjectState.Stopped:
siteState = ServerState.Stopped;
break;
case ObjectState.Stopping:
siteState = ServerState.Stopping;
break;
}
//
return siteState;
}
public bool SiteExists(string siteId)
public bool SiteExists(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{
return (srvman.Sites[siteId] != null);
}
return (srvman.Sites[siteId] != null);
}
public string[] GetSites()
public string[] GetSites(ServerManager srvman)
{
using (var srvman = GetServerManager())
{
var iisObjects = new List<string>();
//
foreach (var item in srvman.Sites)
iisObjects.Add(item.Name);
//
return iisObjects.ToArray();
}
var iisObjects = new List<string>();
//
foreach (var item in srvman.Sites)
iisObjects.Add(item.Name);
//
return iisObjects.ToArray();
}
public string GetWebSiteNameFromIIS(string siteName)
public string GetWebSiteNameFromIIS(ServerManager srvman, string siteName)
{
using (var srvman = GetServerManager())
{
if (srvman.Sites[siteName] != null)
return srvman.Sites[siteName].Name;
//
return null;
}
if (srvman.Sites[siteName] != null)
return srvman.Sites[siteName].Name;
//
return null;
}
public string GetWebSiteIdFromIIS(string siteId, string format)
public string GetWebSiteIdFromIIS(ServerManager srvman, string siteId, string format)
{
using (var srvman = GetServerManager())
{
var iisObject = srvman.Sites[siteId];
// Format string is empty
if (String.IsNullOrEmpty(format))
return Convert.ToString(iisObject.Id);
//
return String.Format(format, iisObject.Id);
}
var iisObject = srvman.Sites[siteId];
// Format string is empty
if (String.IsNullOrEmpty(format))
return Convert.ToString(iisObject.Id);
//
return String.Format(format, iisObject.Id);
}
public WebSite GetWebSiteFromIIS(string siteId)
public WebSite GetWebSiteFromIIS(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
var webSite = new WebSite();
//
var iisObject = srvman.Sites[siteId];
//
webSite.SiteId = webSite.Name = iisObject.Name;
//
if (iisObject.LogFile.Enabled)
{
var webSite = new WebSite();
//
var iisObject = srvman.Sites[siteId];
//
webSite.SiteId = webSite.Name = iisObject.Name;
//
if (iisObject.LogFile.Enabled)
{
webSite.LogsPath = iisObject.LogFile.Directory;
webSite[WebSite.IIS7_LOG_EXT_FILE_FIELDS] = iisObject.LogFile.LogExtFileFlags.ToString();
}
// Read instant website id
webSite[WebSite.IIS7_SITE_ID] = GetWebSiteIdFromIIS(siteId, "W3SVC{0}");
// Read web site iisAppObject pool name
webSite.ApplicationPool = iisObject.Applications["/"].ApplicationPoolName;
//
return webSite;
webSite.LogsPath = iisObject.LogFile.Directory;
webSite[WebSite.IIS7_LOG_EXT_FILE_FIELDS] = iisObject.LogFile.LogExtFileFlags.ToString();
}
// Read instant website id
webSite[WebSite.IIS7_SITE_ID] = GetWebSiteIdFromIIS(srvman, siteId, "W3SVC{0}");
// Read web site iisAppObject pool name
webSite.ApplicationPool = iisObject.Applications["/"].ApplicationPoolName;
//
return webSite;
}
public ServerBinding[] GetSiteBindings(string siteId)
public ServerBinding[] GetSiteBindings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
var iisObject = srvman.Sites[siteId];
// get server bingings
var bindings = new List<ServerBinding>();
//
foreach (var bindingObj in iisObject.Bindings)
{
var iisObject = srvman.Sites[siteId];
// get server bingings
var bindings = new List<ServerBinding>();
//
foreach (var bindingObj in iisObject.Bindings)
{
// return only "http" bindings
if (String.Equals(bindingObj.Protocol, Uri.UriSchemeHttp, StringComparison.InvariantCultureIgnoreCase))
{
string[] parts = bindingObj.BindingInformation.Split(':');
// append binding
bindings.Add(new ServerBinding(bindingObj.Protocol, parts[0], parts[1], parts[2]));
}
}
//
return bindings.ToArray();
// return only "http" bindings
if (String.Equals(bindingObj.Protocol, Uri.UriSchemeHttp, StringComparison.InvariantCultureIgnoreCase))
{
string[] parts = bindingObj.BindingInformation.Split(':');
// append binding
bindings.Add(new ServerBinding(bindingObj.Protocol, parts[0], parts[1], parts[2]));
}
}
//
return bindings.ToArray();
}
private void SyncWebSiteBindingsChanges(string siteId, ServerBinding[] bindings)
@ -487,40 +463,40 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public void UpdateSiteBindings(string siteId, ServerBinding[] bindings)
{
// Ensure web site exists
if (!SiteExists(siteId))
return;
using (ServerManager srvman = GetServerManager())
{
// Ensure web site exists
if (!SiteExists(srvman, siteId))
return;
}
//
SyncWebSiteBindingsChanges(siteId, bindings);
}
public string GetPhysicalPath(WebVirtualDirectory virtualDir)
public string GetPhysicalPath(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
{
string siteId = (virtualDir.ParentSiteName == null)
? virtualDir.Name : virtualDir.ParentSiteName;
//
var iisObject = srvman.Sites[siteId];
string siteId = (virtualDir.ParentSiteName == null)
? virtualDir.Name : virtualDir.ParentSiteName;
//
var iisObject = srvman.Sites[siteId];
if (iisObject == null)
return null;
if (iisObject == null)
return null;
//
var iisAppObject = iisObject.Applications[virtualDir.VirtualPath];
//
var iisAppObject = iisObject.Applications[virtualDir.VirtualPath];
if (iisAppObject == null)
return null;
if (iisAppObject == null)
return null;
//
var iisDirObject = iisAppObject.VirtualDirectories["/"];
//
var iisDirObject = iisAppObject.VirtualDirectories["/"];
if (iisDirObject == null)
return null;
if (iisDirObject == null)
return null;
//
return iisDirObject.PhysicalPath;
}
//
return iisDirObject.PhysicalPath;
}
public void DeleteApplicationPool(params string[] appPoolNames)
@ -552,11 +528,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public void DeleteSite(string siteId)
{
if (!SiteExists(siteId))
return;
//
using (var srvman = GetServerManager())
{
if (!SiteExists(srvman, siteId))
return;
//
var indexOf = srvman.Sites.IndexOf(srvman.Sites[siteId]);
srvman.Sites.RemoveAt(indexOf);
@ -565,31 +541,28 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
}
}
public WebVirtualDirectory[] GetVirtualDirectories(string siteId)
public WebVirtualDirectory[] GetVirtualDirectories(ServerManager srvman, string siteId)
{
if (!SiteExists(siteId))
return new WebVirtualDirectory[] { };
if (!SiteExists(srvman, siteId))
return new WebVirtualDirectory[] { };
using (var srvman = GetServerManager())
var vdirs = new List<WebVirtualDirectory>();
var iisObject = srvman.Sites[siteId];
//
foreach (var item in iisObject.Applications)
{
var vdirs = new List<WebVirtualDirectory>();
var iisObject = srvman.Sites[siteId];
// Skip root application which is web site itself
if (item.Path == "/")
continue;
//
foreach (var item in iisObject.Applications)
vdirs.Add(new WebVirtualDirectory
{
// Skip root application which is web site itself
if (item.Path == "/")
continue;
//
vdirs.Add(new WebVirtualDirectory
{
Name = ConfigurationUtility.GetNonQualifiedVirtualPath(item.Path),
ContentPath = item.VirtualDirectories[0].PhysicalPath
});
}
//
return vdirs.ToArray();
Name = ConfigurationUtility.GetNonQualifiedVirtualPath(item.Path),
ContentPath = item.VirtualDirectories[0].PhysicalPath
});
}
//
return vdirs.ToArray();
}
public WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName)
@ -601,11 +574,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
if (String.IsNullOrEmpty(directoryName))
throw new ArgumentNullException("directoryName");
//
if (!SiteExists(siteId))
return null;
//
using (var srvman = GetServerManager())
{
if (!SiteExists(srvman, siteId))
return null;
var site = srvman.Sites[siteId];
//
var vdir = new WebVirtualDirectory
@ -622,11 +595,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public void CreateVirtualDirectory(string siteId, string directoryName, string physicalPath)
{
if (!SiteExists(siteId))
throw new ApplicationException();
//
using (var srvman = GetServerManager())
{
if (!SiteExists(srvman, siteId))
throw new ApplicationException();
var iisSiteObject = srvman.Sites[siteId];
var iisAppObject = iisSiteObject.Applications.Add(directoryName, physicalPath);
//
@ -636,11 +609,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public bool VirtualDirectoryExists(string siteId, string directoryName)
{
if (!SiteExists(siteId))
return false;
using (var srvman = GetServerManager())
{
if (!SiteExists(srvman, siteId))
return false;
var vdir = new WebVirtualDirectory
{
Name = directoryName,
@ -653,11 +626,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public void DeleteVirtualDirectory(WebVirtualDirectory virtualDir)
{
if (!SiteExists(virtualDir.ParentSiteName))
return;
//
using (var srvman = GetServerManager())
{
if (!SiteExists(srvman, virtualDir.ParentSiteName))
return;
var iisSiteObject = srvman.Sites[virtualDir.ParentSiteName];
var iisAppObject = iisSiteObject.Applications[virtualDir.VirtualPath];
//

View file

@ -71,6 +71,7 @@
<Reference Include="System.Data" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.Management" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>

View file

@ -2392,37 +2392,37 @@ namespace WebsitePanel.Providers.Web
throw new NotImplementedException();
}
public List<HtaccessUser> GetHeliconApeUsers(string siteId)
public virtual List<HtaccessUser> GetHeliconApeUsers(string siteId)
{
throw new NotImplementedException();
}
public HtaccessUser GetHeliconApeUser(string siteId, string userName)
public virtual HtaccessUser GetHeliconApeUser(string siteId, string userName)
{
throw new NotImplementedException();
}
public void UpdateHeliconApeUser(string siteId, HtaccessUser user)
public virtual void UpdateHeliconApeUser(string siteId, HtaccessUser user)
{
throw new NotImplementedException();
}
public void DeleteHeliconApeUser(string siteId, string userName)
public virtual void DeleteHeliconApeUser(string siteId, string userName)
{
throw new NotImplementedException();
}
public List<WebGroup> GetHeliconApeGroups(string siteId)
public virtual List<WebGroup> GetHeliconApeGroups(string siteId)
{
throw new NotImplementedException();
}
public WebGroup GetHeliconApeGroup(string siteId, string groupName)
public virtual WebGroup GetHeliconApeGroup(string siteId, string groupName)
{
throw new NotImplementedException();
}
public void UpdateHeliconApeGroup(string siteId, WebGroup group)
public virtual void UpdateHeliconApeGroup(string siteId, WebGroup group)
{
throw new NotImplementedException();
}
@ -2437,7 +2437,7 @@ namespace WebsitePanel.Providers.Web
throw new NotSupportedException();
}
public void DeleteHeliconApeGroup(string siteId, string groupName)
public virtual void DeleteHeliconApeGroup(string siteId, string groupName)
{
throw new NotImplementedException();
}
@ -3630,27 +3630,27 @@ namespace WebsitePanel.Providers.Web
#endregion
#region Remote Management Access
public void GrantWebManagementAccess(string siteName, string accountName, string accountPassword)
public virtual void GrantWebManagementAccess(string siteName, string accountName, string accountPassword)
{
throw new NotSupportedException();
}
public void RevokeWebManagementAccess(string siteName, string accountName)
public virtual void RevokeWebManagementAccess(string siteName, string accountName)
{
throw new NotSupportedException();
}
public void ChangeWebManagementAccessPassword(string accountName, string accountPassword)
public virtual void ChangeWebManagementAccessPassword(string accountName, string accountPassword)
{
throw new NotSupportedException();
}
public bool CheckWebManagementAccountExists(string accountName)
public virtual bool CheckWebManagementAccountExists(string accountName)
{
throw new NotSupportedException();
}
public ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
public virtual ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
{
throw new NotSupportedException();
}

View file

@ -15,7 +15,7 @@
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>

View file

@ -11,8 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\..\LICENSE.txt = ..\..\LICENSE.txt
..\..\Readme.htm = ..\..\Readme.htm
..\..\ReleaseNotes.htm = ..\..\ReleaseNotes.htm
VersionInfo.cs = VersionInfo.cs
VersionInfo.vb = VersionInfo.vb
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Server", "WebsitePanel.Server\WebsitePanel.Server.csproj", "{38C6047C-E447-4CC2-891F-ABE54D4659F3}"

View file

@ -154,7 +154,7 @@ namespace WebsitePanel.Server
Log.WriteEnd("'{0}' CreateVMFromVM", ProviderSettings.ProviderName);
return result;
}
catch (System.TimeoutException ex)
catch (System.TimeoutException)
{
return result;
}

View file

@ -44,7 +44,7 @@
<!-- Perform security check -->
<enabled value="true"/>
<!-- Server password -->
<password value="${installer.server.password}"/>
<password value="Z6JYIY9o9rX3FCWTz0sffYdiLdg="/>
</security>
</websitepanel.server>
<system.web>
@ -63,7 +63,7 @@
</protocols>
<soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3"/>
</webServices>
<compilation debug="true" targetFramework="4.0"/>
<compilation debug="true" />
</system.web>
<!-- WSE 3.0 settings -->
<microsoft.web.services3>

View file

@ -16,7 +16,7 @@
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
<UseIISExpress>false</UseIISExpress>
</PropertyGroup>
@ -54,7 +54,6 @@
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
@ -203,14 +202,6 @@
<Project>{684C932A-6C75-46AC-A327-F3689D89EB42}</Project>
<Name>WebsitePanel.Providers.Base</Name>
</ProjectReference>
<ProjectReference Include="..\WebsitePanel.Providers.Virtualization.HyperVForPC\WebsitePanel.Providers.VirtualizationForPC.HyperVForPC.csproj">
<Project>{64BEEB10-7F9F-4860-B2FF-84CDA02766B3}</Project>
<Name>WebsitePanel.Providers.VirtualizationForPC.HyperVForPC</Name>
</ProjectReference>
<ProjectReference Include="..\WebsitePanel.Providers.Web.IIs60\WebsitePanel.Providers.Web.IIs60.csproj">
<Project>{9BE0317D-E42E-4FF6-9A87-8C801F046EA1}</Project>
<Name>WebsitePanel.Providers.Web.IIs60</Name>
</ProjectReference>
<ProjectReference Include="..\WebsitePanel.Server.Utils\WebsitePanel.Server.Utils.csproj">
<Project>{E91E52F3-9555-4D00-B577-2B1DBDD87CA7}</Project>
<Name>WebsitePanel.Server.Utils</Name>

View file

@ -51,7 +51,7 @@
/* EDIT */
.EditContainer
{
width: 720px;
width: 100%;
margin-left: auto;
margin-right: auto;
margin-top: 20px;

View file

@ -50,40 +50,40 @@ using WebsitePanel.WebPortal;
namespace WebsitePanel.Portal
{
public class PortalUtils
{
public const string SharedResourcesFile = "SharedResources.ascx.resx";
public class PortalUtils
{
public const string SharedResourcesFile = "SharedResources.ascx.resx";
public const string CONFIG_FOLDER = "~/App_Data/";
public const string SUPPORTED_THEMES_FILE = "SupportedThemes.config";
public const string SUPPORTED_LOCALES_FILE = "SupportedLocales.config";
public const string SUPPORTED_THEMES_FILE = "SupportedThemes.config";
public const string SUPPORTED_LOCALES_FILE = "SupportedLocales.config";
public const string USER_ID_PARAM = "UserID";
public const string SPACE_ID_PARAM = "SpaceID";
public const string SEARCH_QUERY_PARAM = "Query";
public static string CultureCookieName
{
get { return PortalConfiguration.SiteSettings["CultureCookieName"]; }
}
public static string CultureCookieName
{
get { return PortalConfiguration.SiteSettings["CultureCookieName"]; }
}
public static string ThemeCookieName
{
get { return PortalConfiguration.SiteSettings["ThemeCookieName"]; }
}
public static string ThemeCookieName
{
get { return PortalConfiguration.SiteSettings["ThemeCookieName"]; }
}
public static System.Globalization.CultureInfo CurrentCulture
{
get { return GetCurrentCulture(); }
}
public static System.Globalization.CultureInfo CurrentCulture
{
get { return GetCurrentCulture(); }
}
public static System.Globalization.CultureInfo CurrentUICulture
{
get { return GetCurrentCulture(); }
}
public static System.Globalization.CultureInfo CurrentUICulture
{
get { return GetCurrentCulture(); }
}
public static string CurrentTheme
{
get { return GetCurrentTheme(); }
}
public static string CurrentTheme
{
get { return GetCurrentTheme(); }
}
internal static string GetCurrentTheme()
{
@ -131,51 +131,51 @@ namespace WebsitePanel.Portal
return String.IsNullOrEmpty(theme) ? "Default" : theme;
}
public static void SetCurrentTheme(string theme)
{
// theme
if (!String.IsNullOrEmpty(theme))
{
HttpCookie cookieTheme = new HttpCookie(ThemeCookieName, theme);
cookieTheme.Expires = DateTime.Now.AddMonths(2);
HttpContext.Current.Response.Cookies.Add(cookieTheme);
}
}
public static void SetCurrentTheme(string theme)
{
// theme
if (!String.IsNullOrEmpty(theme))
{
HttpCookie cookieTheme = new HttpCookie(ThemeCookieName, theme);
cookieTheme.Expires = DateTime.Now.AddMonths(2);
HttpContext.Current.Response.Cookies.Add(cookieTheme);
}
}
internal static System.Globalization.CultureInfo GetCurrentCulture()
{
System.Globalization.CultureInfo ci = (System.Globalization.CultureInfo)
HttpContext.Current.Items[CultureCookieName];
internal static System.Globalization.CultureInfo GetCurrentCulture()
{
System.Globalization.CultureInfo ci = (System.Globalization.CultureInfo)
HttpContext.Current.Items[CultureCookieName];
if (ci == null)
{
HttpCookie localeCrumb = HttpContext.Current.Request.Cookies[CultureCookieName];
if (localeCrumb != null)
{
ci = System.Globalization.CultureInfo.CreateSpecificCulture(localeCrumb.Value);
if (ci == null)
{
HttpCookie localeCrumb = HttpContext.Current.Request.Cookies[CultureCookieName];
if (localeCrumb != null)
{
ci = System.Globalization.CultureInfo.CreateSpecificCulture(localeCrumb.Value);
if (ci != null)
{
HttpContext.Current.Items[CultureCookieName] = ci;
return ci;
}
}
}
else
return ci;
if (ci != null)
{
HttpContext.Current.Items[CultureCookieName] = ci;
return ci;
}
}
}
else
return ci;
return System.Threading.Thread.CurrentThread.CurrentCulture;
}
return System.Threading.Thread.CurrentThread.CurrentCulture;
}
public static string AdminEmail
{
get { return PortalConfiguration.SiteSettings["AdminEmail"]; }
}
public static string AdminEmail
{
get { return PortalConfiguration.SiteSettings["AdminEmail"]; }
}
public static string FromEmail
{
get { return PortalConfiguration.SiteSettings["FromEmail"]; }
}
public static string FromEmail
{
get { return PortalConfiguration.SiteSettings["FromEmail"]; }
}
public static void SendMail(string from, string to, string bcc, string subject, string body)
{
@ -214,87 +214,87 @@ namespace WebsitePanel.Portal
}
}
public static void UserSignOut()
{
FormsAuthentication.SignOut();
public static void UserSignOut()
{
FormsAuthentication.SignOut();
HttpContext.Current.Response.Redirect(LoginRedirectUrl);
}
}
public static MenuItem GetSpaceMenuItem(string menuItemKey)
{
MenuItem item = new MenuItem();
item.Value = menuItemKey;
public static MenuItem GetSpaceMenuItem(string menuItemKey)
{
MenuItem item = new MenuItem();
item.Value = menuItemKey;
menuItemKey = String.Concat("Space", menuItemKey);
menuItemKey = String.Concat("Space", menuItemKey);
PortalPage page = PortalConfiguration.Site.Pages[menuItemKey];
PortalPage page = PortalConfiguration.Site.Pages[menuItemKey];
if (page != null)
if (page != null)
item.NavigateUrl = DefaultPage.GetPageUrl(menuItemKey);
return item;
}
return item;
}
private static FormsAuthenticationTicket AuthTicket
{
get
{
FormsAuthenticationTicket authTicket = (FormsAuthenticationTicket)HttpContext.Current.Items[FormsAuthentication.FormsCookieName];
private static FormsAuthenticationTicket AuthTicket
{
get
{
FormsAuthenticationTicket authTicket = (FormsAuthenticationTicket)HttpContext.Current.Items[FormsAuthentication.FormsCookieName];
if (authTicket == null)
{
// original code
HttpCookie authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
// workaround for cases when AuthTicket is required before round-trip
if (authCookie == null || String.IsNullOrEmpty(authCookie.Value))
authCookie = HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName];
//
if (authCookie != null)
{
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
HttpContext.Current.Items[FormsAuthentication.FormsCookieName] = authTicket;
}
}
if (authTicket == null)
{
// original code
HttpCookie authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
// workaround for cases when AuthTicket is required before round-trip
if (authCookie == null || String.IsNullOrEmpty(authCookie.Value))
authCookie = HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName];
//
if (authCookie != null)
{
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
HttpContext.Current.Items[FormsAuthentication.FormsCookieName] = authTicket;
}
}
return authTicket;
}
}
return authTicket;
}
}
private static void SetAuthTicket(FormsAuthenticationTicket ticket, bool persistent)
{
// issue authentication cookie
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
authCookie.Domain = FormsAuthentication.CookieDomain;
authCookie.Secure = FormsAuthentication.RequireSSL;
authCookie.Path = FormsAuthentication.FormsCookiePath;
authCookie.Value = FormsAuthentication.Encrypt(ticket);
private static void SetAuthTicket(FormsAuthenticationTicket ticket, bool persistent)
{
// issue authentication cookie
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
authCookie.Domain = FormsAuthentication.CookieDomain;
authCookie.Secure = FormsAuthentication.RequireSSL;
authCookie.Path = FormsAuthentication.FormsCookiePath;
authCookie.Value = FormsAuthentication.Encrypt(ticket);
if (persistent)
authCookie.Expires = DateTime.Now.AddMonths(1);
if (persistent)
authCookie.Expires = DateTime.Now.AddMonths(1);
HttpContext.Current.Response.Cookies.Add(authCookie);
}
HttpContext.Current.Response.Cookies.Add(authCookie);
}
public static string ApplicationPath
{
get
{
if (HttpContext.Current.Request.ApplicationPath == "/")
return "";
else
return HttpContext.Current.Request.ApplicationPath;
}
}
public static string ApplicationPath
{
get
{
if (HttpContext.Current.Request.ApplicationPath == "/")
return "";
else
return HttpContext.Current.Request.ApplicationPath;
}
}
public static string GetSharedLocalizedString(string moduleName, string resourceKey)
{
string className = SharedResourcesFile.Replace(".resx", "");
public static string GetSharedLocalizedString(string moduleName, string resourceKey)
{
string className = SharedResourcesFile.Replace(".resx", "");
if (!String.IsNullOrEmpty(moduleName))
className = String.Concat(moduleName, "_", className);
return (string)HttpContext.GetGlobalResourceObject(className, resourceKey);
}
if (!String.IsNullOrEmpty(moduleName))
className = String.Concat(moduleName, "_", className);
return (string)HttpContext.GetGlobalResourceObject(className, resourceKey);
}
public static string GetCurrentPageId()
{
@ -311,40 +311,40 @@ namespace WebsitePanel.Portal
return DefaultPage.GetLocalizedPageName(pageId);
}
public static int AuthenticateUser(string username, string password, string ipAddress,
bool rememberLogin, string preferredLocale, string theme)
{
esAuthentication authService = new esAuthentication();
ConfigureEnterpriseServerProxy(authService, false);
public static int AuthenticateUser(string username, string password, string ipAddress,
bool rememberLogin, string preferredLocale, string theme)
{
esAuthentication authService = new esAuthentication();
ConfigureEnterpriseServerProxy(authService, false);
try
{
int authResult = authService.AuthenticateUser(username, password, ipAddress);
try
{
int authResult = authService.AuthenticateUser(username, password, ipAddress);
if (authResult < 0)
{
return authResult;
}
else
{
UserInfo user = authService.GetUserByUsernamePassword(username, password, ipAddress);
if (user != null)
{
// issue authentication ticket
FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, user.Password, user.Role, rememberLogin);
SetAuthTicket(ticket, rememberLogin);
if (authResult < 0)
{
return authResult;
}
else
{
UserInfo user = authService.GetUserByUsernamePassword(username, password, ipAddress);
if (user != null)
{
// issue authentication ticket
FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, user.Password, user.Role, rememberLogin);
SetAuthTicket(ticket, rememberLogin);
CompleteUserLogin(username, rememberLogin, preferredLocale, theme);
}
CompleteUserLogin(username, rememberLogin, preferredLocale, theme);
}
return 0;
}
}
catch (Exception ex)
{
throw ex;
}
}
return 0;
}
}
catch (Exception ex)
{
throw ex;
}
}
private static int GetAuthenticationFormsTimeout()
{
@ -381,18 +381,18 @@ namespace WebsitePanel.Portal
);
}
public static int ChangeUserPassword(int userId, string newPassword)
{
// load user account
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
public static int ChangeUserPassword(int userId, string newPassword)
{
// load user account
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
try
{
UserInfo user = usersService.GetUserById(userId);
{
UserInfo user = usersService.GetUserById(userId);
// change WebsitePanel account password
int result = usersService.ChangeUserPassword(userId, newPassword);
// change WebsitePanel account password
int result = usersService.ChangeUserPassword(userId, newPassword);
if (result < 0)
return result;
@ -400,15 +400,15 @@ namespace WebsitePanel.Portal
if (String.Compare(user.Username, AuthTicket.Name, true) == 0)
{
FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, newPassword, user.Role, AuthTicket.IsPersistent);
SetAuthTicket(ticket, AuthTicket.IsPersistent);
SetAuthTicket(ticket, AuthTicket.IsPersistent);
}
return result;
}
catch (Exception ex)
{
throw ex;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
public static int UpdateUserAccount(UserInfo user)
{
@ -416,138 +416,138 @@ namespace WebsitePanel.Portal
}
public static int UpdateUserAccount(string taskId, UserInfo user)
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
try
{
// update user in WebsitePanel
return usersService.UpdateUserTask(taskId, user);
}
catch (Exception ex)
{
throw ex;
}
}
try
{
// update user in WebsitePanel
return usersService.UpdateUserTask(taskId, user);
}
catch (Exception ex)
{
throw ex;
}
}
public static int AddUserAccount(List<string> log, UserInfo user, bool sendLetter)
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
public static int AddUserAccount(List<string> log, UserInfo user, bool sendLetter)
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
try
{
// add user to WebsitePanel server
try
{
// add user to WebsitePanel server
return usersService.AddUser(user, sendLetter);
}
catch (Exception ex)
{
throw ex;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
public static int DeleteUserAccount(int userId)
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
public static int DeleteUserAccount(int userId)
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
try
{
// add user to WebsitePanel server
return usersService.DeleteUser(userId);
}
catch (Exception ex)
{
throw ex;
}
}
try
{
// add user to WebsitePanel server
return usersService.DeleteUser(userId);
}
catch (Exception ex)
{
throw ex;
}
}
public static int ChangeUserStatus(int userId, UserStatus status)
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
public static int ChangeUserStatus(int userId, UserStatus status)
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService, true);
try
{
// add user to WebsitePanel server
return usersService.ChangeUserStatus(userId, status);
}
catch (Exception ex)
{
throw ex;
}
}
try
{
// add user to WebsitePanel server
return usersService.ChangeUserStatus(userId, status);
}
catch (Exception ex)
{
throw ex;
}
}
public static UserInfo GetCurrentUser()
{
UserInfo user = null;
public static UserInfo GetCurrentUser()
{
UserInfo user = null;
if (AuthTicket != null)
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService);
if (AuthTicket != null)
{
esUsers usersService = new esUsers();
ConfigureEnterpriseServerProxy(usersService);
user = usersService.GetUserByUsername(AuthTicket.Name);
}
user = usersService.GetUserByUsername(AuthTicket.Name);
}
return user;
}
return user;
}
private static void CompleteUserLogin(string username, bool rememberLogin,
string preferredLocale, string theme)
{
// store last successful username in the cookie
HttpCookie cookie = new HttpCookie("WebsitePanelLogin", username);
cookie.Expires = DateTime.Now.AddDays(7);
HttpContext.Current.Response.Cookies.Add(cookie);
private static void CompleteUserLogin(string username, bool rememberLogin,
string preferredLocale, string theme)
{
// store last successful username in the cookie
HttpCookie cookie = new HttpCookie("WebsitePanelLogin", username);
cookie.Expires = DateTime.Now.AddDays(7);
HttpContext.Current.Response.Cookies.Add(cookie);
// set language
SetCurrentLanguage(preferredLocale);
// set language
SetCurrentLanguage(preferredLocale);
// set theme
SetCurrentTheme(theme);
// set theme
SetCurrentTheme(theme);
// remember me
if (rememberLogin)
HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(1);
}
// remember me
if (rememberLogin)
HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(1);
}
public static void SetCurrentLanguage(string preferredLocale)
{
if (!String.IsNullOrEmpty(preferredLocale))
{
HttpCookie localeCrumb = new HttpCookie(CultureCookieName, preferredLocale);
localeCrumb.Expires = DateTime.Now.AddMonths(2);
HttpContext.Current.Response.Cookies.Add(localeCrumb);
}
}
public static void SetCurrentLanguage(string preferredLocale)
{
if (!String.IsNullOrEmpty(preferredLocale))
{
HttpCookie localeCrumb = new HttpCookie(CultureCookieName, preferredLocale);
localeCrumb.Expires = DateTime.Now.AddMonths(2);
HttpContext.Current.Response.Cookies.Add(localeCrumb);
}
}
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy)
{
ConfigureEnterpriseServerProxy(proxy, true);
}
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy)
{
ConfigureEnterpriseServerProxy(proxy, true);
}
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy, bool applyPolicy)
{
// load ES properties
string serverUrl = PortalConfiguration.SiteSettings["EnterpriseServer"];
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy, bool applyPolicy)
{
// load ES properties
string serverUrl = PortalConfiguration.SiteSettings["EnterpriseServer"];
EnterpriseServerProxyConfigurator cnfg = new EnterpriseServerProxyConfigurator();
cnfg.EnterpriseServerUrl = serverUrl;
EnterpriseServerProxyConfigurator cnfg = new EnterpriseServerProxyConfigurator();
cnfg.EnterpriseServerUrl = serverUrl;
// create assertion
if (applyPolicy)
{
if (AuthTicket != null)
{
cnfg.Username = AuthTicket.Name;
cnfg.Password = AuthTicket.UserData.Substring(0, AuthTicket.UserData.IndexOf(Environment.NewLine));
}
}
// create assertion
if (applyPolicy)
{
if (AuthTicket != null)
{
cnfg.Username = AuthTicket.Name;
cnfg.Password = AuthTicket.UserData.Substring(0, AuthTicket.UserData.IndexOf(Environment.NewLine));
}
}
cnfg.Configure(proxy);
}
cnfg.Configure(proxy);
}
public static XmlNode GetModuleContentNode(WebPortalControlBase module)
{
@ -560,15 +560,15 @@ namespace WebsitePanel.Portal
return module.Module.SelectNodes("MenuItem");
}
public static string FormatIconImageUrl(string url)
{
return url;
}
public static string FormatIconImageUrl(string url)
{
return url;
}
public static string FormatIconLinkUrl(object url)
{
return DefaultPage.GetPageUrl(url.ToString());
}
public static string FormatIconLinkUrl(object url)
{
return DefaultPage.GetPageUrl(url.ToString());
}
public static string GetThemedImage(string imageUrl)
{
@ -582,76 +582,76 @@ namespace WebsitePanel.Portal
return page.ResolveUrl("~/App_Themes/" + page.Theme + "/" + iconUrl);
}
public static void LoadStatesDropDownList(DropDownList list, string countryCode)
{
public static void LoadStatesDropDownList(DropDownList list, string countryCode)
{
string xmlFilePath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "CountryStates.config");
list.Items.Clear();
if (File.Exists(xmlFilePath))
{
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFilePath);
list.Items.Clear();
if (File.Exists(xmlFilePath))
{
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFilePath);
List<ListItem> items = new List<ListItem>();
List<ListItem> items = new List<ListItem>();
XmlNodeList xmlNodes = xmlDoc.SelectNodes("//State[@countryCode='" + countryCode + "']");
foreach (XmlElement xmlNode in xmlNodes)
{
string nodeName = xmlNode.GetAttribute("name");
string nodeKey = xmlNode.GetAttribute("key");
XmlNodeList xmlNodes = xmlDoc.SelectNodes("//State[@countryCode='" + countryCode + "']");
foreach (XmlElement xmlNode in xmlNodes)
{
string nodeName = xmlNode.GetAttribute("name");
string nodeKey = xmlNode.GetAttribute("key");
items.Add(new ListItem(nodeName, nodeKey));
}
items.Add(new ListItem(nodeName, nodeKey));
}
list.Items.AddRange(items.ToArray());
}
catch
{
}
}
}
list.Items.AddRange(items.ToArray());
}
catch
{
}
}
}
public static void LoadCountriesDropDownList(DropDownList list, string countryToSelect)
{
public static void LoadCountriesDropDownList(DropDownList list, string countryToSelect)
{
string countriesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "Countries.config");
if (File.Exists(countriesPath))
{
try
{
XmlDocument xmlCountriesDoc = new XmlDocument();
xmlCountriesDoc.Load(countriesPath);
if (File.Exists(countriesPath))
{
try
{
XmlDocument xmlCountriesDoc = new XmlDocument();
xmlCountriesDoc.Load(countriesPath);
List<ListItem> items = new List<ListItem>();
List<ListItem> items = new List<ListItem>();
XmlNodeList xmlCountries = xmlCountriesDoc.SelectNodes("//Country");
foreach (XmlElement xmlCountry in xmlCountries)
{
string countryName = xmlCountry.GetAttribute("name");
string countryKey = xmlCountry.GetAttribute("key");
XmlNodeList xmlCountries = xmlCountriesDoc.SelectNodes("//Country");
foreach (XmlElement xmlCountry in xmlCountries)
{
string countryName = xmlCountry.GetAttribute("name");
string countryKey = xmlCountry.GetAttribute("key");
if (String.Compare(countryKey, countryToSelect) == 0)
{
ListItem li = new ListItem(countryName, countryKey);
li.Selected = true;
items.Add(li);
}
else
items.Add(new ListItem(countryName, countryKey));
}
if (String.Compare(countryKey, countryToSelect) == 0)
{
ListItem li = new ListItem(countryName, countryKey);
li.Selected = true;
items.Add(li);
}
else
items.Add(new ListItem(countryName, countryKey));
}
list.Items.AddRange(items.ToArray());
}
catch
{
}
}
}
list.Items.AddRange(items.ToArray());
}
catch
{
}
}
}
public static void LoadCultureDropDownList(DropDownList list)
{
public static void LoadCultureDropDownList(DropDownList list)
{
string localesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "SupportedLocales.config");
if (File.Exists(localesPath))
@ -696,39 +696,39 @@ namespace WebsitePanel.Portal
{
}
}
}
}
public static void LoadThemesDropDownList(DropDownList list)
{
string localesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "SupportedThemes.config");
public static void LoadThemesDropDownList(DropDownList list)
{
string localesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "SupportedThemes.config");
if (File.Exists(localesPath))
{
string themeToSelect = CurrentTheme;
if (File.Exists(localesPath))
{
string themeToSelect = CurrentTheme;
try
{
XmlDocument doc = new XmlDocument();
doc.Load(localesPath);
try
{
XmlDocument doc = new XmlDocument();
doc.Load(localesPath);
XmlNodeList xmlThemes = doc.SelectNodes("//Theme");
for (int i = 0; i < xmlThemes.Count; i++)
{
XmlElement xmlTheme = (XmlElement)xmlThemes[i];
string themeName = xmlTheme.GetAttribute("name");
string themeTitle = xmlTheme.GetAttribute("title");
XmlNodeList xmlThemes = doc.SelectNodes("//Theme");
for (int i = 0; i < xmlThemes.Count; i++)
{
XmlElement xmlTheme = (XmlElement)xmlThemes[i];
string themeName = xmlTheme.GetAttribute("name");
string themeTitle = xmlTheme.GetAttribute("title");
list.Items.Add(new ListItem(themeTitle, themeName));
list.Items.Add(new ListItem(themeTitle, themeName));
if (String.Compare(themeName, themeToSelect) == 0)
list.Items[i].Selected = true;
}
}
catch
{
}
}
}
if (String.Compare(themeName, themeToSelect) == 0)
list.Items[i].Selected = true;
}
}
catch
{
}
}
}
#region Navigation Routines
public static string LoginRedirectUrl
@ -805,23 +805,23 @@ namespace WebsitePanel.Portal
urlBuilder.Add(String.Concat(keyName, "=", keyValue));
// load additional params
if (additionalParams != null)
{
if (additionalParams != null)
{
string controlId = null;
string moduleDefinitionId = null;
//
foreach (string paramStr in additionalParams)
{
if (paramStr.StartsWith("ctl=", StringComparison.InvariantCultureIgnoreCase))
{
// ensure page exists and avoid unnecessary exceptions throw
if (PortalConfiguration.Site.Pages.ContainsKey(pageId))
{
string[] pair = paramStr.Split('=');
foreach (string paramStr in additionalParams)
{
if (paramStr.StartsWith("ctl=", StringComparison.InvariantCultureIgnoreCase))
{
// ensure page exists and avoid unnecessary exceptions throw
if (PortalConfiguration.Site.Pages.ContainsKey(pageId))
{
string[] pair = paramStr.Split('=');
controlId = pair[1];
}
}
}
else if (paramStr.StartsWith("moduleDefId=", StringComparison.InvariantCultureIgnoreCase))
{
// ensure page exists and avoid unnecessary exceptions throw
@ -832,8 +832,8 @@ namespace WebsitePanel.Portal
}
continue;
}
urlBuilder.Add(paramStr);
}
urlBuilder.Add(paramStr);
}
if (!String.IsNullOrEmpty(moduleDefinitionId) && !String.IsNullOrEmpty(controlId))
{
// 1. Read module controls first information first
@ -864,7 +864,7 @@ namespace WebsitePanel.Portal
}
}
}
}
}
End:
if (urlBuilder.Count > 0)

View file

@ -47,7 +47,7 @@ namespace WebsitePanel.Portal
/// </summary
public class Utils
{
public const string ModuleName = "WebsitePanel";
public const string ModuleName = "WebsitePanel";
public const Int32 MAX_DIR_LENGTH = 248;
public const Int32 MAX_FILE_LENGTH = 260;
@ -56,8 +56,18 @@ namespace WebsitePanel.Portal
public static DateTime ParseDate(string val)
{
try { return DateTime.Parse(val); }
catch { /* do nothing */ }
// Perf: allow only non-empty strings to go through
if (!String.IsNullOrEmpty(val))
{
try
{
return DateTime.Parse(val);
}
catch
{
/* do nothing */
}
}
return DateTime.MinValue;
}
@ -65,35 +75,66 @@ namespace WebsitePanel.Portal
{
return ParseInt(val, 0);
}
public static int ParseInt(object val, int defaultValue)
{
int result = defaultValue;
try { result = Int32.Parse(val.ToString()); }
catch { /* do nothing */ }
// Perf: allow only non-empty values to go through
if (val != null && val != String.Empty)
{
try
{
result = Int32.Parse(val.ToString());
}
catch
{
/* do nothing */
}
}
return result;
}
public static bool ParseBool(string val, bool defaultValue)
{
bool result = defaultValue;
try { result = Boolean.Parse(val); }
catch { /* do nothing */ }
// Perf: allow only non-empty strings to go through
if (!String.IsNullOrEmpty(val))
{
try
{
result = Boolean.Parse(val);
}
catch
{
/* do nothing */
}
}
return result;
}
public static decimal ParseDecimal(string val, decimal defaultValue)
{
decimal result = defaultValue;
try { result = Decimal.Parse(val); }
catch { /* do nothing */ }
// Perf: allow only non-empty strings to go through
if (!String.IsNullOrEmpty(val))
{
try
{
result = Decimal.Parse(val);
}
catch
{
/* do nothing */
}
}
return result;
}
public static string FormatDateTime(DateTime dt)
{
return dt == DateTime.MinValue ? "" : dt.ToString();
}
public static string FormatDateTime(DateTime dt)
{
return dt == DateTime.MinValue ? "" : dt.ToString();
}
public static string FixRelativePath(string path)
{
@ -137,31 +178,31 @@ namespace WebsitePanel.Portal
}
/// <summary>
/// Builds list of items from supplied group string.
/// </summary>
/// <param name="group">Group string.</param>
/// <returns>List of items.</returns>
public static List<KeyValuePair<string, string>> ParseGroup(string group)
{
List<KeyValuePair<string, string>> items = new List<KeyValuePair<string, string>>();
string[] vals = group.Split(';');
foreach (string v in vals)
{
string itemValue = v;
string itemText = v;
/// <summary>
/// Builds list of items from supplied group string.
/// </summary>
/// <param name="group">Group string.</param>
/// <returns>List of items.</returns>
public static List<KeyValuePair<string, string>> ParseGroup(string group)
{
List<KeyValuePair<string, string>> items = new List<KeyValuePair<string, string>>();
string[] vals = group.Split(';');
foreach (string v in vals)
{
string itemValue = v;
string itemText = v;
int eqIdx = v.IndexOf("=");
if (eqIdx != -1)
{
itemValue = v.Substring(0, eqIdx);
itemText = v.Substring(eqIdx + 1);
}
int eqIdx = v.IndexOf("=");
if (eqIdx != -1)
{
itemValue = v.Substring(0, eqIdx);
itemText = v.Substring(eqIdx + 1);
}
items.Add(new KeyValuePair<string, string>(itemText, itemValue));
}
return items;
}
items.Add(new KeyValuePair<string, string>(itemText, itemValue));
}
return items;
}
public static void SelectListItem(ListControl ctrl, object value)
@ -215,13 +256,13 @@ namespace WebsitePanel.Portal
}
}
public static string EllipsisString(string str, int maxLen)
{
if (String.IsNullOrEmpty(str) || str.Length <= maxLen)
return str;
public static string EllipsisString(string str, int maxLen)
{
if (String.IsNullOrEmpty(str) || str.Length <= maxLen)
return str;
return str.Substring(0, maxLen) + "...";
}
return str.Substring(0, maxLen) + "...";
}
public static string GetRandomString(int length)
{

View file

@ -121,7 +121,7 @@
<value>&lt;p&gt;When you grant &lt;b&gt;Full Access&lt;/b&gt; permission to a user, that user can open this mailbox and access all of its content.&lt;/p&gt; &lt;br&gt;&lt;p&gt;When you grant &lt;b&gt;Send As&lt;/b&gt; permission to a user, that user can send messages as this mailbox. &lt;/p&gt;&lt;br&gt;&lt;p&gt;We do not recommend to use this setting together “Send on behalf” (“Send as”) it may work unpredictable.&lt;/p&gt;</value>
</data>
<data name="lblGrandPermissions.Text" xml:space="preserve">
<value>Grand this permission to:</value>
<value>Grant this permission to:</value>
</data>
<data name="secSendAs.Text" xml:space="preserve">
<value>Send As</value>

View file

@ -35,7 +35,7 @@
function HighlightRow(chkB)
{
var xState=chkB.checked;
var row = chkB.parentElement.parentElement;
var row = chkB.parentNode.parentNode;
if(xState)
{
row.setAttribute("temp_class", row.className);

View file

@ -68,7 +68,7 @@ namespace WebsitePanel.Portal.ProviderControls
hosts = ES.Services.VPSPC.GetClusters(PanelRequest.ServiceId);
}
}
catch (Exception ex)
catch
{
hosts = null;
}

View file

@ -130,7 +130,7 @@ namespace WebsitePanel.Portal.VPSForPC
btn.Enabled = false;
}
messageBox.ShowErrorMessage("VPS_ERROR_CREATE", new Exception("no templates"));
messageBox.ShowErrorMessage("VPS_ERROR_CREATE", new Exception("no templates", ex));
}
// summary letter e-mail
PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId);

View file

@ -85,7 +85,7 @@ namespace WebsitePanel.Portal.VPSForPC
listOperatingSystems.Enabled = false;
txtVmName.Enabled = false;
btnCreate.Enabled = false;
messageBox.ShowErrorMessage("VPS_ERROR_CREATE", new Exception("no VM"));
messageBox.ShowErrorMessage("VPS_ERROR_CREATE", new Exception("no VM", ex));
}
}

View file

@ -67,12 +67,7 @@ namespace WebsitePanel.Portal.VPSForPC
}
catch (Exception ex)
{
vm = null;
}
if (vm == null)
{
messageBox.ShowErrorMessage("VPS_LOAD_VM_META_ITEM");
messageBox.ShowErrorMessage("VPS_LOAD_VM_META_ITEM", ex);
return;
}

View file

@ -66,44 +66,47 @@ namespace WebsitePanel.Portal
{
if (IsHeliconApeInstalled)
{
WebSite site = null;
try
if (!IsPostBack)
{
site = ES.Services.WebServers.GetWebSite(PanelRequest.ItemID);
}
catch (Exception ex)
{
HostModule.ShowErrorMessage("WEB_GET_SITE", ex);
return;
}
WebSite site = null;
try
{
site = ES.Services.WebServers.GetWebSite(PanelRequest.ItemID);
}
catch (Exception ex)
{
HostModule.ShowErrorMessage("WEB_GET_SITE", ex);
return;
}
if (site == null)
RedirectToBrowsePage();
if (site == null)
RedirectToBrowsePage();
BindHeliconApe(site);
BindHeliconApe(site);
}
}
}
public void BindHeliconApe(WebSite site)
public void BindHeliconApe(WebSite site)
{
// save initial state
IsHeliconApeInstalled = site.HeliconApeInstalled;
IsHeliconApeEnabled = site.HeliconApeEnabled;
IsSecuredFoldersInstalled = site.SecuredFoldersInstalled;
// Render a warning message about the automatic site's settings change
if (!IsHeliconApeEnabled && site.IIs7)
{
// Ensure the message is displayed only when neccessary
if (site.EnableWindowsAuthentication || !site.AspNetInstalled.EndsWith("I") || site.SecuredFoldersInstalled)
{
// TODO: show warning, do not force to enable integrated pool
// Render a warning message about the automatic site's settings change
if (!IsHeliconApeEnabled && site.IIs7)
{
// Ensure the message is displayed only when neccessary
if (site.EnableWindowsAuthentication || !site.AspNetInstalled.EndsWith("I") || site.SecuredFoldersInstalled)
{
// TODO: show warning, do not force to enable integrated pool
string warningStr = GetLocalizedString("EnableFoldersIIs7Warning.Text");
// Render a warning only if specified
if (!String.IsNullOrEmpty(warningStr))
// Render a warning only if specified
if (!String.IsNullOrEmpty(warningStr))
btnToggleHeliconApe.OnClientClick = String.Format("return confirm('{0}')", warningStr);
}
}
}
}
// toggle
ToggleControls();
}
@ -112,7 +115,7 @@ namespace WebsitePanel.Portal
{
if (IsHeliconApeInstalled)
{
// toggle button
// toggle button
btnToggleHeliconApe.Text = GetLocalizedString(
IsHeliconApeEnabled ? "DisableHeliconApe.Text" : "EnableHeliconApe.Text");
@ -130,9 +133,9 @@ namespace WebsitePanel.Portal
}
else
{
// Display the module not installed message for informational purposes.
panelHeliconApeIsNotInstalledMessage.Visible = true;
//
// Display the module not installed message for informational purposes.
panelHeliconApeIsNotInstalledMessage.Visible = true;
//
btnToggleHeliconApe.Visible = false;
HeliconApeFoldersPanel.Visible = false;
}

View file

@ -107,15 +107,23 @@ namespace WebsitePanel.Portal
}
}
private void BindListOfAvailableSslDomains(ServerBinding[] siteBindings, SSLCertificate[] siteCertificates)
private void BindListOfAvailableSslDomains(ServerBinding[] siteBindings, SSLCertificate[] siteCertificates, string websiteName = "")
{
lstDomains.Items.Clear();
//
foreach (ServerBinding binding in siteBindings)
{
//
lstDomains.Items.Add(new ListItem(binding.Host, binding.Host));
}
lstDomains.Items.Clear();
//
foreach (ServerBinding binding in siteBindings)
{
//
if (binding.IP.ToString().Length > 0 && binding.Host.Length == 0)
{
lstDomains.Items.Add(new ListItem(websiteName, websiteName));
lstDomains.Items.Add(new ListItem(String.Format("www.{0}", websiteName), String.Format("www.{0}", websiteName)));
}
else
{
lstDomains.Items.Add(new ListItem(binding.Host, binding.Host));
}
}
}
public void BindWebItem(WebVirtualDirectory item)
@ -137,7 +145,7 @@ namespace WebsitePanel.Portal
SSLNotInstalled.Visible = true;
//
BindListOfAvailableSslDomains(webSite.Bindings, certificates);
BindListOfAvailableSslDomains(webSite.Bindings, certificates, webSite.Name);
if (certificates.Length > 0)
{
@ -560,7 +568,7 @@ namespace WebsitePanel.Portal
SSLNotInstalled.Visible = true;
//
BindListOfAvailableSslDomains(item.Bindings, certificates);
BindListOfAvailableSslDomains(item.Bindings, certificates, item.Name);
if (certificates.Length > 0)
{