예제 #1
0
        /// <summary>
        /// Queue an item of work to be run in the future
        /// </summary>
        /// <param name="workItemBase">
        /// The work item.
        /// </param>
        /// <param name="timeToRun">
        /// The time to run.
        /// </param>
        /// <param name="numberOfTimes">
        /// How many times should this item be queued
        /// </param>
        public override void MassQueue(WorkItemBase workItemBase, DateTime timeToRun, int numberOfTimes)
        {
            Contract.Requires(timeToRun >= DateTime.Now);
            Contract.Requires(numberOfTimes > 0);

            using (var repository = new QueueItemRepository(this.Factory.GetContext()))
            {
                for (int i = 0; i < numberOfTimes; i++)
                {
                    repository.Add(new QueueItem { Processing = false, TimeToRun = timeToRun, Item = workItemBase }, numberOfTimes == (i + 1));
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Queue an item of work to be run in the future
 /// </summary>
 /// <param name="workItemBase">
 /// The work item.
 /// </param>
 /// <param name="timeToRun">
 /// The time to run.
 /// </param>
 /// <returns>
 /// The item queued
 /// </returns>
 public abstract QueueItem Queue(WorkItemBase workItemBase, DateTime timeToRun);
예제 #3
0
 /// <summary>
 /// Queue an item of work to be run in the future
 /// </summary>
 /// <param name="workItemBase">
 /// The work item.
 /// </param>
 /// <param name="timeToRun">
 /// The time to run.
 /// </param>
 /// <param name="numberOfTimes">
 /// How many times should this item be queued
 /// </param>
 public abstract void MassQueue(WorkItemBase workItemBase, DateTime timeToRun, int numberOfTimes);
예제 #4
0
        /// <summary>
        /// Queue an item of work to be run in the future
        /// </summary>
        /// <param name="workItemBase">
        /// The work item.
        /// </param>
        /// <param name="timeToRun">
        /// The time to run.
        /// </param>
        /// <returns>
        /// The item queued
        /// </returns>
        public override QueueItem Queue(WorkItemBase workItemBase, DateTime timeToRun)
        {
            Contract.Requires(timeToRun >= DateTime.Now);
            Contract.Ensures(Contract.Result<QueueItem>().Id != 0);

            var queueItem = new QueueItem { Processing = false, TimeToRun = timeToRun, Item = workItemBase };

            using (var repository = new QueueItemRepository(this.Factory.GetContext()))
            {
                return repository.Add(queueItem);
            }
        }