电子药箱通讯服务端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SyncNodeManager.cs 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. namespace RDH.PharmacyPlatform.Sync.Core
  9. {
  10. /// <summary>
  11. /// 表示同步节点信息管理的类
  12. /// </summary>
  13. public class SyncNodeManager
  14. {
  15. public IEnumerable<SyncNode> ListNodes()
  16. {
  17. using (ConnectionSessionScope conn = new ConnectionSessionScope(Bootstrap.DbConnectionString))
  18. {
  19. SyncNodeDAL syncNodeDAL = new SyncNodeDAL();
  20. return syncNodeDAL.ListModels();
  21. }
  22. }
  23. public void AddNode(SyncNode node)
  24. {
  25. Debug.WriteLine($"添加同步节点 start, id:{Thread.CurrentThread.ManagedThreadId}");
  26. using (ConnectionSessionScope conn = new ConnectionSessionScope(Bootstrap.DbConnectionString))
  27. {
  28. SyncNodeDAL syncNodeDAL = new SyncNodeDAL();
  29. syncNodeDAL.InsertModel(node);
  30. }
  31. }
  32. public void RemoveNode(SyncNode node)
  33. {
  34. Debug.WriteLine($"删除同步节点 start, id:{Thread.CurrentThread.ManagedThreadId}");
  35. using (ConnectionSessionScope conn = new ConnectionSessionScope(Bootstrap.DbConnectionString))
  36. {
  37. SyncNodeDAL syncNodeDAL = new SyncNodeDAL();
  38. syncNodeDAL.DeleteModel(node);
  39. }
  40. }
  41. }
  42. }