Domain Expiraiota task added non-existen option and email tempalte
This commit is contained in:
parent
627572f1c7
commit
9ddd934ff5
6 changed files with 92 additions and 7 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue