IPsQueueStorage.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. using qdr.fnd.core.pqueue.Enums;
  2. using Quadarax.Foundation.Core.Data;
  3. namespace qdr.fnd.core.pqueue.Storages
  4. {
  5. /// <summary>
  6. /// PsQueue persistence storage interface. Manipulates with <see cref="IPsQueueItem"/> entities.
  7. /// <remarks>
  8. /// Has no any business logic. Just a storage interface.
  9. /// Throws directly exceptions if something goes wrong.
  10. /// </remarks>
  11. /// </summary>
  12. public interface IPsQueueStorage : IDisposable
  13. {
  14. #region *** Operations ***
  15. #region **** Items ****
  16. /// <summary>
  17. /// Creates a new item in the queue storage and returns its identifier.
  18. /// <remarks>
  19. /// </remarks>
  20. /// </summary>
  21. /// <param name="owner">Owner identifier</param>
  22. /// <param name="ownerRef">Owner reference identifier</param>
  23. /// <param name="providerClass">Process provider qualified type name</param>
  24. /// <param name="initialAttempts">Initial amount of attempts to processing items</param>
  25. /// <param name="created">Timestamp when record will be created. If null use current datetime.</param>
  26. /// <returns>Item identifier.</returns>
  27. public string CreateItem(string owner, string ownerRef, string providerClass,int initialAttempts, DateTime? created);
  28. /// <summary>
  29. /// Deletes (force) the item (and all related entities) specified by the <paramref name="itemId"/> no matter what status item has.
  30. /// <remarks>
  31. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  32. /// </remarks>
  33. /// </summary>
  34. /// <param name="itemId">Item identifier.</param>
  35. public void DeleteItem(string itemId);
  36. /// <summary>
  37. /// Updates the priority of the item specified by the <paramref name="itemId"/>.
  38. /// <remarks>
  39. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  40. /// </remarks>
  41. /// </summary>
  42. /// <param name="itemId">Item identifier.</param>
  43. /// <param name="priority">Process priority value.</param>
  44. public void UpdateItemPriority(string itemId, int priority);
  45. /// <summary>
  46. /// Updates the validity of the item specified by the <paramref name="itemId"/>.
  47. /// <remarks>
  48. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  49. /// </remarks>
  50. /// </summary>
  51. /// <param name="itemId">Item identifier.</param>
  52. /// <param name="validForm">Timestamp for validFrom value.</param>
  53. /// <param name="validTo">Timespamp for validTo value.</param>
  54. public void UpdateItemValidity(string itemId, DateTime validForm, DateTime? validTo);
  55. /// <summary>
  56. /// Updates the status of the item specified by the <paramref name="itemId"/>. Doesn't affects the status journal or logs.
  57. /// <remarks>
  58. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  59. /// Doesn't validate the status transitions. Force update.
  60. /// </remarks>
  61. /// </summary>
  62. /// <param name="itemId">Item identifier.</param>
  63. /// <param name="status">New item status. If null status will be kept.</param>
  64. /// <param name="isTransient">New transient flag.</param>
  65. public void UpdateItemStatus(string itemId, PsStatusEnum? status, bool isTransient);
  66. /// <summary>
  67. /// Updates the attempts left value of the item specified by the <paramref name="itemId"/>.
  68. /// <remarks>
  69. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  70. /// Doesn't validate attempts counter. Force update.
  71. /// </remarks>
  72. /// </summary>
  73. /// <param name="itemId">Item identifier.</param>
  74. /// <param name="attemptsLeft">New attempt value.</param>
  75. public void UpdateItemAttempts(string itemId, int attemptsLeft);
  76. /// <summary>
  77. /// Updates the process started timestamp of the item specified by the <paramref name="itemId"/>.
  78. /// <remarks>
  79. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  80. /// </remarks>
  81. /// </summary>
  82. /// <param name="itemId">Item identifier.</param>
  83. /// <param name="started">New timestamp value or null.</param>
  84. public void UpdateItemStarted(string itemId, DateTime? started);
  85. /// <summary>
  86. /// Updates the process finished timestamp of the item specified by the <paramref name="itemId"/>.
  87. /// <remarks>
  88. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  89. /// </remarks>
  90. /// </summary>
  91. /// <param name="itemId">Item identifier.</param>
  92. /// <param name="finished">New timestamp value or null.</param>
  93. public void UpdateItemFinished(string itemId, DateTime? finished);
  94. #endregion
  95. #region **** Item Attributes ****
  96. /// <summary>
  97. /// Creates a new item attribute with the specified <paramref name="name"/> and <paramref name="value"/> for the item specified by the <paramref name="itemId"/>.
  98. /// <remarks>
  99. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  100. /// If <paramref name="name"/> already exists, the method should throw an exception.
  101. /// </remarks>
  102. /// </summary>
  103. /// <param name="itemId">Item identifier.</param>
  104. /// <param name="name">Unique attribute name in <paramref name="itemId"/> scope.</param>
  105. /// <param name="value">Value serialized as string or null.</param>
  106. /// <param name="valueTypeClass">Value type qualified class name.</param>
  107. /// <param name="isOutput">Flag defines if attribute is input/output.</param>
  108. public void CreateItemAttribute(string itemId, string name, string? value, string valueTypeClass,bool isOutput);
  109. /// <summary>
  110. /// Updates the value of the item attribute specified by the <paramref name="name"/> for the item specified by the <paramref name="itemId"/>.
  111. /// <remarks>
  112. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  113. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  114. /// If <paramref name="name"/> not exists, the method should throw an exception.
  115. /// </remarks>
  116. /// </summary>
  117. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  118. /// <param name="itemId">Item identifier.</param>
  119. /// <param name="name">Unique attribute name in <paramref name="itemId"/> scope.</param>
  120. /// <param name="value">Value serialized as string or null.</param>
  121. public void UpdateItemAttribute(string itemId, string name, string value);
  122. /// <summary>
  123. /// Deletes the item attribute specified by the <paramref name="name"/> for the item specified by the <paramref name="itemId"/>.
  124. /// <remarks>
  125. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  126. /// If <paramref name="name"/> not exists, the method should throw an exception.
  127. /// </remarks>
  128. /// </summary>
  129. /// <param name="itemId">Item identifier.</param>
  130. /// <param name="name">Unique attribute name in <paramref name="itemId"/> scope.</param>
  131. public void DeleteItemAttribute(string itemId, string name);
  132. #endregion
  133. #region **** Item Collections ****
  134. /// <summary>
  135. /// Appends a new log record to the item specified by the <paramref name="itemId"/>.
  136. /// <remarks>
  137. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  138. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  139. /// </remarks>
  140. /// </summary>
  141. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  142. /// <param name="itemId">Item identifier.</param>
  143. /// <param name="message">Log message.</param>
  144. /// <param name="code">Message code</param>
  145. /// <param name="messageType">Message type</param>
  146. public void AppendLog(string transactionId, string itemId, string message, int code, ErrorLevelEnum messageType);
  147. /// <summary>
  148. /// Appends a new status journal record to the item specified by the <paramref name="itemId"/>.
  149. /// <remarks>
  150. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  151. /// </remarks>
  152. /// </summary>
  153. /// <param name="itemId">Item identifier.</param>
  154. /// <param name="status">Previous status.</param>
  155. /// <param name="isTransient">Previous isTransient flag.</param>
  156. /// <param name="message">Message.</param>
  157. public void AppendStatusJournal(string itemId, PsStatusEnum status, bool isTransient, string message);
  158. #endregion
  159. #region **** Queries & Get ****
  160. /// <summary>
  161. /// Returns collection of process item by input conditions.
  162. /// <remarks>
  163. /// Query items outside the transaction scope (must be committed).
  164. /// </remarks>
  165. /// </summary>
  166. /// <param name="owner">Owner identifier. If null then condition is skipped.</param>
  167. /// <param name="ownerRef">Owner reference identifier. If null then condition is skipped.</param>
  168. /// <param name="status">Collection of requested complex statuses (isTransient, Status).</param>
  169. /// <returns>Queryable collection of requested items.</returns>
  170. public IQueryable<IPsQueueItem> Query(string? owner, string? ownerRef, params Tuple<bool,PsStatusEnum>[] status);
  171. /// <summary>
  172. /// Gets the item specified by the <paramref name="itemId"/>.
  173. /// <remarks>
  174. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  175. /// </remarks>
  176. /// </summary>
  177. /// <param name="itemId">Item identifier.</param>
  178. /// <returns>Requested item.</returns>
  179. public IPsQueueItem GetItem(string itemId);
  180. /// <summary>
  181. /// Checks if the item with the specified <paramref name="itemId"/> exists in the storage.
  182. /// </summary>
  183. /// <param name="itemId">Item identifier.</param>
  184. /// <returns>Returns true if item exists in storage.</returns>
  185. public bool ContainsItem(string itemId);
  186. #endregion
  187. #endregion
  188. }
  189. }