public async Task NotificationWorker() { try { #region Read from Config var frequency = configuration["Frequency:Every"]; int delay = 5; int realtImeMaxLevel = 2; if (frequency != null) { if (frequency?.ToLower() == "hour") { int.TryParse(configuration["Frequency:Hour"], out int hour); delay = hour * 60; } else if (frequency?.ToLower() == "minute") { int.TryParse(configuration["Frequency:Minute"], out int minute); delay = minute; } int.TryParse(configuration["Frequency:RealtImeMaxLevel"], out realtImeMaxLevel); bool.TryParse(configuration["Frequency:AccountLevleIsEod"], out accountLevelIsEOD); } if (delay < 1) { delay = 5; } log.logMessage += $"Frequency : {delay}\n"; #region Check CustomSMTP bool.TryParse(configuration["CustomeMailServer:EnableSSL"], out bool enablessl); int.TryParse(configuration["CustomeMailServer:FromAddress"], out int port); smtpServer = new SMTPServer() { EnableSSL = enablessl, FromAddress = configuration["CustomeMailServer:FromAddress"], FromName = configuration["CustomeMailServer:FromName"], Login = configuration["CustomeMailServer:Login"], Password = configuration["CustomeMailServer:Password"], Port = port, Server = configuration["CustomeMailServer:Server"], }; #endregion if (smtpServer == null) { //add log and return log.logMessage += $"Invalid smtp details configured!\n"; return; } emailPathForLog = configuration["PathToEmail"]; applicationLog = configuration["ApplicationLogpath"]; logFilePath = configuration["LogFilePath"]; logFileManagement = new LogFileManagement(logFilePath, log); #endregion await StartNotificationTask(delay, realtImeMaxLevel); } catch (Exception ex0) { log.logMessage += $"{ex0.Message} {ex0.StackTrace}\n"; return; } }
public SendOutNotification(SMTPServer smtp) { customMailSever = smtp; }
public FormatEmailTemplate(SMTPServer smtpserver, string url, ApplicationLog appLog) { smtp = smtpserver; fileBaseUrl = url; log = appLog; }