19 changed files with 119 additions and 101 deletions
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
|
||||
namespace Teknik.Configuration |
||||
{ |
||||
public class EmailAccount |
||||
{ |
||||
public string EmailAddress { get; set; } |
||||
public string Host { get; set; } |
||||
public int Port { get; set; } |
||||
public string Username { get; set; } |
||||
public string Password { get; set; } |
||||
public bool SSL { get; set; } |
||||
|
||||
public EmailAccount() |
||||
{ |
||||
SetDefaults(); |
||||
} |
||||
|
||||
public void SetDefaults() |
||||
{ |
||||
EmailAddress = string.Empty; |
||||
Host = string.Empty; |
||||
Port = 25; |
||||
Username = string.Empty; |
||||
Password = string.Empty; |
||||
SSL = false; |
||||
} |
||||
} |
||||
} |
@ -1,25 +1,59 @@
@@ -1,25 +1,59 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Net.Mail; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
using Teknik.Configuration; |
||||
|
||||
namespace Teknik.Logging |
||||
{ |
||||
public class Logger |
||||
{ |
||||
public Logger() |
||||
{ |
||||
private Config m_Config; |
||||
|
||||
public Logger(Config config) |
||||
{ |
||||
m_Config = config; |
||||
} |
||||
|
||||
public void WriteEntry(Exception ex) |
||||
{ |
||||
// write an entry to the logs
|
||||
|
||||
} |
||||
|
||||
public void WriteEntry(string message, LogLevel level) |
||||
{ |
||||
if (m_Config.LoggingConfig.Enabled) |
||||
{ |
||||
|
||||
} |
||||
} |
||||
|
||||
private void SendErrorEmail(string subject, string message) |
||||
{ |
||||
try |
||||
{ |
||||
// Let's also email the message to support
|
||||
SmtpClient client = new SmtpClient(); |
||||
client.Host = m_Config.LoggingConfig.SenderAccount.Host; |
||||
client.Port = m_Config.LoggingConfig.SenderAccount.Port; |
||||
client.EnableSsl = m_Config.LoggingConfig.SenderAccount.SSL; |
||||
client.DeliveryMethod = SmtpDeliveryMethod.Network; |
||||
client.UseDefaultCredentials = true; |
||||
client.Credentials = new System.Net.NetworkCredential(m_Config.LoggingConfig.SenderAccount.Username, m_Config.LoggingConfig.SenderAccount.Password); |
||||
client.Timeout = 5000; |
||||
|
||||
MailMessage mail = new MailMessage(m_Config.LoggingConfig.SenderAccount.EmailAddress, m_Config.LoggingConfig.RecipientEmailAddress); |
||||
mail.Subject = subject; |
||||
mail.Body = message; |
||||
mail.BodyEncoding = UTF8Encoding.UTF8; |
||||
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Never; |
||||
|
||||
client.Send(mail); |
||||
} |
||||
catch (Exception) { /* don't handle something in the handler */ } |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue