public string StoreScannerNotification(ScannerNotificationDTO notificationDTO) { try { var accountId = GetAccountIdWithApiKey(notificationDTO.ApiKey); var scannerNotificationId = Guid.NewGuid().ToString(); string sql = "INSERT INTO scanner_notification VALUES (@id,@accId,@instrument,@notificationDate, @notificationMessage, @scannerName)"; using (var connection = new SqlConnection(GetConnectionString())) { var affectedRows = connection.Execute(sql, new { id = scannerNotificationId, accId = accountId, instrument = notificationDTO.Instrument, notificationDate = DateTime.Now, notificationMessage = notificationDTO.NotificationMessage, scannerName = notificationDTO.ScannerName }); } return(scannerNotificationId); } catch (Exception exp) { return(null); } }
public void SendScannerNotification(ScannerNotificationDTO scannerNotificationDTO) { var client = new SendGridClient(GetApiKey()); var from = new EmailAddress(GetSender()); var subject = GetScannerNotificationSubject(scannerNotificationDTO); var to = new EmailAddress(GetReceiver()); var plainTextContent = GetScannerNotificationBody(scannerNotificationDTO); var htmlContent = "<strong>" + GetScannerNotificationBody(scannerNotificationDTO) + "</strong>"; var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); var response = client.SendEmailAsync(msg); response.Wait(); }
private string GetScannerNotificationBody(ScannerNotificationDTO notificationDTO) { return(notificationDTO.ScannerName + " " + notificationDTO.Instrument + "\n" + notificationDTO.NotificationMessage); }
private string GetScannerNotificationSubject(ScannerNotificationDTO notificationDTO) { return("Scanner notification : " + notificationDTO.ScannerName + " " + notificationDTO.Instrument); }