Ejemplo n.º 1
0
 public void SendInputFileEmail(Application info, Int32 runNumberID, List <string> emailList)
 {
     try
     {
         SingletonLogger.Instance.Debug("Fetching email template for TOKEN = " + "DOWNLOAD_FILE");
         EmailTemplate template = _emailTemplateRepository.EmailTemplate(x => x.ClientId == info.ClientId && x.ApplicationId == info.ApplicationId && x.EmailToken == "{{DOWNLOAD_FILE}}");
         if (template != null)
         {
             SingletonLogger.Instance.Debug("templateID  = " + template.EmailTemplateId + " runId " + runNumberID);
             EmailTracking tracking = new EmailTracking()
             {
                 RunNumberId     = runNumberID,
                 FromEmailId     = template.EmailFromSmtpId.ToString(),
                 EmailTemplateId = template.EmailTemplateId,
                 Subjects        = template.Subject,
                 Body            = template.Body,
                 EmailStatus     = (int)EmailStatusType.Ready,
                 EmailToIds      = template.EmailToIds,
                 EmailCcIds      = template.EmailCcIds
             };
             SingletonLogger.Instance.Debug("trackingID  = " + tracking.EmailTrackingId);
             if (tracking != null)
             {
                 tracking.SentDate  = DateTime.Now;
                 tracking.CreatedAt = DateTimeOffset.Now;
                 tracking.Body      = tracking.Body.Replace("{{FILE_LIST}}", CreateTable(emailList));
                 tracking.Body      = tracking.Body.Replace("{{FILE_NAME}}", CreateTable(emailList));
                 tracking.Subjects  = tracking.Subjects.Replace("{{APPLICATION_NAME}}", info.Name);
                 tracking.Body      = tracking.Body.Replace("{{APPLICATION_NAME}}", info.Name);
                 tracking.Status    = true;
                 if (_emailTrackingRepository.Save(tracking) != 0)
                 {
                     SingletonLogger.Instance.Error("Error occured while email saving to email tracking.");
                 }
             }
         }
         else
         {
             SingletonLogger.Instance.Debug("Email Template not found in database for TOKEN = " + "DOWNLOAD_FILE");
         }
     }
     catch (Exception ex)
     {
         SingletonLogger.Instance.Error("Error occured while sending email about file download = " + ex.Message + " " + ex.InnerException != null?ex.InnerException.Message:"" + ex.ToString() + " " + ex.StackTrace);
     }
 }
Ejemplo n.º 2
0
        public void SendInputFileEmail(int runComponentId, string component, string runNumber, string token, string message = "Success")
        {
            try
            {
                SingletonLogger.Instance.Debug("Fetching email template for TOKEN = " + token);
                Application   appInfo     = _applicationRepository.Find(_runNumberRepository.GetApplicationIdByRunNumber(runNumber));
                int           componentId = _runComponentRepository.Find(runComponentId).ComponentId;
                EmailTemplate template    = _emailTemplateRepository.EmailTemplate(x => x.ClientId == appInfo.ClientId && x.ApplicationId == appInfo.ApplicationId && x.ApplicationComponentId == componentId && x.EmailToken == token);
                if (template != null)
                {
                    EmailTracking tracking = new EmailTracking()
                    {
                        RunNumberId     = _runNumberRepository.GetRunNumberIdByRunNumber(runNumber),
                        FromEmailId     = template.EmailFromSmtpId.ToString(),
                        EmailTemplateId = template.EmailTemplateId,
                        Subjects        = template.Subject,
                        Body            = template.Body,
                        EmailStatus     = (int)EmailStatusType.Ready
                    };

                    if (tracking != null)
                    {
                        tracking.SentDate = DateTime.Now;
                        tracking.Body     = tracking.Body.Replace("{{CLIENT_NAME}}", appInfo.ClientId.ToString());
                        tracking.Body     = tracking.Body.Replace("{{APPLICATION_NAME}}", appInfo.Name).Replace("{{COMPONENT_NAME}}", component);
                        tracking.Body     = tracking.Body.Replace("{{MESSAGE}}", message);
                        tracking.Subjects = tracking.Subjects.Replace("{{COMPONENT_NAME}}", component).Replace("{{APPLICATION_NAME}}", appInfo.Name).Replace("{{CLIENT_NAME}}", appInfo.ClientId.ToString());
                        if (_emailTrackingRepository.Save(tracking) != 0)
                        {
                            SingletonLogger.Instance.Error("Error occured while email saving to email tracking.");
                        }
                    }
                }
                else
                {
                    SingletonLogger.Instance.Debug("Email Template not found in database for TOKEN = " + token);
                }
            }
            catch (Exception ex)
            {
                SingletonLogger.Instance.Error("Error occured while sending email about file download = " + ex.Message);
            }
        }