Beispiel #1
0
        public SmtpClient CreateSmtpClient(IMsgContext msgContext)
        {
            var smtpClient = new SmtpClient();

            smtpClient.Host                  = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_HOST);
            smtpClient.Port                  = Convert.ToInt32(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_PORT));
            smtpClient.EnableSsl             = msgContext.GetConfigValue(IFConfigPropertyNames.SMTP_ENABLESSL, false);
            smtpClient.DeliveryMethod        = SmtpDeliveryMethod.Network;
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials           = new NetworkCredential(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_FROM), msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_PASSWORD));

            return(smtpClient);
        }
Beispiel #2
0
 public void Send(IMsgContext msgContext)
 {
     try
     {
         var smtpClient  = CreateSmtpClient(msgContext);
         var mailMessage = GenerateMailMessage(msgContext);
         smtpClient.Send(mailMessage);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #3
0
        private void validate_it_is_not_a_merge(IMsgContext prev, IMsgContext next, object msg)
        {
            if (prev == null)
                return;

            if (ReferenceEquals(prev, Null.MsgContext))
                return;

            if (ReferenceEquals(prev, next))
                return;

            throw new MsgIsTheAppException(
                "Merging of two applications is not supported; '{0}' {1}", msg.GetType().Name, msg.ToJson());
        }
Beispiel #4
0
        public MailMessage GenerateMailMessage(IMsgContext msgContext)
        {
            var messageFromAddress = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_FROM);
            var messageToAddresses = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_TO);
            var messageFrom        = new MailAddress(messageFromAddress);
            var messageTo          = new MailAddress(messageToAddresses);
            var message            = new MailMessage(messageFrom, messageTo);

            message.CC.Add(messageFrom);
            message.Subject = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_SUBJECT);
            message.Body    = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_BODY);
            message.Attachments.Add(AddAttachment(msgContext));

            return(message);
        }
Beispiel #5
0
        void IMsgIsTheApp.SetContextFor(MsgContext access, IMsgContext context, object msg)
        {
            Validate.NotNull(access);

            MsgContextProxy prev;
            _contexts.TryGetValue(msg, out prev);

            if (prev != null)
            {
                validate_it_is_not_a_merge(prev.Impl, context.Impl, msg);
                return;
            }

            var proxy = new MsgContextProxy(context);
            proxy.SetMsgIsTheApp(this);

            try
            {
                _contexts.Add(msg, proxy);
            }
            catch (ArgumentException)   // key already exists
            {}
        }
 public IMessageAction Process(IMsgContext msgContext)
 {
     return(MessageAction.ContinueProcessing);
 }
Beispiel #7
0
 public IMessageAction Process(IMsgContext msgContext)
 {
     MailService.Send(msgContext);
     return(MessageAction.ContinueProcessing);
 }
Beispiel #8
0
 public Attachment AddAttachment(IMsgContext msgContext)
 {
     return(new Attachment(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.FILE_PATH), MediaTypeNames.Application.Octet));
 }
Beispiel #9
0
 public RabbitConsumer(IMsgContext <IModel> context)
 {
     _context = context;
 }
Beispiel #10
0
 public RabbitProducer(IMsgContext <IModel> context)
 {
     _context = context;
 }
Beispiel #11
0
 IMessageAction IFComponent.Process(IMsgContext msgContext)
 {
     //This is a listner
     throw new NotImplementedException();
 }