This commit is contained in:
vfedosevich 2015-01-16 05:21:33 -08:00
commit 15ff62dbab
2951 changed files with 72429 additions and 7413 deletions

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -75,4 +75,4 @@ namespace WebsitePanel.EnterpriseServer
}
#endregion
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -235,4 +235,4 @@ namespace WebsitePanel.EnterpriseServer {
public class NullIPAddress { }
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -2223,4 +2223,4 @@ namespace WebsitePanel.EnterpriseServer
}
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -681,4 +681,4 @@ namespace WebsitePanel.EnterpriseServer
#endregion
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -246,4 +246,4 @@ namespace WebsitePanel.EnterpriseServer
return 0;
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -170,4 +170,4 @@ namespace WebsitePanel.EnterpriseServer
}
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -36,6 +36,8 @@ using Microsoft.ApplicationBlocks.Data;
using System.Collections.Generic;
using Microsoft.Win32;
using WebsitePanel.Providers.RemoteDesktopServices;
using WebsitePanel.Providers.DNS;
using WebsitePanel.Providers.DomainLookup;
namespace WebsitePanel.EnterpriseServer
{
@ -1578,7 +1580,7 @@ namespace WebsitePanel.EnterpriseServer
public static DataSet UpdatePackage(int actorId, int packageId, int planId, string packageName,
string packageComments, int statusId, DateTime purchaseDate,
bool overrideQuotas, string quotasXml)
bool overrideQuotas, string quotasXml, bool defaultTopPackage)
{
return SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure,
ObjectQualifier + "UpdatePackage",
@ -1590,7 +1592,8 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@planId", planId),
new SqlParameter("@purchaseDate", purchaseDate),
new SqlParameter("@overrideQuotas", overrideQuotas),
new SqlParameter("@quotasXml", quotasXml));
new SqlParameter("@quotasXml", quotasXml),
new SqlParameter("@defaultTopPackage", defaultTopPackage));
}
public static void UpdatePackageName(int actorId, int packageId, string packageName,
@ -1908,9 +1911,9 @@ namespace WebsitePanel.EnterpriseServer
public static IDataReader GetProcessBackgroundTasks(BackgroundTaskStatus status)
{
return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure,
ObjectQualifier + "GetProcessBackgroundTasks",
new SqlParameter("@status", (int)status));
return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure,
ObjectQualifier + "GetProcessBackgroundTasks",
new SqlParameter("@status", (int)status));
}
public static IDataReader GetBackgroundTopTask(Guid guid)
@ -2681,6 +2684,17 @@ namespace WebsitePanel.EnterpriseServer
);
}
public static IDataReader GetExchangeAccountByAccountNameWithoutItemId(string primaryEmailAddress)
{
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"GetExchangeAccountByAccountNameWithoutItemId",
new SqlParameter("@PrimaryEmailAddress", primaryEmailAddress)
);
}
public static IDataReader GetExchangeMailboxes(int itemId)
{
return SqlHelper.ExecuteReader(
@ -3294,6 +3308,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
@ -4524,7 +4550,7 @@ namespace WebsitePanel.EnterpriseServer
);
}
public static int AddRDSCollection(int itemId, string name, string description)
public static int AddRDSCollection(int itemId, string name, string description, string displayName)
{
SqlParameter rdsCollectionId = new SqlParameter("@RDSCollectionID", SqlDbType.Int);
rdsCollectionId.Direction = ParameterDirection.Output;
@ -4536,7 +4562,8 @@ namespace WebsitePanel.EnterpriseServer
rdsCollectionId,
new SqlParameter("@ItemID", itemId),
new SqlParameter("@Name", name),
new SqlParameter("@Description", description)
new SqlParameter("@Description", description),
new SqlParameter("DisplayName", displayName)
);
// read identity
@ -4557,12 +4584,40 @@ namespace WebsitePanel.EnterpriseServer
return Convert.ToInt32(count.Value);
}
public static void UpdateRDSCollection(RdsCollection collection)
public static int GetOrganizationRdsCollectionsCount(int itemId)
{
UpdateRDSCollection(collection.Id, collection.ItemId, collection.Name, collection.Description);
SqlParameter count = new SqlParameter("@TotalNumber", SqlDbType.Int);
count.Direction = ParameterDirection.Output;
DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure,
ObjectQualifier + "GetOrganizationRdsCollectionsCount",
count,
new SqlParameter("@ItemId", itemId));
// read identity
return Convert.ToInt32(count.Value);
}
public static void UpdateRDSCollection(int id, int itemId, string name, string description)
public static int GetOrganizationRdsServersCount(int itemId)
{
SqlParameter count = new SqlParameter("@TotalNumber", SqlDbType.Int);
count.Direction = ParameterDirection.Output;
DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure,
ObjectQualifier + "GetOrganizationRdsServersCount",
count,
new SqlParameter("@ItemId", itemId));
// read identity
return Convert.ToInt32(count.Value);
}
public static void UpdateRDSCollection(RdsCollection collection)
{
UpdateRDSCollection(collection.Id, collection.ItemId, collection.Name, collection.Description, collection.DisplayName);
}
public static void UpdateRDSCollection(int id, int itemId, string name, string description, string displayName)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
@ -4571,7 +4626,8 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@Id", id),
new SqlParameter("@ItemID", itemId),
new SqlParameter("@Name", name),
new SqlParameter("@Description", description)
new SqlParameter("@Description", description),
new SqlParameter("@DisplayName", displayName)
);
}
@ -4665,10 +4721,10 @@ namespace WebsitePanel.EnterpriseServer
public static void UpdateRDSServer(RdsServer server)
{
UpdateRDSServer(server.Id, server.ItemId, server.Name, server.FqdName, server.Description,
server.RdsCollectionId);
server.RdsCollectionId, server.ConnectionEnabled);
}
public static void UpdateRDSServer(int id, int? itemId, string name, string fqdName, string description, int? rdsCollectionId)
public static void UpdateRDSServer(int id, int? itemId, string name, string fqdName, string description, int? rdsCollectionId, bool connectionEnabled)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
@ -4679,7 +4735,8 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@Name", name),
new SqlParameter("@FqdName", fqdName),
new SqlParameter("@Description", description),
new SqlParameter("@RDSCollectionId", rdsCollectionId)
new SqlParameter("@RDSCollectionId", rdsCollectionId),
new SqlParameter("@ConnectionEnabled", connectionEnabled)
);
}
@ -4758,5 +4815,127 @@ namespace WebsitePanel.EnterpriseServer
}
#endregion
#region MX|NX Services
public static IDataReader GetAllPackages()
{
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"GetAllPackages"
);
}
public static IDataReader GetDomainDnsRecords(int domainId, DnsRecordType recordType)
{
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"GetDomainDnsRecords",
new SqlParameter("@DomainId", domainId),
new SqlParameter("@RecordType", recordType)
);
}
public static IDataReader GetDomainAllDnsRecords(int domainId)
{
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"GetDomainAllDnsRecords",
new SqlParameter("@DomainId", domainId)
);
}
public static void AddDomainDnsRecord(DnsRecordInfo domainDnsRecord)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"AddDomainDnsRecord",
new SqlParameter("@DomainId", domainDnsRecord.DomainId),
new SqlParameter("@RecordType", domainDnsRecord.RecordType),
new SqlParameter("@DnsServer", domainDnsRecord.DnsServer),
new SqlParameter("@Value", domainDnsRecord.Value),
new SqlParameter("@Date", domainDnsRecord.Date)
);
}
public static IDataReader GetScheduleTaskEmailTemplate(string taskId)
{
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"GetScheduleTaskEmailTemplate",
new SqlParameter("@taskId", taskId)
);
}
public static void DeleteDomainDnsRecord(int id)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"DeleteDomainDnsRecord",
new SqlParameter("@Id", id)
);
}
public static void UpdateDomainCreationDate(int domainId, DateTime date)
{
UpdateDomainDate(domainId, "UpdateDomainCreationDate", date);
}
public static void UpdateDomainExpirationDate(int domainId, DateTime date)
{
UpdateDomainDate(domainId, "UpdateDomainExpirationDate", date);
}
public static void UpdateDomainLastUpdateDate(int domainId, DateTime date)
{
UpdateDomainDate(domainId, "UpdateDomainLastUpdateDate", date);
}
private static void UpdateDomainDate(int domainId, string stroredProcedure, DateTime date)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
stroredProcedure,
new SqlParameter("@DomainId", domainId),
new SqlParameter("@Date", date)
);
}
public static void UpdateDomainDates(int domainId, DateTime? domainCreationDate, DateTime? domainExpirationDate, DateTime? domainLastUpdateDate)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"UpdateDomainDates",
new SqlParameter("@DomainId", domainId),
new SqlParameter("@DomainCreationDate", domainCreationDate),
new SqlParameter("@DomainExpirationDate", domainExpirationDate),
new SqlParameter("@DomainLastUpdateDate", domainLastUpdateDate)
);
}
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

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -2235,4 +2235,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
#endregion
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -837,8 +837,8 @@ namespace Microsoft.ApplicationBlocks.Data
// Detach the SqlParameters from the command object, so they can be used again.
// HACK: There is a problem here, the output parameter values are fletched
// when the reader is closed, so if the parameters are detached from the command
// then the SqlReader can´t set its values.
// When this happen, the parameters can´t be used again in other command.
// then the SqlReader can<EFBFBD>t set its values.
// When this happen, the parameters can<EFBFBD>t be used again in other command.
bool canClear = true;
foreach(SqlParameter commandParameter in cmd.Parameters)
{

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -29,6 +29,8 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Linq;
using System.Xml;
using System.Xml.Serialization;
using WebsitePanel.Providers;
@ -38,6 +40,13 @@ namespace WebsitePanel.EnterpriseServer
{
public class DnsServerController : IImportController, IBackupController
{
private static string GetAsciiZoneName(string zoneName)
{
if (string.IsNullOrEmpty(zoneName)) return zoneName;
var idn = new IdnMapping();
return idn.GetAscii(zoneName);
}
private static DNSServer GetDNSServer(int serviceId)
{
DNSServer dns = new DNSServer();
@ -55,6 +64,9 @@ namespace WebsitePanel.EnterpriseServer
// get DNS provider
DNSServer dns = GetDNSServer(serviceId);
// Ensure zoneName is in ascii before saving to database
zoneName = GetAsciiZoneName(zoneName);
// check if zone already exists
if (dns.ZoneExists(zoneName))
return BusinessErrorCodes.ERROR_DNS_ZONE_EXISTS;
@ -199,7 +211,7 @@ namespace WebsitePanel.EnterpriseServer
{
// zone item
DnsZone zone = primaryZone ? new DnsZone() : new SecondaryDnsZone();
zone.Name = zoneName;
zone.Name = GetAsciiZoneName(zoneName);
zone.PackageId = spaceId;
zone.ServiceId = serviceId;
int zoneItemId = PackageController.AddPackageItem(zone);
@ -280,6 +292,8 @@ namespace WebsitePanel.EnterpriseServer
foreach (GlobalDnsRecord record in records)
{
domainName = GetAsciiZoneName(domainName);
DnsRecord rr = new DnsRecord();
rr.RecordType = (DnsRecordType)Enum.Parse(typeof(DnsRecordType), record.RecordType, true);
rr.RecordName = Utils.ReplaceStringVariable(record.RecordName, "host_name", hostName, true);
@ -359,8 +373,11 @@ namespace WebsitePanel.EnterpriseServer
DNSServer dns = new DNSServer();
ServiceProviderProxy.Init(dns, serviceId);
// IDN: The list of importable names is populated with unicode names, to make it easier for the user
var idn = new IdnMapping();
if (itemType == typeof(DnsZone))
items.AddRange(dns.GetZones());
items.AddRange(dns.GetZones().Select(z => idn.GetUnicode(z)));
return items;
}
@ -375,13 +392,62 @@ namespace WebsitePanel.EnterpriseServer
if (itemType == typeof(DnsZone))
{
// Get ascii form in punycode
var zoneName = GetAsciiZoneName(itemName);
// add DNS zone
DnsZone zone = new DnsZone();
zone.Name = itemName;
zone.Name = zoneName;
zone.ServiceId = serviceId;
zone.PackageId = packageId;
int zoneId = PackageController.AddPackageItem(zone);
// Add secondary zone(s)
try
{
// get secondary DNS services
var primSettings = ServerController.GetServiceSettings(serviceId);
var secondaryServiceIds = new List<int>();
var strSecondaryServices = primSettings["SecondaryDNSServices"];
if (!String.IsNullOrEmpty(strSecondaryServices))
{
var secondaryServices = strSecondaryServices.Split(',');
secondaryServiceIds.AddRange(secondaryServices.Select(strSecondaryId => Utils.ParseInt(strSecondaryId, 0)).Where(secondaryId => secondaryId != 0));
}
// add secondary zones
var secondaryZoneFound = false;
foreach (var secondaryId in secondaryServiceIds)
{
var secDns = GetDNSServer(secondaryId);
if (secDns.ZoneExists(zoneName))
{
secondaryZoneFound = true;
var secondaryZone = new SecondaryDnsZone
{
Name = zoneName,
ServiceId = secondaryId,
PackageId = packageId
};
PackageController.AddPackageItem(secondaryZone);
}
}
if (!secondaryZoneFound)
{
TaskManager.WriteWarning("No secondary zone(s) found when importing zone " + itemName);
}
}
catch (Exception ex)
{
TaskManager.WriteError(ex, "Error importing secondary zone(s)");
}
// add/update domains/pointers
RestoreDomainByZone(itemName, packageId, zoneId);
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -217,4 +217,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer.ContractSystem
return account;
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -360,7 +360,7 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
Dictionary<string, Currency> currencies = new Dictionary<string, Currency>();
// add euro first
currencies.Add("EUR", new Currency("EUR", "ˆ", 1));
currencies.Add("EUR", new Currency("EUR", "<EFBFBD>", 1));
if (ecbXml != null)
{
@ -588,4 +588,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
}
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -540,4 +540,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
return args;
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -670,4 +670,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
}
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -47,4 +47,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
GenericSvcResult CancelService(ProvisioningContext context);
void LogServiceUsage(ProvisioningContext context);
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -362,4 +362,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
/*}
}
}*/
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -301,4 +301,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
return EcommerceProvider.DeleteCustomerService(ES.SecurityContext.User.UserId, serviceId);
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -370,4 +370,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
#endregion
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -1276,4 +1276,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
tran.Currency, tran.MethodName, tran.PluginId, status);
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -317,4 +317,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
#endregion
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -109,4 +109,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer.TaskEventHandlers
}
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -150,4 +150,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
}
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -108,4 +108,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer.TriggerSystem
EcommerceProvider.DeleteSystemTrigger(ES.SecurityContext.User.UserId, triggerId);
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -1216,6 +1216,20 @@ namespace WebsitePanel.EnterpriseServer
return account;
}
public static ExchangeAccount GetAccountByAccountName(string primaryEmailAddress)
{
ExchangeAccount account = ObjectUtils.FillObjectFromDataReader<ExchangeAccount>(
DataProvider.GetExchangeAccountByAccountNameWithoutItemId(primaryEmailAddress));
if (account == null)
return null;
// decrypt password
account.AccountPassword = CryptoUtils.Decrypt(account.AccountPassword);
return account;
}
public static bool CheckAccountCredentials(int itemId, string email, string password)
{
// place log record

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -26,7 +26,6 @@
// (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.Data;
@ -267,4 +266,4 @@ namespace WebsitePanel.EnterpriseServer
#endregion
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -94,4 +94,4 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -524,6 +524,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
@ -1001,6 +1010,13 @@ namespace WebsitePanel.EnterpriseServer
stats.UsedEnterpriseStorageSpace = folders.Where(x => x.FRSMQuotaMB != -1).Sum(x => x.FRSMQuotaMB);
}
if (cntxTmp.Groups.ContainsKey(ResourceGroups.RDS))
{
stats.CreatedRdsUsers = RemoteDesktopServicesController.GetOrganizationRdsUsersCount(org.Id);
stats.CreatedRdsCollections = RemoteDesktopServicesController.GetOrganizationRdsCollectionsCount(org.Id);
stats.CreatedRdsServers = RemoteDesktopServicesController.GetOrganizationRdsServersCount(org.Id);
}
}
else
{
@ -1075,6 +1091,13 @@ namespace WebsitePanel.EnterpriseServer
stats.UsedEnterpriseStorageSpace += folders.Where(x => x.FRSMQuotaMB != -1).Sum(x => x.FRSMQuotaMB);
}
if (cntxTmp.Groups.ContainsKey(ResourceGroups.RDS))
{
stats.CreatedRdsUsers += RemoteDesktopServicesController.GetOrganizationRdsUsersCount(o.Id);
stats.CreatedRdsCollections += RemoteDesktopServicesController.GetOrganizationRdsCollectionsCount(o.Id);
stats.CreatedRdsServers += RemoteDesktopServicesController.GetOrganizationRdsServersCount(o.Id);
}
}
}
}
@ -1129,6 +1152,13 @@ namespace WebsitePanel.EnterpriseServer
stats.AllocatedEnterpriseStorageSpace = cntx.Quotas[Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE].QuotaAllocatedValue;
}
if (cntx.Groups.ContainsKey(ResourceGroups.RDS))
{
stats.AllocatedRdsServers = cntx.Quotas[Quotas.RDS_SERVERS].QuotaAllocatedValue;
stats.AllocatedRdsCollections = cntx.Quotas[Quotas.RDS_COLLECTIONS].QuotaAllocatedValue;
stats.AllocatedRdsUsers = cntx.Quotas[Quotas.RDS_USERS].QuotaAllocatedValue;
}
return stats;
}
catch (Exception ex)
@ -3460,5 +3490,10 @@ namespace WebsitePanel.EnterpriseServer
}
#endregion
public static DataSet GetOrganizationObjectsByDomain(int itemId, string domainName)
{
return DataProvider.GetOrganizationObjectsByDomain(itemId, domainName);
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -278,11 +278,16 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
private static void PopulateOrganizationData(Organization org, EnterpriseSolutionStatisticsReport report, string topReseller)
{
{
TaskManager.Write("Stat populate organization data "+org.Name);
if (report.ExchangeReport != null)
{
try
{
TaskManager.Write("Populate exchange report items");
PopulateExchangeReportItems(org, report, topReseller);
}
catch(Exception ex)
@ -295,6 +300,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
{
try
{
TaskManager.Write("Populate populate CRM report items");
PopulateCRMReportItems(org, report, topReseller);
}
catch(Exception ex)
@ -307,6 +314,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
{
try
{
TaskManager.Write("Populate SharePoint item ");
PopulateSharePointItem(org, report, topReseller);
}
catch(Exception ex)
@ -319,6 +328,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
{
try
{
TaskManager.Write("Populate Lync report items");
PopulateLyncReportItems(org, report, topReseller);
}
catch (Exception ex)
@ -331,6 +342,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
{
try
{
TaskManager.Write("Populate Organization statistics report");
PopulateOrganizationStatisticsReport(org, report, topReseller);
}
catch(Exception ex)
@ -339,7 +352,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
}
TaskManager.Write("End populate organization data " + org.Name);
}
private static int GetExchangeServiceID(int packageId)
@ -408,6 +421,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
private static void PopulateExchangeReportItems(Organization org, EnterpriseSolutionStatisticsReport report, string topReseller)
{
TaskManager.Write("Exchange Report Items " + org.Name);
//Check if exchange organization
if (string.IsNullOrEmpty(org.GlobalAddressList))
return;
@ -420,10 +435,14 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
catch (Exception ex)
{
TaskManager.WriteError(ex);
throw new ApplicationException(
string.Format("Could not get mailboxes for current organization {0}", org.Id), ex);
}
TaskManager.WriteParameter("mailboxes.Count", mailboxes.Count);
try
{
int exchangeServiceId = GetExchangeServiceID(org.PackageId);
@ -431,6 +450,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
catch(Exception ex)
{
TaskManager.WriteError(ex);
throw new ApplicationException(
string.Format("Could not get exchange server. PackageId: {0}", org.PackageId), ex);
}
@ -440,6 +461,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
{
try
{
TaskManager.WriteParameter("mailbox", mailbox.UserPrincipalName);
stats = null;
try
{
@ -448,6 +471,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
catch (Exception ex)
{
TaskManager.WriteError(ex);
TaskManager.WriteError(ex, "Could not get mailbox statistics. AccountName: {0}",
mailbox.UserPrincipalName);
}
@ -466,6 +491,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
stats.BlackberryEnabled = BlackBerryController.CheckBlackBerryUserExists(mailbox.AccountId);
report.ExchangeReport.Items.Add(stats);
TaskManager.Write("Items.Add");
}
}
catch(Exception ex)
@ -473,7 +500,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
TaskManager.WriteError(ex);
}
}
TaskManager.Write("End Populate Exchange Report Items " + org.Name);
}
@ -547,6 +575,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
private static void PopulateSpaceData(int packageId, EnterpriseSolutionStatisticsReport report, string topReseller)
{
TaskManager.Write("Populate SpaceData " + packageId);
List<Organization> organizations;
try
@ -570,10 +600,14 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
TaskManager.WriteError(ex);
}
}
TaskManager.Write("End Populate SpaceData " + packageId);
}
private static void PopulateUserData(UserInfo user, EnterpriseSolutionStatisticsReport report, string topReseller)
{
TaskManager.Write("Populate UserData " + user.Username);
DataSet ds;
try
{
@ -596,11 +630,14 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
TaskManager.WriteError(ex);
}
}
TaskManager.Write("End Populate UserData " + user.Username);
}
private static void GetUsersData(EnterpriseSolutionStatisticsReport report, int userId, bool generateExchangeReport, bool generateSharePointReport, bool generateCRMReport, bool generateOrganizationReport, bool generateLyncReport, string topReseller)
{
TaskManager.Write("Get UsersData " + userId);
List<UserInfo> users;
try
{
@ -611,9 +648,12 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
throw new ApplicationException("Cannot get users for report", ex);
}
TaskManager.WriteParameter("users.Count", users.Count);
foreach (UserInfo user in users)
{
TaskManager.WriteParameter("User", user.Username);
try
{
PopulateUserData(user, report, topReseller);
@ -631,11 +671,16 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
{
TaskManager.WriteError(ex);
}
}
}
TaskManager.Write("End get UsersData " + userId);
}
public static EnterpriseSolutionStatisticsReport GetEnterpriseSolutionStatisticsReport(int userId, bool generateExchangeReport, bool generateSharePointReport, bool generateCRMReport, bool generateOrganizationReport, bool generateLyncReport)
{
TaskManager.Write("Get enterprise solution statistics report " + userId);
EnterpriseSolutionStatisticsReport report = new EnterpriseSolutionStatisticsReport();
if (generateExchangeReport || generateOrganizationReport)
@ -647,7 +692,6 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
if (generateLyncReport || generateOrganizationReport)
report.LyncReport = new LyncStatisticsReport();
if (generateCRMReport || generateOrganizationReport)
report.CRMReport = new CRMStatisticsReport();
@ -664,6 +708,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
TaskManager.WriteError(ex, "Cannot get enterprise solution statistics report");
}
TaskManager.Write("End get enterprise solution statistics report " + userId);
return report;
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -1505,6 +1505,13 @@ namespace WebsitePanel.EnterpriseServer
/// <returns>True if quota will exceed. Otherwise, false.</returns>
protected bool VerifyIfQuotaWillBeExceeded(int packageId, string quotaName, int numberOfItemsToAdd)
{
// Don't bother to check quota if the number of items to add is zero or less otherwise IsQuotasWillExceed
// will fail when quota is set to 0 on lists or groups and still thera are no items to import
if (numberOfItemsToAdd <= 0)
{
return false;
}
bool result = false;
QuotaValueInfo quotaInfo = PackageController.GetPackageQuota(packageId, quotaName);

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -40,6 +40,9 @@ using WebsitePanel.Providers;
using WebsitePanel.Providers.OS;
using OS = WebsitePanel.Providers.OS;
using System.Collections;
using WebsitePanel.Providers.DomainLookup;
using WebsitePanel.Providers.DNS;
using System.Linq;
namespace WebsitePanel.EnterpriseServer
@ -811,5 +814,6 @@ namespace WebsitePanel.EnterpriseServer
#endregion
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -778,7 +778,7 @@ namespace WebsitePanel.EnterpriseServer
// update package
result.ExceedingQuotas = DataProvider.UpdatePackage(SecurityContext.User.UserId,
package.PackageId, package.PlanId, package.PackageName, package.PackageComments, package.StatusId,
package.PurchaseDate, package.OverrideQuotas, quotasXml);
package.PurchaseDate, package.OverrideQuotas, quotasXml, package.DefaultTopPackage);
if (result.ExceedingQuotas.Tables[0].Rows.Count > 0)
result.Result = BusinessErrorCodes.ERROR_PACKAGE_QUOTA_EXCEED;
@ -980,11 +980,13 @@ namespace WebsitePanel.EnterpriseServer
homeFolder.PackageId = packageId;
homeFolder.Name = path;
int res = AddPackageItem(homeFolder);
// Added By Haya
UpdatePackageHardQuota(packageId);
// save package item
return AddPackageItem(homeFolder);
return res;
}
public static DateTime GetPackageBandwidthUpdate(int packageId)
@ -1740,6 +1742,21 @@ namespace WebsitePanel.EnterpriseServer
//}
}
public static bool SetDefaultTopPackage(int userId, int packageId) {
List<PackageInfo> lpi = GetPackages(userId);
foreach(PackageInfo pi in lpi) {
if(pi.DefaultTopPackage) {
pi.DefaultTopPackage = false;
UpdatePackage(pi);
}
if(pi.PackageId == packageId) {
pi.DefaultTopPackage = true;
UpdatePackage(pi);
}
}
return true;
}
#endregion
#region Quotas

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -68,6 +68,11 @@ namespace WebsitePanel.EnterpriseServer
return AddRdsCollectionInternal(itemId, collection);
}
public static ResultObject EditRdsCollection(int itemId, RdsCollection collection)
{
return EditRdsCollectionInternal(itemId, collection);
}
public static RdsCollectionPaged GetRdsCollectionsPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
return GetRdsCollectionsPagedInternal(itemId, filterColumn, filterValue, sortColumn, startRow, maximumRows);
@ -88,14 +93,14 @@ namespace WebsitePanel.EnterpriseServer
return GetRdsServersPagedInternal(filterColumn, filterValue, sortColumn, startRow, maximumRows);
}
public static RdsServersPaged GetFreeRdsServersPaged(string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
public static RdsServersPaged GetFreeRdsServersPaged(int packageId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
return GetFreeRdsServersPagedInternal(filterColumn, filterValue, sortColumn, startRow, maximumRows);
return GetFreeRdsServersPagedInternal(packageId, filterColumn, filterValue, sortColumn, startRow, maximumRows);
}
public static RdsServersPaged GetOrganizationRdsServersPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
public static RdsServersPaged GetOrganizationRdsServersPaged(int itemId, int? collectionId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
return GetOrganizationRdsServersPagedInternal(itemId, filterColumn, filterValue, sortColumn, startRow, maximumRows);
return GetOrganizationRdsServersPagedInternal(itemId, collectionId, filterColumn, filterValue, sortColumn, startRow, maximumRows);
}
public static RdsServersPaged GetOrganizationFreeRdsServersPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
@ -108,6 +113,11 @@ namespace WebsitePanel.EnterpriseServer
return GetRdsServerInternal(rdsSeverId);
}
public static ResultObject SetRDServerNewConnectionAllowed(int itemId, bool newConnectionAllowed, int rdsSeverId)
{
return SetRDServerNewConnectionAllowedInternal(itemId, newConnectionAllowed, rdsSeverId);
}
public static List<RdsServer> GetCollectionRdsServers(int collectionId)
{
return GetCollectionRdsServersInternal(collectionId);
@ -193,6 +203,26 @@ namespace WebsitePanel.EnterpriseServer
return GetOrganizationRdsUsersCountInternal(itemId);
}
public static int GetOrganizationRdsServersCount(int itemId)
{
return GetOrganizationRdsServersCountInternal(itemId);
}
public static int GetOrganizationRdsCollectionsCount(int itemId)
{
return GetOrganizationRdsCollectionsCountInternal(itemId);
}
public static List<string> GetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp)
{
return GetApplicationUsersInternal(itemId, collectionId, remoteApp);
}
public static ResultObject SetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, List<string> users)
{
return SetApplicationUsersInternal(itemId, collectionId, remoteApp, users);
}
private static RdsCollection GetRdsCollectionInternal(int collectionId)
{
var collection = ObjectUtils.FillObjectFromDataReader<RdsCollection>(DataProvider.GetRDSCollectionById(collectionId));
@ -251,10 +281,9 @@ namespace WebsitePanel.EnterpriseServer
}
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
rds.CreateCollection(org.OrganizationId, collection);
collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description);
collection.Name = GetFormattedCollectionName(collection.DisplayName, org.OrganizationId);
rds.CreateCollection(org.OrganizationId, collection);
collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description, collection.DisplayName);
foreach (var server in collection.Servers)
{
@ -262,6 +291,59 @@ namespace WebsitePanel.EnterpriseServer
}
}
catch (Exception ex)
{
result.AddError("REMOTE_DESKTOP_SERVICES_ADD_RDS_COLLECTION", ex);
throw TaskManager.WriteError(ex);
}
finally
{
if (!result.IsSuccess)
{
TaskManager.CompleteResultTask(result);
}
else
{
TaskManager.CompleteResultTask();
}
}
return result;
}
private static ResultObject EditRdsCollectionInternal(int itemId, RdsCollection collection)
{
var result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "EDIT_RDS_COLLECTION");
try
{
Organization org = OrganizationController.GetOrganization(itemId);
if (org == null)
{
result.IsSuccess = false;
result.AddError("", new NullReferenceException("Organization not found"));
return result;
}
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
var existingServers =
ObjectUtils.CreateListFromDataReader<RdsServer>(DataProvider.GetRDSServersByCollectionId(collection.Id)).ToList();
var removedServers = existingServers.Where(x => !collection.Servers.Select(y => y.Id).Contains(x.Id));
var newServers = collection.Servers.Where(x => !existingServers.Select(y => y.Id).Contains(x.Id));
foreach(var server in removedServers)
{
DataProvider.RemoveRDSServerFromCollection(server.Id);
}
rds.AddRdsServersToDeployment(newServers.ToArray());
foreach (var server in newServers)
{
DataProvider.AddRDSServerToCollection(server.Id, collection.Id);
}
}
catch (Exception ex)
{
result.AddError("REMOTE_DESKTOP_SERVICES_ADD_RDS_COLLECTION", ex);
}
@ -404,25 +486,34 @@ namespace WebsitePanel.EnterpriseServer
return result;
}
private static RdsServersPaged GetFreeRdsServersPagedInternal(string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
private static RdsServersPaged GetFreeRdsServersPagedInternal(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
DataSet ds = DataProvider.GetRDSServersPaged(null, null, filterColumn, filterValue, sortColumn, startRow, maximumRows);
RdsServersPaged result = new RdsServersPaged();
Organization org = OrganizationController.GetOrganization(itemId);
if (org == null)
{
return result;
}
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
var existingServers = rds.GetServersExistingInCollections();
DataSet ds = DataProvider.GetRDSServersPaged(null, null, filterColumn, filterValue, sortColumn, startRow, maximumRows);
result.RecordsCount = (int)ds.Tables[0].Rows[0][0];
List<RdsServer> tmpServers = new List<RdsServer>();
ObjectUtils.FillCollectionFromDataView(tmpServers, ds.Tables[1].DefaultView);
tmpServers = tmpServers.Where(x => !existingServers.Select(y => y.ToUpper()).Contains(x.FqdName.ToUpper())).ToList();
result.Servers = tmpServers.ToArray();
return result;
}
private static RdsServersPaged GetOrganizationRdsServersPagedInternal(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
private static RdsServersPaged GetOrganizationRdsServersPagedInternal(int itemId, int? collectionId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
DataSet ds = DataProvider.GetRDSServersPaged(itemId, null, filterColumn, filterValue, sortColumn, startRow, maximumRows, ignoreRdsCollectionId: true);
DataSet ds = DataProvider.GetRDSServersPaged(itemId, collectionId, filterColumn, filterValue, sortColumn, startRow, maximumRows, ignoreRdsCollectionId: !collectionId.HasValue);
RdsServersPaged result = new RdsServersPaged();
result.RecordsCount = (int)ds.Tables[0].Rows[0][0];
@ -457,11 +548,68 @@ namespace WebsitePanel.EnterpriseServer
return ObjectUtils.FillObjectFromDataReader<RdsServer>(DataProvider.GetRDSServerById(rdsSeverId));
}
private static ResultObject SetRDServerNewConnectionAllowedInternal(int itemId, bool newConnectionAllowed, int rdsSeverId)
{
ResultObject result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "SET_RDS_SERVER_NEW_CONNECTIONS_ALLOWED"); ;
try
{
// load organization
Organization org = OrganizationController.GetOrganization(itemId);
if (org == null)
{
result.IsSuccess = false;
result.AddError("", new NullReferenceException("Organization not found"));
return result;
}
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
var rdsServer = GetRdsServer(rdsSeverId);
if (rdsServer == null)
{
result.IsSuccess = false;
result.AddError("", new NullReferenceException("RDS Server not found"));
return result;
}
rds.SetRDServerNewConnectionAllowed(newConnectionAllowed, rdsServer);
rdsServer.ConnectionEnabled = newConnectionAllowed;
DataProvider.UpdateRDSServer(rdsServer);
}
catch (Exception ex)
{
result.AddError("REMOTE_DESKTOP_SERVICES_SET_RDS_SERVER_NEW_CONNECTIONS_ALLOWED", ex);
}
finally
{
if (!result.IsSuccess)
{
TaskManager.CompleteResultTask(result);
}
else
{
TaskManager.CompleteResultTask();
}
}
return result;
}
private static int GetOrganizationRdsUsersCountInternal(int itemId)
{
return DataProvider.GetOrganizationRdsUsersCount(itemId);
}
private static int GetOrganizationRdsServersCountInternal(int itemId)
{
return DataProvider.GetOrganizationRdsServersCount(itemId);
}
private static int GetOrganizationRdsCollectionsCountInternal(int itemId)
{
return DataProvider.GetOrganizationRdsCollectionsCount(itemId);
}
private static List<RdsServer> GetCollectionRdsServersInternal(int collectionId)
{
@ -479,19 +627,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
{
@ -639,7 +794,7 @@ namespace WebsitePanel.EnterpriseServer
RdsServer rdsServer = GetRdsServer(serverId);
if (!rds.CheckSessionHostFeatureInstallation(rdsServer.FqdName))
//if (!rds.CheckSessionHostFeatureInstallation(rdsServer.FqdName))
{
rds.AddSessionHostFeatureToServer(rdsServer.FqdName);
}
@ -722,7 +877,7 @@ namespace WebsitePanel.EnterpriseServer
private static List<OrganizationUser> GetRdsCollectionUsersInternal(int collectionId)
{
return ObjectUtils.CreateListFromDataReader<OrganizationUser>(DataProvider.GetRDSCollectionUsersByRDSCollectionId(collectionId));
}
}
private static ResultObject SetUsersToRdsCollectionInternal(int itemId, int collectionId, List<OrganizationUser> users)
{
@ -802,6 +957,61 @@ namespace WebsitePanel.EnterpriseServer
return result;
}
private static List<string> GetApplicationUsersInternal(int itemId, int collectionId, RemoteApplication remoteApp)
{
var result = new List<string>();
Organization org = OrganizationController.GetOrganization(itemId);
if (org == null)
{
return result;
}
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
var collection = GetRdsCollection(collectionId);
result.AddRange(rds.GetApplicationUsers(collection.Name, remoteApp.DisplayName));
return result;
}
private static ResultObject SetApplicationUsersInternal(int itemId, int collectionId, RemoteApplication remoteApp, List<string> users)
{
var result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "SET_REMOTE_APP_USERS");
try
{
Organization org = OrganizationController.GetOrganization(itemId);
if (org == null)
{
result.IsSuccess = false;
result.AddError("", new NullReferenceException("Organization not found"));
return result;
}
var collection = GetRdsCollection(collectionId);
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
rds.SetApplicationUsers(collection.Name, remoteApp, users.ToArray());
}
catch (Exception ex)
{
result.AddError("REMOTE_DESKTOP_SERVICES_SET_REMOTE_APP_USERS", ex);
}
finally
{
if (!result.IsSuccess)
{
TaskManager.CompleteResultTask(result);
}
else
{
TaskManager.CompleteResultTask();
}
}
return result;
}
private static ResultObject AddRemoteApplicationToCollectionInternal(int itemId, RdsCollection collection, RemoteApplication remoteApp)
{
var result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "ADD_REMOTE_APP_TO_COLLECTION");
@ -992,18 +1202,12 @@ namespace WebsitePanel.EnterpriseServer
private static bool CheckRDSServerAvaliable(string hostname)
{
bool result = false;
var ping = new Ping();
var reply = ping.Send(hostname, 1000);
try
if (reply.Status == IPStatus.Success)
{
var ping = new Ping();
var reply = ping.Send(hostname, 1000); // 1 second time out (in ms)
if (reply.Status == IPStatus.Success)
result = true;
}
catch (Exception)
{
result = false;
result = true;
}
return result;
@ -1061,5 +1265,10 @@ namespace WebsitePanel.EnterpriseServer
return rds;
}
private static string GetFormattedCollectionName(string displayName, string organizationId)
{
return string.Format("{0}-{1}", organizationId, displayName.Replace(" ", "_"));
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -198,4 +198,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
return result;
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -140,15 +140,18 @@ namespace WebsitePanel.EnterpriseServer
if (!string.IsNullOrEmpty(org.GlobalAddressList))
{
int exchangeServiceId = GetExchangeServiceID(org.PackageId);
ServiceProvider exchangeProvider = ExchangeServerController.GetExchangeServiceProvider(exchangeServiceId, item.ServiceId);
SoapServiceProviderItem soapOrg = SoapServiceProviderItem.Wrap(org);
ServiceProviderItemDiskSpace[] itemsDiskspace =
exchangeProvider.GetServiceItemsDiskSpace(new SoapServiceProviderItem[] {soapOrg});
if (itemsDiskspace != null && itemsDiskspace.Length > 0)
if (exchangeServiceId > 0)
{
size += itemsDiskspace[0].DiskSpace;
ServiceProvider exchangeProvider = ExchangeServerController.GetExchangeServiceProvider(exchangeServiceId, item.ServiceId);
SoapServiceProviderItem soapOrg = SoapServiceProviderItem.Wrap(org);
ServiceProviderItemDiskSpace[] itemsDiskspace =
exchangeProvider.GetServiceItemsDiskSpace(new SoapServiceProviderItem[] { soapOrg });
if (itemsDiskspace != null && itemsDiskspace.Length > 0)
{
size += itemsDiskspace[0].DiskSpace;
}
}
}
@ -200,11 +203,14 @@ namespace WebsitePanel.EnterpriseServer
//TaskManager.Write(String.Format("{0} - Invoke GetServiceItemsDiskSpace method ('{1}' items) - {2} attempt",
// DateTime.Now, objItems.Count, attempt));
ServiceProvider prov = new ServiceProvider();
ServiceProviderProxy.Init(prov, serviceId);
ServiceProviderItemDiskSpace[] itemsDiskSpace = prov.GetServiceItemsDiskSpace(objItems.ToArray());
if (itemsDiskSpace != null && itemsDiskSpace.Length > 0)
organizationDiskSpaces.AddRange(itemsDiskSpace);
if (objItems.Count > 0)
{
ServiceProvider prov = new ServiceProvider();
ServiceProviderProxy.Init(prov, serviceId);
ServiceProviderItemDiskSpace[] itemsDiskSpace = prov.GetServiceItemsDiskSpace(objItems.ToArray());
if (itemsDiskSpace != null && itemsDiskSpace.Length > 0)
organizationDiskSpaces.AddRange(itemsDiskSpace);
}
return organizationDiskSpaces.ToArray();
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -0,0 +1,237 @@
// Copyright (c) 2015, 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;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using WebsitePanel.Providers.DomainLookup;
using Whois.NET;
namespace WebsitePanel.EnterpriseServer
{
public class DomainExpirationTask: SchedulerTask
{
private static readonly string TaskId = "SCHEDULE_TASK_DOMAIN_EXPIRATION";
// Input parameters:
private static readonly string DaysBeforeNotify = "DAYS_BEFORE";
private static readonly string MailToParameter = "MAIL_TO";
private static readonly string EnableNotification = "ENABLE_NOTIFICATION";
private static readonly string IncludeNonExistenDomains = "INCLUDE_NONEXISTEN_DOMAINS";
private static readonly string MailBodyTemplateParameter = "MAIL_BODY";
private static readonly string MailBodyDomainRecordTemplateParameter = "MAIL_DOMAIN_RECORD";
public override void DoWork()
{
BackgroundTask topTask = TaskManager.TopTask;
var domainUsers = new Dictionary<int, UserInfo>();
var checkedDomains = new List<DomainInfo>();
var expiredDomains = new List<DomainInfo>();
var nonExistenDomains = new List<DomainInfo>();
var allDomains = new List<DomainInfo>();
var allTopLevelDomains = new List<DomainInfo>();
// get input parameters
int daysBeforeNotify;
bool sendEmailNotifcation = Convert.ToBoolean( topTask.GetParamValue(EnableNotification));
bool includeNonExistenDomains = Convert.ToBoolean(topTask.GetParamValue(IncludeNonExistenDomains));
// check input parameters
if (String.IsNullOrEmpty((string)topTask.GetParamValue("MAIL_TO")))
{
TaskManager.WriteWarning("The e-mail message has not been sent because 'Mail To' is empty.");
return;
}
int.TryParse((string)topTask.GetParamValue(DaysBeforeNotify), out daysBeforeNotify);
var user = UserController.GetUser(topTask.EffectiveUserId);
var packages = GetUserPackages(user.UserId, user.Role);
foreach (var package in packages)
{
var domains = ServerController.GetDomains(package.PackageId);
allDomains.AddRange(domains);
domains = domains.Where(x => !x.IsSubDomain && !x.IsDomainPointer).ToList(); //Selecting top-level domains
allTopLevelDomains.AddRange(domains);
var domainUser = UserController.GetUser(package.UserId);
if (!domainUsers.ContainsKey(package.PackageId))
{
domainUsers.Add(package.PackageId, domainUser);
}
foreach (var domain in domains)
{
if (checkedDomains.Any(x=> x.DomainId == domain.DomainId))
{
continue;
}
checkedDomains.Add(domain);
ServerController.UpdateDomainWhoisData(domain);
if (CheckDomainExpiration(domain.ExpirationDate, daysBeforeNotify))
{
expiredDomains.Add(domain);
}
if (domain.ExpirationDate == null && domain.CreationDate == null)
{
nonExistenDomains.Add(domain);
}
Thread.Sleep(100);
}
}
var subDomains = allDomains.Where(x => !checkedDomains.Any(z => z.DomainId == x.DomainId && z.ExpirationDate != null)).GroupBy(p => p.DomainId).Select(g => g.First()).ToList();
foreach (var subDomain in subDomains)
{
var mainDomain = checkedDomains.Where(x => subDomain.DomainId != x.DomainId && subDomain.DomainName.ToLowerInvariant().Contains(x.DomainName.ToLowerInvariant())).OrderByDescending(s => s.DomainName.Length).FirstOrDefault(); ;
if (mainDomain != null)
{
ServerController.UpdateDomainWhoisData(subDomain, mainDomain.CreationDate, mainDomain.ExpirationDate, mainDomain.RegistrarName);
var nonExistenDomain = nonExistenDomains.FirstOrDefault(x => subDomain.DomainId == x.DomainId);
if (nonExistenDomain != null)
{
nonExistenDomains.Remove(nonExistenDomain);
}
Thread.Sleep(100);
}
}
expiredDomains = expiredDomains.GroupBy(p => p.DomainId).Select(g => g.First()).ToList();
if (expiredDomains.Count > 0 && sendEmailNotifcation)
{
SendMailMessage(user, expiredDomains, domainUsers, nonExistenDomains, includeNonExistenDomains);
}
}
private IEnumerable<PackageInfo> GetUserPackages(int userId,UserRole userRole)
{
var packages = new List<PackageInfo>();
switch (userRole)
{
case UserRole.Administrator:
{
packages = ObjectUtils.CreateListFromDataReader<PackageInfo>(DataProvider.GetAllPackages());
break;
}
default:
{
packages = PackageController.GetMyPackages(userId);
break;
}
}
return packages;
}
private bool CheckDomainExpiration(DateTime? date, int daysBeforeNotify)
{
if (date == null)
{
return false;
}
return (date.Value - DateTime.Now).Days < daysBeforeNotify;
}
private void SendMailMessage(UserInfo user, IEnumerable<DomainInfo> domains, Dictionary<int, UserInfo> domainUsers, IEnumerable<DomainInfo> nonExistenDomains, bool includeNonExistenDomains)
{
BackgroundTask topTask = TaskManager.TopTask;
UserSettings settings = UserController.GetUserSettings(user.UserId, UserSettings.DOMAIN_EXPIRATION_LETTER);
string from = settings["From"];
var bcc = settings["CC"];
string subject = settings["Subject"];
string body = user.HtmlMail ? settings["HtmlBody"] : settings["TextBody"];
bool isHtml = user.HtmlMail;
MailPriority priority = MailPriority.Normal;
if (!String.IsNullOrEmpty(settings["Priority"]))
priority = (MailPriority)Enum.Parse(typeof(MailPriority), settings["Priority"], true);
// input parameters
string mailTo = (string)topTask.GetParamValue("MAIL_TO");
Hashtable items = new Hashtable();
items["user"] = user;
items["Domains"] = domains.Select(x => new { DomainName = x.DomainName,
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;
items["NonExistenDomains"] = nonExistenDomains.Select(x => new
{
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);
// send mail message
MailHelper.SendMessage(from, mailTo, bcc, subject, body, priority, isHtml);
}
}
}

View file

@ -0,0 +1,422 @@
// Copyright (c) 2015, 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;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using WebsitePanel.Providers.DNS;
using WebsitePanel.Providers.DomainLookup;
using WebsitePanel.Server;
namespace WebsitePanel.EnterpriseServer
{
public class DomainLookupViewTask : SchedulerTask
{
private static readonly string TaskId = "SCHEDULE_TASK_DOMAIN_LOOKUP";
// Input parameters:
private static readonly string DnsServersParameter = "DNS_SERVERS";
private static readonly string MailToParameter = "MAIL_TO";
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()
{
BackgroundTask topTask = TaskManager.TopTask;
List<DomainDnsChanges> domainsChanges = new List<DomainDnsChanges>();
var domainUsers = new Dictionary<int, UserInfo>();
// get input parameters
string dnsServersString = (string)topTask.GetParamValue(DnsServersParameter);
string serverName = (string)topTask.GetParamValue(ServerNameParameter);
int pause;
// check input parameters
if (String.IsNullOrEmpty(dnsServersString))
{
TaskManager.WriteWarning("Specify 'DNS' task parameter.");
return;
}
if (String.IsNullOrEmpty((string)topTask.GetParamValue("MAIL_TO")))
{
TaskManager.WriteWarning("The e-mail message has not been sent because 'Mail To' is empty.");
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)
{
TaskManager.WriteWarning(String.Format("Server with the name '{0}' was not found", serverName));
return;
}
WindowsServer winServer = new WindowsServer();
ServiceProviderProxy.ServerInit(winServer, server.ServerId);
var user = UserController.GetUser(topTask.UserId);
var dnsServers = dnsServersString.Split(';');
var packages = ObjectUtils.CreateListFromDataReader<PackageInfo>(DataProvider.GetAllPackages());
foreach (var package in packages)
{
var domains = ServerController.GetDomains(package.PackageId);
domains = domains.Where(x => !x.IsSubDomain && !x.IsDomainPointer).ToList(); //Selecting top-level domains
//domains = domains.Where(x => x.ZoneItemId > 0).ToList(); //Selecting only dns enabled domains
foreach (var domain in domains)
{
if (domainsChanges.Any(x => x.DomainName == domain.DomainName))
{
continue;
}
if (!domainUsers.ContainsKey(domain.PackageId))
{
var domainUser = UserController.GetUser(packages.First(x=>x.PackageId == domain.PackageId).UserId);
domainUsers.Add(domain.PackageId, domainUser);
}
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, 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);
domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(dbDnsRecords.Where(x => x.RecordType == DnsRecordType.MX), dnsMxRecords, dnsServer));
domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(dbDnsRecords.Where(x => x.RecordType == DnsRecordType.NS), dnsNsRecords, dnsServer));
domainChanges.DnsChanges = CombineDnsRecordChanges(domainChanges.DnsChanges, dnsServer).ToList();
}
domainsChanges.Add(domainChanges);
}
}
var changedDomains = FindDomainsWithChangedRecords(domainsChanges);
SendMailMessage(user, changedDomains, domainUsers);
}
#region Helpers
private IEnumerable<DomainDnsChanges> FindDomainsWithChangedRecords(IEnumerable<DomainDnsChanges> domainsChanges)
{
var changedDomains = new List<DomainDnsChanges>();
foreach (var domainChanges in domainsChanges)
{
var firstTimeAdditon = domainChanges.DnsChanges.All(x => x.Status == DomainDnsRecordStatuses.Added);
if (firstTimeAdditon)
{
continue;
}
bool isChanged = domainChanges.DnsChanges.Any(d => d.Status != DomainDnsRecordStatuses.NotChanged);
if (isChanged)
{
changedDomains.Add(domainChanges);
}
}
return changedDomains;
}
private IEnumerable<DnsRecordInfoChange> ApplyDomainRecordsChanges(IEnumerable<DnsRecordInfo> dbRecords, List<DnsRecordInfo> dnsRecords, string dnsServer)
{
var dnsRecordChanges = new List<DnsRecordInfoChange>();
var filteredDbRecords = dbRecords.Where(x => x.DnsServer == dnsServer);
foreach (var record in filteredDbRecords)
{
var dnsRecord = dnsRecords.FirstOrDefault(x => x.Value == record.Value);
if (dnsRecord != null)
{
dnsRecordChanges.Add(new DnsRecordInfoChange { OldRecord = record, NewRecord = dnsRecord, Type = record.RecordType, Status = DomainDnsRecordStatuses.NotChanged, DnsServer = dnsServer });
dnsRecords.Remove(dnsRecord);
}
else
{
dnsRecordChanges.Add(new DnsRecordInfoChange { OldRecord = record, NewRecord = new DnsRecordInfo { Value = string.Empty}, Type = record.RecordType, Status = DomainDnsRecordStatuses.Removed, DnsServer = dnsServer });
RemoveRecord(record);
}
}
foreach (var record in dnsRecords)
{
dnsRecordChanges.Add(new DnsRecordInfoChange { OldRecord = new DnsRecordInfo { Value = string.Empty }, NewRecord = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.Added, DnsServer = dnsServer });
AddRecord(record);
}
return dnsRecordChanges;
}
private IEnumerable<DnsRecordInfoChange> CombineDnsRecordChanges(IEnumerable<DnsRecordInfoChange> records, string dnsServer)
{
var resultRecords = records.Where(x => x.DnsServer == dnsServer).ToList();
var recordsToRemove = new List<DnsRecordInfoChange>();
var removedRecords = records.Where(x => x.Status == DomainDnsRecordStatuses.Removed);
var addedRecords = records.Where(x => x.Status == DomainDnsRecordStatuses.Added);
foreach (DnsRecordType type in (DnsRecordType[])Enum.GetValues(typeof(DnsRecordType)))
{
foreach (var removedRecord in removedRecords.Where(x => x.Type == type))
{
var addedRecord = addedRecords.FirstOrDefault(x => x.Type == type && !recordsToRemove.Contains(x));
if (addedRecord != null)
{
recordsToRemove.Add(addedRecord);
removedRecord.NewRecord = addedRecord.NewRecord;
removedRecord.Status = DomainDnsRecordStatuses.Updated;
}
}
}
foreach (var record in recordsToRemove)
{
resultRecords.Remove(record);
}
return resultRecords;
}
private void FillRecordData(IEnumerable<DnsRecordInfo> records, DomainInfo domain, string dnsServer)
{
foreach (var record in records)
{
FillRecordData(record, domain, dnsServer);
}
}
private void FillRecordData(DnsRecordInfo record, DomainInfo domain, string dnsServer)
{
record.DomainId = domain.DomainId;
record.Date = DateTime.Now;
record.DnsServer = dnsServer;
}
private void RemoveRecords(IEnumerable<DnsRecordInfo> dnsRecords)
{
foreach (var record in dnsRecords)
{
RemoveRecord(record);
}
}
private void RemoveRecord(DnsRecordInfo dnsRecord)
{
DataProvider.DeleteDomainDnsRecord(dnsRecord.Id);
Thread.Sleep(100);
}
private void AddRecords(IEnumerable<DnsRecordInfo> dnsRecords)
{
foreach (var record in dnsRecords)
{
AddRecord(record);
}
}
private void AddRecord(DnsRecordInfo dnsRecord)
{
DataProvider.AddDomainDnsRecord(dnsRecord);
Thread.Sleep(100);
}
private void SendMailMessage(UserInfo user, IEnumerable<DomainDnsChanges> domainsChanges, Dictionary<int, UserInfo> domainUsers)
{
BackgroundTask topTask = TaskManager.TopTask;
UserSettings settings = UserController.GetUserSettings(user.UserId, UserSettings.DOMAIN_LOOKUP_LETTER);
string from = settings["From"];
var bcc = settings["CC"];
string subject = settings["Subject"];
MailPriority priority = MailPriority.Normal;
if (!String.IsNullOrEmpty(settings["Priority"]))
priority = (MailPriority)Enum.Parse(typeof(MailPriority), settings["Priority"], true);
// input parameters
string mailTo = (string)topTask.GetParamValue("MAIL_TO");
string body = string.Empty;
bool isHtml = user.HtmlMail;
if (domainsChanges.Any())
{
body = user.HtmlMail ? settings["HtmlBody"] : settings["TextBody"];
}
else
{
body = user.HtmlMail ? settings["NoChangesHtmlBody"] : settings["NoChangesTextBody"];
}
Hashtable items = new Hashtable();
items["user"] = user;
items["DomainUsers"] = domainUsers;
items["Domains"] = domainsChanges;
body = PackageController.EvaluateTemplate(body, items);
// send mail message
MailHelper.SendMessage(from, mailTo, bcc, subject, body, priority, isHtml);
}
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 = 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);
return records.ToList();
}
private IEnumerable<DnsRecordInfo> ParseNsLookupResult(string raw, string dnsServer, DnsRecordType recordType)
{
var records = new List<DnsRecordInfo>();
var recordTypePattern = string.Empty;
switch (recordType)
{
case DnsRecordType.NS:
{
recordTypePattern = NsRecordPattern;
break;
}
case DnsRecordType.MX:
{
recordTypePattern = MxRecordPattern;
break;
}
}
var regex = new Regex(recordTypePattern, RegexOptions.IgnoreCase);
foreach (Match match in regex.Matches(raw))
{
if (match.Groups.Count != 2)
{
continue;
}
var dnsRecord = new DnsRecordInfo
{
Value = match.Groups[1].Value != null ? match.Groups[1].Value.Replace("\r\n", "").Replace("\r", "").Replace("\n", "").ToLowerInvariant().Trim() : null,
RecordType = recordType,
DnsServer = dnsServer
};
records.Add(dnsRecord);
}
return records;
}
#endregion
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -32,6 +32,7 @@ using System.IO;
using System.Net.Mail;
using System.Net.Mime;
using System.Text;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.EnterpriseServer.Code.HostedSolution;
using WebsitePanel.Providers.HostedSolution;
@ -51,6 +52,8 @@ namespace WebsitePanel.EnterpriseServer
{
try
{
TaskManager.Write("Start HostedSolutionReportTask");
BackgroundTask topTask = TaskManager.TopTask;
bool isExchange = Utils.ParseBool(topTask.GetParamValue(EXCHANGE_REPORT), false);
@ -61,23 +64,41 @@ namespace WebsitePanel.EnterpriseServer
string email = topTask.GetParamValue(EMAIL).ToString();
TaskManager.WriteParameter("isExchange",isExchange);
TaskManager.WriteParameter("isSharePoint",isSharePoint);
TaskManager.WriteParameter("isLync", isLync);
TaskManager.WriteParameter("isCRM", isCRM);
TaskManager.WriteParameter("isOrganization", isOrganization);
TaskManager.WriteParameter("email", email);
UserInfo user = PackageController.GetPackageOwner(topTask.PackageId);
TaskManager.WriteParameter("user", user.Username);
EnterpriseSolutionStatisticsReport report =
ReportController.GetEnterpriseSolutionStatisticsReport(user.UserId, isExchange, isSharePoint, isCRM,
isOrganization, isLync);
TaskManager.WriteParameter("report.ExchangeReport.Items.Count", report.ExchangeReport.Items.Count);
TaskManager.WriteParameter("report.SharePointReport.Items.Count", report.SharePointReport.Items.Count);
TaskManager.WriteParameter("report.CRMReport.Items.Count", report.CRMReport.Items.Count);
TaskManager.WriteParameter("report.OrganizationReport.Items.Count", report.OrganizationReport.Items.Count);
TaskManager.WriteParameter("report.LyncReport.Items.Count", report.LyncReport.Items.Count);
SendMessage(user, email, isExchange && report.ExchangeReport != null ? report.ExchangeReport.ToCSV() : string.Empty,
isSharePoint && report.SharePointReport != null ? report.SharePointReport.ToCSV() : string.Empty,
isCRM && report.CRMReport != null ? report.CRMReport.ToCSV() : string.Empty,
isOrganization && report.OrganizationReport != null ? report.OrganizationReport.ToCSV() : string.Empty,
isLync && report.LyncReport != null ? report.LyncReport.ToCSV() : string.Empty);
}
catch(Exception ex)
{
TaskManager.WriteError(ex);
}
TaskManager.Write("End HostedSolutionReportTask");
}
@ -97,6 +118,8 @@ namespace WebsitePanel.EnterpriseServer
private void SendMessage(UserInfo user,string email, string exchange_csv, string sharepoint_csv, string crm_csv, string organization_csv, string lync_csv)
{
TaskManager.Write("SendMessage");
List<Attachment> attacments = new List<Attachment>();
PrepareAttament("exchange.csv", exchange_csv, attacments);
PrepareAttament("sharepoint.csv", sharepoint_csv, attacments);
@ -104,9 +127,6 @@ namespace WebsitePanel.EnterpriseServer
PrepareAttament("crm.csv", crm_csv, attacments);
PrepareAttament("organization.csv", organization_csv, attacments);
// get letter settings
UserSettings settings = UserController.GetUserSettings(user.UserId, UserSettings.HOSTED_SOLUTION_REPORT);
@ -116,9 +136,29 @@ namespace WebsitePanel.EnterpriseServer
string body = user.HtmlMail ? settings["HtmlBody"] : settings["TextBody"];
bool isHtml = user.HtmlMail;
MailPriority priority = MailPriority.Normal;
MailPriority priority = MailPriority.Normal;
TaskManager.WriteParameter("from", from);
TaskManager.WriteParameter("email", email);
TaskManager.WriteParameter("subject", subject);
TaskManager.WriteParameter("body", body);
MailHelper.SendMessage(from, email, cc, subject, body, priority, isHtml, attacments.ToArray());
int res = MailHelper.SendMessage(from, email, cc, subject, body, priority, isHtml, attacments.ToArray());
if (res==0)
{
TaskManager.Write("SendMessage OK");
}
else
{
TaskManager.WriteError("SendMessage error ", "error code", res.ToString());
}
TaskManager.WriteParameter("", res);
TaskManager.Write("End SendMessage");
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -84,4 +84,4 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
}
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -45,7 +45,7 @@ namespace WebsitePanel.EnterpriseServer
public static SchedulerJob nextSchedule = null;
public static void Start()
{
{
ScheduleTasks();
}
@ -73,7 +73,7 @@ namespace WebsitePanel.EnterpriseServer
private static void RunManualTasks()
{
var tasks = TaskController.GetProcessTasks(BackgroundTaskStatus.Stopping);
var tasks = TaskController.GetProcessTasks(BackgroundTaskStatus.Stopping);
foreach (var task in tasks)
{

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -30,6 +30,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Linq;
using System.Net;
using System.Xml;
using WebsitePanel.Providers;
@ -39,6 +40,11 @@ using WebsitePanel.Server;
using WebsitePanel.Providers.ResultObjects;
using WebsitePanel.Providers.Web;
using WebsitePanel.Providers.HostedSolution;
using Whois.NET;
using System.Text.RegularExpressions;
using WebsitePanel.Providers.DomainLookup;
using System.Globalization;
using System.Linq;
namespace WebsitePanel.EnterpriseServer
{
@ -49,6 +55,35 @@ namespace WebsitePanel.EnterpriseServer
{
private const string LOG_SOURCE_SERVERS = "SERVERS";
private static List<string> _createdDatePatterns = new List<string> { @"Creation Date:(.+)", // base
@"created:(.+)",
@"Created On:(.+) UTC",
@"Created On:(.+)",
@"Domain Registration Date:(.+)",
@"Domain Create Date:(.+)",
@"Registered on:(.+)"};
private static List<string> _expiredDatePatterns = new List<string> { @"Expiration Date:(.+) UTC", //base UTC
@"Expiration Date:(.+)", // base
@"Registry Expiry Date:(.+)", //.org
@"paid-till:(.+)", //.ru
@"Expires On:(.+)", //.name
@"Domain Expiration Date:(.+)", //.us
@"renewal date:(.+)", //.pl
@"Expiry date:(.+)", //.uk
@"anniversary:(.+)", //.fr
@"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"
};
#region Servers
public static List<ServerInfo> GetAllServers()
{
@ -1613,6 +1648,26 @@ namespace WebsitePanel.EnterpriseServer
#endregion
#region Domains
public static List<DnsRecordInfo> GetDomainDnsRecords(int domainId)
{
var result = new List<DnsRecordInfo>();
var records = ObjectUtils.CreateListFromDataReader<DnsRecordInfo>(DataProvider.GetDomainAllDnsRecords(domainId));
var activeDomain = records.OrderByDescending(x => x.Date).FirstOrDefault();
if (activeDomain != null)
{
records = records.Where(x => x.DnsServer == activeDomain.DnsServer).ToList();
}
result.AddRange(records);
return result;
}
public static int CheckDomain(string domainName)
{
int checkDomainResult = DataProvider.CheckDomain(-10, domainName, false);
@ -1787,6 +1842,8 @@ namespace WebsitePanel.EnterpriseServer
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS, domain, "");
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPSForPC, domain, "");
}
UpdateDomainWhoisData(domain);
}
// add instant alias
@ -2138,11 +2195,13 @@ namespace WebsitePanel.EnterpriseServer
}
}
// Find and delete all zone items for this domain
var zoneItems = PackageController.GetPackageItemsByType(domain.PackageId, ResourceGroups.Dns, typeof (DnsZone));
zoneItems.AddRange(PackageController.GetPackageItemsByType(domain.PackageId, ResourceGroups.Dns, typeof(SecondaryDnsZone)));
// remove DNS zone meta-item if required
if (domain.ZoneItemId > 0)
foreach (var zoneItem in zoneItems.Where(z => z.Name == domain.ZoneName))
{
PackageController.DeletePackageItem(domain.ZoneItemId);
PackageController.DeletePackageItem(zoneItem.Id);
}
// delete domain
@ -2637,6 +2696,81 @@ namespace WebsitePanel.EnterpriseServer
TaskManager.CompleteTask();
}
}
public static DomainInfo UpdateDomainWhoisData(DomainInfo domain)
{
try
{
var whoisResult = WhoisClient.Query(domain.DomainName.ToLowerInvariant());
string creationDateString = ParseWhoisDomainInfo(whoisResult.Raw, _createdDatePatterns);
string expirationDateString = ParseWhoisDomainInfo(whoisResult.Raw, _expiredDatePatterns);
domain.CreationDate = ParseDate(creationDateString);
domain.ExpirationDate = ParseDate(expirationDateString);
domain.RegistrarName = ParseWhoisDomainInfo(whoisResult.Raw, _registrarNamePatterns);
domain.LastUpdateDate = DateTime.Now;
DataProvider.UpdateWhoisDomainInfo(domain.DomainId, domain.CreationDate, domain.ExpirationDate, DateTime.Now, domain.RegistrarName);
}
catch (Exception e)
{
//wrong domain
}
return domain;
}
public static DomainInfo UpdateDomainWhoisData(DomainInfo domain, DateTime? creationDate, DateTime? expirationDate, string registrarName)
{
DataProvider.UpdateWhoisDomainInfo(domain.DomainId, creationDate, expirationDate, DateTime.Now, registrarName);
domain.CreationDate = creationDate;
domain.ExpirationDate = expirationDate;
domain.RegistrarName = registrarName;
domain.LastUpdateDate = DateTime.Now;
return domain;
}
private static string ParseWhoisDomainInfo(string raw, IEnumerable<string> patterns)
{
foreach (var createdRegex in patterns)
{
var regex = new Regex(createdRegex, RegexOptions.IgnoreCase);
foreach (Match match in regex.Matches(raw))
{
if (match.Success && match.Groups.Count == 2)
{
return match.Groups[1].ToString().Trim();
}
}
}
return null;
}
private static DateTime? ParseDate(string dateString)
{
if (string.IsNullOrEmpty(dateString))
{
return null;
}
var result = DateTime.MinValue;
foreach (var datePattern in _datePatterns)
{
if (DateTime.TryParseExact(dateString, datePattern, CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
{
return result;
}
}
return DateTime.Parse(dateString);
}
#endregion
#region DNS Zones
@ -2654,7 +2788,7 @@ namespace WebsitePanel.EnterpriseServer
DNSServer dns = new DNSServer();
ServiceProviderProxy.Init(dns, zoneItem.ServiceId);
return dns.GetZoneRecords(domain.DomainName);
return dns.GetZoneRecords(zoneItem.Name);
}
return new DnsRecord[] { };

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -191,4 +191,4 @@ namespace WebsitePanel.EnterpriseServer
}
}
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -147,4 +147,4 @@ namespace WebsitePanel.EnterpriseServer.Tasks
}
}
}
}
}

View file

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

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,

Some files were not shown because too many files have changed in this diff Show more