ITaskItem.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Quadarax.Foundation.Core.Business.Processor.Enums;
  2. using Quadarax.Foundation.Core.Business.Processor.Exceptons;
  3. namespace Quadarax.Foundation.Core.Business.Processor.Task;
  4. public interface ITaskItem : ITaskItemData
  5. {
  6. #region *** Operations ***
  7. /// <summary>
  8. /// Re-Schedules inactive task to future and sets <see cref="Status"/> to <see cref="ProcessStatusEnum.Pending"/> (affects <see cref="ProcessingValidFrom"/> and <see cref="ProcessingValidTo"/>).
  9. /// <list type="bullet">
  10. /// <item><description>Allowed state: <see cref="ProcessStatusEnum.Pending"/>, <see cref="ProcessStatusEnum.Paused"/></description></item>
  11. /// <item><description>Set state to: <see cref="ProcessStatusEnum.Pending"/></description></item>
  12. /// </list>
  13. /// <exception cref="InvalidTaskStateException">When task state is invalid for operation.</exception>
  14. /// </summary>
  15. /// <param name="postponeInterval">Interval to shift to future.</param>
  16. /// <param name="reason">Reason message to postpone.</param>
  17. void Postpone(TimeSpan postponeInterval, string reason);
  18. /// <summary>
  19. /// Stops running task and sets <see cref="Status"/> to <see cref="ProcessStatusEnum.Paused"/> or
  20. /// <see cref="ProcessStatusEnum.ProcessedSucc"/> or <see cref="ProcessStatusEnum.ProcessedFail"/> (target status is depends on input arguments)..
  21. /// <list type="bullet">
  22. /// <item><description>Allowed state: <see cref="ProcessStatusEnum.Started"/></description></item>
  23. /// <item><description>Set state to: <see cref="ProcessStatusEnum.Paused"/> or <see cref="ProcessStatusEnum.ProcessedSucc"/> or <see cref="ProcessStatusEnum.ProcessedFail"/></description></item>
  24. /// </list>
  25. /// <exception cref="InvalidTaskStateException">When task state is invalid for operation.</exception>
  26. /// </summary>
  27. /// <param name="reason">Reason message to stop.</param>
  28. /// <param name="willPause">If true, then <see cref="Status"/> will be set to <see cref="ProcessStatusEnum.Paused"/> otherwise to <see cref="ProcessStatusEnum.ProcessedSucc"/> or <see cref="ProcessStatusEnum.ProcessedFail"/>.</param>
  29. /// <param name="willFail">If true, then <see cref="Status"/> will be set to <see cref="ProcessStatusEnum.ProcessedFail"/> otherwise to <see cref="ProcessStatusEnum.ProcessedSucc"/>.</param>
  30. void Stop(string reason, bool willPause = true, bool willFail = false);
  31. /// <summary>
  32. /// Resets task to initial state and sets <see cref="Status"/> to <see cref="ProcessStatusEnum.Pending"/>.
  33. /// Uses current validity to re-calculate <see cref="ProcessingValidFrom"/> and <see cref="ProcessingValidTo"/> to now + <see cref="postponeValid"/>.
  34. /// <list type="bullet">
  35. /// <item><description>Allowed state: <see cref="ProcessStatusEnum.Attached"/>, <see cref="ProcessStatusEnum.ProcessedSucc"/>, <see cref="ProcessStatusEnum.ProcessedFail"/>, <see cref="ProcessStatusEnum.Paused"/></description></item>
  36. /// <item><description>Set state to: <see cref="ProcessStatusEnum.Pending"/></description></item>
  37. /// </list>
  38. /// <exception cref="InvalidTaskStateException">When task state is invalid for operation.</exception>
  39. /// </summary>
  40. /// <param name="reason">Reason to reset task.</param>
  41. /// <param name="postponeValid">Postpone current validity from now.</param>
  42. void Reset(string reason, TimeSpan postponeValid);
  43. /// <summary>
  44. /// Deletes task and sets <see cref="Status"/> to <see cref="ProcessStatusEnum.Deleted"/>.
  45. /// </summary>
  46. /// <param name="reason">Reason to delete current task.</param>
  47. /// <param name="immediate">Flag is true, deletes task immediately (afters status change)</param>
  48. void Delete(string reason, bool immediate = false);
  49. #endregion
  50. }