コード例 #1
0
        public override void AckRecipient(AckStatus ackStatus, SmtpResponse smtpResponse)
        {
            TraceHelper.SmtpSendTracer.TracePass <string, string>(TraceHelper.MessageProbeActivityId, (long)this.GetHashCode(), "InboundProxyNextHopConnection.AckRecipient. Ackstatus  = {0}. SmtpResponse = {1}", ackStatus.ToString(), smtpResponse.ToString());
            if (!this.recipientEnumeratorAck.MoveNext() || this.recipientsPending <= 0)
            {
                throw new InvalidOperationException("AckRecipient called but no recipients left to ack");
            }
            this.recipientsPending--;
            MailRecipient recipient = this.recipientEnumeratorAck.Current;

            switch (ackStatus)
            {
            case AckStatus.Pending:
            case AckStatus.Success:
            case AckStatus.Retry:
            case AckStatus.Fail:
                if (this.result == null)
                {
                    this.result = new SmtpMailItemResult();
                }
                if (this.result.RecipientResponses == null)
                {
                    this.result.RecipientResponses = new Dictionary <MailRecipient, AckStatusAndResponse>();
                }
                this.result.RecipientResponses.Add(recipient, new AckStatusAndResponse(ackStatus, smtpResponse));
                if (this.notificationHandler != null)
                {
                    this.notificationHandler.AckRecipient(ackStatus, smtpResponse, recipient);
                }
                return;

            default:
                throw new InvalidOperationException(string.Format("AckRecipient with status: {0} is invalid", ackStatus));
            }
        }