Esempio n. 1
0
        public void Delete(Guid mailID)
        {
            //process deleteing event
            MailDeletingMailEventArgs deletingArgs = new MailDeletingMailEventArgs();

            deletingArgs.EmailID = mailID;
            deletingArgs.Cancel  = false;
            OnDeletingMail(this, deletingArgs);

            try
            {
                MailQueueDB.DeleteMailFromQueue(this._connectionString, mailID);
            }
            catch (SqlException ex)
            {
                //Process Mail Error Event
                MailErrorEventArgs errorArgs = new MailErrorEventArgs();
                errorArgs.Exception = ex;
                errorArgs.ErrorType = MailErrorType.Delete;
                OnMailError(this, errorArgs);
            }

            //process deleted event
            MailDeletedMailEventArgs deletedArgs = new MailDeletedMailEventArgs();

            OnDeletedMail(this, deletedArgs);
        }
Esempio n. 2
0
        /// <summary>
        /// Add the email to the queue
        /// </summary>
        /// <param name="mail"></param>
        /// <remarks></remarks>
        public bool Enqueue(Email mail, ref string msg)
        {
            if (this._queueSize > this._count)
            {
                try
                {
                    //process adding mail event
                    MailAddingMailEventArgs addingMailArgs = new MailAddingMailEventArgs();
                    addingMailArgs.Email = mail;
                    OnAddingMail(this, addingMailArgs);

                    this._count = MailQueueDB.SaveMailToQueue(this._connectionString, mail);

                    //process added mail event
                    MailAddedMailEventArgs addedMailArgs = new MailAddedMailEventArgs();
                    addedMailArgs.Email = mail;
                    OnAddedMail(this, addedMailArgs);
                }
                catch (SqlException ex)
                {
                    msg = ex.Message;
                    //Process Mail Error Event
                    MailErrorEventArgs args = new MailErrorEventArgs();
                    args.Exception = ex;
                    args.ErrorType = MailErrorType.Enqueue;
                    OnMailError(this, args);

                    return(false);
                }
                return(true);
            }
            else
            {
                //process Exceed Queue Max Size event
                MailExceedQueueSizeEventArgs args = new MailExceedQueueSizeEventArgs();
                args.QueueMaxSize = this._queueSize;
                OnExceedQueueSize(this, args);
                msg = "Mail Queue is full, please try later.";
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Get an email from the queue
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        public List <Email> Dequeue()
        {
            List <Email> mailList = new List <Email>();

            try
            {
                mailList = MailQueueDB.GetMailsFromQueue(this._connectionString);
            }
            catch (SqlException ex)
            {
                //Process Mail Error event
                MailErrorEventArgs errorArgs = new MailErrorEventArgs();
                errorArgs.Exception = ex;
                errorArgs.ErrorType = MailErrorType.Dequeue;
                OnMailError(this, errorArgs);
            }

            MailDequeueMailEventArgs args = new MailDequeueMailEventArgs();

            args.EmailList = mailList;
            //Process the Dequeue Mail event
            OnDequeueMail(this, args);
            return(mailList);
        }
Esempio n. 4
0
 public void UpdateFailure(Guid mailID, int failureInterval, int maxNumberOfTries, bool isArchiveFailure)
 {
     MailQueueDB.UpdateFailure(this._connectionString, mailID, failureInterval, maxNumberOfTries, isArchiveFailure);
 }