123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- /* ==============================================================================
- * 功能描述:图类型基类
- * 创 建 者:Garrett
- * 创建日期:2018/4/1 11:15:29
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Newtonsoft.Json.Linq;
- using SAGA.DotNetUtils;
- using SAGA.DotNetUtils.Logger;
- using SAGA.MBI.Common;
- using SAGA.MBI.JsonConvert;
- using SAGA.MBI.RequestData;
- namespace SAGA.MBI.Model
- {
- /// <summary>
- /// RltEquipInSpace
- /// </summary>
- public abstract class MGraphRelationBase : CloudDataBase
- {
- public string GraphId { get; set; }
- public string RelationType { get; set; }
- public MGraphRelationBase(string fromId, string toId)
- {
- FromId = fromId;
- ToId = toId;
- }
- public virtual string GetFromId()
- {
- return "";
- }
- public virtual string GetToId()
- {
- return "";
- }
- private string m_FromId;
- /// <summary>
- /// fromid
- /// </summary>
- public string FromId
- {
- get
- {
- if (m_FromId.IsNullOrEmpty() )
- {
- m_FromId = GetFromId();
- }
- return m_FromId;
- }
- set { m_FromId = value; }
- }
- private string m_ToId;
- /// <summary>
- /// toid
- /// </summary>
- public string ToId
- {
- get
- {
- if (m_ToId.IsNullOrEmpty())
- {
- m_ToId = GetToId();
- }
- return m_ToId;
- }
- set { m_ToId = value; }
- }
- public override bool AddObject()
- {
- if (GraphId.IsNullOrEmpty() || RelationType.IsNullOrEmpty())
- return false;
- string graphId = RelationRequest.GetCurrentGraphId(GraphId);
- if (graphId == null) return false;
- return RelationRequest.AddRelation(graphId, FromId, ToId, RelationType);
- }
- public override bool AddorUpdateObject()
- {
- switch (Operator)
- {
- case DocumentChangedOperator.Add:
- this.AddObject();
- break;
- case DocumentChangedOperator.Delete:
- this.DelObject();
- break;
- default:
- break;
- }
- return true;
- }
- public override bool DelObject()
- {
- if (GraphId.IsNullOrEmpty() || RelationType.IsNullOrEmpty())
- return false;
- string graphId = RelationRequest.GetCurrentGraphId(GraphId);
- if (graphId == null) return false;
- return RelationRequest.DeleteRelation(graphId, FromId, ToId, RelationType);
- }
- }
- }
|