/// <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)); } } }
/// <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);
/// <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);
/// <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); } }