예제 #1
0
        void DoProcessExchange()
        {
            try
            {
                var exchangeEvent = new AppProcessExchangeEvent();

                // attempt to connect to the backend server...
                using (PapercutClient client = GetClient())
                {
                    if (!client.ExchangeEventServer(ref exchangeEvent))
                    {
                        return;
                    }

                    IsBackendServiceOnline = true;

                    // backend server is online...
                    _logger.Information("Papercut Backend Service Running. Disabling SMTP in App.");
                    _smtpServerCoordinator.SmtpServerEnabled = false;

                    if (!string.IsNullOrWhiteSpace(exchangeEvent.MessageWritePath))
                    {
                        _logger.Debug(
                            "Background Process Returned {@Event} -- Publishing",
                            exchangeEvent);

                        this._messageBus.Publish(exchangeEvent);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Warning(ex, BackendServiceFailureMessage);
            }
        }
        private void AttemptExchange()
        {
            try
            {
                var sendEvent = new AppProcessExchangeEvent();

                // attempt to connect to the backend server...
                using (var ipCommClient = this.GetClient())
                {
                    var receivedEvent = ipCommClient.ExchangeEventServer(sendEvent);

                    if (receivedEvent == null)
                    {
                        return;
                    }

                    this.IsBackendServiceOnline = true;

                    // backend server is online...
                    this._logger.Information("Papercut Backend Service Running. Disabling SMTP in App.");
                    this._smtpServerCoordinator.SmtpServerEnabled = false;

                    if (!string.IsNullOrWhiteSpace(receivedEvent.MessageWritePath))
                    {
                        this._logger.Debug(
                            "Background Process Returned {@Event} -- Publishing",
                            receivedEvent);

                        this._messageBus.Publish(receivedEvent);
                    }
                }
            }
            catch (Exception ex)
            {
                this._logger.Warning(ex, BackendServiceFailureMessage);
            }
        }