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 }