You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MsgQueueManager.cs 2.2KB

1 年之前
1 年之前
1 年之前
4 月之前
1 年之前
4 月之前
1 年之前
4 月之前
1 年之前
1 年之前
4 月之前
1 年之前
1 年之前
1 年之前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using HealthMonitor.Service.Resolver;
  2. using HealthMonitor.Service.Resolver.Interface;
  3. using HealthMonitor.Service.Sub.Topic.Model;
  4. using Microsoft.Extensions.Logging;
  5. using System;
  6. using System.Collections.Concurrent;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace HealthMonitor.Service.Sub
  12. {
  13. public class MsgQueueManager: ConcurrentQueue<PackageMsgModel>
  14. {
  15. private readonly ILogger<MsgQueueManager> _logger;
  16. private readonly BloodpressResolver _resolverBloodpress;
  17. private readonly PregnancyHeartRateResolver _resolverPregnacyHeartRate;
  18. //private const string BP = nameof(TopicHmBloodPress).ToLower();
  19. public MsgQueueManager(ILogger<MsgQueueManager> logger,
  20. BloodpressResolver resolverBloodpress,
  21. PregnancyHeartRateResolver pregnacyHeartRateResolver)
  22. {
  23. _logger = logger;
  24. _resolverBloodpress = resolverBloodpress;
  25. _resolverPregnacyHeartRate = pregnacyHeartRateResolver;
  26. }
  27. //public IResolver? GetMsgResolver()
  28. //{
  29. // TryDequeue(out var msg);
  30. // if (msg == null)
  31. // {
  32. // return null;
  33. // }
  34. // _resolver.SetResolveInfo(msg);
  35. // return _resolver;
  36. //}
  37. public IResolver? GetMsgResolver(PackageMsgModel msg)
  38. {
  39. if (msg == null) return null;
  40. //switch (msg.Topic)
  41. //{
  42. // case BP:
  43. // _resolverBloodpress.SetResolveInfo(msg);
  44. // return _resolverBloodpress;
  45. // default:
  46. // return null;
  47. //}
  48. if (msg.Topic.Equals(nameof(TopicHmBloodPress).ToLower()))
  49. {
  50. _resolverBloodpress.SetResolveInfo(msg);
  51. return _resolverBloodpress;
  52. }
  53. if (msg.Topic.Equals(nameof(TopicHmPregnancyHeartRate).ToLower()))
  54. {
  55. _resolverPregnacyHeartRate.SetResolveInfo(msg);
  56. return _resolverPregnacyHeartRate;
  57. }
  58. return null;
  59. }
  60. }
  61. }