/// <summary>
 /// Initializes a new instance of the <see cref="PerformanceLoggingRequestProcessor"/> class.
 /// </summary>
 /// <param name="serviceLayerConfiguration">The service layer configuration.</param>
 /// <param name="cacheManager">The cache manager.</param>
 /// <param name="configurationPropertiesProvider">The configuration properties provider.</param>
 /// <param name="sessionProvider">The session provider.</param>
 public PerformanceLoggingRequestProcessor(
     ServiceLayerConfiguration serviceLayerConfiguration, 
     ICacheManager cacheManager, 
     IConfigurationPropertiesProvider configurationPropertiesProvider, 
     ISessionProvider sessionProvider )
     : base(serviceLayerConfiguration, cacheManager, sessionProvider)
 {
     _configurationPropertiesProvider = configurationPropertiesProvider;
     _webServiceCallPerformanceLimitInMilliseconds =
         _configurationPropertiesProvider.GetPropertyInt ( SettingKeyNames.WebServiceCallPerformanceLimitInMilliseconds );
     _requestHandlerPerformanceLimitInMilliseconds =
         _configurationPropertiesProvider.GetPropertyInt ( SettingKeyNames.AgathaRequestHandlerPerformanceLimitInMilliseconds );
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PerformanceLoggingRequestProcessor"/> class.
 /// </summary>
 /// <param name="serviceLayerConfiguration">The service layer configuration.</param>
 /// <param name="cacheManager">The cache manager.</param>
 /// <param name="configurationPropertiesProvider">The configuration properties provider.</param>
 /// <param name="sessionProvider">The session provider.</param>
 public PerformanceLoggingRequestProcessor(
     ServiceLayerConfiguration serviceLayerConfiguration,
     ICacheManager cacheManager,
     IConfigurationPropertiesProvider configurationPropertiesProvider,
     ISessionProvider sessionProvider)
     : base(serviceLayerConfiguration, cacheManager, sessionProvider)
 {
     _configurationPropertiesProvider = configurationPropertiesProvider;
     _webServiceCallPerformanceLimitInMilliseconds =
         _configurationPropertiesProvider.GetPropertyInt(SettingKeyNames.WebServiceCallPerformanceLimitInMilliseconds);
     _requestHandlerPerformanceLimitInMilliseconds =
         _configurationPropertiesProvider.GetPropertyInt(SettingKeyNames.AgathaRequestHandlerPerformanceLimitInMilliseconds);
 }
Beispiel #3
0
        /// <summary>
        /// Gets the imap client.
        /// </summary>
        /// <returns>Imap 4 client.</returns>
        public Imap4Client GetImapClient()
        {
            string imapServer = _configurationPropertiesProvider.GetProperty(SettingKeyNames.ImapServer);
            int    imapPort   = _configurationPropertiesProvider.GetPropertyInt(SettingKeyNames.ImapPort);

            // Retrieves the Current User Context
            UserInformationDto info = _userInformationDtoFactory.CreateUserInformationDto();

            // Retrieves the corresponding Staff record for the current user
            Staff staff = _sessionProvider.GetSession().QueryOver <Staff>().Where(s => s.Key == info.StaffKey).SingleOrDefault();

            //string username = "******";
            //string password = "******";

            string username = null;
            string password = null;

            if (staff.DirectAddressCredential.DirectAddress != null)
            {
                username = staff.DirectAddressCredential.DirectAddress.Address;
                password = staff.DirectAddressCredential.DirectAddressPassword;
            }

            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
            {
                throw new ApplicationException("Username/password are not provided to access IMAP mail server.");
            }

            var imap4Client = new Imap4Client();

            imap4Client.Connect(imapServer, imapPort, username, password);

            return(imap4Client);
        }
Beispiel #4
0
        /// <summary>
        /// Sends the specified mail message.
        /// </summary>
        /// <param name="mailMessage">The mail message.</param>
        public void Send(MailMessage <MailMessageHeader> mailMessage)
        {
            Check.IsNotNull(mailMessage, "Mail message cannot be null.");

            var smtpServer = _configurationPropertiesProvider.GetProperty(SettingKeyNames.SmtpServer);
            var smtpPort   = _configurationPropertiesProvider.GetPropertyInt(SettingKeyNames.SmtpPort);

            using (var client = new SmtpClient(smtpServer, smtpPort))
            {
                var message = new MailMessage(
                    new MailAddress(mailMessage.Header.FromAddress, mailMessage.Header.FromName),
                    new MailAddress(mailMessage.Header.ToAddress))
                {
                    Subject = mailMessage.Header.Subject, Body = mailMessage.BodyText
                };

                mailMessage.Attachments.ForEach(
                    p =>
                {
                    if (!string.IsNullOrWhiteSpace(p.FileName))
                    {
                        Attachment smtpAttachment;
                        if (p.ContentBytes != null)
                        {
                            smtpAttachment = CreateAttachmentFromBytes(p.ContentBytes, p.FileName);
                        }
                        else
                        {
                            smtpAttachment = CreateAttachmentFromString(p.ContentString, p.FileName);
                        }
                        message.Attachments.Add(smtpAttachment);
                    }
                }
                    );

                client.Send(message);
            }
        }