This commit is contained in:
Olov Karlsson 2014-12-25 23:35:51 +01:00
commit bc0ea107d1
43 changed files with 3533 additions and 2612 deletions

View file

@ -82,7 +82,9 @@
</Dialog>
<Dialog Id="InstallLocationDlg" Width="370" Height="270" Title="[ProductName] Setup">
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next">
<Publish Event="NewDialog" Value="DatabaseConnectionDlg" Order="3">1</Publish>
<Publish Event="DoAction" Value="PreInstallationAction">1</Publish>
<Publish Event="NewDialog" Value="DatabaseConnectionDlg" Order="3">SKIPCONNECTIONSTRINGSTEP = "0"</Publish>
<Publish Event="NewDialog" Value="VerifyReadyDlg" Order="3">SKIPCONNECTIONSTRINGSTEP = "1"</Publish>
</Control>
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back">
<Publish Event="NewDialog" Value="LicenseAgreementDlg" Order="3">1</Publish>
@ -101,13 +103,15 @@
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="InstallLocationDlg" Order="3">
LicenseAccepted = "1"
</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="DatabaseConnectionDlg">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="DatabaseConnectionDlg">SKIPCONNECTIONSTRINGSTEP = "0"</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallLocationDlg">SKIPCONNECTIONSTRINGSTEP = "1"</Publish>
<TextStyle Id="DlgTitleFont" FaceName="Tahoma" Size="8" Bold="yes" />
</UI>
<InstallExecuteSequence>
<Custom Action="PropertyFinalizeInstall" After='InstallValidate'/>
<Custom Action="FinalizeUnInstall" After="InstallValidate">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
<RemoveExistingProducts After="InstallValidate" />
<Custom Action='FinalizeInstall' After='InstallFinalize'>NOT Installed or REINSTALL</Custom>
<Custom Action='FinalizeInstall' After='InstallFiles' >NOT Installed or REINSTALL</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
@ -115,9 +119,16 @@
<Binary Id="CheckConnection.CA" SourceFile="bin\WebsitePanel.SchedulerServiceInstaller.CA.dll" />
</Fragment>
<Fragment>
<CustomAction Id="FinalizeInstall" BinaryKey="CheckConnection.CA" DllEntry="FinalizeInstall" />
<!-- immediate CA -->
<CustomAction Id='PropertyFinalizeInstall' Property='FinalizeInstall' Value='ConnectionString=[CONNECTIONSTRING];PreviousConnectionString=[PREVIOUSCONNECTIONSTRING];ServiceFolder=[SERVICEFOLDER];PreviousCryptoKey=[PREVIOUSCRYPTOKEY]' Return="check"/>
<!-- deferred CA -->
<CustomAction Id='FinalizeInstall' BinaryKey ='CheckConnection.CA' DllEntry='FinalizeInstall' Impersonate='no' Execute='deferred' Return='check' HideTarget='yes'/>
<!--<CustomAction Id="FinalizeInstall" BinaryKey="CheckConnection.CA" DllEntry="FinalizeInstall" />-->
</Fragment>
<Fragment>
<CustomAction Id="PreInstallationAction" BinaryKey="CheckConnection.CA" DllEntry="PreInstallationAction" />
<CustomAction Id="FinalizeUnInstall" BinaryKey="CheckConnection.CA" DllEntry="FinalizeUnInstall" />
<CustomAction Id='AlreadyUpdated' Error='Product has already been updated to $(var.VERSION) or newer.' />
<CustomAction Id='NoDowngrade' Error='A later version of [ProductName] is already installed.' />

View file

@ -27,6 +27,7 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Configuration.Install;
using System.Data;
using System.Data.SqlClient;
@ -35,6 +36,9 @@ using System.Linq;
using System.ServiceProcess;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Xml;
using Microsoft.Deployment.WindowsInstaller;
using WebsitePanel.Setup;
@ -42,6 +46,8 @@ namespace WebsitePanel.SchedulerServiceInstaller
{
public class CustomActions
{
public const string CustomDataDelimiter = "-=del=-";
[CustomAction]
public static ActionResult CheckConnection(Session session)
{
@ -63,9 +69,23 @@ namespace WebsitePanel.SchedulerServiceInstaller
[CustomAction]
public static ActionResult FinalizeInstall(Session session)
{
ChangeConfigString("installer.connectionstring", session["CONNECTIONSTRING"], session["INSTALLFOLDER"]);
ChangeCryptoKey(session["INSTALLFOLDER"]);
InstallService(session["INSTALLFOLDER"]);
var connectionString = GetCustomActionProperty(session, "ConnectionString").Replace(CustomDataDelimiter, ";");
var serviceFolder = GetCustomActionProperty(session, "ServiceFolder");
var previousConnectionString = GetCustomActionProperty(session, "PreviousConnectionString").Replace(CustomDataDelimiter, ";");
var previousCryptoKey = GetCustomActionProperty(session, "PreviousCryptoKey");
if (string.IsNullOrEmpty(serviceFolder))
{
return ActionResult.Success;
}
connectionString = string.IsNullOrEmpty(previousConnectionString)
? connectionString
: previousConnectionString;
ChangeConfigString("/configuration/connectionStrings/add[@name='EnterpriseServer']", "connectionString", connectionString, serviceFolder);
ChangeConfigString("/configuration/appSettings/add[@key='WebsitePanel.CryptoKey']", "value", previousCryptoKey, serviceFolder);
InstallService(serviceFolder);
return ActionResult.Success;
}
@ -78,6 +98,46 @@ namespace WebsitePanel.SchedulerServiceInstaller
return ActionResult.Success;
}
[CustomAction]
public static ActionResult PreInstallationAction(Session session)
{
session["SKIPCONNECTIONSTRINGSTEP"] = "0";
session["SERVICEFOLDER"] = session["INSTALLFOLDER"];
var servicePath = SecurityUtils.GetServicePath("WebsitePanel Scheduler");
if (!string.IsNullOrEmpty(servicePath))
{
string path = Path.Combine(servicePath, "WebsitePanel.SchedulerService.exe.config");
if (File.Exists(path))
{
using (var reader = new StreamReader(path))
{
string content = reader.ReadToEnd();
var pattern = new Regex(@"(?<=<add key=""WebsitePanel.CryptoKey"" .*?value\s*=\s*"")[^""]+(?="".*?>)");
Match match = pattern.Match(content);
session["PREVIOUSCRYPTOKEY"] = match.Value;
var connectionStringPattern = new Regex(@"(?<=<add name=""EnterpriseServer"" .*?connectionString\s*=\s*"")[^""]+(?="".*?>)");
match = connectionStringPattern.Match(content);
session["PREVIOUSCONNECTIONSTRING"] = match.Value.Replace(";", CustomDataDelimiter);
}
session["SKIPCONNECTIONSTRINGSTEP"] = "1";
if (string.IsNullOrEmpty(session["SERVICEFOLDER"]))
{
session["SERVICEFOLDER"] = servicePath;
}
}
}
return ActionResult.Success;
}
private static void InstallService(string installFolder)
{
try
@ -122,44 +182,29 @@ namespace WebsitePanel.SchedulerServiceInstaller
}
}
private static void ChangeCryptoKey(string installFolder)
private static void ChangeConfigString(string nodePath, string attrToChange, string value, string installFolder)
{
string path = Path.Combine(installFolder.Replace("SchedulerService", "Enterprise Server"), "web.config");
string cryptoKey = "0123456789";
if (File.Exists(path))
{
using (var reader = new StreamReader(path))
{
string content = reader.ReadToEnd();
var pattern = new Regex(@"(?<=<add key=""WebsitePanel.CryptoKey"" .*?value\s*=\s*"")[^""]+(?="".*?>)");
Match match = pattern.Match(content);
cryptoKey = match.Value;
}
}
ChangeConfigString("installer.cryptokey", cryptoKey, installFolder);
}
private static void ChangeConfigString(string searchString, string replaceValue, string installFolder)
{
string content;
string path = Path.Combine(installFolder, "WebsitePanel.SchedulerService.exe.config");
using (var reader = new StreamReader(path))
if (!File.Exists(path))
{
content = reader.ReadToEnd();
return;
}
var re = new Regex("\\$\\{" + searchString + "\\}+", RegexOptions.IgnoreCase);
content = re.Replace(content, replaceValue);
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(path);
using (var writer = new StreamWriter(path))
XmlElement node = xmldoc.SelectSingleNode(nodePath) as XmlElement;
if (node != null)
{
writer.Write(content);
node.SetAttribute(attrToChange, value);
xmldoc.Save(path);
}
}
private static void StopService(string serviceName)
{
var sc = new ServiceController(serviceName);
@ -184,12 +229,12 @@ namespace WebsitePanel.SchedulerServiceInstaller
private static string GetConnectionString(string serverName, string databaseName)
{
return string.Format("Server={0};database={1};Trusted_Connection=true;", serverName, databaseName);
return string.Format("Server={0};database={1};Trusted_Connection=true;", serverName, databaseName).Replace(";", CustomDataDelimiter);
}
private static string GetConnectionString(string serverName, string databaseName, string login, string password)
{
return string.Format("Server={0};database={1};uid={2};password={3};", serverName, databaseName, login, password);
return string.Format("Server={0};database={1};uid={2};password={3};", serverName, databaseName, login, password).Replace(";", CustomDataDelimiter);
}
private static bool CheckConnection(string connectionString)
@ -215,5 +260,15 @@ namespace WebsitePanel.SchedulerServiceInstaller
return result;
}
private static string GetCustomActionProperty(Session session, string key)
{
if (session.CustomActionData.ContainsKey(key))
{
return session.CustomActionData[key].Replace("-=-", ";");
}
return string.Empty;
}
}
}

View file

@ -1110,6 +1110,25 @@ namespace WebsitePanel.Setup
wmiService.Delete();
}
public static string GetServicePath(string serviceName)
{
var mc = new ManagementClass("Win32_Service");
foreach (var mo in mc.GetInstances())
{
if (mo.GetPropertyValue("Name").ToString() == serviceName)
{
var path = mo.GetPropertyValue("PathName").ToString().Trim('"');
var directory = Path.GetDirectoryName(path);
return directory;
}
}
return string.Empty;
}
#endregion
}

View file

@ -6195,6 +6195,12 @@ INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [D
END
GO
IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'PAUSE_BETWEEN_QUERIES' )
BEGIN
INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'PAUSE_BETWEEN_QUERIES', N'String', N'100', 4)
END
GO
IF EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'SERVER_NAME' )
BEGIN
UPDATE [dbo].[ScheduleTaskParameters] SET [DefaultValue] = N'' WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'SERVER_NAME'
@ -6346,6 +6352,7 @@ Please, find below details of your domain expiration information.
<thead>
<tr>
<th>Domain</th>
<th>Registrar</th>
<th>Customer</th>
<th>Expiration Date</th>
</tr>
@ -6354,8 +6361,9 @@ Please, find below details of your domain expiration information.
<ad:foreach collection="#Domains#" var="Domain" index="i">
<tr>
<td>#Domain.DomainName#</td>
<td>#iif(isnull(Domain.Registrar), "", Domain.Registrar)#</td>
<td>#Domain.Customer#</td>
<td>#Domain.ExpirationDate#</td>
<td>#iif(isnull(Domain.ExpirationDate), "", Domain.ExpirationDate)#</td>
</tr>
</ad:foreach>
</tbody>
@ -6418,8 +6426,9 @@ Please, find below details of your domain expiration information.
<ad:foreach collection="#Domains#" var="Domain" index="i">
Domain: #Domain.DomainName#
Registrar: #iif(isnull(Domain.Registrar), "", Domain.Registrar)#
Customer: #Domain.Customer#
Expiration Date: #Domain.ExpirationDate#
Expiration Date: #iif(isnull(Domain.ExpirationDate), "", Domain.ExpirationDate)#
</ad:foreach>
@ -6464,6 +6473,7 @@ INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [Property
.Summary { font-family: Tahoma; font-size: 9pt; }
.Summary H1 { font-size: 1.7em; color: ##1F4978; border-bottom: dotted 3px ##efefef; }
.Summary H2 { font-size: 1.3em; color: ##1F4978; }
.Summary H3 { font-size: 1em; color: ##1F4978; }
.Summary TABLE { border: solid 1px ##e5e5e5; }
.Summary TH,
.Summary TD.Label { padding: 5px; font-size: 8pt; font-weight: bold; background-color: ##f5f5f5; }
@ -6492,6 +6502,7 @@ Please, find below details of MX and NS changes.
<ad:foreach collection="#Domains#" var="Domain" index="i">
<h2>#Domain.DomainName# - #DomainUsers[Domain.PackageId].FirstName# #DomainUsers[Domain.PackageId].LastName#</h2>
<h3>#iif(isnull(Domain.Registrar), "", Domain.Registrar)# #iif(isnull(Domain.ExpirationDate), "", Domain.ExpirationDate)#</h3>
<table>
<thead>
@ -6552,6 +6563,8 @@ Please, find below details of MX and NS changes.
<ad:foreach collection="#Domains#" var="Domain" index="i">
#Domain.DomainName# - #DomainUsers[Domain.PackageId].FirstName# #DomainUsers[Domain.PackageId].LastName#
Registrar: #iif(isnull(Domain.Registrar), "", Domain.Registrar)#
ExpirationDate: #iif(isnull(Domain.ExpirationDate), "", Domain.ExpirationDate)#
<ad:foreach collection="#Domain.DnsChanges#" var="DnsChange" index="j">
DNS: #DnsChange.DnsServer#
@ -6959,7 +6972,6 @@ exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @PackageID int, @Fil
RETURN
GO
@ -7064,3 +7076,259 @@ BEGIN
UPDATE [dbo].[Providers] SET [EditorControl] = 'Windows2012' WHERE [ProviderName] = 'Windows2012'
END
GO
-- fix check domain used by HostedOrganization
ALTER PROCEDURE [dbo].[CheckDomainUsedByHostedOrganization]
@DomainName nvarchar(100),
@Result int OUTPUT
AS
SET @Result = 0
IF EXISTS(SELECT 1 FROM ExchangeAccounts WHERE UserPrincipalName LIKE '%@'+ @DomainName AND AccountType!=2)
BEGIN
SET @Result = 1
END
ELSE
IF EXISTS(SELECT 1 FROM ExchangeAccountEmailAddresses WHERE EmailAddress LIKE '%@'+ @DomainName)
BEGIN
SET @Result = 1
END
ELSE
IF EXISTS(SELECT 1 FROM LyncUsers WHERE SipAddress LIKE '%@'+ @DomainName)
BEGIN
SET @Result = 1
END
RETURN @Result
GO
-- check domain used by hosted organization
IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetOrganizationObjectsByDomain')
DROP PROCEDURE GetOrganizationObjectsByDomain
GO
CREATE PROCEDURE [dbo].[GetOrganizationObjectsByDomain]
(
@ItemID int,
@DomainName nvarchar(100)
)
AS
SELECT
'ExchangeAccounts' as ObjectName,
AccountID as ObjectID,
AccountType as ObjectType,
DisplayName as DisplayName,
0 as OwnerID
FROM
ExchangeAccounts
WHERE
UserPrincipalName LIKE '%@'+ @DomainName AND AccountType!=2
UNION
SELECT
'ExchangeAccountEmailAddresses' as ObjectName,
eam.AddressID as ObjectID,
ea.AccountType as ObjectType,
eam.EmailAddress as DisplayName,
eam.AccountID as OwnerID
FROM
ExchangeAccountEmailAddresses as eam
INNER JOIN
ExchangeAccounts ea
ON
ea.AccountID = eam.AccountID
WHERE
(ea.PrimaryEmailAddress != eam.EmailAddress)
AND (ea.UserPrincipalName != eam.EmailAddress)
AND (eam.EmailAddress LIKE '%@'+ @DomainName)
UNION
SELECT
'LyncUsers' as ObjectName,
ea.AccountID as ObjectID,
ea.AccountType as ObjectType,
ea.DisplayName as DisplayName,
0 as OwnerID
FROM
ExchangeAccounts ea
INNER JOIN
LyncUsers ou
ON
ea.AccountID = ou.AccountID
WHERE
ou.SipAddress LIKE '%@'+ @DomainName
ORDER BY
DisplayName
RETURN
GO
IF NOT EXISTS(SELECT * FROM sys.columns
WHERE [name] = N'RegistrarName' AND [object_id] = OBJECT_ID(N'Domains'))
BEGIN
ALTER TABLE [dbo].[Domains] ADD RegistrarName nvarchar(max);
END
GO
IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateWhoisDomainInfo')
DROP PROCEDURE UpdateWhoisDomainInfo
GO
CREATE PROCEDURE [dbo].UpdateWhoisDomainInfo
(
@DomainId INT,
@DomainCreationDate DateTime,
@DomainExpirationDate DateTime,
@DomainLastUpdateDate DateTime,
@DomainRegistrarName nvarchar(max)
)
AS
UPDATE [dbo].[Domains] SET [CreationDate] = @DomainCreationDate, [ExpirationDate] = @DomainExpirationDate, [LastUpdateDate] = @DomainLastUpdateDate, [RegistrarName] = @DomainRegistrarName WHERE [DomainID] = @DomainId
GO
IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetDomainsPaged')
DROP PROCEDURE GetDomainsPaged
GO
CREATE PROCEDURE [dbo].[GetDomainsPaged]
(
@ActorID int,
@PackageID int,
@ServerID int,
@Recursive bit,
@FilterColumn nvarchar(50) = '',
@FilterValue nvarchar(50) = '',
@SortColumn nvarchar(50),
@StartRow int,
@MaximumRows int
)
AS
SET NOCOUNT ON
-- check rights
IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0
RAISERROR('You are not allowed to access this package', 16, 1)
-- build query and run it to the temporary table
DECLARE @sql nvarchar(2500)
IF @SortColumn = '' OR @SortColumn IS NULL
SET @SortColumn = 'DomainName'
SET @sql = '
DECLARE @Domains TABLE
(
ItemPosition int IDENTITY(1,1),
DomainID int
)
INSERT INTO @Domains (DomainID)
SELECT
D.DomainID
FROM Domains AS D
INNER JOIN Packages AS P ON D.PackageID = P.PackageID
INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID
LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID
LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID
LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID
WHERE (D.IsInstantAlias = 0 AND D.IsDomainPointer = 0) AND
((@Recursive = 0 AND D.PackageID = @PackageID)
OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, D.PackageID) = 1))
AND (@ServerID = 0 OR (@ServerID > 0 AND S.ServerID = @ServerID))
'
IF @FilterColumn <> '' AND @FilterValue <> ''
SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue '
IF @SortColumn <> '' AND @SortColumn IS NOT NULL
SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' '
SET @sql = @sql + ' SELECT COUNT(DomainID) FROM @Domains;SELECT
D.DomainID,
D.PackageID,
D.ZoneItemID,
D.DomainItemID,
D.DomainName,
D.HostingAllowed,
ISNULL(WS.ItemID, 0) AS WebSiteID,
WS.ItemName AS WebSiteName,
ISNULL(MD.ItemID, 0) AS MailDomainID,
MD.ItemName AS MailDomainName,
D.IsSubDomain,
D.IsInstantAlias,
D.IsDomainPointer,
D.ExpirationDate,
D.LastUpdateDate,
D.RegistrarName,
P.PackageName,
ISNULL(SRV.ServerID, 0) AS ServerID,
ISNULL(SRV.ServerName, '''') AS ServerName,
ISNULL(SRV.Comments, '''') AS ServerComments,
ISNULL(SRV.VirtualServer, 0) AS VirtualServer,
P.UserID,
U.Username,
U.FirstName,
U.LastName,
U.FullName,
U.RoleID,
U.Email
FROM @Domains AS SD
INNER JOIN Domains AS D ON SD.DomainID = D.DomainID
INNER JOIN Packages AS P ON D.PackageID = P.PackageID
INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID
LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID
LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID
LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID
LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID
LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID
WHERE SD.ItemPosition BETWEEN @StartRow + 1 AND @StartRow + @MaximumRows'
exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @PackageID int, @FilterValue nvarchar(50), @ServerID int, @Recursive bit',
@StartRow, @MaximumRows, @PackageID, @FilterValue, @ServerID, @Recursive
RETURN
GO
IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetDomains')
DROP PROCEDURE GetDomains
GO
CREATE PROCEDURE [dbo].[GetDomains]
(
@ActorID int,
@PackageID int,
@Recursive bit = 1
)
AS
-- check rights
IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0
RAISERROR('You are not allowed to access this package', 16, 1)
SELECT
D.DomainID,
D.PackageID,
D.ZoneItemID,
D.DomainItemID,
D.DomainName,
D.HostingAllowed,
ISNULL(WS.ItemID, 0) AS WebSiteID,
WS.ItemName AS WebSiteName,
ISNULL(MD.ItemID, 0) AS MailDomainID,
MD.ItemName AS MailDomainName,
Z.ItemName AS ZoneName,
D.IsSubDomain,
D.IsInstantAlias,
D.CreationDate,
D.ExpirationDate,
D.LastUpdateDate,
D.IsDomainPointer,
D.RegistrarName
FROM Domains AS D
INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON D.PackageID = PT.PackageID
LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID
LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID
LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID
RETURN
GO

View file

@ -151,5 +151,6 @@ namespace WebsitePanel.EnterpriseServer
public DateTime? CreationDate { get; set; }
public DateTime? ExpirationDate { get; set; }
public DateTime? LastUpdateDate { get; set; }
public string RegistrarName { get; set; }
}
}

View file

@ -3256,6 +3256,18 @@ namespace WebsitePanel.EnterpriseServer
);
}
public static DataSet GetOrganizationObjectsByDomain(int itemId, string domainName)
{
return SqlHelper.ExecuteDataset(
ConnectionString,
CommandType.StoredProcedure,
"GetOrganizationObjectsByDomain",
new SqlParameter("@ItemID", itemId),
new SqlParameter("@DomainName", domainName)
);
}
#endregion
#region CRM
@ -4827,6 +4839,20 @@ namespace WebsitePanel.EnterpriseServer
);
}
public static void UpdateWhoisDomainInfo(int domainId, DateTime? domainCreationDate, DateTime? domainExpirationDate, DateTime? domainLastUpdateDate, string registrarName)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"UpdateWhoisDomainInfo",
new SqlParameter("@DomainId", domainId),
new SqlParameter("@DomainCreationDate", domainCreationDate),
new SqlParameter("@DomainExpirationDate", domainExpirationDate),
new SqlParameter("@DomainLastUpdateDate", domainLastUpdateDate),
new SqlParameter("@DomainRegistrarName", registrarName)
);
}
#endregion
}

View file

@ -507,6 +507,15 @@ namespace WebsitePanel.EnterpriseServer
}
}
public static bool CheckDomainUsedByHostedOrganization(int itemId, int domainId)
{
DomainInfo domain = ServerController.GetDomain(domainId);
if (domain == null)
return false;
return (DataProvider.CheckDomainUsedByHostedOrganization(domain.DomainName) == 1);
}
private static void DeleteOCSUsers(int itemId, ref bool successful)
{
try
@ -3080,5 +3089,10 @@ namespace WebsitePanel.EnterpriseServer
}
#endregion
public static DataSet GetOrganizationObjectsByDomain(int itemId, string domainName)
{
return DataProvider.GetOrganizationObjectsByDomain(itemId, domainName);
}
}
}

View file

@ -599,19 +599,26 @@ namespace WebsitePanel.EnterpriseServer
try
{
if (1 == 1)//(CheckRDSServerAvaliable(rdsServer.FqdName))
if (CheckRDSServerAvaliable(rdsServer.FqdName))
{
rdsServer.Id = DataProvider.AddRDSServer(rdsServer.Name, rdsServer.FqdName, rdsServer.Description);
}
else
{
result.AddError("", new Exception("The server that you are adding, is not available"));
result.AddError("REMOTE_DESKTOP_SERVICES_ADD_RDS_SERVER", new Exception("The server that you are adding, is not available"));
return result;
}
}
catch (Exception ex)
{
result.AddError("REMOTE_DESKTOP_SERVICES_ADD_RDS_SERVER", ex);
if (ex.InnerException != null)
{
result.AddError("Unable to add RDS Server", ex.InnerException);
}
else
{
result.AddError("Unable to add RDS Server", ex);
}
}
finally
{
@ -1167,18 +1174,12 @@ namespace WebsitePanel.EnterpriseServer
private static bool CheckRDSServerAvaliable(string hostname)
{
bool result = false;
try
{
var ping = new Ping();
var reply = ping.Send(hostname, 1000); // 1 second time out (in ms)
var reply = ping.Send(hostname, 1000);
if (reply.Status == IPStatus.Success)
result = true;
}
catch (Exception)
{
result = false;
result = true;
}
return result;

View file

@ -80,7 +80,7 @@ namespace WebsitePanel.EnterpriseServer
checkedDomains.Add(domain.DomainId);
ServerController.UpdateDomainRegistrationData(domain);
ServerController.UpdateDomainWhoisData(domain);
if (CheckDomainExpiration(domain.ExpirationDate, daysBeforeNotify))
{
@ -105,7 +105,7 @@ namespace WebsitePanel.EnterpriseServer
if (mainDomain != null)
{
ServerController.UpdateDomainRegistrationData(subDomain, mainDomain.CreationDate, mainDomain.ExpirationDate);
ServerController.UpdateDomainWhoisData(subDomain, mainDomain.CreationDate, mainDomain.ExpirationDate, mainDomain.RegistrarName);
var nonExistenDomain = nonExistenDomains.FirstOrDefault(x => subDomain.DomainId == x.DomainId);
@ -181,9 +181,13 @@ namespace WebsitePanel.EnterpriseServer
Hashtable items = new Hashtable();
items["user"] = user;
items["Domains"] = domains.Select(x => new { DomainName = x.DomainName,
ExpirationDate = x.ExpirationDate,
Customer = string.Format("{0} {1}", domainUsers[x.PackageId].FirstName, domainUsers[x.PackageId].LastName) });
ExpirationDate = x.ExpirationDate < DateTime.Now ? "Expired" : x.ExpirationDate.ToString(),
ExpirationDateOrdering = x.ExpirationDate,
Registrar = x.RegistrarName,
Customer = string.Format("{0} {1}", domainUsers[x.PackageId].FirstName, domainUsers[x.PackageId].LastName) })
.OrderBy(x => x.ExpirationDateOrdering).ThenBy(x => x.Customer).ThenBy(x => x.DomainName);
items["IncludeNonExistenDomains"] = includeNonExistenDomains;
@ -191,7 +195,7 @@ namespace WebsitePanel.EnterpriseServer
{
DomainName = x.DomainName,
Customer = string.Format("{0} {1}", domainUsers[x.PackageId].FirstName, domainUsers[x.PackageId].LastName)
});
}).OrderBy(x => x.Customer).ThenBy(x => x.DomainName);
body = PackageController.EvaluateTemplate(body, items);

View file

@ -23,9 +23,12 @@ namespace WebsitePanel.EnterpriseServer
private static readonly string MailBodyTemplateParameter = "MAIL_BODY";
private static readonly string MailBodyDomainRecordTemplateParameter = "MAIL_DOMAIN_RECORD";
private static readonly string ServerNameParameter = "SERVER_NAME";
private static readonly string PauseBetweenQueriesParameter = "PAUSE_BETWEEN_QUERIES";
private const string MxRecordPattern = @"mail exchanger = (.+)";
private const string NsRecordPattern = @"nameserver = (.+)";
private const string DnsTimeOutMessage = @"dns request timed out";
private const int DnsTimeOutRetryCount = 3;
public override void DoWork()
{
@ -38,6 +41,8 @@ namespace WebsitePanel.EnterpriseServer
string dnsServersString = (string)topTask.GetParamValue(DnsServersParameter);
string serverName = (string)topTask.GetParamValue(ServerNameParameter);
int pause;
// check input parameters
if (String.IsNullOrEmpty(dnsServersString))
{
@ -51,6 +56,13 @@ namespace WebsitePanel.EnterpriseServer
return;
}
if (!int.TryParse((string)topTask.GetParamValue(PauseBetweenQueriesParameter), out pause))
{
TaskManager.WriteWarning("The 'pause between queries' parameter is not valid.");
return;
}
// find server by name
ServerInfo server = ServerController.GetServerByName(serverName);
if (server == null)
@ -94,14 +106,16 @@ namespace WebsitePanel.EnterpriseServer
DomainDnsChanges domainChanges = new DomainDnsChanges();
domainChanges.DomainName = domain.DomainName;
domainChanges.PackageId = domain.PackageId;
domainChanges.Registrar = domain.RegistrarName;
domainChanges.ExpirationDate = domain.ExpirationDate;
var dbDnsRecords = ObjectUtils.CreateListFromDataReader<DnsRecordInfo>(DataProvider.GetDomainAllDnsRecords(domain.DomainId));
//execute server
foreach (var dnsServer in dnsServers)
{
var dnsMxRecords = GetDomainDnsRecords(winServer, domain.DomainName, dnsServer, DnsRecordType.MX);
var dnsNsRecords = GetDomainDnsRecords(winServer, domain.DomainName, dnsServer, DnsRecordType.NS);
var dnsMxRecords = GetDomainDnsRecords(winServer, domain.DomainName, dnsServer, DnsRecordType.MX, pause) ?? dbDnsRecords.Where(x => x.RecordType == DnsRecordType.MX).ToList();
var dnsNsRecords = GetDomainDnsRecords(winServer, domain.DomainName, dnsServer, DnsRecordType.NS, pause) ?? dbDnsRecords.Where(x => x.RecordType == DnsRecordType.NS).ToList();
FillRecordData(dnsMxRecords, domain, dnsServer);
FillRecordData(dnsNsRecords, domain, dnsServer);
@ -304,14 +318,29 @@ namespace WebsitePanel.EnterpriseServer
MailHelper.SendMessage(from, mailTo, bcc, subject, body, priority, isHtml);
}
public List<DnsRecordInfo> GetDomainDnsRecords(WindowsServer winServer, string domain, string dnsServer, DnsRecordType recordType)
public List<DnsRecordInfo> GetDomainDnsRecords(WindowsServer winServer, string domain, string dnsServer, DnsRecordType recordType, int pause)
{
Thread.Sleep(pause);
//nslookup -type=mx google.com 195.46.39.39
var command = "nslookup";
var args = string.Format("-type={0} {1} {2}", recordType, domain, dnsServer);
// execute system command
var raw = winServer.ExecuteSystemCommand(command, args);
var raw = string.Empty;
int triesCount = 0;
do
{
raw = winServer.ExecuteSystemCommand(command, args);
}
while (raw.ToLowerInvariant().Contains(DnsTimeOutMessage) && ++triesCount < DnsTimeOutRetryCount);
//timeout check
if (raw.ToLowerInvariant().Contains(DnsTimeOutMessage))
{
return null;
}
var records = ParseNsLookupResult(raw, dnsServer, recordType);

View file

@ -75,6 +75,12 @@ namespace WebsitePanel.EnterpriseServer
@"expires:(.+)" //.fi
};
private static List<string> _registrarNamePatterns = new List<string> {
@"Created by Registrar:(.+)",
@"Registrar:(.+)",
@"Registrant Name:(.+)"
};
private static List<string> _datePatterns = new List<string> { @"ddd MMM dd HH:mm:ss G\MT yyyy"
};
@ -1837,7 +1843,7 @@ namespace WebsitePanel.EnterpriseServer
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPSForPC, domain, "");
}
UpdateDomainRegistrationData(domain);
UpdateDomainWhoisData(domain);
}
// add instant alias
@ -2691,22 +2697,20 @@ namespace WebsitePanel.EnterpriseServer
}
}
public static DomainInfo UpdateDomainRegistrationData(DomainInfo domain)
public static DomainInfo UpdateDomainWhoisData(DomainInfo domain)
{
DateTime? createdDate = null;
DateTime? expiredDate = null;
try
{
var whoisResult = WhoisClient.Query(domain.DomainName.ToLowerInvariant());
createdDate = GetDomainInfoDate(whoisResult.Raw, _createdDatePatterns);
expiredDate = GetDomainInfoDate(whoisResult.Raw, _expiredDatePatterns);
string creationDateString = ParseWhoisDomainInfo(whoisResult.Raw, _createdDatePatterns);
string expirationDateString = ParseWhoisDomainInfo(whoisResult.Raw, _expiredDatePatterns);
domain.CreationDate = createdDate;
domain.ExpirationDate = expiredDate;
domain.CreationDate = ParseDate(creationDateString);
domain.ExpirationDate = ParseDate(expirationDateString);
domain.RegistrarName = ParseWhoisDomainInfo(whoisResult.Raw, _registrarNamePatterns);
DataProvider.UpdateDomainDates(domain.DomainId, createdDate, expiredDate, DateTime.Now);
DataProvider.UpdateWhoisDomainInfo(domain.DomainId, domain.CreationDate, domain.ExpirationDate, DateTime.Now, domain.RegistrarName);
}
catch (Exception e)
{
@ -2716,17 +2720,18 @@ namespace WebsitePanel.EnterpriseServer
return domain;
}
public static DomainInfo UpdateDomainRegistrationData(DomainInfo domain, DateTime? creationDate, DateTime? expirationDate)
public static DomainInfo UpdateDomainWhoisData(DomainInfo domain, DateTime? creationDate, DateTime? expirationDate, string registrarName)
{
DataProvider.UpdateDomainDates(domain.DomainId, creationDate, expirationDate, DateTime.Now);
DataProvider.UpdateWhoisDomainInfo(domain.DomainId, creationDate, expirationDate, DateTime.Now, registrarName);
domain.CreationDate = creationDate;
domain.ExpirationDate = expirationDate;
domain.RegistrarName = registrarName;
return domain;
}
private static DateTime? GetDomainInfoDate(string raw, IEnumerable<string> patterns)
private static string ParseWhoisDomainInfo(string raw, IEnumerable<string> patterns)
{
foreach (var createdRegex in patterns)
{
@ -2736,7 +2741,7 @@ namespace WebsitePanel.EnterpriseServer
{
if (match.Success && match.Groups.Count == 2)
{
return ParseDate(match.Groups[1].ToString().Trim());
return match.Groups[1].ToString().Trim();
}
}
}
@ -2746,6 +2751,11 @@ namespace WebsitePanel.EnterpriseServer
private static DateTime? ParseDate(string dateString)
{
if (string.IsNullOrEmpty(dateString))
{
return null;
}
var result = DateTime.MinValue;
foreach (var datePattern in _datePatterns)

View file

@ -158,6 +158,18 @@ namespace WebsitePanel.EnterpriseServer
return OrganizationController.SetOrganizationDefaultDomain(itemId, domainId);
}
[WebMethod]
public DataSet GetOrganizationObjectsByDomain(int itemId, string domainName)
{
return OrganizationController.GetOrganizationObjectsByDomain(itemId, domainName);
}
[WebMethod]
public bool CheckDomainUsedByHostedOrganization(int itemId, int domainId)
{
return OrganizationController.CheckDomainUsedByHostedOrganization(itemId, domainId);
}
#endregion
#region Users

View file

@ -8,6 +8,8 @@ namespace WebsitePanel.Providers.DomainLookup
public class DomainDnsChanges
{
public string DomainName { get; set; }
public string Registrar { get; set; }
public DateTime? ExpirationDate { get; set; }
public int PackageId { get; set; }
public List<DnsRecordInfoChange> DnsChanges { get; set; }

View file

@ -63,5 +63,6 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
bool CheckServerAvailability(string hostName);
string[] GetApplicationUsers(string collectionName, string applicationName);
bool SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users);
bool CheckRDSServerAvaliable(string hostname);
}
}

View file

@ -165,6 +165,20 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
return new string[]{};
}
public bool CheckRDSServerAvaliable(string hostname)
{
bool result = false;
var ping = new Ping();
var reply = ping.Send(hostname, 1000);
if (reply.Status == IPStatus.Success)
{
result = true;
}
return result;
}
#endregion
#region RDS Collections

View file

@ -69,6 +69,8 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
private System.Threading.SendOrPostCallback SetApplicationUsersOperationCompleted;
private System.Threading.SendOrPostCallback CheckRDSServerAvaliableOperationCompleted;
/// <remarks/>
public RemoteDesktopServices() {
this.Url = "http://localhost:9003/RemoteDesktopServices.asmx";
@ -134,6 +136,9 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
/// <remarks/>
public event SetApplicationUsersCompletedEventHandler SetApplicationUsersCompleted;
/// <remarks/>
public event CheckRDSServerAvaliableCompletedEventHandler CheckRDSServerAvaliableCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CreateCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
@ -1021,6 +1026,48 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CheckRDSServerAvaliable", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public bool CheckRDSServerAvaliable(string hostname) {
object[] results = this.Invoke("CheckRDSServerAvaliable", new object[] {
hostname});
return ((bool)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginCheckRDSServerAvaliable(string hostname, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("CheckRDSServerAvaliable", new object[] {
hostname}, callback, asyncState);
}
/// <remarks/>
public bool EndCheckRDSServerAvaliable(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((bool)(results[0]));
}
/// <remarks/>
public void CheckRDSServerAvaliableAsync(string hostname) {
this.CheckRDSServerAvaliableAsync(hostname, null);
}
/// <remarks/>
public void CheckRDSServerAvaliableAsync(string hostname, object userState) {
if ((this.CheckRDSServerAvaliableOperationCompleted == null)) {
this.CheckRDSServerAvaliableOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCheckRDSServerAvaliableOperationCompleted);
}
this.InvokeAsync("CheckRDSServerAvaliable", new object[] {
hostname}, this.CheckRDSServerAvaliableOperationCompleted, userState);
}
private void OnCheckRDSServerAvaliableOperationCompleted(object arg) {
if ((this.CheckRDSServerAvaliableCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.CheckRDSServerAvaliableCompleted(this, new CheckRDSServerAvaliableCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
@ -1436,4 +1483,30 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
public delegate void CheckRDSServerAvaliableCompletedEventHandler(object sender, CheckRDSServerAvaliableCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class CheckRDSServerAvaliableCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal CheckRDSServerAvaliableCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <remarks/>
public bool Result {
get {
this.RaiseExceptionIfNecessary();
return ((bool)(this.results[0]));
}
}
}
}

View file

@ -393,5 +393,22 @@ namespace WebsitePanel.Server
throw;
}
}
[WebMethod, SoapHeader("settings")]
public bool CheckRDSServerAvaliable(string hostname)
{
try
{
Log.WriteStart("'{0}' CheckRDSServerAvaliable", ProviderSettings.ProviderName);
var result = RDSProvider.CheckRDSServerAvaliable(hostname);
Log.WriteEnd("'{0}' CheckRDSServerAvaliable", ProviderSettings.ProviderName);
return result;
}
catch (Exception ex)
{
Log.WriteError(String.Format("'{0}' CheckRDSServerAvaliable", ProviderSettings.ProviderName), ex);
throw;
}
}
}
}

View file

@ -64,6 +64,7 @@
<Control key="domains" />
<Control key="add_domain" general_key="domains" />
<Control key="domain_records" general_key="domains" />
<Control key="check_domain" />
<Control key="storage_usage" />
<Control key="storage_usage_details" general_key="storage_usage" />

View file

@ -513,6 +513,7 @@
<Control key="org_domains" src="WebsitePanel/ExchangeServer/OrganizationDomainNames.ascx" title="OrganizationDomainNames" type="View" />
<Control key="org_add_domain" src="WebsitePanel/ExchangeServer/OrganizationAddDomainName.ascx" title="OrganizationAddDomainName" type="View" />
<Control key="add_domain" src="WebsitePanel/ExchangeServer/ExchangeAddDomainName.ascx" title="ExchangeAddDomainName" type="View" />
<Control key="check_domain" src="WebsitePanel/ExchangeServer/ExchangeCheckDomainName.ascx" title="ExchangeCheckDomainName" type="View" />
<Control key="domain_records" src="WebsitePanel/ExchangeServer/ExchangeDomainRecords.ascx" title="ExchangeDomainRecords" type="View" />
<Control key="storage_usage" src="WebsitePanel/ExchangeServer/ExchangeStorageUsage.ascx" title="ExchangeStorageUsage" type="View" />
<Control key="storage_usage_details" src="WebsitePanel/ExchangeServer/ExchangeStorageUsageBreakdown.ascx" title="ExchangeStorageUsageBreakdown" type="View" />

View file

@ -216,4 +216,7 @@
<data name="DomainLookup.TooltipHeader" xml:space="preserve">
<value>Current Real DNS Values</value>
</data>
<data name="DomainLookup.TooltipHeader.Registrar" xml:space="preserve">
<value>Registrar:</value>
</data>
</root>

View file

@ -38,12 +38,16 @@
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="gvDomainsExpirationDate">
<ItemStyle Width="15%"></ItemStyle>
<ItemStyle Width="11%"></ItemStyle>
<ItemTemplate>
<%# GetDomainExpirationDate(Eval("ExpirationDate"), Eval("LastUpdateDate"))%>
<div style="display:inline-block" runat="server" Visible='<%# ShowDomainDnsInfo(Eval("ExpirationDate"), Eval("LastUpdateDate"), !(bool)Eval("IsSubDomain") && !(bool)Eval("IsInstantAlias") && !(bool)Eval("IsDomainPointer")) %>'>
<img style="border-width: 0px;" src="App_Themes/Default/Images/information_icon_small.gif" title="<%# GetDomainDnsRecords((int)Eval("DomainId")) %>">
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<div style="display:inline-block" runat="server" Visible='<%# ShowDomainDnsInfo(Eval("ExpirationDate"), Eval("LastUpdateDate"), !(bool)Eval("IsSubDomain") && !(bool)Eval("IsInstantAlias") && !(bool)Eval("IsDomainPointer")) && !string.IsNullOrEmpty(GetDomainDnsRecords((int)Eval("DomainId"))) %>'>
<img style="border-width: 0px;" src="App_Themes/Default/Images/information_icon_small.gif" title="<%# GetDomainTooltip((int)Eval("DomainId"), Eval("RegistrarName") != DBNull.Value ? (string)Eval("RegistrarName"):string.Empty) %>">
</div>
</ItemTemplate>
</asp:TemplateField>

View file

@ -45,16 +45,20 @@ namespace WebsitePanel.Portal
{
public partial class Domains : WebsitePanelModuleBase
{
public Dictionary<int, string> dnsRecords;
protected void Page_Load(object sender, EventArgs e)
{
dnsRecords = new Dictionary<int, string>();
gvDomains.PageSize = UsersHelper.GetDisplayItemsPerPage();
// visibility
chkRecursive.Visible = (PanelSecurity.SelectedUser.Role != UserRole.User);
gvDomains.Columns[3].Visible = gvDomains.Columns[3].Visible =
gvDomains.Columns[4].Visible = gvDomains.Columns[5].Visible =
(PanelSecurity.SelectedUser.Role != UserRole.User) && chkRecursive.Checked;
gvDomains.Columns[5].Visible = (PanelSecurity.SelectedUser.Role == UserRole.Administrator);
gvDomains.Columns[6].Visible = (PanelSecurity.EffectiveUser.Role == UserRole.Administrator);
gvDomains.Columns[6].Visible = (PanelSecurity.SelectedUser.Role == UserRole.Administrator);
gvDomains.Columns[7].Visible = (PanelSecurity.EffectiveUser.Role == UserRole.Administrator);
if (!IsPostBack)
{
@ -154,11 +158,18 @@ namespace WebsitePanel.Portal
public string GetDomainDnsRecords(int domainId)
{
if(dnsRecords.ContainsKey(domainId))
{
return dnsRecords[domainId];
}
var records = ES.Services.Servers.GetDomainDnsRecords(domainId);
if (!records.Any())
{
return "No Dns Records";
dnsRecords.Add(domainId, string.Empty);
return string.Empty;
}
var header = GetLocalizedString("DomainLookup.TooltipHeader");
@ -169,7 +180,25 @@ namespace WebsitePanel.Portal
tooltipLines.Add(" ");
tooltipLines.AddRange( records.Select(x=>string.Format("{0}: {1}", x.RecordType, x.Value)));
return string.Join("\r\n", tooltipLines);
dnsRecords.Add(domainId, string.Join("\r\n", tooltipLines));
return dnsRecords[domainId];
}
public string GetDomainTooltip(int domainId, string registrar)
{
var dnsString = GetDomainDnsRecords(domainId);
var tooltipLines = new List<string>();
if (!string.IsNullOrEmpty(registrar))
{
var header = GetLocalizedString("DomainLookup.TooltipHeader.Registrar");
tooltipLines.Add(header + " " + registrar);
tooltipLines.Add("\r\n");
}
return string.Join("\r\n", tooltipLines) + dnsString;
}
protected void odsDomainsPaged_Selected(object sender, ObjectDataSourceStatusEventArgs e)

View file

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="locTitle.Text" xml:space="preserve">
<value>Domain Dependencies</value>
</data>
<data name="Text.PageName" xml:space="preserve">
<value>Domain Dependencies</value>
</data>
<data name="gvObjectsDisplayName.Header" xml:space="preserve">
<value>Display Name</value>
</data>
<data name="TopComments.Text" xml:space="preserve">
<value>Objects listed Below are dependent on this domain and must be removed prior to domain</value>
</data>
<data name="Contact.Text" xml:space="preserve">
<value>Contact</value>
</data>
<data name="DefaultSecurityGroup.Text" xml:space="preserve">
<value>Security group</value>
</data>
<data name="DistributionList.Text" xml:space="preserve">
<value>Distribution list</value>
</data>
<data name="Equipment.Text" xml:space="preserve">
<value>Equipment</value>
</data>
<data name="ExchangeAccountEmailAddresses.Text" xml:space="preserve">
<value>Email address</value>
</data>
<data name="gvObjectsDelete.Header" xml:space="preserve">
<value>Delete</value>
</data>
<data name="gvObjectsObjectType.Header" xml:space="preserve">
<value>Object Type</value>
</data>
<data name="gvObjectsView.Header" xml:space="preserve">
<value>View</value>
</data>
<data name="lnkDelete.Text" xml:space="preserve">
<value>Delete</value>
</data>
<data name="lnkView.Text" xml:space="preserve">
<value>View</value>
</data>
<data name="Mailbox.Text" xml:space="preserve">
<value>Mailbox</value>
</data>
<data name="PublicFolder.Text" xml:space="preserve">
<value>Public folder</value>
</data>
<data name="Room.Text" xml:space="preserve">
<value>Room</value>
</data>
<data name="SecurityGroup.Text" xml:space="preserve">
<value>Security group</value>
</data>
<data name="SharedMailbox.Text" xml:space="preserve">
<value>Shared mailbox</value>
</data>
<data name="User.Text" xml:space="preserve">
<value>Organization user</value>
</data>
<data name="LyncUsers.Text" xml:space="preserve">
<value>Lync User</value>
</data>
</root>

View file

@ -0,0 +1,81 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ExchangeCheckDomainName.ascx.cs" Inherits="WebsitePanel.Portal.ExchangeServer.ExchangeCheckDomainName" %>
<%@ Register Src="../UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" TagPrefix="wsp" %>
<%@ Register Src="../UserControls/QuotaViewer.ascx" TagName="QuotaViewer" TagPrefix="wsp" %>
<%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %>
<wsp:EnableAsyncTasksSupport id="asyncTasks" runat="server"/>
<div id="ExchangeContainer">
<div class="Module">
<div class="Left">
</div>
<div class="Content">
<div class="Center">
<div class="Title">
<asp:Image ID="Image1" SkinID="ExchangeDomainName48" runat="server" />
<asp:Localize ID="locTitle" runat="server" meta:resourcekey="locTitle" Text="Domain Names"></asp:Localize>
-
<asp:Literal ID="litDomainName" runat="server"></asp:Literal>
</div>
<asp:Literal ID="TopComments" runat="server" meta:resourcekey="TopComments"></asp:Literal>
<div class="FormBody">
<wsp:SimpleMessageBox id="messageBox" runat="server" />
<br />
<asp:GridView ID="gvObjects" runat="server" AutoGenerateColumns="False" EnableViewState="true"
Width="100%" CssSelectorClass="NormalGridView" OnRowCommand="gvObjects_RowCommand">
<Columns>
<asp:TemplateField HeaderText="gvObjectsDisplayName">
<ItemStyle Width="40%"></ItemStyle>
<ItemTemplate>
<asp:Image ID="img1" runat="server" ImageUrl='<%# GetObjectImage(Eval("ObjectName").ToString(),(int)Eval("ObjectType")) %>' ImageAlign="AbsMiddle" />
<asp:hyperlink id="lnk1" runat="server"
NavigateUrl='<%# GetEditUrl(Eval("ObjectName").ToString(),(int)Eval("ObjectType"),Eval("ObjectID").ToString(),Eval("OwnerID").ToString()) %>'>
<%# Eval("DisplayName") %>
</asp:hyperlink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="gvObjectsObjectType">
<ItemStyle Width="40%"></ItemStyle>
<ItemTemplate>
<%# GetObjectType(Eval("ObjectName").ToString(),(int)Eval("ObjectType")) %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="gvObjectsView">
<ItemStyle Width="10%"></ItemStyle>
<ItemTemplate>
<asp:hyperlink id="lnk2" runat="server"
NavigateUrl='<%# GetEditUrl(Eval("ObjectName").ToString(),(int)Eval("ObjectType"),Eval("ObjectID").ToString(),Eval("OwnerID").ToString()) %>'>
<asp:Literal id="lnkView" runat="server" Text="View" meta:resourcekey="lnkView" />
</asp:hyperlink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="gvObjectsDelete">
<ItemStyle Width="10%"></ItemStyle>
<ItemTemplate>
<asp:LinkButton id="lnkDelete" runat="server" Text="Delete" meta:resourcekey="lnkDelete"
OnClientClick="if(!confirm('Are you sure you want to delete ?')) return false; else ShowProgressDialog('Deleting ...');"
CommandName="DeleteItem" CommandArgument='<%# Eval("OwnerID").ToString() + "," + Eval("ObjectType").ToString() + "," + Eval("DisplayName") %>'
Visible='<%# AllowDelete(Eval("ObjectName").ToString(), (int)Eval("ObjectType")) %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Button id="btnBack" runat="server" Text="Back" CssClass="Button1" meta:resourcekey="btnBack"
OnClick="btnBack_Click" ></asp:Button>
</div>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,282 @@
// Copyright (c) 2014, 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.Web.UI.WebControls;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Providers.HostedSolution;
namespace WebsitePanel.Portal.ExchangeServer
{
public partial class ExchangeCheckDomainName : WebsitePanelModuleBase
{
private static string EXCHANGEACCOUNTEMAILADDRESSES = "ExchangeAccountEmailAddresses";
private static string EXCHANGEACCOUNTS = "ExchangeAccounts";
private static string LYNCUSERS = "LyncUsers";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// save return URL
if (Request.UrlReferrer!=null)
ViewState["ReturnUrl"] = Request.UrlReferrer.ToString();
// domain name
DomainInfo domain = ES.Services.Servers.GetDomain(PanelRequest.DomainID);
litDomainName.Text = domain.DomainName;
Bind();
}
}
public string GetObjectType(string objectName, int objectType)
{
if (objectName == EXCHANGEACCOUNTS)
{
ExchangeAccountType accountType = (ExchangeAccountType)objectType;
objectName = accountType.ToString();
}
string res = GetLocalizedString(objectName+".Text");
if (string.IsNullOrEmpty(res))
res = objectName;
return res;
}
public bool AllowDelete(string objectName, int objectType)
{
if (objectName == EXCHANGEACCOUNTEMAILADDRESSES)
{
ExchangeAccountType accountType = (ExchangeAccountType)objectType;
switch (accountType)
{
case ExchangeAccountType.Room:
case ExchangeAccountType.Equipment:
case ExchangeAccountType.SharedMailbox:
case ExchangeAccountType.Mailbox:
case ExchangeAccountType.DistributionList:
case ExchangeAccountType.PublicFolder:
return true;
}
}
return false;
}
public string GetObjectImage(string objectName, int objectType)
{
string imgName = "blank16.gif";
if (objectName == EXCHANGEACCOUNTS)
{
ExchangeAccountType accountType = (ExchangeAccountType)objectType;
imgName = "mailbox_16.gif";
switch(accountType)
{
case ExchangeAccountType.Contact:
imgName = "contact_16.gif";
break;
case ExchangeAccountType.DistributionList:
imgName = "dlist_16.gif";
break;
case ExchangeAccountType.Room:
imgName = "room_16.gif";
break;
case ExchangeAccountType.Equipment:
imgName = "equipment_16.gif";
break;
case ExchangeAccountType.SharedMailbox:
imgName = "shared_16.gif";
break;
}
}
else if (objectName == EXCHANGEACCOUNTEMAILADDRESSES)
{
imgName = "mailbox_16.gif";
}
return GetThemedImage("Exchange/" + imgName);
}
public string GetEditUrl(string objectName, int objectType, string objectId, string ownerId)
{
if (objectName == EXCHANGEACCOUNTS)
{
string key = "";
ExchangeAccountType accountType = (ExchangeAccountType)objectType;
switch (accountType)
{
case ExchangeAccountType.User:
key = "edit_user";
return EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), key,
"AccountID=" + objectId,
"ItemID=" + PanelRequest.ItemID, "context=user");
case ExchangeAccountType.Mailbox:
case ExchangeAccountType.Room:
case ExchangeAccountType.Equipment:
case ExchangeAccountType.SharedMailbox:
key = "mailbox_settings";
break;
case ExchangeAccountType.DistributionList:
key = "dlist_settings";
break;
case ExchangeAccountType.PublicFolder:
key = "public_folder_settings";
break;
case ExchangeAccountType.SecurityGroup:
case ExchangeAccountType.DefaultSecurityGroup:
key = "secur_group_settings";
break;
}
if (!string.IsNullOrEmpty(key))
{
return EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), key,
"AccountID=" + objectId,
"ItemID=" + PanelRequest.ItemID);
}
}
if (objectName == EXCHANGEACCOUNTEMAILADDRESSES)
{
string key = "";
ExchangeAccountType accountType = (ExchangeAccountType)objectType;
switch (accountType)
{
case ExchangeAccountType.Mailbox:
case ExchangeAccountType.Room:
case ExchangeAccountType.Equipment:
case ExchangeAccountType.SharedMailbox:
key = "mailbox_addresses";
break;
case ExchangeAccountType.DistributionList:
key = "dlist_addresses";
break;
case ExchangeAccountType.PublicFolder:
key = "public_folder_addresses";
break;
}
if (!string.IsNullOrEmpty(key))
{
return EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), key,
"AccountID=" + ownerId,
"ItemID=" + PanelRequest.ItemID);
}
}
if (objectName == LYNCUSERS)
{
return EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "edit_lync_user",
"AccountID=" + objectId,
"ItemID=" + PanelRequest.ItemID);
}
return "";
}
private void Bind()
{
DomainInfo domain = ES.Services.Servers.GetDomain(PanelRequest.DomainID);
gvObjects.DataSource =
ES.Services.Organizations.GetOrganizationObjectsByDomain(PanelRequest.ItemID, domain.DomainName);
gvObjects.DataBind();
}
protected void btnBack_Click(object sender, EventArgs e)
{
if (ViewState["ReturnUrl"] != null)
Response.Redirect((string)ViewState["ReturnUrl"]);
}
protected void gvObjects_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DeleteItem")
{
try
{
string[] arg = e.CommandArgument.ToString().Split(',');
if (arg.Length != 3) return;
string[] emails = { arg[2] };
int accountID = 0;
if (!int.TryParse(arg[0], out accountID))
return;
int accountTypeID = 0;
if (!int.TryParse(arg[1], out accountTypeID))
return;
ExchangeAccountType accountType = (ExchangeAccountType)accountTypeID;
int result;
switch(accountType)
{
case ExchangeAccountType.Room:
case ExchangeAccountType.Equipment:
case ExchangeAccountType.SharedMailbox:
case ExchangeAccountType.Mailbox:
result = ES.Services.ExchangeServer.DeleteMailboxEmailAddresses(
PanelRequest.ItemID, accountID, emails);
break;
case ExchangeAccountType.DistributionList:
result = ES.Services.ExchangeServer.DeleteDistributionListEmailAddresses(
PanelRequest.ItemID, accountID, emails);
break;
case ExchangeAccountType.PublicFolder:
result = ES.Services.ExchangeServer.DeletePublicFolderEmailAddresses(
PanelRequest.ItemID, accountID, emails);
break;
}
Bind();
}
catch (Exception ex)
{
}
}
}
}
}

View file

@ -0,0 +1,87 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WebsitePanel.Portal.ExchangeServer {
public partial class ExchangeCheckDomainName {
/// <summary>
/// asyncTasks control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.EnableAsyncTasksSupport asyncTasks;
/// <summary>
/// Image1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Image Image1;
/// <summary>
/// locTitle control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Localize locTitle;
/// <summary>
/// litDomainName control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litDomainName;
/// <summary>
/// TopComments control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal TopComments;
/// <summary>
/// messageBox control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.UserControls.SimpleMessageBox messageBox;
/// <summary>
/// gvObjects control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvObjects;
/// <summary>
/// btnBack control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnBack;
}
}

View file

@ -30,7 +30,7 @@
<ItemStyle Width="50%"></ItemStyle>
<ItemTemplate>
<asp:hyperlink id="lnkEditZone" runat="server" EnableViewState="false"
NavigateUrl='<%# GetDomainRecordsEditUrl(Eval("DomainID").ToString()) %>' Enabled='<%# !(bool)Eval("IsHost") %>'>
NavigateUrl='<%# GetDomainRecordsEditUrl(Eval("DomainID").ToString()) %>' Enabled="true">
<%# Eval("DomainName") %>
</asp:hyperlink>
</ItemTemplate>
@ -59,8 +59,12 @@
<asp:TemplateField>
<ItemTemplate>
&nbsp;<asp:ImageButton ID="imgDelDomain" runat="server" Text="Delete" SkinID="ExchangeDelete"
CommandName="DeleteItem" CommandArgument='<%# Eval("DomainId") %>' Visible='<%# !((bool)Eval("IsHost") || (bool)Eval("IsDefault")) %>'
meta:resourcekey="cmdDelete" OnClientClick="return confirm('Are you sure you want to delete selected domain?')"></asp:ImageButton>
CommandName="DeleteItem" CommandArgument='<%# Eval("DomainId") %>' Visible='<%# ((!(bool)Eval("IsDefault"))) && (!CheckDomainUsedByHostedOrganization(Eval("DomainID").ToString())) %>'
meta:resourcekey="cmdDelete" OnClientClick="return confirm('Are you sure you want to delete selected domain?')"
/>
&nbsp;<asp:LinkButton ID="lnkViewUsage" runat="server" Text="View Usage" Visible='<%# CheckDomainUsedByHostedOrganization(Eval("DomainID").ToString()) %>'
CommandName="ViewUsage" CommandArgument='<%# Eval("DomainId") %>'
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>

View file

@ -65,6 +65,14 @@ namespace WebsitePanel.Portal.ExchangeServer
"ItemID=" + PanelRequest.ItemID);
}
public bool CheckDomainUsedByHostedOrganization(string domainId)
{
int id;
if (!int.TryParse(domainId, out id)) return false;
return ES.Services.Organizations.CheckDomainUsedByHostedOrganization(PanelRequest.ItemID, id);
}
private void BindDomainNames()
{
OrganizationDomainName[] list = ES.Services.Organizations.GetOrganizationDomains(PanelRequest.ItemID);
@ -103,7 +111,9 @@ namespace WebsitePanel.Portal.ExchangeServer
int result = ES.Services.Organizations.DeleteOrganizationDomain(PanelRequest.ItemID, domainId);
if (result < 0)
{
messageBox.ShowErrorMessage("EXCHANGE_UNABLE_TO_DELETE_DOMAIN");
Response.Redirect(EditUrl("ItemID", PanelRequest.ItemID.ToString(), "check_domain",
"SpaceID=" + PanelSecurity.PackageId, "DomainID=" + domainId));
return;
}
// rebind domains
@ -147,6 +157,14 @@ namespace WebsitePanel.Portal.ExchangeServer
ShowErrorMessage("EXCHANGE_CHANGE_DOMAIN", ex);
}
}
if (e.CommandName == "ViewUsage")
{
int domainId = Utils.ParseInt(e.CommandArgument.ToString(), 0);
Response.Redirect(EditUrl("ItemID", PanelRequest.ItemID.ToString(), "check_domain",
"SpaceID=" + PanelSecurity.PackageId, "DomainID=" + domainId));
return;
}
}
protected void btnSetDefaultDomain_Click(object sender, EventArgs e)

View file

@ -30,7 +30,7 @@
<ItemStyle Width="50%"></ItemStyle>
<ItemTemplate>
<asp:hyperlink id="lnkEditZone" runat="server" EnableViewState="false"
NavigateUrl='<%# GetDomainRecordsEditUrl(Eval("DomainID").ToString()) %>' Enabled='<%# !(bool)Eval("IsHost") %>'>
NavigateUrl='<%# GetDomainRecordsEditUrl(Eval("DomainID").ToString()) %>' Enabled="true">
<%# Eval("DomainName") %>
</asp:hyperlink>
</ItemTemplate>
@ -45,7 +45,7 @@
<asp:TemplateField>
<ItemTemplate>
&nbsp;<asp:ImageButton ID="imgDelDomain" runat="server" Text="Delete" SkinID="ExchangeDelete"
CommandName="DeleteItem" CommandArgument='<%# Eval("DomainId") %>' Visible='<%# !((bool)Eval("IsHost") || (bool)Eval("IsDefault")) %>'
CommandName="DeleteItem" CommandArgument='<%# Eval("DomainId") %>' Visible='<%# !((bool)Eval("IsDefault")) %>'
meta:resourcekey="cmdDelete" OnClientClick="return confirm('Are you sure you want to delete selected domain?')"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateField>

View file

@ -103,7 +103,9 @@ namespace WebsitePanel.Portal.ExchangeServer
int result = ES.Services.Organizations.DeleteOrganizationDomain(PanelRequest.ItemID, domainId);
if (result < 0)
{
messageBox.ShowErrorMessage("EXCHANGE_UNABLE_TO_DELETE_DOMAIN");
Response.Redirect(EditUrl("ItemID", PanelRequest.ItemID.ToString(), "check_domain",
"SpaceID=" + PanelSecurity.PackageId, "DomainID=" + domainId));
return;
}
// rebind domains

View file

@ -68,7 +68,6 @@
<asp:LinkButton ID="imgRemove1" runat="server" Text="Remove" Visible='<%# Eval("RdsCollectionId") == null %>'
CommandName="DeleteItem" CommandArgument='<%# Eval("Id") %>'
meta:resourcekey="cmdDelete" OnClientClick="return confirm('Are you sure you want to remove selected server?')"></asp:LinkButton>
<asp:Label ID="lbRemove" Text="Remove" runat="server" Visible='<%# Eval("RdsCollectionId") != null %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>

View file

@ -41,6 +41,8 @@ namespace WebsitePanel.Portal.RDS
protected void Page_Load(object sender, EventArgs e)
{
remoreApps.Module = Module;
if (!IsPostBack)
{
RdsCollection collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID);
@ -48,7 +50,7 @@ namespace WebsitePanel.Portal.RDS
locCName.Text = collection.Name;
remoreApps.SetApps(collectionApps, Module);
remoreApps.SetApps(collectionApps);
}
}

View file

@ -43,16 +43,16 @@
<Columns>
<asp:BoundField DataField="Name" HtmlEncode="true" SortExpression="Name" HeaderText="Server name">
<HeaderStyle Wrap="false" />
<ItemStyle Wrap="False" Width="35%"/>
<ItemStyle Wrap="False" Width="25%"/>
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="IP Address"><ItemStyle Width="20%"/></asp:BoundField>
<asp:BoundField DataField="ItemName" HeaderText="Organization"><ItemStyle Width="35%"/></asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="IP Address"><ItemStyle Width="15%"/></asp:BoundField>
<asp:BoundField DataField="ItemName" HeaderText="Organization"><ItemStyle Width="20%"/></asp:BoundField>
<asp:BoundField DataField="Description" HeaderText="Comments"><ItemStyle Width="30%"/></asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkRemove" runat="server" Text="Remove" Visible='<%# Eval("ItemId") == null %>'
CommandName="DeleteItem" CommandArgument='<%# Eval("Id") %>'
meta:resourcekey="cmdDelete" OnClientClick="return confirm('Are you sure you want to delete selected rds server?')"></asp:LinkButton>
<asp:Label ID="lbRemove" Text="Remove" runat="server" Visible='<%# Eval("ItemId") != null %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>

View file

@ -21,7 +21,6 @@
<td class="FormLabel150"><asp:Localize ID="locServerComments" runat="server" meta:resourcekey="locServerComments" Text="Server Comments:"></asp:Localize></td>
<td>
<asp:TextBox ID="txtServerComments" runat="server" CssClass="NormalTextBox" Width="145px"></asp:TextBox>
<asp:RequiredFieldValidator ID="valServerComments" runat="server" ErrorMessage="*" ControlToValidate="txtServerComments"></asp:RequiredFieldValidator>
</td>
</tr>
</table>

View file

@ -75,15 +75,6 @@ namespace WebsitePanel.Portal {
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtServerComments;
/// <summary>
/// valServerComments control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator valServerComments;
/// <summary>
/// btnAdd control.
/// </summary>

View file

@ -79,6 +79,15 @@ namespace WebsitePanel.Portal.ScheduleTaskControls.App_LocalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Pause between queries (ms):.
/// </summary>
internal static string lblPause {
get {
return ResourceManager.GetString("lblPause", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Server Name:.
/// </summary>

View file

@ -123,6 +123,9 @@
<data name="lblDnsServersHint" xml:space="preserve">
<value>Please enter dns servers to check.</value>
</data>
<data name="lblPause" xml:space="preserve">
<value>Pause between queries (ms):</value>
</data>
<data name="lblServerName" xml:space="preserve">
<value>Server Name:</value>
</data>

View file

@ -25,4 +25,12 @@
<asp:TextBox ID="txtMailTo" runat="server" Width="95%" CssClass="NormalTextBox" MaxLength="1000"></asp:TextBox>
</td>
</tr>
<tr>
<td class="SubHead" nowrap>
<asp:Label ID="lblPause" runat="server" meta:resourcekey="lblPause" Text="Pause between queries (ms):"></asp:Label>
</td>
<td class="Normal" width="100%">
<asp:TextBox ID="txtPause" runat="server" Width="95%" CssClass="NormalTextBox" MaxLength="1000"></asp:TextBox>
</td>
</tr>
</table>

View file

@ -14,6 +14,7 @@ namespace WebsitePanel.Portal.ScheduleTaskControls
private static readonly string DnsServersParameter = "DNS_SERVERS";
private static readonly string MailToParameter = "MAIL_TO";
private static readonly string ServerNameParameter = "SERVER_NAME";
private static readonly string PauseBetweenQueriesParameter = "PAUSE_BETWEEN_QUERIES";
protected void Page_Load(object sender, EventArgs e)
{
@ -30,6 +31,7 @@ namespace WebsitePanel.Portal.ScheduleTaskControls
this.SetParameter(this.txtDnsServers, DnsServersParameter);
this.SetParameter(this.txtMailTo, MailToParameter);
this.SetParameter(this.txtPause, PauseBetweenQueriesParameter);
this.SetParameter(this.ddlServers, ServerNameParameter);
var servers = ES.Services.Servers.GetAllServers();
@ -68,8 +70,9 @@ namespace WebsitePanel.Portal.ScheduleTaskControls
ScheduleTaskParameterInfo dnsServers = this.GetParameter(this.txtDnsServers, DnsServersParameter);
ScheduleTaskParameterInfo mailTo = this.GetParameter(this.txtMailTo, MailToParameter);
ScheduleTaskParameterInfo serverName = this.GetParameter(this.ddlServers, ServerNameParameter);
ScheduleTaskParameterInfo pause = this.GetParameter(this.txtPause, PauseBetweenQueriesParameter);
return new ScheduleTaskParameterInfo[3] { dnsServers, mailTo, serverName };
return new ScheduleTaskParameterInfo[4] { dnsServers, mailTo, serverName, pause };
}
}
}

View file

@ -65,5 +65,23 @@ namespace WebsitePanel.Portal.ScheduleTaskControls {
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtMailTo;
/// <summary>
/// lblPause control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblPause;
/// <summary>
/// txtPause control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtPause;
}
}

View file

@ -185,6 +185,9 @@ namespace WebsitePanel.Portal
private void BindControls()
{
try
{
// hide database server parameters
DeploymentParameterWellKnownTag hiddenTags =
DeploymentParameterWellKnownTag.IisApp |
@ -238,21 +241,22 @@ namespace WebsitePanel.Portal
{
// Text value
TextControl.Visible = true;
textValue.Text = DefaultValue;
valPrefix.Text = ValuePrefix;
valSuffix.Text = ValueSuffix;
textValue.Text = DefaultValue == null ? "" : DefaultValue;
valPrefix.Text = ValuePrefix == null ? "" : ValuePrefix;
valSuffix.Text = ValueSuffix == null ? "" : ValueSuffix;
if (
(WellKnownTags & DeploymentParameterWellKnownTag.MySql) == DeploymentParameterWellKnownTag.MySql
(ValuePrefix != null) && (ValueSuffix != null)
&&
(WellKnownTags & DeploymentParameterWellKnownTag.DBUserName) == DeploymentParameterWellKnownTag.DBUserName
((WellKnownTags & DeploymentParameterWellKnownTag.MySql) == DeploymentParameterWellKnownTag.MySql)
&&
((WellKnownTags & DeploymentParameterWellKnownTag.DBUserName) == DeploymentParameterWellKnownTag.DBUserName)
)
{
MysqlUsernameLengthValidator.Enabled = true;
}
}
// enforce validation for database parameters if they are allowed empty by app pack developers
bool isDatabaseParameter = (WellKnownTags & (
DeploymentParameterWellKnownTag.DBName |
@ -284,6 +288,9 @@ namespace WebsitePanel.Portal
String.Format(GetLocalizedString("RegexpValidator.Text"), FriendlyName, ValidationString);
}
catch { } // just skip
}
protected void mysqlUsernameLen_OnServerValidate(object source, ServerValidateEventArgs args)

View file

@ -211,6 +211,13 @@
<Compile Include="Code\ReportingServices\IResourceStorage.cs" />
<Compile Include="Code\ReportingServices\ReportingServicesUtils.cs" />
<Compile Include="Code\UserControls\Tab.cs" />
<Compile Include="ExchangeServer\ExchangeCheckDomainName.ascx.cs">
<DependentUpon>ExchangeCheckDomainName.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="ExchangeServer\ExchangeCheckDomainName.ascx.designer.cs">
<DependentUpon>ExchangeCheckDomainName.ascx</DependentUpon>
</Compile>
<Compile Include="ProviderControls\Windows2012_Settings.ascx.cs">
<DependentUpon>Windows2012_Settings.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@ -4291,6 +4298,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="ApplyEnableHardQuotaFeature.ascx" />
<Content Include="ExchangeServer\ExchangeCheckDomainName.ascx" />
<Content Include="ProviderControls\Windows2012_Settings.ascx" />
<Content Include="RDSServersAddserver.ascx" />
<Content Include="RDSServers.ascx" />
@ -4315,6 +4323,9 @@
<Content Include="RDS\App_LocalResources\RDSEditApplicationUsers.ascx.resx">
<SubType>Designer</SubType>
</Content>
<Content Include="ExchangeServer\App_LocalResources\ExchangeCheckDomainName.ascx.resx">
<SubType>Designer</SubType>
</Content>
<EmbeddedResource Include="ScheduleTaskControls\App_LocalResources\DomainLookupView.ascx.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>DomainLookupView.ascx.Designer.cs</LastGenOutput>