ElectricalRelationUploader.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using SAGA.GplotRelationComputerManage;
  2. using SAGA.Models;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace SAGA.GplotManage
  9. {
  10. public class ElectricalRelationUploader : RelationUploader
  11. {
  12. public ElectricalRelationUploader(string relationType, string relationDisplay) : base(relationType, relationDisplay)
  13. {
  14. CurrentHandler = ElectricalRelationHandlerFactory.Create(relationType);
  15. }
  16. public IElectricalRelationHandler CurrentHandler { get; private set; }
  17. protected override object GetDefaultUploadData()
  18. {
  19. //计算数据
  20. if (CurrentHandler == null)
  21. return null;
  22. //加载数据
  23. var data = CurrentHandler.GetComputeData(new PowerComputerContext());
  24. return data;
  25. }
  26. protected override List<GraphRelationItem> CreateGraph(object loadData)
  27. {
  28. List<GraphRelationItem> items = new List<GraphRelationItem>();
  29. List<DataNode> dataNodes = loadData as List<DataNode>;
  30. if (dataNodes == null)
  31. {
  32. return items;
  33. }
  34. foreach (DataNode dataNode in dataNodes)
  35. {
  36. items.AddRange(CreateGraph(dataNode));
  37. }
  38. return items;
  39. }
  40. #region 数据上传方法
  41. protected List<GraphRelationItem> CreateGraph(DataNode dn)
  42. {
  43. List<GraphRelationItem> items = new List<GraphRelationItem>();
  44. if (dn!=null&&dn.Childrens.Count > 0)
  45. {
  46. foreach (var child in dn.Childrens)
  47. {
  48. GraphRelationItem item = new GraphRelationItem();
  49. item.FromId = dn.EId;
  50. item.ToId = child.EId;
  51. item.RelType = "1";
  52. //item.GraphId = string.Empty;
  53. if (!string.IsNullOrWhiteSpace(child.InLineNo1) && child.InLineNo1 == dn.Sno)
  54. {
  55. item.RelType = "1";
  56. }
  57. else
  58. {
  59. item.RelType = "2";
  60. }
  61. items.Add(item);
  62. items.AddRange(CreateGraph(child));
  63. }
  64. }
  65. return items;
  66. }
  67. #endregion
  68. }
  69. }