PsProcessProviderBase.cs 2.1 KB

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