IPsQueueStorage.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 **** Transactions ****
  16. /// <summary>
  17. /// Creates a new transaction and returns its id
  18. /// </summary>
  19. /// <returns>Transaction identifier</returns>
  20. public string CreateTransaction();
  21. /// <summary>
  22. /// Commits all changes on the transaction specified by the <paramref name="transactionId"/> and closes transaction.
  23. /// <remarks>
  24. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  25. /// </remarks>
  26. /// </summary>
  27. /// <param name="transactionId">Transaction identifier</param>
  28. public void CommitTransaction(string transactionId);
  29. /// <summary>
  30. /// Rollbacks all changes on the transaction specified by the <paramref name="transactionId"/> and closes transaction.
  31. /// <remarks>
  32. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  33. /// </remarks>
  34. /// </summary>
  35. /// <param name="transactionId">Transaction identifier</param>
  36. public void RollbackTransaction(string transactionId);
  37. #endregion
  38. #region **** Items ****
  39. /// <summary>
  40. /// Creates a new item in the queue storage and returns its identifier.
  41. /// <remarks>
  42. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  43. /// </remarks>
  44. /// </summary>
  45. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  46. /// <param name="owner">Owner identifier</param>
  47. /// <param name="ownerRef">Owner reference identifier</param>
  48. /// <param name="providerClass">Process provider qualified type name</param>
  49. /// <param name="created">Timestamp when record will be created. If null use current datetime.</param>
  50. /// <returns>Item identifier.</returns>
  51. public string CreateItem(string transactionId, string owner, string ownerRef, string providerClass, DateTime? created);
  52. /// <summary>
  53. /// Deletes (force) the item (and all related entities) specified by the <paramref name="itemId"/> no matter what status item has.
  54. /// <remarks>
  55. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  56. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  57. /// </remarks>
  58. /// </summary>
  59. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  60. /// <param name="itemId">Item identifier.</param>
  61. public void DeleteItem(string transactionId, string itemId);
  62. /// <summary>
  63. /// Updates the priority of the item specified by the <paramref name="itemId"/>.
  64. /// <remarks>
  65. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  66. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  67. /// </remarks>
  68. /// </summary>
  69. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  70. /// <param name="itemId">Item identifier.</param>
  71. /// <param name="priority">Process priority value.</param>
  72. public void UpdateItemPriority(string transactionId, string itemId, int priority);
  73. /// <summary>
  74. /// Updates the validity of the item specified by the <paramref name="itemId"/>.
  75. /// <remarks>
  76. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  77. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  78. /// </remarks>
  79. /// </summary>
  80. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  81. /// <param name="itemId">Item identifier.</param>
  82. /// <param name="validForm">Timestamp for validFrom value.</param>
  83. /// <param name="validTo">Timespamp for validTo value.</param>
  84. public void UpdateItemValidity(string transactionId, string itemId, DateTime validForm, DateTime? validTo);
  85. /// <summary>
  86. /// Updates the status of the item specified by the <paramref name="itemId"/>. Doesn't affects the status journal or logs.
  87. /// <remarks>
  88. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  89. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  90. /// Doesn't validate the status transitions. Force update.
  91. /// </remarks>
  92. /// </summary>
  93. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  94. /// <param name="itemId">Item identifier.</param>
  95. /// <param name="status">New item status. If null status will be kept.</param>
  96. /// <param name="isTransient">New transient flag.</param>
  97. public void UpdateItemStatus(string transactionId, string itemId, PsStatusEnum? status, bool isTransient);
  98. /// <summary>
  99. /// Updates the attempts left value of the item specified by the <paramref name="itemId"/>.
  100. /// <remarks>
  101. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  102. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  103. /// Doesn't validate attempts counter. Force update.
  104. /// </remarks>
  105. /// </summary>
  106. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  107. /// <param name="itemId">Item identifier.</param>
  108. /// <param name="attemptsLeft">New attempt value.</param>
  109. public void UpdateItemAttempts(string transactionId, string itemId, int attemptsLeft);
  110. /// <summary>
  111. /// Updates the process started timestamp of the item specified by the <paramref name="itemId"/>.
  112. /// <remarks>
  113. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  114. /// If <paramref name="itemId"/> 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="started">New timestamp value or null.</param>
  120. public void UpdateItemStarted(string transactionId, string itemId, DateTime? started);
  121. /// <summary>
  122. /// Updates the process finished timestamp of the item specified by the <paramref name="itemId"/>.
  123. /// <remarks>
  124. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  125. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  126. /// </remarks>
  127. /// </summary>
  128. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  129. /// <param name="itemId">Item identifier.</param>
  130. /// <param name="finished">New timestamp value or null.</param>
  131. public void UpdateItemFinished(string transactionId, string itemId, DateTime? finished);
  132. #endregion
  133. #region **** Item Attributes ****
  134. /// <summary>
  135. /// Creates a new item attribute with the specified <paramref name="name"/> and <paramref name="value"/> for 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. /// If <paramref name="name"/> already exists, the method should throw an exception.
  140. /// </remarks>
  141. /// </summary>
  142. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  143. /// <param name="itemId">Item identifier.</param>
  144. /// <param name="name">Unique attribute name in <paramref name="itemId"/> scope.</param>
  145. /// <param name="value">Value serialized as string or null.</param>
  146. /// <param name="valueTypeClass">Value type qualified class name.</param>
  147. /// <param name="isOutput">Flag defines if attribute is input/output.</param>
  148. public void CreateItemAttribute(string transactionId, string itemId, string name, string? value, string valueTypeClass,bool isOutput);
  149. /// <summary>
  150. /// Updates the value of the item attribute specified by the <paramref name="name"/> for the item specified by the <paramref name="itemId"/>.
  151. /// <remarks>
  152. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  153. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  154. /// If <paramref name="name"/> not exists, the method should throw an exception.
  155. /// </remarks>
  156. /// </summary>
  157. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  158. /// <param name="itemId">Item identifier.</param>
  159. /// <param name="name">Unique attribute name in <paramref name="itemId"/> scope.</param>
  160. /// <param name="value">Value serialized as string or null.</param>
  161. public void UpdateItemAttribute(string transactionId, string itemId, string name, string value);
  162. /// <summary>
  163. /// Deletes the item attribute specified by the <paramref name="name"/> for the item specified by the <paramref name="itemId"/>.
  164. /// <remarks>
  165. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  166. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  167. /// If <paramref name="name"/> not exists, the method should throw an exception.
  168. /// </remarks>
  169. /// </summary>
  170. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  171. /// <param name="itemId">Item identifier.</param>
  172. /// <param name="name">Unique attribute name in <paramref name="itemId"/> scope.</param>
  173. public void DeleteItemAttribute(string transactionId, string itemId, string name);
  174. #endregion
  175. #region **** Item Collections ****
  176. /// <summary>
  177. /// Appends a new log record to the item specified by the <paramref name="itemId"/>.
  178. /// <remarks>
  179. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  180. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  181. /// </remarks>
  182. /// </summary>
  183. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  184. /// <param name="itemId">Item identifier.</param>
  185. /// <param name="message">Log message.</param>
  186. /// <param name="code">Message code</param>
  187. /// <param name="messageType">Message type</param>
  188. public void AppendLog(string transactionId, string itemId, string message, int code, ErrorLevelEnum messageType);
  189. /// <summary>
  190. /// Appends a new status journal record to the item specified by the <paramref name="itemId"/>.
  191. /// <remarks>
  192. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  193. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  194. /// </remarks>
  195. /// </summary>
  196. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation.</param>
  197. /// <param name="itemId">Item identifier.</param>
  198. /// <param name="status">Previous status.</param>
  199. /// <param name="isTransient">Previous isTransient flag.</param>
  200. /// <param name="message">Message.</param>
  201. public void AppendStatusJournal(string transactionId, string itemId, PsStatusEnum status, bool isTransient, string message);
  202. #endregion
  203. #region **** Queries & Get ****
  204. /// <summary>
  205. /// Returns collection of process item by input conditions.
  206. /// <remarks>
  207. /// Query items outside the transaction scope (must be committed).
  208. /// </remarks>
  209. /// </summary>
  210. /// <param name="owner">Owner identifier. If null then condition is skipped.</param>
  211. /// <param name="ownerRef">Owner reference identifier. If null then condition is skipped.</param>
  212. /// <param name="status">Collection of requested complex statuses (isTransient, Status).</param>
  213. /// <returns>Queryable collection of requested items.</returns>
  214. public IQueryable<IPsQueueItem> Query(string? owner, string? ownerRef, params Tuple<bool,PsStatusEnum>[] status);
  215. /// <summary>
  216. /// Gets the item specified by the <paramref name="itemId"/>.
  217. /// <remarks>
  218. /// If <paramref name="transactionId"/> not exists, the method should throw an exception.
  219. /// If <paramref name="itemId"/> not exists, the method should throw an exception.
  220. /// </remarks>
  221. /// </summary>
  222. /// <param name="transactionId">Transaction identifier generated by <see cref="CreateTransaction"/> operation. If null works outside transaction scope.</param>
  223. /// <param name="itemId">Item identifier.</param>
  224. /// <returns>Requested item.</returns>
  225. public IPsQueueItem GetItem(string? transactionId, string itemId);
  226. #endregion
  227. #endregion
  228. }
  229. }