1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using SAGA.GplotRelationComputerManage;
- using SAGA.Models;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SAGA.GplotManage
- {
- public class ElectricalRelationUploader : RelationUploader
- {
- public ElectricalRelationUploader(string relationType, string relationDisplay) : base(relationType, relationDisplay)
- {
- CurrentHandler = ElectricalRelationHandlerFactory.Create(relationType);
- }
- public IElectricalRelationHandler CurrentHandler { get; private set; }
- protected override object GetDefaultUploadData()
- {
- //计算数据
- if (CurrentHandler == null)
- return null;
- //加载数据
- var data = CurrentHandler.GetComputeData(new PowerComputerContext());
- return data;
- }
- protected override List<GraphRelationItem> CreateGraph(object loadData)
- {
- List<GraphRelationItem> items = new List<GraphRelationItem>();
- List<DataNode> dataNodes = loadData as List<DataNode>;
- if (dataNodes == null)
- {
- return items;
- }
- foreach (DataNode dataNode in dataNodes)
- {
- items.AddRange(CreateGraph(dataNode));
- }
- return items;
- }
- #region 数据上传方法
- protected List<GraphRelationItem> CreateGraph(DataNode dn)
- {
- List<GraphRelationItem> items = new List<GraphRelationItem>();
- if (dn!=null&&dn.Childrens.Count > 0)
- {
- foreach (var child in dn.Childrens)
- {
- GraphRelationItem item = new GraphRelationItem();
- item.FromId = dn.EId;
- item.ToId = child.EId;
- item.RelType = "1";
- //item.GraphId = string.Empty;
- if (!string.IsNullOrWhiteSpace(child.InLineNo1) && child.InLineNo1 == dn.Sno)
- {
- item.RelType = "1";
- }
- else
- {
- item.RelType = "2";
- }
- items.Add(item);
- items.AddRange(CreateGraph(child));
- }
- }
- return items;
- }
- #endregion
- }
- }
|