Domain Expiraiota task added non-existen option and email tempalte

This commit is contained in:
vfedosevich 2014-12-10 07:02:49 -08:00
parent 627572f1c7
commit 9ddd934ff5
6 changed files with 92 additions and 7 deletions

View file

@ -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.
</tbody>
</table>
<ad:if test="#IncludeNonExistenDomains#">
<p>
Please, find below details of your non-existen domains.
</p>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Customer</th>
</tr>
</thead>
<tbody>
<ad:foreach collection="#NonExistenDomains#" var="Domain" index="i">
<tr>
<td>#Domain.DomainName#</td>
<td>#Domain.Customer#</td>
</tr>
</ad:foreach>
</tbody>
</table>
</ad:if>
<p>
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
=================================
<ad:if test="#user#">
<p>
Hello #user.FirstName#,
</p>
</ad:if>
Please, find below details of your domain expiration information.
@ -6373,6 +6400,16 @@ Please, find below details of your domain expiration information.
</ad:foreach>
<ad:if test="#IncludeNonExistenDomains#">
Please, find below details of your non-existen domains.
<ad:foreach collection="#NonExistenDomains#" var="Domain" index="i">
Domain: #Domain.DomainName#
Customer: #Domain.Customer#
</ad:foreach>
</ad:if>
If you have any questions regarding your hosting account, feel free to contact our support department at any time.
Best regards')

View file

@ -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<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;
}
@ -47,7 +50,6 @@ namespace WebsitePanel.EnterpriseServer
var packages = GetUserPackages(user.UserId, user.Role);
var expiredDomains = new List<DomainInfo>();
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<DomainInfo> domains, Dictionary<int, UserInfo> domainUsers)
private void SendMailMessage(UserInfo user, IEnumerable<DomainInfo> domains, Dictionary<int, UserInfo> domainUsers, IEnumerable<DomainInfo> 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);

View file

@ -120,6 +120,9 @@
<data name="cbEnableNotify" xml:space="preserve">
<value>Enable Client Notification</value>
</data>
<data name="cbIncludeNonExistenDomains" xml:space="preserve">
<value>Include Non-Existen Domains</value>
</data>
<data name="lblDayBeforeNotify" xml:space="preserve">
<value>Notify before (days)</value>
</data>

View file

@ -10,6 +10,14 @@
<asp:CheckBox runat="server" ID="cbEnableNotify" meta:resourcekey="cbEnableNotify" /><br/>
</td>
</tr>
<tr>
<td class="SubHead" nowrap>
<asp:Label ID="lblSendNonExistenDomains" runat="server" meta:resourcekey="cbIncludeNonExistenDomains" Text="Include Non-Existen Domains:"></asp:Label>
</td>
<td>
<asp:CheckBox runat="server" ID="cbIncludeNonExistenDomains" meta:resourcekey="cbIncludeNonExistenDomains" /><br/>
</td>
</tr>
<tr>
<td class="SubHead" nowrap>
<asp:Label ID="lblMailTo" runat="server" meta:resourcekey="lblMailTo" Text="Mail To:"></asp:Label>

View file

@ -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);
}
/// <summary>
@ -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 };
}
}
}

View file

@ -30,6 +30,24 @@ namespace WebsitePanel.Portal.ScheduleTaskControls {
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox cbEnableNotify;
/// <summary>
/// lblSendNonExistenDomains control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblSendNonExistenDomains;
/// <summary>
/// cbIncludeNonExistenDomains control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox cbIncludeNonExistenDomains;
/// <summary>
/// lblMailTo control.
/// </summary>