示例#1
0
        public static MailboxReaderConfig GetBugNetConfig()
        {
            var state = new MailboxReaderThreadState
            {
                UploadsFolderPath = @"c:\temp\",
            };

            var hostSettings = HostSettingManager.LoadHostSettings();

            var emailFormat = HostSettingManager.Get(hostSettings, HostSettingNames.SMTPEMailFormat, EmailFormatType.Text);

            var mailBoxConfig = new MailboxReaderConfig
            {
                Server   = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3Server, string.Empty),
                Port     = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3Port, 110),
                UseSsl   = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3UseSSL, false),
                Username = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3Username, string.Empty),
                Password = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3Password, string.Empty),
                ProcessInlineAttachedPictures = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3InlineAttachedPictures, false),
                DeleteAllMessages             = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3DeleteAllMessages, false),
                ReportingUserName             = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3ReportingUsername, string.Empty),
                ProcessAttachments            = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3ProcessAttachments, true),
                UploadsFolderPath             = state.UploadsFolderPath,
                EmailFormatType = emailFormat,
                BodyTemplate    = GetEmailTemplateContent()
            };

            return(mailBoxConfig);
        }
示例#2
0
        public static MailboxReaderConfig GetBugNetConfig()
        {
            var state = new MailboxReaderThreadState
            {
                UploadsFolderPath = @"c:\temp\",
            };

            var hostSettings = HostSettingManager.LoadHostSettings();

            var emailFormat = HostSettingManager.Get(hostSettings, HostSettingNames.SMTPEMailFormat, EmailFormatType.Text);

            var mailBoxConfig = new MailboxReaderConfig
            {
                Server = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3Server, string.Empty),
                Port = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3Port, 110),
                UseSsl = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3UseSSL, false),
                Username = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3Username, string.Empty),
                Password = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3Password, string.Empty),
                ProcessInlineAttachedPictures = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3InlineAttachedPictures, false),
                DeleteAllMessages = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3DeleteAllMessages, false),
                ReportingUserName = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3ReportingUsername, string.Empty),
                ProcessAttachments = HostSettingManager.Get(hostSettings, HostSettingNames.Pop3ProcessAttachments, true),
                UploadsFolderPath = state.UploadsFolderPath,
                EmailFormatType = emailFormat,
                BodyTemplate = GetEmailTemplateContent()
            };

            return mailBoxConfig;
        }
示例#3
0
        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="application"></param>
        public void Init(HttpApplication application)
        {
            var readerEnabled = HostSettingManager.Get(HostSettingNames.Pop3ReaderEnabled, false);

            // only run the rest of the code if we need to
            // check to see if the timer is active and the reader is now disabled
            // if so we will turn it off only if we are not processing a poll
            if (!readerEnabled)
            {
                lock (_locker)
                {
                    if (_timerIsActive && !_isMailboxReaderProcessing)
                    {
                        _timer.Change(Timeout.Infinite, Timeout.Infinite);
                        _isMailboxReaderProcessing = false;
                        _timerIsActive             = false;
                        _timer.Dispose();
                        _timer = null;
                        Log.Warn("MailboxReaderModule: User disabled POP3 reader via host settings");
                    }
                }

                return;
            }

            // is the timer already active?
            if (_timerIsActive)
            {
                return;
            }

            Log.Info("MailboxReaderModule: Enabling POP3 reader");

            // get the interval
            _interval = HostSettingManager.Get(HostSettingNames.Pop3Interval, CNST_DEFAULT_INTERVAL);

            // if the interval is to small change to the min interval
            if (_interval < MIN_INTERVAL)
            {
                _interval = MIN_INTERVAL;
                Log.Warn(string.Format("MailboxReaderModule: [Pop3Interval] was too small. Using minimum threshold of {0} milliseconds", MIN_INTERVAL));
            }
            else
            {
                Log.Info(string.Format("MailboxReaderModule: Enabling threshold of {0} milliseconds", _interval));
            }

            // Clear the number of consecutive errors we may have only when
            // creating the timer.
            lock (_locker) _readerErrors = 0;

            var uploadPath = HostSettingManager.Get(HostSettingNames.AttachmentUploadPath);

            if (uploadPath.StartsWith("~"))
            {
                uploadPath = application.Context.Server.MapPath(uploadPath);
            }

            var state = new MailboxReaderThreadState
            {
                UploadsFolderPath = uploadPath,
            };

            // create the timer instance
            // don't spin it up right away, wait a few
            // this to allow the asp.net worker thread time to get going
            // no need to bog down the threading while spin up.
            _timer = new Timer(ScheduledWorkCallback, state, 15, _interval);

            // set the timer to active
            lock (_locker) _timerIsActive = true;
        }