Merge
This commit is contained in:
commit
ddc94cb44c
113 changed files with 5660 additions and 2425 deletions
|
@ -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
|
||||
{
|
||||
|
@ -4719,5 +4721,90 @@ 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 void AddDomainDnsRecord(DnsRecordInfo domainDnsRecord)
|
||||
{
|
||||
SqlHelper.ExecuteReader(
|
||||
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.ExecuteReader(
|
||||
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.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
stroredProcedure,
|
||||
new SqlParameter("@DomainId", domainId),
|
||||
new SqlParameter("@Date", date)
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,6 +193,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
stats.UsedDiskSpace = tempStats.UsedDiskSpace;
|
||||
stats.UsedLitigationHoldSpace = tempStats.UsedLitigationHoldSpace;
|
||||
stats.UsedArchingStorage = tempStats.UsedArchingStorage;
|
||||
|
||||
stats.CreatedSharedMailboxes = tempStats.CreatedSharedMailboxes;
|
||||
stats.CreatedResourceMailboxes = tempStats.CreatedResourceMailboxes;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -221,6 +224,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
stats.UsedDiskSpace += tempStats.UsedDiskSpace;
|
||||
stats.UsedLitigationHoldSpace += tempStats.UsedLitigationHoldSpace;
|
||||
stats.UsedArchingStorage += tempStats.UsedArchingStorage;
|
||||
|
||||
stats.CreatedSharedMailboxes += tempStats.CreatedSharedMailboxes;
|
||||
stats.CreatedResourceMailboxes += tempStats.CreatedResourceMailboxes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,6 +247,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
stats.AllocatedLitigationHoldSpace = cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue;
|
||||
stats.AllocatedArchingStorage = cntx.Quotas[Quotas.EXCHANGE2013_ARCHIVINGSTORAGE].QuotaAllocatedValue;
|
||||
|
||||
stats.AllocatedSharedMailboxes = cntx.Quotas[Quotas.EXCHANGE2013_SHAREDMAILBOXES].QuotaAllocatedValue;
|
||||
stats.AllocatedResourceMailboxes = cntx.Quotas[Quotas.EXCHANGE2013_RESOURCEMAILBOXES].QuotaAllocatedValue;
|
||||
|
||||
return stats;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1665,8 +1674,21 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
// check mailbox quota
|
||||
OrganizationStatistics orgStats = GetOrganizationStatistics(itemId);
|
||||
if ((orgStats.AllocatedMailboxes > -1) && (orgStats.CreatedMailboxes >= orgStats.AllocatedMailboxes))
|
||||
return BusinessErrorCodes.ERROR_EXCHANGE_MAILBOXES_QUOTA_LIMIT;
|
||||
if (accountType == ExchangeAccountType.SharedMailbox)
|
||||
{
|
||||
if ((orgStats.AllocatedSharedMailboxes > -1) && (orgStats.CreatedSharedMailboxes >= orgStats.AllocatedSharedMailboxes))
|
||||
return BusinessErrorCodes.ERROR_EXCHANGE_MAILBOXES_QUOTA_LIMIT;
|
||||
}
|
||||
else if ((accountType == ExchangeAccountType.Room) || (accountType == ExchangeAccountType.Equipment))
|
||||
{
|
||||
if ((orgStats.AllocatedResourceMailboxes > -1) && (orgStats.CreatedResourceMailboxes >= orgStats.AllocatedResourceMailboxes))
|
||||
return BusinessErrorCodes.ERROR_EXCHANGE_MAILBOXES_QUOTA_LIMIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((orgStats.AllocatedMailboxes > -1) && (orgStats.CreatedMailboxes >= orgStats.AllocatedMailboxes))
|
||||
return BusinessErrorCodes.ERROR_EXCHANGE_MAILBOXES_QUOTA_LIMIT;
|
||||
}
|
||||
|
||||
|
||||
// place log record
|
||||
|
|
|
@ -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,24 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Domain DNS Records lookup
|
||||
|
||||
public static List<DnsRecordInfo> GetDomainRecords(int packageId, string domain, string dnsServer, DnsRecordType recordType)
|
||||
{
|
||||
List<DnsRecordInfo> records = new List<DnsRecordInfo>();
|
||||
|
||||
// load OS service
|
||||
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);
|
||||
|
||||
var os = GetOS(serviceId);
|
||||
|
||||
records = os.GetDomainDnsRecords(domain, dnsServer, recordType).ToList();
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,186 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
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<int>();
|
||||
var expiredDomains = new List<DomainInfo>();
|
||||
var nonExistenDomains = 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);
|
||||
|
||||
var subDomains = domains.Where(x => x.IsSubDomain).ToList();
|
||||
|
||||
var topLevelDomains = domains = domains.Where(x => !x.IsSubDomain && !x.IsDomainPointer).ToList(); //Selecting top-level domains
|
||||
|
||||
domains = topLevelDomains.Where(x => x.CreationDate == null || x.ExpirationDate == null ? true : CheckDomainExpiration(x.ExpirationDate, daysBeforeNotify)).ToList(); // selecting expired or with empty expire date domains
|
||||
|
||||
var domainUser = UserController.GetUser(package.UserId);
|
||||
|
||||
if (!domainUsers.ContainsKey(package.PackageId))
|
||||
{
|
||||
domainUsers.Add(package.PackageId, domainUser);
|
||||
}
|
||||
|
||||
foreach (var domain in domains)
|
||||
{
|
||||
if (checkedDomains.Contains(domain.DomainId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
checkedDomains.Add(domain.DomainId);
|
||||
|
||||
ServerController.UpdateDomainRegistrationData(domain);
|
||||
|
||||
if (CheckDomainExpiration(domain.ExpirationDate, daysBeforeNotify))
|
||||
{
|
||||
expiredDomains.Add(domain);
|
||||
}
|
||||
|
||||
if (domain.ExpirationDate == null && domain.CreationDate == null)
|
||||
{
|
||||
nonExistenDomains.Add(domain);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var subDomain in subDomains)
|
||||
{
|
||||
var mainDomain = topLevelDomains.Where(x => subDomain.DomainName.Contains(x.DomainName)).OrderByDescending(s => s.DomainName.Length).FirstOrDefault(); ;
|
||||
|
||||
if (mainDomain != null)
|
||||
{
|
||||
ServerController.UpdateDomainRegistrationData(subDomain, mainDomain.CreationDate, mainDomain.ExpirationDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
Customer = string.Format("{0} {1}", domainUsers[x.PackageId].FirstName, domainUsers[x.PackageId].LastName) });
|
||||
|
||||
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)
|
||||
});
|
||||
|
||||
|
||||
body = PackageController.EvaluateTemplate(body, items);
|
||||
|
||||
// send mail message
|
||||
MailHelper.SendMessage(from, mailTo, bcc, subject, body, priority, isHtml);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,234 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using WebsitePanel.Providers.DNS;
|
||||
using WebsitePanel.Providers.DomainLookup;
|
||||
|
||||
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";
|
||||
|
||||
public override void DoWork()
|
||||
{
|
||||
BackgroundTask topTask = TaskManager.TopTask;
|
||||
|
||||
List<DomainDnsChanges> domainsChanges = new List<DomainDnsChanges>();
|
||||
|
||||
// get input parameters
|
||||
string dnsServersString = (string)topTask.GetParamValue(DnsServersParameter);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
DomainDnsChanges domainChanges = new DomainDnsChanges();
|
||||
domainChanges.DomainName = domain.DomainName;
|
||||
|
||||
var mxRecords = ObjectUtils.CreateListFromDataReader<DnsRecordInfo>(DataProvider.GetDomainDnsRecords(domain.DomainId, DnsRecordType.MX));
|
||||
var nsRecords = ObjectUtils.CreateListFromDataReader<DnsRecordInfo>(DataProvider.GetDomainDnsRecords(domain.DomainId, DnsRecordType.NS));
|
||||
|
||||
//execute server
|
||||
foreach (var dnsServer in dnsServers)
|
||||
{
|
||||
var dnsMxRecords = OperatingSystemController.GetDomainRecords(domain.PackageId, domain.DomainName, dnsServer, DnsRecordType.MX);
|
||||
var dnsNsRecords = OperatingSystemController.GetDomainRecords(domain.PackageId, domain.DomainName, dnsServer, DnsRecordType.NS);
|
||||
|
||||
FillRecordData(dnsMxRecords, domain, dnsServer);
|
||||
FillRecordData(dnsNsRecords, domain, dnsServer);
|
||||
|
||||
domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(mxRecords, dnsMxRecords, dnsServer));
|
||||
domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(nsRecords, dnsNsRecords, dnsServer));
|
||||
}
|
||||
|
||||
domainsChanges.Add(domainChanges);
|
||||
}
|
||||
}
|
||||
|
||||
var changedDomains = FindDomainsWithChangedRecords(domainsChanges);
|
||||
|
||||
if (changedDomains.Any())
|
||||
{
|
||||
SendMailMessage(user,changedDomains);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#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(List<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 { Record = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.NotChanged, DnsServer = dnsServer });
|
||||
|
||||
dnsRecords.Remove(dnsRecord);
|
||||
}
|
||||
else
|
||||
{
|
||||
dnsRecordChanges.Add(new DnsRecordInfoChange { Record = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.Removed, DnsServer = dnsServer });
|
||||
|
||||
RemoveRecord(record);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var record in dnsRecords)
|
||||
{
|
||||
dnsRecordChanges.Add(new DnsRecordInfoChange { Record = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.Added, DnsServer= dnsServer});
|
||||
|
||||
AddRecord(record);
|
||||
}
|
||||
|
||||
return dnsRecordChanges;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void AddRecords(IEnumerable<DnsRecordInfo> dnsRecords)
|
||||
{
|
||||
foreach (var record in dnsRecords)
|
||||
{
|
||||
AddRecord(record);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddRecord(DnsRecordInfo dnsRecord)
|
||||
{
|
||||
DataProvider.AddDomainDnsRecord(dnsRecord);
|
||||
}
|
||||
|
||||
private void SendMailMessage(UserInfo user, IEnumerable<DomainDnsChanges> domainsChanges)
|
||||
{
|
||||
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"];
|
||||
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"] = domainsChanges;
|
||||
|
||||
body = PackageController.EvaluateTemplate(body, items);
|
||||
|
||||
// send mail message
|
||||
MailHelper.SendMessage(from, mailTo, bcc, subject, body, priority, isHtml);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -39,6 +39,8 @@ using WebsitePanel.Server;
|
|||
using WebsitePanel.Providers.ResultObjects;
|
||||
using WebsitePanel.Providers.Web;
|
||||
using WebsitePanel.Providers.HostedSolution;
|
||||
using Whois.NET;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
|
@ -49,6 +51,24 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
private const string LOG_SOURCE_SERVERS = "SERVERS";
|
||||
|
||||
private static List<string> _createdDatePatterns = new List<string> { @"Creation Date:(.+)", // base
|
||||
@"created:(.+)",
|
||||
@"Created On:(.+)",
|
||||
@"Domain Registration Date:(.+)",
|
||||
@"Domain Create Date:(.+)",
|
||||
@"Registered on:(.+)"};
|
||||
|
||||
private static List<string> _expiredDatePatterns = new List<string> { @"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
|
||||
};
|
||||
|
||||
#region Servers
|
||||
public static List<ServerInfo> GetAllServers()
|
||||
{
|
||||
|
@ -1787,6 +1807,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS, domain, "");
|
||||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPSForPC, domain, "");
|
||||
}
|
||||
|
||||
UpdateDomainRegistrationData(domain);
|
||||
}
|
||||
|
||||
// add instant alias
|
||||
|
@ -2637,6 +2659,67 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static DomainInfo UpdateDomainRegistrationData(DomainInfo domain)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataProvider.UpdateDomainLastUpdateDate(domain.DomainId, DateTime.Now);
|
||||
|
||||
var whoisResult = WhoisClient.Query(domain.DomainName);
|
||||
|
||||
var createdDate = GetDomainInfoDate(whoisResult.Raw, _createdDatePatterns);
|
||||
var expiredDate = GetDomainInfoDate(whoisResult.Raw, _expiredDatePatterns);
|
||||
|
||||
if (createdDate != null)
|
||||
{
|
||||
domain.CreationDate = createdDate;
|
||||
DataProvider.UpdateDomainCreationDate(domain.DomainId, createdDate.Value);
|
||||
}
|
||||
|
||||
if (expiredDate != null)
|
||||
{
|
||||
domain.ExpirationDate = expiredDate;
|
||||
DataProvider.UpdateDomainExpirationDate(domain.DomainId, expiredDate.Value);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//wrong domain
|
||||
}
|
||||
|
||||
return domain;
|
||||
}
|
||||
|
||||
public static DomainInfo UpdateDomainRegistrationData(DomainInfo domain, DateTime? creationDate, DateTime? expirationDate)
|
||||
{
|
||||
domain.CreationDate = creationDate;
|
||||
DataProvider.UpdateDomainCreationDate(domain.DomainId, creationDate.Value);
|
||||
domain.ExpirationDate = expirationDate;
|
||||
DataProvider.UpdateDomainExpirationDate(domain.DomainId, expirationDate.Value);
|
||||
DataProvider.UpdateDomainLastUpdateDate(domain.DomainId, DateTime.Now);
|
||||
|
||||
return domain;
|
||||
}
|
||||
|
||||
private static DateTime? GetDomainInfoDate(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 DateTime.Parse(match.Groups[1].ToString().Trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DNS Zones
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<Reference Include="Ionic.Zip.Reduced">
|
||||
<HintPath>..\..\Lib\Ionic.Zip.Reduced.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IPAddressRange">
|
||||
<HintPath>..\..\Lib\References\Whois.NET\IPAddressRange.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Services3">
|
||||
<HintPath>..\..\Lib\Microsoft.Web.Services3.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
@ -62,6 +65,9 @@
|
|||
<Reference Include="WebsitePanel.Server.Client">
|
||||
<HintPath>..\..\Bin\WebsitePanel.Server.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WhoisClient">
|
||||
<HintPath>..\..\Lib\References\Whois.NET\WhoisClient.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Comments\CommentsController.cs" />
|
||||
|
@ -140,9 +146,11 @@
|
|||
<Compile Include="SchedulerTasks\CalculatePackagesDiskspaceTask.cs" />
|
||||
<Compile Include="SchedulerTasks\CancelOverdueInvoicesTask.cs" />
|
||||
<Compile Include="SchedulerTasks\CheckWebSiteTask.cs" />
|
||||
<Compile Include="SchedulerTasks\DomainExpirationTask.cs" />
|
||||
<Compile Include="SchedulerTasks\FTPFilesTask.cs" />
|
||||
<Compile Include="SchedulerTasks\GenerateInvoicesTask.cs" />
|
||||
<Compile Include="SchedulerTasks\HostedSolutionReport.cs" />
|
||||
<Compile Include="SchedulerTasks\DomainLookupViewTask.cs" />
|
||||
<Compile Include="SchedulerTasks\NotifyOverusedDatabasesTask.cs" />
|
||||
<Compile Include="SchedulerTasks\RunPaymentQueueTask.cs" />
|
||||
<Compile Include="SchedulerTasks\RunSystemCommandTask.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue