| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- using System.Collections.Concurrent;
- using qdr.fnd.core.pqueue.Enums;
- using Quadarax.Foundation.Core.Data;
- using Quadarax.Foundation.Core.Logging;
- using Quadarax.Foundation.Core.Object;
- using Quadarax.Foundation.Core.Value.Generators;
- namespace qdr.fnd.core.pqueue.Storages
- {
- public abstract class BaseStorageProvider : DisposableObject, IPsQueueStorage
- {
- #region *** Properties ***
- #endregion
- #region *** Private Fields ***
- private IDictionary<string, IList<IPsQueueItem>> _tranScopes =
- new ConcurrentDictionary<string, IList<IPsQueueItem>>();
- private ILog? _log;
- private IIdGenerator<string>? _tranGenerator;
- #endregion
- #region *** Constructors ***
- protected BaseStorageProvider(ILogger? logger)
- {
- _log = logger?.GetLogger(GetType().Name);
- _tranGenerator = new TinyHash(10);
- }
- #endregion
- #region *** Operations ***
- #region **** Transaction ****
- /// <inheritdoc />
- public string CreateTransaction()
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void CommitTransaction(string transactionId)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void RollbackTransaction(string transactionId)
- {
- throw new NotImplementedException();
- }
- #endregion
- /// <inheritdoc />
- public string CreateItem(string transactionId, string owner, string ownerRef, string providerClass, DateTime? created)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void DeleteItem(string transactionId, string itemId)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void UpdateItemPriority(string transactionId, string itemId, int priority)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void UpdateItemValidity(string transactionId, string itemId, DateTime validForm, DateTime? validTo)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void UpdateItemStatus(string transactionId, string itemId, PsStatusEnum? status, bool isTransient)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void UpdateItemAttempts(string transactionId, string itemId, int attemptsLeft)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void UpdateItemStarted(string transactionId, string itemId, DateTime? started)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void UpdateItemFinished(string transactionId, string itemId, DateTime? finished)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void CreateItemAttribute(string transactionId, string itemId, string name, string? value, string valueTypeClass,
- bool isOutput)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void UpdateItemAttribute(string transactionId, string itemId, string name, string value)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void DeleteItemAttribute(string transactionId, string itemId, string name)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void AppendLog(string transactionId, string itemId, string message, int code, ErrorLevelEnum messageType)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public void AppendStatusJournal(string transactionId, string itemId, PsStatusEnum status, bool isTransient, string message)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public IQueryable<IPsQueueItem> Query(string? owner, string? ownerRef, params Tuple<bool, PsStatusEnum>[] status)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public IPsQueueItem GetItem(string? transactionId, string itemId)
- {
- throw new NotImplementedException();
- }
- #endregion
- #region *** Private Operations ***
- #region Overrides of DisposableObject
- /// <inheritdoc />
- protected override void OnDisposing()
- {
- // rollback all transactions
- foreach (var tranId in _tranScopes.Keys.ToArray())
- {
- if(_tranScopes.ContainsKey(tranId))
- RollbackTransaction(tranId);
- }
- // cleanup rest of transaction scopes
- _tranScopes.Clear();
- // cleanup logger
- _log = null;
- // cleanup id generator
- _tranGenerator = null;
- }
- protected void Log(LogSeverityEnum severity, string? transactionId, string itemId, string message, Exception? ex = null)
- {
- if (!string.IsNullOrWhiteSpace(transactionId))
- message = $"[TRX: {transactionId}; ID: {itemId}] {message}";
- _log?.Log(severity, message, ex);
- }
- protected void Log(LogSeverityEnum severity, string message, Exception? ex = null)
- {
- Log(severity, null, string.Empty, message, ex);
- }
- #endregion
- #endregion
- }
- }
|