Beispiel #1
0
 public static User Closer(ActivityEntity entity)
 {
     return(string.IsNullOrEmpty(entity.CloserId) ? null : new User(entity.CloserId, entity.CloserId));
 }
Beispiel #2
0
 public static User Dealer(ActivityEntity entity)
 {
     return(string.IsNullOrEmpty(entity.DealerId) ? null : new User(entity.DealerId, entity.DealerName));
 }
Beispiel #3
0
 public static User Creator(ActivityEntity entity)
 {
     return(string.IsNullOrEmpty(entity.CreatorId)?null:new User(entity.CreatorId, entity.CreatorName));
 }
Beispiel #4
0
        public Action(Engine engine, Action parent, Node node, string version, object inputs, IUser creator, IUser dealer = null)
        {
            this.Engine = engine;
            this.graph  = node;
            this.parent = parent;

            #region init entity
            var entity = new ActivityEntity()
            {
                Id           = Guid.NewGuid(),
                NodeName     = node.Name,
                NodePath     = parent == null?node.Name:parent.NodePath + "/" + node.Name,
                Status       = ActivityStates.Created,
                Version      = version ?? parent?.Version,
                Domain       = engine.Name,
                ActivityType = node.InstanceType ?? engine.DefaultActivityInstanceType,
                Graph        = JSON.Stringify(node),
                HasChildren  = node.Nodes != null && node.Nodes.Count > 0,
                Inputs       = JSON.Stringify(inputs),
                CreateTime   = DateTime.Now,
                CreatorId    = creator.Id,
                CreatorName  = creator.Name
            };

            this.entity = entity;
            if (dealer != null)
            {
                this.dealer       = dealer;
                entity.DealerId   = dealer.Id;
                entity.DealerName = dealer.Name;
            }
            #endregion
            #region init states
            var states = new JObject();
            if (node.Meta != null)
            {
                foreach (var pair in node.Meta)
                {
                    states.Add(pair.Key, pair.Value.DeepClone());
                }
            }
            if (parent != null && node.Imports != null)
            {
                var pStates = parent.States as JObject;
                foreach (var pair in node.Imports)
                {
                    var value = JSON.GetPathValue(pStates, pair.Value);
                    JSON.SetPathValue(states, pair.Key, value);
                }
            }
            if (inputs != null)
            {
                var inputObj = JObject.FromObject(inputs);
                foreach (var pair in inputObj)
                {
                    states[pair.Key] = pair.Value;
                }
            }
            this.entity.States = states.ToString();
            this.states        = states;
            #endregion
        }
Beispiel #5
0
 public Action(Action parent, ActivityEntity entity)
 {
     this.parent = parent;
     this.Engine = parent.Engine;
     this.entity = entity;
 }
Beispiel #6
0
 public Action(Engine engine, ActivityEntity entity)
 {
     this.Engine = engine;
     this.entity = entity;
     this.id     = entity.Id;
 }