PsProcessProviderBase.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Quadarax.Foundation.Core.Data;
  2. using Quadarax.Foundation.Core.Logging;
  3. using Quadarax.Foundation.Core.Object;
  4. namespace qdr.fnd.core.pqueue.Process
  5. {
  6. public class PsProcessProviderBase : DisposableObject
  7. {
  8. protected ILog Log { get; private set; }
  9. public IDictionary<string, TypedArgument> Arguments { get; private set; }
  10. public bool IsRunning { get; private set; }
  11. public string ItemId { get; private set; }
  12. public PsProcessProviderBase(string itemId, TypedArgument[] arguments, ILogger logger)
  13. {
  14. if (string.IsNullOrEmpty(itemId)) throw new ArgumentNullException(nameof(itemId));
  15. ItemId = itemId;
  16. Log = logger.GetLogger(GetType());
  17. Arguments = arguments.ToDictionary(x => x.Name, x => x);
  18. }
  19. #region Overrides of DisposableObject
  20. /// <inheritdoc />
  21. protected override void OnDisposing()
  22. {
  23. throw new NotImplementedException();
  24. }
  25. #endregion
  26. #region Implementation of IPsProcessProvider
  27. /// <inheritdoc />
  28. public void Validate()
  29. {
  30. }
  31. /// <inheritdoc />
  32. public async Task Start()
  33. {
  34. Validate();
  35. try
  36. {
  37. await OnProcess();
  38. }
  39. catch (Exception e)
  40. {
  41. await OnProcessError(e);
  42. Log.Log(LogSeverityEnum.Error, "Provider running failed.", e);
  43. }
  44. }
  45. private async Task OnProcessError(Exception exception)
  46. {
  47. throw new NotImplementedException();
  48. }
  49. private async Task OnProcess()
  50. {
  51. throw new NotImplementedException();
  52. }
  53. /// <inheritdoc />
  54. public async void Stop()
  55. {
  56. throw new NotImplementedException();
  57. }
  58. #endregion
  59. }
  60. }