Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
 private string GetScannerNotificationBody(ScannerNotificationDTO notificationDTO)
 {
     return(notificationDTO.ScannerName + " " + notificationDTO.Instrument + "\n" + notificationDTO.NotificationMessage);
 }
Ejemplo n.º 4
0
 private string GetScannerNotificationSubject(ScannerNotificationDTO notificationDTO)
 {
     return("Scanner notification : " + notificationDTO.ScannerName + " " + notificationDTO.Instrument);
 }