From 7d753484d96c0eac6ab565e6eef2081b5532b2d6 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 10 Dec 2014 01:48:18 -0800 Subject: [PATCH 1/3] MX NS Scheduler tasks fixes --- WebsitePanel/Database/update_db.sql | 182 ++++++++++++++++-- .../Users/UserSettings.cs | 1 + .../Data/DataProvider.cs | 2 +- .../SchedulerTasks/DomainExpirationTask.cs | 8 + .../SchedulerTasks/DomainLookupViewTask.cs | 113 ++++++----- ...ecordCompare.cs => DnsRecordInfoChange.cs} | 6 +- .../DomainLookup/DomainChanges.cs | 19 -- .../DomainLookup/DomainDnsChanges.cs | 19 ++ .../DomainLookup/DomainDnsRecordsChanges.cs | 21 -- .../DomainLookup/ScheduleTaskEmailTemplate.cs | 15 -- .../WebsitePanel.Providers.Base.csproj | 6 +- .../SettingsDomainLookupLetter.ascx.resx | 147 ++++++++++++++ .../UserAccountMailTemplateSettings.ascx.resx | 3 + .../SettingsDomainLookupLetter.ascx | 42 ++++ .../SettingsDomainLookupLetter.ascx.cs | 33 ++++ ...ettingsDomainLookupLetter.ascx.designer.cs | 123 ++++++++++++ .../UserAccountMailTemplateSettings.ascx | 4 + ...countMailTemplateSettings.ascx.designer.cs | 9 + .../WebsitePanel.Portal.Modules.csproj | 9 + 19 files changed, 619 insertions(+), 143 deletions(-) rename WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/{DomainDnsRecordCompare.cs => DnsRecordInfoChange.cs} (64%) delete mode 100644 WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainChanges.cs create mode 100644 WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsChanges.cs delete mode 100644 WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordsChanges.cs delete mode 100644 WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/ScheduleTaskEmailTemplate.cs create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SettingsDomainLookupLetter.ascx.resx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx.cs create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx.designer.cs diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index a15974e1..89d4b28f 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6154,39 +6154,46 @@ GO -- Domain lookup tasks ---IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP') ---BEGIN ---INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'WebsitePanel.EnterpriseServer.DomainLookupViewTask, WebsitePanel.EnterpriseServer.Code', 1) ---END ---GO +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP') +BEGIN +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'WebsitePanel.EnterpriseServer.DomainLookupViewTask, WebsitePanel.EnterpriseServer.Code', 1) +END +GO ---IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskViewConfiguration] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP') ---BEGIN ---INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx') ---END ---GO +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskViewConfiguration] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP') +BEGIN +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx') +END +GO ---IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'DNS_SERVERS' ) ---BEGIN ---INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'DNS_SERVERS', N'String', NULL, 1) ---END ---GO +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'DNS_SERVERS' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'DNS_SERVERS', N'String', NULL, 1) +END +GO ---IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'MAIL_TO' ) ---BEGIN ---INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'MAIL_TO', N'String', NULL, 2) ---END ---GO +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'MAIL_TO' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'MAIL_TO', N'String', NULL, 2) +END +GO -- Domain Expiration Task IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION') BEGIN -INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'WebsitePanel.EnterpriseServer.DomainExpirationTask, WebsitePanel.EnterpriseServer.Code', 1) +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'WebsitePanel.EnterpriseServer.DomainExpirationTask, WebsitePanel.EnterpriseServer.Code', 3) END GO +IF EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION' AND [RoleID] = 1) +BEGIN +UPDATE [dbo].[ScheduleTasks] SET [RoleID] = 3 WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION' +END +GO + + IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskViewConfiguration] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION') BEGIN INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx') @@ -6366,6 +6373,139 @@ END GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'CC' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'CC', N'support@HostingCompany.com') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'From' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'From', N'support@HostingCompany.com') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'HtmlBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'HtmlBody', N' + + MX and NS Changes Information + + + +
+ + +
+ MX and NS Changes Information +
+ + +

+Hello #user.FirstName#, +

+
+ +

+Please, find below details of MX and NS changes. +

+ + +

#Domain.DomainName#

+ + + + + + + + + + + + + + + + + + + + +
DNSTypeStatusValue
#DnsChange.DnsServer##DnsChange.Type##DnsChange.Status##DnsChange.Record.Value#
+ +
+ +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards +

') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'Priority' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'Priority', N'Normal') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'Subject' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'Subject', N'MX and NS changes notification') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'TextBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'TextBody', N'================================= + MX and NS Changes Information +================================= + +

+Hello #user.FirstName#, +

+
+ +Please, find below details of your domain expiration information. + + + + + + #Domain.DomainName# + + + DNS: #DnsChange.DnsServer# + Type: #DnsChange.Type# + Status: #DnsChange.Status# + Value: #DnsChange.Record.Value# + + + + + + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards +') +END +GO + + -- Procedures for Domain lookup service IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetAllPackages') diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserSettings.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserSettings.cs index d5dcb39a..da8ad05c 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserSettings.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserSettings.cs @@ -46,6 +46,7 @@ namespace WebsitePanel.EnterpriseServer public const string ORGANIZATION_USER_SUMMARY_LETTER = "OrganizationUserSummaryLetter"; public const string VPS_SUMMARY_LETTER = "VpsSummaryLetter"; public const string DOMAIN_EXPIRATION_LETTER = "DomainExpirationLetter"; + public const string DOMAIN_LOOKUP_LETTER = "DomainLookupLetter"; public const string WEB_POLICY = "WebPolicy"; public const string FTP_POLICY = "FtpPolicy"; public const string MAIL_POLICY = "MailPolicy"; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs index 52c0bbc3..803bc8ef 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs @@ -4732,7 +4732,7 @@ namespace WebsitePanel.EnterpriseServer ); } - public static IDataReader GetDomainMXRecords(int domainId, DnsRecordType recordType) + public static IDataReader GetDomainDnsRecords(int domainId, DnsRecordType recordType) { return SqlHelper.ExecuteReader( ConnectionString, diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs index a500a869..088d9aa7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs @@ -27,6 +27,7 @@ namespace WebsitePanel.EnterpriseServer { BackgroundTask topTask = TaskManager.TopTask; var domainUsers = new Dictionary(); + var checkedDomains = new List(); // get input parameters int daysBeforeNotify; @@ -65,6 +66,13 @@ namespace WebsitePanel.EnterpriseServer foreach (var domain in domains) { + if (checkedDomains.Contains(domain.DomainId)) + { + continue; + } + + checkedDomains.Add(domain.DomainId); + ServerController.UpdateDomainRegistrationData(domain); if (CheckDomainExpiration(domain.ExpirationDate, daysBeforeNotify)) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs index 414b7fd2..930f40c7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs @@ -1,6 +1,8 @@ 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; @@ -22,7 +24,7 @@ namespace WebsitePanel.EnterpriseServer { BackgroundTask topTask = TaskManager.TopTask; - List domainsChanges = new List(); + List domainsChanges = new List(); // get input parameters string dnsServersString = (string)topTask.GetParamValue(DnsServersParameter); @@ -34,6 +36,14 @@ namespace WebsitePanel.EnterpriseServer 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(DataProvider.GetAllPackages()); @@ -48,11 +58,16 @@ namespace WebsitePanel.EnterpriseServer foreach (var domain in domains) { - DomainChanges domainChanges = new DomainChanges(); - domainChanges.Domain = domain.DomainName; + if (domainsChanges.Any(x => x.DomainName == domain.DomainName)) + { + continue; + } - var mxRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainMXRecords(domain.DomainId, DnsRecordType.MX)); - var nsRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainMXRecords(domain.DomainId, DnsRecordType.NS)); + DomainDnsChanges domainChanges = new DomainDnsChanges(); + domainChanges.DomainName = domain.DomainName; + + var mxRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainDnsRecords(domain.DomainId, DnsRecordType.MX)); + var nsRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainDnsRecords(domain.DomainId, DnsRecordType.NS)); //execute server foreach (var dnsServer in dnsServers) @@ -63,8 +78,8 @@ namespace WebsitePanel.EnterpriseServer FillRecordData(dnsMxRecords, domain, dnsServer); FillRecordData(dnsNsRecords, domain, dnsServer); - domainChanges.DnsChanges.Add(ApplyDomainRecordsChanges(mxRecords, dnsMxRecords, dnsServer)); - domainChanges.DnsChanges.Add(ApplyDomainRecordsChanges(nsRecords, dnsNsRecords, dnsServer)); + domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(mxRecords, dnsMxRecords, dnsServer)); + domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(nsRecords, dnsNsRecords, dnsServer)); } domainsChanges.Add(domainChanges); @@ -75,7 +90,7 @@ namespace WebsitePanel.EnterpriseServer if (changedDomains.Any()) { - SendMailMessage(changedDomains); + SendMailMessage(user,changedDomains); } } @@ -83,20 +98,20 @@ namespace WebsitePanel.EnterpriseServer #region Helpers - private IEnumerable FindDomainsWithChangedRecords(IEnumerable domainsChanges) + private IEnumerable FindDomainsWithChangedRecords(IEnumerable domainsChanges) { - var changedDomains = new List(); + var changedDomains = new List(); foreach (var domainChanges in domainsChanges) { - var firstTimeAdditon = domainChanges.DnsChanges.All(x => x.DnsRecordsCompare.All(dns => dns.DbRecord == null)); + var firstTimeAdditon = domainChanges.DnsChanges.All(x => x.Status == DomainDnsRecordStatuses.Added); if (firstTimeAdditon) { continue; } - bool isChanged = domainChanges.DnsChanges.Any(x => x.DnsRecordsCompare.Any(d => d.Status != DomainDnsRecordStatuses.NotChanged)); + bool isChanged = domainChanges.DnsChanges.Any(d => d.Status != DomainDnsRecordStatuses.NotChanged); if (isChanged) { @@ -107,10 +122,9 @@ namespace WebsitePanel.EnterpriseServer return changedDomains; } - private DomainDnsRecordsChanges ApplyDomainRecordsChanges(List dbRecords, List dnsRecords, string dnsServer) + private IEnumerable ApplyDomainRecordsChanges(List dbRecords, List dnsRecords, string dnsServer) { - var domainRecordChanges = new DomainDnsRecordsChanges(); - domainRecordChanges.DnsServer = dnsServer; + var dnsRecordChanges = new List(); var filteredDbRecords = dbRecords.Where(x => x.DnsServer == dnsServer); @@ -120,30 +134,26 @@ namespace WebsitePanel.EnterpriseServer if (dnsRecord != null) { - domainRecordChanges.DnsRecordsCompare.Add(new DomainDnsRecordCompare { DbRecord = record, DnsRecord = dnsRecord, Type= record.RecordType, Status = DomainDnsRecordStatuses.NotChanged }); + dnsRecordChanges.Add(new DnsRecordInfoChange { Record = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.NotChanged, DnsServer = dnsServer }); dnsRecords.Remove(dnsRecord); } else { - domainRecordChanges.DnsRecordsCompare.Add(new DomainDnsRecordCompare { DbRecord = record, DnsRecord = null, Type = record.RecordType, Status = DomainDnsRecordStatuses.Removed }); + dnsRecordChanges.Add(new DnsRecordInfoChange { Record = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.Removed, DnsServer = dnsServer }); RemoveRecord(record); - - domainRecordChanges.IsChanged = true; } } foreach (var record in dnsRecords) { - domainRecordChanges.DnsRecordsCompare.Add(new DomainDnsRecordCompare { DbRecord = null, DnsRecord = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.Added }); + dnsRecordChanges.Add(new DnsRecordInfoChange { Record = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.Added, DnsServer= dnsServer}); AddRecord(record); - - domainRecordChanges.IsChanged = true; } - return domainRecordChanges; + return dnsRecordChanges; } private void FillRecordData(IEnumerable records, DomainInfo domain, string dnsServer) @@ -187,52 +197,37 @@ namespace WebsitePanel.EnterpriseServer DataProvider.AddDomainDnsRecord(dnsRecord); } - private void SendMailMessage(IEnumerable domainsChanges) + private void SendMailMessage(UserInfo user, IEnumerable domainsChanges) { BackgroundTask topTask = TaskManager.TopTask; - var bodyTempalte = ObjectUtils.FillObjectFromDataReader(DataProvider.GetScheduleTaskEmailTemplate(TaskId)); - var domainRecordTemplate = ObjectUtils.FillObjectFromDataReader(DataProvider.GetScheduleTaskEmailTemplate(TaskId)); + 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 mailFrom = "wsp-scheduler@noreply.net"; string mailTo = (string)topTask.GetParamValue("MAIL_TO"); - string mailSubject = "MX and NS notification"; - if (String.IsNullOrEmpty(mailTo)) - { - TaskManager.WriteWarning("The e-mail message has not been sent because 'Mail To' is empty."); - } - else - { - var tableRecords = new List(); + Hashtable items = new Hashtable(); - foreach (var domain in domainsChanges) - { - var changes = domain.DnsChanges; + items["user"] = user; + items["Domains"] = domainsChanges; - foreach (var dnsChanged in changes.Where(x=>x.IsChanged)) - { - foreach (var record in dnsChanged.DnsRecordsCompare.Where(x=>x.Status != DomainDnsRecordStatuses.NotChanged)) - { - var tableRow = Utils.ReplaceStringVariable(domainRecordTemplate.Template, "domain", domain.Domain); - tableRow = Utils.ReplaceStringVariable(tableRow, "dns", dnsChanged.DnsServer); - tableRow = Utils.ReplaceStringVariable(tableRow, "recordType", record.Type.ToString()); - tableRow = Utils.ReplaceStringVariable(tableRow, "dbRecord", record.DbRecord != null ? record.DbRecord.Value : "-"); - tableRow = Utils.ReplaceStringVariable(tableRow, "dnsRecord", record.DnsRecord != null ? record.DnsRecord.Value : "-"); + body = PackageController.EvaluateTemplate(body, items); - tableRecords.Add(tableRow); - } - } - } - - - var mailBody = Utils.ReplaceStringVariable(bodyTempalte.Template, "RecordRow", string.Join(" ", tableRecords)); - - // send mail message - MailHelper.SendMessage(mailFrom, mailTo, mailSubject, mailBody, true); - } - } + // send mail message + MailHelper.SendMessage(from, mailTo, bcc, subject, body, priority, isHtml); + } #endregion } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordCompare.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DnsRecordInfoChange.cs similarity index 64% rename from WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordCompare.cs rename to WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DnsRecordInfoChange.cs index e21d0eac..183c16e0 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordCompare.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DnsRecordInfoChange.cs @@ -6,10 +6,10 @@ using WebsitePanel.Providers.DNS; namespace WebsitePanel.Providers.DomainLookup { - public class DomainDnsRecordCompare + public class DnsRecordInfoChange { - public DnsRecordInfo DbRecord { get; set; } - public DnsRecordInfo DnsRecord { get; set; } + public string DnsServer { get; set; } + public DnsRecordInfo Record { get; set; } public DomainDnsRecordStatuses Status { get; set; } public DnsRecordType Type { get; set; } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainChanges.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainChanges.cs deleted file mode 100644 index 9af977ae..00000000 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainChanges.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace WebsitePanel.Providers.DomainLookup -{ - public class DomainChanges - { - public string Domain { get; set; } - - public List DnsChanges { get; set; } - - public DomainChanges() - { - DnsChanges = new List(); - } - } -} diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsChanges.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsChanges.cs new file mode 100644 index 00000000..ff178e77 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsChanges.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace WebsitePanel.Providers.DomainLookup +{ + public class DomainDnsChanges + { + public string DomainName { get; set; } + + public List DnsChanges { get; set; } + + public DomainDnsChanges() + { + DnsChanges = new List(); + } + } +} diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordsChanges.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordsChanges.cs deleted file mode 100644 index 27d07337..00000000 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordsChanges.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace WebsitePanel.Providers.DomainLookup -{ - public class DomainDnsRecordsChanges - { - public string DnsServer { get; set; } - - public bool IsChanged { get; set; } - - public List DnsRecordsCompare { get; set; } - - public DomainDnsRecordsChanges() - { - DnsRecordsCompare = new List(); - } - } -} diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/ScheduleTaskEmailTemplate.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/ScheduleTaskEmailTemplate.cs deleted file mode 100644 index 4680efed..00000000 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/ScheduleTaskEmailTemplate.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace WebsitePanel.Providers.DomainLookup -{ - public class ScheduleTaskEmailTemplate - { - public string TaskId { get; set; } - public string From { get; set; } - public string Subject { get; set; } - public string Template { get; set; } - } -} diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj b/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj index 43abd255..93fd43e7 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj @@ -86,11 +86,9 @@ - - - + + - diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SettingsDomainLookupLetter.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SettingsDomainLookupLetter.ascx.resx new file mode 100644 index 00000000..c0e9bcb8 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SettingsDomainLookupLetter.ascx.resx @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + High + + + Low + + + Normal + + + CC: + + + From: + + + HTML Body: + + + Priority: + + + Subject: + + + Text Body: + + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/UserAccountMailTemplateSettings.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/UserAccountMailTemplateSettings.ascx.resx index 5d73fb9d..fddd4fbc 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/UserAccountMailTemplateSettings.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/UserAccountMailTemplateSettings.ascx.resx @@ -144,4 +144,7 @@ Domain Expiration Letter + + Domain MX and NS Letter + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx new file mode 100644 index 00000000..435167f8 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx @@ -0,0 +1,42 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SettingsDomainLookupLetter.ascx.cs" Inherits="WebsitePanel.Portal.SettingsDomainLookupLetter" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + High + Normal + Low + +


+


+
\ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx.cs new file mode 100644 index 00000000..b8a9951d --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using WebsitePanel.EnterpriseServer; + +namespace WebsitePanel.Portal +{ + public partial class SettingsDomainLookupLetter : WebsitePanelControlBase, IUserSettingsEditorControl + { + public void BindSettings(UserSettings settings) + { + txtFrom.Text = settings["From"]; + txtCC.Text = settings["CC"]; + txtSubject.Text = settings["Subject"]; + Utils.SelectListItem(ddlPriority, settings["Priority"]); + txtHtmlBody.Text = settings["HtmlBody"]; + txtTextBody.Text = settings["TextBody"]; + } + + public void SaveSettings(UserSettings settings) + { + settings["From"] = txtFrom.Text; + settings["CC"] = txtCC.Text; + settings["Subject"] = txtSubject.Text; + settings["Priority"] = ddlPriority.SelectedValue; + settings["HtmlBody"] = txtHtmlBody.Text; + settings["TextBody"] = txtTextBody.Text; + } + } +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx.designer.cs new file mode 100644 index 00000000..afcf7988 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsDomainLookupLetter.ascx.designer.cs @@ -0,0 +1,123 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WebsitePanel.Portal { + + + public partial class SettingsDomainLookupLetter { + + /// + /// lblFrom control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblFrom; + + /// + /// txtFrom control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtFrom; + + /// + /// lblCC control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblCC; + + /// + /// txtCC control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtCC; + + /// + /// lblSubject control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblSubject; + + /// + /// txtSubject control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtSubject; + + /// + /// lblPriority control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblPriority; + + /// + /// ddlPriority control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList ddlPriority; + + /// + /// lblHtmlBody control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblHtmlBody; + + /// + /// txtHtmlBody control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtHtmlBody; + + /// + /// lblTextBody control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblTextBody; + + /// + /// txtTextBody control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtTextBody; + } +} diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMailTemplateSettings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMailTemplateSettings.ascx index 218e959e..45a3d489 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMailTemplateSettings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMailTemplateSettings.ascx @@ -34,6 +34,10 @@ +
  • + +
  • diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMailTemplateSettings.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMailTemplateSettings.ascx.designer.cs index 6fd0c406..0822c99e 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMailTemplateSettings.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMailTemplateSettings.ascx.designer.cs @@ -84,6 +84,15 @@ namespace WebsitePanel.Portal { /// protected global::System.Web.UI.WebControls.HyperLink lnkDomainExpirationLetter; + /// + /// lnkDomainLookupLetter control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HyperLink lnkDomainLookupLetter; + /// /// btnCancel control. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj index df6b3ef5..25d1e885 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -314,6 +314,13 @@ SettingsDomainExpirationLetter.ascx + + SettingsDomainLookupLetter.ascx + ASPXCodeBehind + + + SettingsDomainLookupLetter.ascx + SettingsServiceLevels.ascx ASPXCodeBehind @@ -4269,6 +4276,7 @@ + ResXFileCodeGenerator DomainLookupView.ascx.Designer.cs @@ -4276,6 +4284,7 @@ + From 627572f1c766fddfa1cd9406fa9c762af17216f3 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 10 Dec 2014 05:46:38 -0800 Subject: [PATCH 2/3] Domain Expiration tasks Fixes --- WebsitePanel/Database/update_db.sql | 21 +++++++++++++++++++ .../Servers/DomainInfo.cs | 1 + .../Data/DataProvider.cs | 5 +++++ .../SchedulerTasks/DomainExpirationTask.cs | 16 ++++++++++++-- .../Servers/ServerController.cs | 13 ++++++++++++ .../App_LocalResources/Domains.ascx.resx | 6 ++++++ .../DesktopModules/WebsitePanel/Domains.ascx | 2 +- .../WebsitePanel/Domains.ascx.cs | 21 ++++++++++++++----- 8 files changed, 77 insertions(+), 8 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 89d4b28f..aff39efa 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6254,6 +6254,13 @@ BEGIN END GO +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'LastUpdateDate' AND [object_id] = OBJECT_ID(N'Domains')) +BEGIN + ALTER TABLE [dbo].[Domains] ADD LastUpdateDate DateTime null; +END +GO + IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'ScheduleTasksEmailTemplates') DROP TABLE ScheduleTasksEmailTemplates GO @@ -6639,6 +6646,18 @@ AS UPDATE [dbo].[Domains] SET [ExpirationDate] = @Date WHERE [DomainID] = @DomainId GO +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateDomainLastUpdateDate') +DROP PROCEDURE UpdateDomainLastUpdateDate +GO +CREATE PROCEDURE [dbo].UpdateDomainLastUpdateDate +( + @DomainId INT, + @Date DateTime +) +AS +UPDATE [dbo].[Domains] SET [LastUpdateDate] = @Date WHERE [DomainID] = @DomainId +GO + --Updating Domain procedures @@ -6673,6 +6692,7 @@ SELECT D.IsInstantAlias, D.CreationDate, D.ExpirationDate, + D.LastUpdateDate, D.IsDomainPointer FROM Domains AS D INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON D.PackageID = PT.PackageID @@ -6754,6 +6774,7 @@ SET @sql = @sql + ' SELECT COUNT(DomainID) FROM @Domains;SELECT D.IsInstantAlias, D.IsDomainPointer, D.ExpirationDate, + D.LastUpdateDate, P.PackageName, ISNULL(SRV.ServerID, 0) AS ServerID, ISNULL(SRV.ServerName, '''') AS ServerName, diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/DomainInfo.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/DomainInfo.cs index d4a4c5d8..1fbca5da 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/DomainInfo.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/DomainInfo.cs @@ -150,5 +150,6 @@ namespace WebsitePanel.EnterpriseServer public DateTime? CreationDate { get; set; } public DateTime? ExpirationDate { get; set; } + public DateTime? LastUpdateDate { get; set; } } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs index 803bc8ef..5edbdd3d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs @@ -4787,6 +4787,11 @@ namespace WebsitePanel.EnterpriseServer 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( diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs index 088d9aa7..986118e4 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs @@ -53,9 +53,11 @@ namespace WebsitePanel.EnterpriseServer { var domains = ServerController.GetDomains(package.PackageId); - domains = domains.Where(x => !x.IsSubDomain && !x.IsDomainPointer).ToList(); //Selecting top-level domains + var subDomains = domains.Where(x => x.IsSubDomain).ToList(); - domains = domains.Where(x => x.CreationDate == null || x.ExpirationDate == null ? true : CheckDomainExpiration(x.ExpirationDate, daysBeforeNotify)).ToList(); // selecting expired or with empty expire date domains + 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); @@ -80,6 +82,16 @@ namespace WebsitePanel.EnterpriseServer expiredDomains.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(); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs index 059ba096..ecb354b9 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs @@ -2664,6 +2664,8 @@ namespace WebsitePanel.EnterpriseServer { try { + DataProvider.UpdateDomainLastUpdateDate(domain.DomainId, DateTime.Now); + var whoisResult = WhoisClient.Query(domain.DomainName); var createdDate = GetDomainInfoDate(whoisResult.Raw, _createdDatePatterns); @@ -2689,6 +2691,17 @@ namespace WebsitePanel.EnterpriseServer 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 patterns) { foreach (var createdRegex in patterns) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/Domains.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/Domains.ascx.resx index 66e3563a..3116414f 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/Domains.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/Domains.ascx.resx @@ -207,4 +207,10 @@ Expiration Date + + Not Checked + + + Non-Existent + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx index 7d3d6a3f..e7b86704 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx @@ -40,7 +40,7 @@ - <%# GetDomainExpirationDate(Eval("ExpirationDate"))%> + <%# GetDomainExpirationDate(Eval("ExpirationDate"), Eval("LastUpdateDate"))%> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx.cs index acbf7863..77ccd425 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx.cs @@ -100,16 +100,27 @@ namespace WebsitePanel.Portal return GetLocalizedString("DomainType.Domain"); } - public string GetDomainExpirationDate(object expirationDateObject) + public string GetDomainExpirationDate(object expirationDateObject, object LastUpdateDateObject) { var expirationDate = expirationDateObject as DateTime?; + var lastUpdateDate = LastUpdateDateObject as DateTime?; - if (expirationDate == null) - return GetLocalizedString("DomainExpirationDate.Unknown"); - else if (expirationDate < DateTime.Now) + if (expirationDate != null && expirationDate < DateTime.Now) + { return GetLocalizedString("DomainExpirationDate.Expired"); - else + } + else if(expirationDate != null) + { return expirationDate.Value.ToShortDateString(); + } + else if (lastUpdateDate == null) + { + return GetLocalizedString("DomainExpirationDate.NotChecked"); + } + else + { + return GetLocalizedString("DomainExpirationDate.NotExist"); + } } protected void odsDomainsPaged_Selected(object sender, ObjectDataSourceStatusEventArgs e) From 9ddd934ff52be3f49e37d1c95d2b941eb835a09e Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 10 Dec 2014 07:02:49 -0800 Subject: [PATCH 3/3] Domain Expiraiota task added non-existen option and email tempalte --- WebsitePanel/Database/update_db.sql | 41 ++++++++++++++++++- .../SchedulerTasks/DomainExpirationTask.cs | 24 +++++++++-- .../DomainExpirationView.ascx.resx | 3 ++ .../DomainExpirationView.ascx | 8 ++++ .../DomainExpirationView.ascx.cs | 5 ++- .../DomainExpirationView.ascx.designer.cs | 18 ++++++++ 6 files changed, 92 insertions(+), 7 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index aff39efa..c2c07f94 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6218,6 +6218,12 @@ INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [D END GO +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION' AND [ParameterID]= N'INCLUDE_NONEXISTEN_DOMAINS' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'INCLUDE_NONEXISTEN_DOMAINS', N'Boolean', N'false', 4) +END +GO + -- Domain lookup tables @@ -6332,6 +6338,29 @@ Please, find below details of your domain expiration information. + +

    + Please, find below details of your non-existen domains. +

    + + + + + + + + + + + + + + + + +
    DomainCustomer
    #Domain.DomainName##Domain.Customer#
    +
    +

    If you have any questions regarding your hosting account, feel free to contact our support department at any time. @@ -6358,9 +6387,7 @@ INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [Property Domain Expiration Information ================================= -

    Hello #user.FirstName#, -

    Please, find below details of your domain expiration information. @@ -6373,6 +6400,16 @@ Please, find below details of your domain expiration information. + +Please, find below details of your non-existen domains. + + + Domain: #Domain.DomainName# + Customer: #Domain.Customer# + + + + If you have any questions regarding your hosting account, feel free to contact our support department at any time. Best regards') diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs index 986118e4..f3cbf413 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs @@ -18,6 +18,7 @@ namespace WebsitePanel.EnterpriseServer 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"; @@ -28,16 +29,18 @@ namespace WebsitePanel.EnterpriseServer BackgroundTask topTask = TaskManager.TopTask; var domainUsers = new Dictionary(); var checkedDomains = new List(); + var expiredDomains = new List(); + var nonExistenDomains = new List(); // 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; } @@ -47,7 +50,6 @@ namespace WebsitePanel.EnterpriseServer var packages = GetUserPackages(user.UserId, user.Role); - var expiredDomains = new List(); foreach (var package in packages) { @@ -81,6 +83,11 @@ namespace WebsitePanel.EnterpriseServer { expiredDomains.Add(domain); } + + if (domain.ExpirationDate == null && domain.CreationDate == null) + { + nonExistenDomains.Add(domain); + } } foreach (var subDomain in subDomains) @@ -98,7 +105,7 @@ namespace WebsitePanel.EnterpriseServer if (expiredDomains.Count > 0 && sendEmailNotifcation) { - SendMailMessage(user, expiredDomains, domainUsers); + SendMailMessage(user, expiredDomains, domainUsers, nonExistenDomains, includeNonExistenDomains); } } @@ -133,7 +140,7 @@ namespace WebsitePanel.EnterpriseServer return (date.Value - DateTime.Now).Days < daysBeforeNotify; } - private void SendMailMessage(UserInfo user, IEnumerable domains, Dictionary domainUsers) + private void SendMailMessage(UserInfo user, IEnumerable domains, Dictionary domainUsers, IEnumerable nonExistenDomains, bool includeNonExistenDomains) { BackgroundTask topTask = TaskManager.TopTask; @@ -160,6 +167,15 @@ namespace WebsitePanel.EnterpriseServer 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); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/App_LocalResources/DomainExpirationView.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/App_LocalResources/DomainExpirationView.ascx.resx index 85ff7ae2..e5d6418b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/App_LocalResources/DomainExpirationView.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/App_LocalResources/DomainExpirationView.ascx.resx @@ -120,6 +120,9 @@ Enable Client Notification + + Include Non-Existen Domains + Notify before (days) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx index b74c3128..9f341587 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx @@ -10,6 +10,14 @@
    + + + + + +
    + + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx.cs index e5e12907..80aaaf00 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx.cs @@ -14,6 +14,7 @@ namespace WebsitePanel.Portal.ScheduleTaskControls private static readonly string DaysBeforeParameter = "DAYS_BEFORE"; private static readonly string MailToParameter = "MAIL_TO"; private static readonly string EnableNotificationParameter = "ENABLE_NOTIFICATION"; + private static readonly string IncludeNonExistenDomainsParameter = "INCLUDE_NONEXISTEN_DOMAINS"; protected void Page_Load(object sender, EventArgs e) { @@ -31,6 +32,7 @@ namespace WebsitePanel.Portal.ScheduleTaskControls this.SetParameter(this.txtDaysBeforeNotify, DaysBeforeParameter); this.SetParameter(this.txtMailTo, MailToParameter); this.SetParameter(this.cbEnableNotify, EnableNotificationParameter); + this.SetParameter(this.cbIncludeNonExistenDomains, IncludeNonExistenDomainsParameter); } /// @@ -42,8 +44,9 @@ namespace WebsitePanel.Portal.ScheduleTaskControls ScheduleTaskParameterInfo daysBefore = this.GetParameter(this.txtDaysBeforeNotify, DaysBeforeParameter); ScheduleTaskParameterInfo mailTo = this.GetParameter(this.txtMailTo, MailToParameter); ScheduleTaskParameterInfo enableNotification = this.GetParameter(this.cbEnableNotify, EnableNotificationParameter); + ScheduleTaskParameterInfo includeNonExistenDomains = this.GetParameter(this.cbIncludeNonExistenDomains, IncludeNonExistenDomainsParameter); - return new ScheduleTaskParameterInfo[3] { daysBefore, mailTo, enableNotification }; + return new ScheduleTaskParameterInfo[4] { daysBefore, mailTo, enableNotification, includeNonExistenDomains }; } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx.designer.cs index 994ed328..27ee5ba7 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx.designer.cs @@ -30,6 +30,24 @@ namespace WebsitePanel.Portal.ScheduleTaskControls { /// protected global::System.Web.UI.WebControls.CheckBox cbEnableNotify; + /// + /// lblSendNonExistenDomains control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblSendNonExistenDomains; + + /// + /// cbIncludeNonExistenDomains control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox cbIncludeNonExistenDomains; + /// /// lblMailTo control. ///