feature: email service and configuration

This commit is contained in:
Gary Sharp
2021-01-10 13:57:25 +11:00
parent af4a94870e
commit 806aadd161
14 changed files with 1229 additions and 186 deletions
@@ -271,6 +271,39 @@ namespace Disco.Data.Configuration
} }
#endregion #endregion
#region Email Configuration
public string EmailSmtpServer
{
get => Get<string>(null);
set => Set(value);
}
public int EmailSmtpPort
{
get => Get(25);
set => Set(value);
}
public bool EmailEnableSsl
{
get => Get(false);
set => Set(value);
}
public string EmailFromAddress
{
get => Get<string>(null);
set => Set(value);
}
public string EmailUsername
{
get => Get<string>(null);
set => Set(value);
}
public string EmailPassword
{
get => GetDeobsfucated(null);
set => SetObsfucated(value);
}
#endregion
#region UpdateCheck #region UpdateCheck
public string DeploymentId public string DeploymentId
{ {
+2
View File
@@ -143,6 +143,8 @@
<Compile Include="Services\Jobs\JobLists\JobTableStatusQueueItemModel.cs" /> <Compile Include="Services\Jobs\JobLists\JobTableStatusQueueItemModel.cs" />
<Compile Include="Services\Jobs\JobQueues\IJobQueueToken.cs" /> <Compile Include="Services\Jobs\JobQueues\IJobQueueToken.cs" />
<Compile Include="Services\Jobs\Noticeboards\IHeldDeviceItem.cs" /> <Compile Include="Services\Jobs\Noticeboards\IHeldDeviceItem.cs" />
<Compile Include="Services\Messaging\Email.cs" />
<Compile Include="Services\Messaging\EmailAttachment.cs" />
<Compile Include="Services\Searching\DeviceSearchResultItem.cs" /> <Compile Include="Services\Searching\DeviceSearchResultItem.cs" />
<Compile Include="Services\Searching\ISearchResultItem.cs" /> <Compile Include="Services\Searching\ISearchResultItem.cs" />
<Compile Include="Services\Searching\JobSearchResultItem.cs" /> <Compile Include="Services\Searching\JobSearchResultItem.cs" />
+30
View File
@@ -0,0 +1,30 @@
using System.Collections.Generic;
namespace Disco.Models.Services.Messaging
{
public class Email
{
public string From { get; set; }
public List<string> To { get; } = new List<string>();
public List<string> CC { get; } = new List<string>();
public List<string> BCC { get; } = new List<string>();
public string Subject { get; set; }
public bool IsBodyHtml { get; set; }
public string Body { get; set; }
public List<EmailAttachment> Attachments { get; } = new List<EmailAttachment>();
public Email()
{
}
public Email(string to, string subject, string body)
: this()
{
To.Add(to);
Subject = subject;
Body = body;
}
}
}
@@ -0,0 +1,8 @@
namespace Disco.Models.Services.Messaging
{
public class EmailAttachment
{
public string Name { get; set; }
public byte[] Data { get; set; }
}
}
+8
View File
@@ -60,6 +60,7 @@ namespace Disco.Services.Authorization
{ "Config.Plugin.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Plugin.Show, (c, v) => c.Config.Plugin.Show = v, "Show Plugins", "Can show plugins", false) }, { "Config.Plugin.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Plugin.Show, (c, v) => c.Config.Plugin.Show = v, "Show Plugins", "Can show plugins", false) },
{ "Config.Plugin.Uninstall", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Plugin.Uninstall, (c, v) => c.Config.Plugin.Uninstall = v, "Uninstall Plugins", "Can uninstall plugins", false) }, { "Config.Plugin.Uninstall", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Plugin.Uninstall, (c, v) => c.Config.Plugin.Uninstall = v, "Uninstall Plugins", "Can uninstall plugins", false) },
{ "Config.System.ConfigureActiveDirectory", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.ConfigureActiveDirectory, (c, v) => c.Config.System.ConfigureActiveDirectory = v, "Configure Active Directory Settings", "Can configure the Active Directory interoperability settings", false) }, { "Config.System.ConfigureActiveDirectory", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.ConfigureActiveDirectory, (c, v) => c.Config.System.ConfigureActiveDirectory = v, "Configure Active Directory Settings", "Can configure the Active Directory interoperability settings", false) },
{ "Config.System.ConfigureEmail", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.ConfigureEmail, (c, v) => c.Config.System.ConfigureEmail = v, "Configure Email Settings", "Can configure the email settings", false) },
{ "Config.System.ConfigureProxy", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.ConfigureProxy, (c, v) => c.Config.System.ConfigureProxy = v, "Configure Proxy Settings", "Can configure the proxy settings", false) }, { "Config.System.ConfigureProxy", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.ConfigureProxy, (c, v) => c.Config.System.ConfigureProxy = v, "Configure Proxy Settings", "Can configure the proxy settings", false) },
{ "Config.System.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.Show, (c, v) => c.Config.System.Show = v, "Show System Configuration", "Can show the system configuration", false) }, { "Config.System.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.Show, (c, v) => c.Config.System.Show = v, "Show System Configuration", "Can show the system configuration", false) },
{ "Config.Organisation.ConfigureAddresses", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Organisation.ConfigureAddresses, (c, v) => c.Config.Organisation.ConfigureAddresses = v, "Configure Addresses", "Can configure organisation addresses", false) }, { "Config.Organisation.ConfigureAddresses", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Organisation.ConfigureAddresses, (c, v) => c.Config.Organisation.ConfigureAddresses = v, "Configure Addresses", "Can configure organisation addresses", false) },
@@ -297,6 +298,7 @@ namespace Disco.Services.Authorization
}), }),
new ClaimNavigatorItem("Config.System", "System", "Permissions related to System Configuration", false, new List<IClaimNavigatorItem>() { new ClaimNavigatorItem("Config.System", "System", "Permissions related to System Configuration", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.System.ConfigureActiveDirectory", false), new ClaimNavigatorItem("Config.System.ConfigureActiveDirectory", false),
new ClaimNavigatorItem("Config.System.ConfigureEmail", false),
new ClaimNavigatorItem("Config.System.ConfigureProxy", false), new ClaimNavigatorItem("Config.System.ConfigureProxy", false),
new ClaimNavigatorItem("Config.System.Show", false) new ClaimNavigatorItem("Config.System.Show", false)
}), }),
@@ -574,6 +576,7 @@ namespace Disco.Services.Authorization
c.Config.Plugin.Show = true; c.Config.Plugin.Show = true;
c.Config.Plugin.Uninstall = true; c.Config.Plugin.Uninstall = true;
c.Config.System.ConfigureActiveDirectory = true; c.Config.System.ConfigureActiveDirectory = true;
c.Config.System.ConfigureEmail = true;
c.Config.System.ConfigureProxy = true; c.Config.System.ConfigureProxy = true;
c.Config.System.Show = true; c.Config.System.Show = true;
c.Config.Organisation.ConfigureAddresses = true; c.Config.Organisation.ConfigureAddresses = true;
@@ -993,6 +996,11 @@ namespace Disco.Services.Authorization
/// </summary> /// </summary>
public const string ConfigureActiveDirectory = "Config.System.ConfigureActiveDirectory"; public const string ConfigureActiveDirectory = "Config.System.ConfigureActiveDirectory";
/// <summary>Configure Email Settings
/// <para>Can configure the email settings</para>
/// </summary>
public const string ConfigureEmail = "Config.System.ConfigureEmail";
/// <summary>Configure Proxy Settings /// <summary>Configure Proxy Settings
/// <para>Can configure the proxy settings</para> /// <para>Can configure the proxy settings</para>
/// </summary> /// </summary>
@@ -9,6 +9,9 @@
[ClaimDetails("Configure Proxy Settings", "Can configure the proxy settings")] [ClaimDetails("Configure Proxy Settings", "Can configure the proxy settings")]
public bool ConfigureProxy { get; set; } public bool ConfigureProxy { get; set; }
[ClaimDetails("Configure Email Settings", "Can configure the email settings")]
public bool ConfigureEmail { get; set; }
[ClaimDetails("Configure Active Directory Settings", "Can configure the Active Directory interoperability settings")] [ClaimDetails("Configure Active Directory Settings", "Can configure the Active Directory interoperability settings")]
public bool ConfigureActiveDirectory { get; set; } public bool ConfigureActiveDirectory { get; set; }
} }
+1
View File
@@ -390,6 +390,7 @@
<Compile Include="Logging\Persistance\LogPersistContext.cs" /> <Compile Include="Logging\Persistance\LogPersistContext.cs" />
<Compile Include="Logging\Persistance\LogPersistContextInitializer.cs" /> <Compile Include="Logging\Persistance\LogPersistContextInitializer.cs" />
<Compile Include="Logging\Utilities.cs" /> <Compile Include="Logging\Utilities.cs" />
<Compile Include="Messaging\EmailService.cs" />
<Compile Include="Plugins\Features\CertificateAuthorityProvider\CertificateAuthorityProviderFeature.cs" /> <Compile Include="Plugins\Features\CertificateAuthorityProvider\CertificateAuthorityProviderFeature.cs" />
<Compile Include="Plugins\Features\CertificateProvider\ProvisionPersonalCertificateResult.cs" /> <Compile Include="Plugins\Features\CertificateProvider\ProvisionPersonalCertificateResult.cs" />
<Compile Include="Plugins\Features\CertificateAuthorityProvider\ProvisionAuthorityCertificatesResult.cs" /> <Compile Include="Plugins\Features\CertificateAuthorityProvider\ProvisionAuthorityCertificatesResult.cs" />
+109
View File
@@ -0,0 +1,109 @@
using Disco.Data.Configuration;
using Disco.Data.Repository;
using Disco.Models.Services.Messaging;
using System;
using System.Net;
using System.Net.Mail;
namespace Disco.Services.Messaging
{
public static class EmailService
{
private static string smtpServer;
private static int smtpPort;
private static string smtpFromAddress;
private static bool smtpEnableSsl;
private static string smtpUsername;
private static string smtpPassword;
public static bool IsConfigured { get; private set; }
static EmailService()
{
using (var database = new DiscoDataContext())
{
Update(database.DiscoConfiguration);
}
}
public static void ValidateConfiguration(string smtpServer, int smtpPort, string fromAddress, bool enableSsl, string username, string password)
{
// if smtpServer is null, we aren't configured (emailing is disabled)
if (!string.IsNullOrWhiteSpace(smtpServer))
{
// validate
if (smtpPort <= 0)
throw new ArgumentOutOfRangeException(nameof(smtpPort), "Invalid SMTP port specified");
if (string.IsNullOrWhiteSpace(fromAddress))
throw new ArgumentOutOfRangeException(nameof(fromAddress), "From Address is required");
// try parse FromAddress
new MailAddress(fromAddress);
}
}
public static void Update(SystemConfiguration systemConfiguration)
{
smtpServer = systemConfiguration.EmailSmtpServer;
smtpPort = systemConfiguration.EmailSmtpPort;
smtpEnableSsl = systemConfiguration.EmailEnableSsl;
smtpFromAddress = systemConfiguration.EmailFromAddress;
smtpUsername = systemConfiguration.EmailUsername;
smtpPassword = systemConfiguration.EmailPassword;
IsConfigured =
!string.IsNullOrWhiteSpace(smtpServer) &&
smtpPort > 0 &&
!string.IsNullOrWhiteSpace(smtpFromAddress);
}
public static void SendEmail(Email email)
{
if (!IsConfigured)
throw new InvalidOperationException("Unable to send email, the email service has not been configured.");
var message = new MailMessage()
{
Subject = email.Subject,
IsBodyHtml = email.IsBodyHtml,
Body = email.Body,
};
if (!string.IsNullOrWhiteSpace(email.From))
message.From = new MailAddress(email.From);
else
message.From = new MailAddress(smtpFromAddress);
if (email.To.Count > 0)
{
foreach (var recipient in email.To)
message.To.Add(recipient);
}
if (email.CC.Count > 0)
{
foreach (var recipient in email.CC)
message.CC.Add(recipient);
}
if (email.BCC.Count > 0)
{
foreach (var recipient in email.BCC)
message.Bcc.Add(recipient);
}
using (var smtpClient = new SmtpClient(smtpServer, smtpPort))
{
smtpClient.EnableSsl = smtpEnableSsl;
if (!string.IsNullOrWhiteSpace(smtpUsername))
smtpClient.Credentials = new NetworkCredential(smtpUsername, smtpPassword);
smtpClient.Send(message);
}
}
public static void SendTestEmail(string recipient)
{
var email = new Email(recipient, "Disco ICT Test Email", @"Disco ICT has successfully been configured to send to this recipient.");
SendEmail(email);
}
}
}
@@ -3,6 +3,7 @@ using Disco.Services;
using Disco.Services.Authorization; using Disco.Services.Authorization;
using Disco.Services.Interop.ActiveDirectory; using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Interop.DiscoServices; using Disco.Services.Interop.DiscoServices;
using Disco.Services.Messaging;
using Disco.Services.Web; using Disco.Services.Web;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -364,5 +365,50 @@ namespace Disco.Web.Areas.API.Controllers
#endregion #endregion
#region Email Settings
[DiscoAuthorize(Claims.Config.System.ConfigureEmail), ValidateInput(false), ValidateAntiForgeryToken]
public virtual ActionResult UpdateEmailSettings(string SmtpServer, int? SmtpPort, string FromAddress, bool EnableSsl, string Username, string Password, bool redirect = false)
{
// Default Port
if (!SmtpPort.HasValue)
SmtpPort = 25;
EmailService.ValidateConfiguration(SmtpServer, SmtpPort.Value, FromAddress, EnableSsl, Username, Password);
SystemConfiguration config = Database.DiscoConfiguration;
config.EmailSmtpServer = SmtpServer;
config.EmailSmtpPort = SmtpPort.Value;
config.EmailFromAddress = FromAddress;
config.EmailEnableSsl = EnableSsl;
config.EmailUsername = Username;
config.EmailPassword = Password;
EmailService.Update(config);
Database.SaveChanges();
if (redirect)
return RedirectToAction(MVC.Config.SystemConfig.Index());
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
[DiscoAuthorize(Claims.Config.System.ConfigureEmail), ValidateAntiForgeryToken]
public virtual ActionResult SendTestEmail(string Recipient, bool redirect = false)
{
if (string.IsNullOrWhiteSpace(Recipient))
throw new ArgumentNullException(nameof(Recipient));
EmailService.SendTestEmail(Recipient);
if (redirect)
return RedirectToAction(MVC.Config.SystemConfig.Index());
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
#endregion
} }
} }
@@ -2,6 +2,7 @@
using Disco.Models.Services.Interop.DiscoServices; using Disco.Models.Services.Interop.DiscoServices;
using Disco.Services.Interop.ActiveDirectory; using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Interop.DiscoServices; using Disco.Services.Interop.DiscoServices;
using Disco.Services.Messaging;
using Disco.Services.Tasks; using Disco.Services.Tasks;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -98,6 +99,18 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig
public string ProxyPassword { get; set; } public string ProxyPassword { get; set; }
#endregion #endregion
#region Email
public string EmailSmtpServer { get; set; }
public int EmailSmtpPort { get; set; }
public string EmailFromAddress { get; set; }
[Display(Name = "Enable SSL")]
public bool EmailEnableSsl { get; set; }
public string EmailUsername { get; set; }
[DataType(DataType.Password)]
public string EmailPassword { get; set; }
public bool EmailIsConfigured { get; set; }
#endregion
public ScheduledTaskStatus UpdateRunningStatus { get; set; } public ScheduledTaskStatus UpdateRunningStatus { get; set; }
public DateTime? UpdateNextScheduled { get; set; } public DateTime? UpdateNextScheduled { get; set; }
public UpdateResponseV2 UpdateLatestResponse { get; set; } public UpdateResponseV2 UpdateLatestResponse { get; set; }
@@ -114,10 +127,17 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig
ProxyPort = config.ProxyPort, ProxyPort = config.ProxyPort,
ProxyUsername = config.ProxyUsername, ProxyUsername = config.ProxyUsername,
ProxyPassword = config.ProxyPassword, ProxyPassword = config.ProxyPassword,
EmailSmtpServer = config.EmailSmtpServer,
EmailSmtpPort = config.EmailSmtpPort,
EmailFromAddress = config.EmailFromAddress,
EmailEnableSsl = config.EmailEnableSsl,
EmailUsername = config.EmailUsername,
EmailPassword = config.EmailPassword,
EmailIsConfigured = EmailService.IsConfigured,
UpdateLatestResponse = config.UpdateLastCheckResponse, UpdateLatestResponse = config.UpdateLastCheckResponse,
UpdateRunningStatus = UpdateQueryTask.RunningStatus, UpdateRunningStatus = UpdateQueryTask.RunningStatus,
UpdateNextScheduled = UpdateQueryTask.NextScheduled, UpdateNextScheduled = UpdateQueryTask.NextScheduled,
UpdateBetaDeployment = config.UpdateBetaDeployment UpdateBetaDeployment = config.UpdateBetaDeployment,
}; };
// Is an update available? // Is an update available?
@@ -3,6 +3,7 @@
Authorization.Require(Claims.Config.System.Show); Authorization.Require(Claims.Config.System.Show);
var canConfigProxy = Authorization.Has(Claims.Config.System.ConfigureProxy); var canConfigProxy = Authorization.Has(Claims.Config.System.ConfigureProxy);
var canConfigEmail = Authorization.Has(Claims.Config.System.ConfigureEmail);
var canConfigAD = Authorization.Has(Claims.Config.System.ConfigureActiveDirectory); var canConfigAD = Authorization.Has(Claims.Config.System.ConfigureActiveDirectory);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "System"); ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "System");
@@ -605,9 +606,9 @@
dataType: 'json', dataType: 'json',
url: url, url: url,
data: data, data: data,
success: function (response, result) { complete: function (response, result) {
if (result != 'success' || response != 'OK') { if (result != 'success' || response.responseJSON != 'OK') {
alert('Unable to change property "' + UpdatePropertyName + '":\n' + response); alert('Unable to change proxy settings:\nCheck logs for more information');
ajaxLoading.hide(); ajaxLoading.hide();
} else { } else {
ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow'); ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
@@ -663,6 +664,217 @@ else
</table> </table>
</div> </div>
} }
@if (canConfigEmail)
{
<div class="form" style="width: 450px; margin-top: 15px;">
<h2>Email Settings</h2>
<table>
<tr>
<th style="width: 135px">
SMTP Server:
</th>
<td>
@Html.EditorFor(m => m.EmailSmtpServer)<br />
@Html.ValidationMessageFor(m => m.EmailSmtpServer)
</td>
</tr>
<tr>
<th style="width: 135px">
Port:
</th>
<td>
@Html.EditorFor(m => m.EmailSmtpPort)<br />
@Html.ValidationMessageFor(m => m.EmailSmtpPort)
</td>
</tr>
<tr>
<th style="width: 135px">
Default From Address:
</th>
<td>
@Html.EditorFor(m => m.EmailFromAddress)<br />
@Html.ValidationMessageFor(m => m.EmailFromAddress)
</td>
</tr>
<tr>
<th style="width: 135px">
&nbsp;
</th>
<td>
@Html.CheckBoxFor(m => m.EmailEnableSsl) @Html.LabelFor(m => m.EmailEnableSsl)
</td>
</tr>
<tr>
<th style="width: 135px">
Username:
</th>
<td>
@Html.EditorFor(m => m.EmailUsername)<br />
@Html.ValidationMessageFor(m => m.EmailUsername)
</td>
</tr>
<tr>
<th style="width: 135px">
Password:
</th>
<td>
@Html.EditorFor(m => m.EmailPassword)<br />
@Html.ValidationMessageFor(m => m.EmailPassword)
</td>
</tr>
<tr>
<th style="width: 135px">
&nbsp;
</th>
<td>
@Html.AntiForgeryToken()
<button id="Config_System_Email_Test" type="button" class="button small" @(Model.EmailIsConfigured ? null : "disabled")>Send Test Email</button>
<button id="Config_System_Email_Save" type="button" class="button small">Save Email Settings</button>@AjaxHelpers.AjaxLoader()
<div id="Config_System_Email_Test_Dialog" class="dialog" title="Send Test Email">
<h4><i class="fa fa-envelope information"></i>&nbsp;Recipient Email Address:</h4>
<br />
@using (Html.BeginForm(MVC.API.System.SendTestEmail(), FormMethod.Post))
{
<input type="hidden" name="redirect" value="true" />
<input id="Config_System_Email_Test_Recipient" name="Recipient" type="text" value="@CurrentUser.EmailAddress" />
@Html.AntiForgeryToken()
}
</div>
<script>
$(function () {
var button = $('#Config_System_Email_Save');
var testButton = $('#Config_System_Email_Test');
var testDialog = null;
button.click(function () {
var url = '@(Url.Action(MVC.API.System.UpdateEmailSettings()))';
var data = {
SmtpServer: $('#EmailSmtpServer').val(),
SmtpPort: $('#EmailSmtpPort').val(),
FromAddress: $('#EmailFromAddress').val(),
EnableSsl: $('#EmailEnableSsl').is(':checked'),
Username: $('#EmailUsername').val(),
Password: $('#EmailPassword').val(),
'__RequestVerificationToken': button.parent().find('input[name="__RequestVerificationToken"]').first().val()
}
var ajaxLoading = button.next('.ajaxLoading').first().show();
$.ajax({
type: 'POST',
dataType: 'json',
url: url,
data: data,
complete: function (response, result) {
if (result != 'success' || response.responseJSON != 'OK') {
alert('Unable to change email settings:\nCheck logs for more information');
ajaxLoading.hide();
} else {
ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
if (!!$('#EmailSmtpServer').val()) {
testButton.removeAttr('disabled');
} else {
testButton.attr('disabled', 'disabled');
}
}
}
});
});
testButton.closest('table').find('td>input').change(function () {
testButton.attr('disabled', 'disabled');
});
testButton.click(function () {
if (!testDialog) {
testDialog = $('#Config_System_Email_Test_Dialog')
.dialog({
resizable: false,
height: 180,
modal: true,
autoOpen: false,
buttons: {
Send: function () {
var $this = $(this);
var recipientInput = $('#Config_System_Email_Test_Recipient');
if (!!recipientInput.val()) {
$this.dialog("disable");
$this.dialog("option", "buttons", null);
recipientInput.closest('form').submit()
} else {
alert('Enter the recipient address for the test email');
}
},
Cancel: function () {
$(this).dialog("close");
}
}
});
}
testDialog.dialog('open');
});
});
</script>
</td>
</tr>
</table>
</div>
}
else
{
<div class="form" style="width: 450px; margin-top: 15px;">
<h2>Email Settings</h2>
<table>
<tr>
<th style="width: 135px">
SMTP Server:
</th>
<td>
@Html.DisplayFor(m => m.EmailSmtpServer)
</td>
</tr>
<tr>
<th style="width: 135px">
Port:
</th>
<td>
@Html.DisplayFor(m => m.EmailSmtpPort)
</td>
</tr>
<tr>
<th style="width: 135px">
Default From Address:
</th>
<td>
@Html.DisplayFor(m => m.EmailFromAddress)
</td>
</tr>
<tr>
<th style="width: 135px">
Enable SSL:
</th>
<td>
@Html.CheckBoxFor(m => m.EmailEnableSsl, new { disabled = "disabled" }) @Html.LabelFor(m => m.EmailEnableSsl)
</td>
</tr>
<tr>
<th style="width: 135px">
Username:
</th>
<td>
@Html.DisplayFor(m => m.EmailUsername)
</td>
</tr>
<tr>
<th style="width: 135px">
Password:
</th>
<td>
********
</td>
</tr>
</table>
</div>
}
<div class="actionBar"> <div class="actionBar">
@Html.ActionLinkButton("Update Device Last Network Logons", MVC.API.System.UpdateLastNetworkLogonDates()) @Html.ActionLinkButton("Update Device Last Network Logons", MVC.API.System.UpdateLastNetworkLogonDates())
</div> </div>
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -1210,22 +1210,22 @@
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>Show.generated.cs</LastGenOutput> <LastGenOutput>Show.generated.cs</LastGenOutput>
</None> </None>
<Content Include="Areas\Config\Views\DocumentTemplate\ShowPackage.cshtml"> <None Include="Areas\Config\Views\DocumentTemplate\ShowPackage.cshtml">
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>ShowPackage1.generated.cs</LastGenOutput> <LastGenOutput>ShowPackage1.generated.cs</LastGenOutput>
</Content> </None>
<Content Include="Areas\Config\Views\DocumentTemplate\CreatePackage.cshtml"> <None Include="Areas\Config\Views\DocumentTemplate\CreatePackage.cshtml">
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>CreatePackage.generated.cs</LastGenOutput> <LastGenOutput>CreatePackage.generated.cs</LastGenOutput>
</Content> </None>
<None Include="Areas\Config\Views\JobPreferences\Index.cshtml"> <None Include="Areas\Config\Views\JobPreferences\Index.cshtml">
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>Index.generated.cs</LastGenOutput> <LastGenOutput>Index.generated.cs</LastGenOutput>
</None> </None>
<Content Include="Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"> <None Include="Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml">
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>Expressions.generated.cs</LastGenOutput> <LastGenOutput>Expressions.generated.cs</LastGenOutput>
</Content> </None>
<None Include="Areas\Config\Views\JobPreferences\Parts\General.cshtml"> <None Include="Areas\Config\Views\JobPreferences\Parts\General.cshtml">
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>General.generated.cs</LastGenOutput> <LastGenOutput>General.generated.cs</LastGenOutput>
@@ -129,6 +129,18 @@ namespace Disco.Web.Areas.API.Controllers
{ {
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateProxySettings); return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateProxySettings);
} }
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UpdateEmailSettings()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateEmailSettings);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult SendTestEmail()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.SendTestEmail);
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public SystemController Actions { get { return MVC.API.System; } } public SystemController Actions { get { return MVC.API.System; } }
@@ -163,6 +175,8 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string Subject = "Subject"; public readonly string Subject = "Subject";
public readonly string SyncActiveDirectoryManagedGroup = "SyncActiveDirectoryManagedGroup"; public readonly string SyncActiveDirectoryManagedGroup = "SyncActiveDirectoryManagedGroup";
public readonly string UpdateProxySettings = "UpdateProxySettings"; public readonly string UpdateProxySettings = "UpdateProxySettings";
public readonly string UpdateEmailSettings = "UpdateEmailSettings";
public readonly string SendTestEmail = "SendTestEmail";
} }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
@@ -186,6 +200,8 @@ namespace Disco.Web.Areas.API.Controllers
public const string Subject = "Subject"; public const string Subject = "Subject";
public const string SyncActiveDirectoryManagedGroup = "SyncActiveDirectoryManagedGroup"; public const string SyncActiveDirectoryManagedGroup = "SyncActiveDirectoryManagedGroup";
public const string UpdateProxySettings = "UpdateProxySettings"; public const string UpdateProxySettings = "UpdateProxySettings";
public const string UpdateEmailSettings = "UpdateEmailSettings";
public const string SendTestEmail = "SendTestEmail";
} }
@@ -310,6 +326,29 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string ProxyPassword = "ProxyPassword"; public readonly string ProxyPassword = "ProxyPassword";
public readonly string redirect = "redirect"; public readonly string redirect = "redirect";
} }
static readonly ActionParamsClass_UpdateEmailSettings s_params_UpdateEmailSettings = new ActionParamsClass_UpdateEmailSettings();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UpdateEmailSettings UpdateEmailSettingsParams { get { return s_params_UpdateEmailSettings; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_UpdateEmailSettings
{
public readonly string SmtpServer = "SmtpServer";
public readonly string SmtpPort = "SmtpPort";
public readonly string FromAddress = "FromAddress";
public readonly string EnableSsl = "EnableSsl";
public readonly string Username = "Username";
public readonly string Password = "Password";
public readonly string redirect = "redirect";
}
static readonly ActionParamsClass_SendTestEmail s_params_SendTestEmail = new ActionParamsClass_SendTestEmail();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_SendTestEmail SendTestEmailParams { get { return s_params_SendTestEmail; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_SendTestEmail
{
public readonly string Recipient = "Recipient";
public readonly string redirect = "redirect";
}
static readonly ViewsClass s_views = new ViewsClass(); static readonly ViewsClass s_views = new ViewsClass();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ViewsClass Views { get { return s_views; } } public ViewsClass Views { get { return s_views; } }
@@ -568,6 +607,37 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo; return callInfo;
} }
[NonAction]
partial void UpdateEmailSettingsOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string SmtpServer, int? SmtpPort, string FromAddress, bool EnableSsl, string Username, string Password, bool redirect);
[NonAction]
public override System.Web.Mvc.ActionResult UpdateEmailSettings(string SmtpServer, int? SmtpPort, string FromAddress, bool EnableSsl, string Username, string Password, bool redirect)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateEmailSettings);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "SmtpServer", SmtpServer);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "SmtpPort", SmtpPort);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "FromAddress", FromAddress);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "EnableSsl", EnableSsl);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Username", Username);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Password", Password);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
UpdateEmailSettingsOverride(callInfo, SmtpServer, SmtpPort, FromAddress, EnableSsl, Username, Password, redirect);
return callInfo;
}
[NonAction]
partial void SendTestEmailOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string Recipient, bool redirect);
[NonAction]
public override System.Web.Mvc.ActionResult SendTestEmail(string Recipient, bool redirect)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.SendTestEmail);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Recipient", Recipient);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
SendTestEmailOverride(callInfo, Recipient, redirect);
return callInfo;
}
} }
} }