Ejemplo n.º 1
0
        public Guid InsertImplicitSyncEmailUpload(EmailInfo emailinfo)
        {
            Guid requestguid = Guid.NewGuid();

            Logger.Current.Verbose("Request received for logging the mail response");
            var sentMail = new SentMailDb
            {
                TokenGuid       = Guid.NewGuid(),
                RequestGuid     = requestguid,
                From            = emailinfo.FromEmail,
                PriorityID      = 0,
                ScheduledTime   = emailinfo.SentDate,
                QueueTime       = DateTime.Now.ToUniversalTime(),
                StatusID        = Responses.CommunicationStatus.Success,
                ServiceResponse = ""
            };
            var sentMailDetail = new SentMailDetailDb
            {
                RequestGuid                                        = requestguid,
                To                                                 = emailinfo.To != null?string.Join(",", emailinfo.To) : "",
                                            CC                     = emailinfo.CC != null?string.Join(",", emailinfo.CC) : "",
                                                               BCC = emailinfo.BCC != null?string.Join(",", emailinfo.BCC) : "",
                                                                         Subject    = emailinfo.Subject,
                                                                         Body       = emailinfo.Body,
                                                                         IsBodyHtml = true
            };

            unitOfWork.SentMailsRepository.Add(sentMail);
            unitOfWork.SentMailDetailsRepository.Add(sentMailDetail);
            unitOfWork.Commit();
            Logger.Current.Verbose("Logging mail response was successful");
            return(requestguid);
        }
Ejemplo n.º 2
0
        public void LogResponse(SendMailRequest request, SendMailResponse response)
        {
            var queueTime = DateTime.UtcNow;

            //SentMail & SentMailDetail Table
            Logger.Current.Verbose("Request received for logging the mail response");
            var sentMail = new SentMailDb
            {
                TokenGuid       = response.Token,
                RequestGuid     = request.RequestGuid,
                From            = request.From,
                PriorityID      = request.PriorityID,
                ScheduledTime   = request.ScheduledTime,
                QueueTime       = queueTime,
                StatusID        = response.StatusID,
                ServiceResponse = response.ServiceResponse
            };
            var sentMailDetail = new SentMailDetailDb
            {
                RequestGuid = request.RequestGuid,
                DisplayName = request.DisplayName,
                ReplyTo     = request.ReplyTo,
                To          = request.To.ToPlainString(),
                //To = request.To,
                CC             = request.CC.ToPlainString(),
                BCC            = request.BCC.ToPlainString(),
                Subject        = request.Subject,
                Body           = request.Body,
                IsBodyHtml     = request.IsBodyHtml,
                AttachmentGUID = !string.IsNullOrEmpty(request.NotificationAttachementGuid) ? new Guid(request.NotificationAttachementGuid) : request.AttachmentGUID,
                CategoryID     = request.CategoryID,
                AccountID      = request.AccountID
            };

            unitOfWork.SentMailsRepository.Add(sentMail);
            unitOfWork.SentMailDetailsRepository.Add(sentMailDetail);
            unitOfWork.Commit();
            Logger.Current.Verbose("Logging mail response was successful");
        }
Ejemplo n.º 3
0
 public void UpdateScheduledReminder(Guid requestGuid, SendMailRequest updateRequest)
 {
     Logger.Current.Verbose("Request recieved for updating scheduled reminder in SentMailQueue and SentMailDetail");
     if (requestGuid != null && updateRequest != null)
     {
         SentMailDetailDb sentMailDetail = this.unitOfWork.SentMailDetailsRepository.FirstOrDefault(smd => smd.RequestGuid == requestGuid);
         if (sentMailDetail != null)
         {
             sentMailDetail.To   = updateRequest.To.FirstOrDefault();
             sentMailDetail.Body = updateRequest.Body;
         }
         SentMailQueueDb sentMailQueue = this.unitOfWork.SentMailQueuesRepository.FirstOrDefault(sm => sm.RequestGuid == requestGuid);
         if (sentMailQueue != null)
         {
             sentMailQueue.From          = updateRequest.From;
             sentMailQueue.ScheduledTime = updateRequest.ScheduledTime;
         }
         else if (sentMailQueue == null && sentMailDetail != null)
         {
             Logger.Current.Informational("Data not found in Queue but found in mail-details.So inserting new reminder in to queue");
             var queueTime = DateTime.UtcNow;
             this.unitOfWork.SentMailQueuesRepository.Add(new SentMailQueueDb
             {
                 TokenGuid       = updateRequest.TokenGuid,
                 RequestGuid     = sentMailDetail.RequestGuid,
                 From            = updateRequest.From,
                 PriorityID      = updateRequest.PriorityID,
                 ScheduledTime   = updateRequest.ScheduledTime,
                 QueueTime       = queueTime,
                 StatusID        = LandmarkIT.Enterprise.CommunicationManager.Responses.CommunicationStatus.Queued,
                 ServiceResponse = string.Empty
             });
         }
         unitOfWork.Commit();
     }
 }