/// <summary>
        /// Gets all queued emails
        /// </summary>
        /// <param name="fromEmail">From Email</param>
        /// <param name="toEmail">To Email</param>
        /// <param name="startTime">The start time</param>
        /// <param name="endTime">The end time</param>
        /// <param name="queuedEmailCount">Email item count. 0 if you want to get all items</param>
        /// <param name="loadNotSentItemsOnly">A value indicating whether to load only not sent emails</param>
        /// <param name="maxSendTries">Maximum send tries</param>
        /// <returns>Email item collection</returns>
        public override DBQueuedEmailCollection GetAllQueuedEmails(string fromEmail,
                                                                   string toEmail, DateTime?startTime, DateTime?endTime,
                                                                   int queuedEmailCount, bool loadNotSentItemsOnly, int maxSendTries)
        {
            var       result    = new DBQueuedEmailCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_QueuedEmailLoadAll");

            db.AddInParameter(dbCommand, "FromEmail", DbType.String, fromEmail);
            db.AddInParameter(dbCommand, "ToEmail", DbType.String, toEmail);
            if (startTime.HasValue)
            {
                db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, startTime.Value);
            }
            else
            {
                db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, DBNull.Value);
            }
            if (endTime.HasValue)
            {
                db.AddInParameter(dbCommand, "EndTime", DbType.DateTime, endTime.Value);
            }
            else
            {
                db.AddInParameter(dbCommand, "EndTime", DbType.DateTime, DBNull.Value);
            }
            db.AddInParameter(dbCommand, "QueuedEmailCount", DbType.Int32, queuedEmailCount);
            db.AddInParameter(dbCommand, "LoadNotSentItemsOnly", DbType.Boolean, loadNotSentItemsOnly);
            db.AddInParameter(dbCommand, "MaxSendTries", DbType.Int32, maxSendTries);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    var item = GetQueuedEmailFromReader(dataReader);
                    result.Add(item);
                }
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// Gets all queued emails
        /// </summary>
        /// <param name="FromEmail">From Email</param>
        /// <param name="ToEmail">To Email</param>
        /// <param name="StartTime">The start time</param>
        /// <param name="EndTime">The end time</param>
        /// <param name="QueuedEmailCount">Email item count. 0 if you want to get all items</param>
        /// <param name="LoadNotSentItemsOnly">A value indicating whether to load only not sent emails</param>
        /// <param name="MaxSendTries">Maximum send tries</param>
        /// <returns>Email item collection</returns>
        public override DBQueuedEmailCollection GetAllQueuedEmails(string FromEmail,
                                                                   string ToEmail, DateTime?StartTime, DateTime?EndTime,
                                                                   int QueuedEmailCount, bool LoadNotSentItemsOnly, int MaxSendTries)
        {
            DBQueuedEmailCollection queuedEmailCollection = new DBQueuedEmailCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_QueuedEmailLoadAll");

            db.AddInParameter(dbCommand, "FromEmail", DbType.String, FromEmail);
            db.AddInParameter(dbCommand, "ToEmail", DbType.String, ToEmail);
            if (StartTime.HasValue)
            {
                db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, StartTime.Value);
            }
            else
            {
                db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, DBNull.Value);
            }
            if (EndTime.HasValue)
            {
                db.AddInParameter(dbCommand, "EndTime", DbType.DateTime, EndTime.Value);
            }
            else
            {
                db.AddInParameter(dbCommand, "EndTime", DbType.DateTime, DBNull.Value);
            }
            db.AddInParameter(dbCommand, "QueuedEmailCount", DbType.Int32, QueuedEmailCount);
            db.AddInParameter(dbCommand, "LoadNotSentItemsOnly", DbType.Boolean, LoadNotSentItemsOnly);
            db.AddInParameter(dbCommand, "MaxSendTries", DbType.Int32, MaxSendTries);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBQueuedEmail queuedEmail = GetQueuedEmailFromReader(dataReader);
                    queuedEmailCollection.Add(queuedEmail);
                }
            }

            return(queuedEmailCollection);
        }