|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using HealthMonitor.Service.Resolver;
- using HealthMonitor.Service.Resolver.Interface;
- using HealthMonitor.Service.Sub.Topic.Model;
- using Microsoft.Extensions.Logging;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace HealthMonitor.Service.Sub
- {
- public class MsgQueueManager: ConcurrentQueue<PackageMsgModel>
- {
- private readonly ILogger<MsgQueueManager> _logger;
- private readonly BloodpressResolver _resolverBloodpress;
- private readonly PregnancyHeartRateResolver _resolverPregnacyHeartRate;
-
- //private const string BP = nameof(TopicHmBloodPress).ToLower();
-
-
-
- public MsgQueueManager(ILogger<MsgQueueManager> logger,
- BloodpressResolver resolverBloodpress,
- PregnancyHeartRateResolver pregnacyHeartRateResolver)
- {
- _logger = logger;
- _resolverBloodpress = resolverBloodpress;
- _resolverPregnacyHeartRate = pregnacyHeartRateResolver;
- }
-
- //public IResolver? GetMsgResolver()
- //{
- // TryDequeue(out var msg);
- // if (msg == null)
- // {
- // return null;
- // }
- // _resolver.SetResolveInfo(msg);
-
- // return _resolver;
- //}
-
- public IResolver? GetMsgResolver(PackageMsgModel msg)
- {
- if (msg == null) return null;
- //switch (msg.Topic)
- //{
- // case BP:
- // _resolverBloodpress.SetResolveInfo(msg);
- // return _resolverBloodpress;
- // default:
- // return null;
- //}
-
- if (msg.Topic.Equals(nameof(TopicHmBloodPress).ToLower()))
- {
- _resolverBloodpress.SetResolveInfo(msg);
- return _resolverBloodpress;
- }
-
- if (msg.Topic.Equals(nameof(TopicHmPregnancyHeartRate).ToLower()))
- {
- _resolverPregnacyHeartRate.SetResolveInfo(msg);
- return _resolverPregnacyHeartRate;
- }
- return null;
-
-
- }
- }
- }
|