Beispiel #1
0
 public void Add(PollNode node)
 {
     lock (nodes)
     {
         if (!nodes.ContainsKey(node.GetId()))
         {
             nodes.Add(node.GetId(), node);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// построение
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        private List <List <PollNodePathWrapper> > BuildPath(PollNode root)
        {
            if (root == null)
            {
                return(null);
            }
            if (root.IsFinalNode())
            {
                return(new List <List <PollNodePathWrapper> >()
                {
                    new List <PollNodePathWrapper>()
                    {
                        new PollNodePathWrapper(root)
                    }
                });
            }

            var allPaths = new List <List <PollNodePathWrapper> >();

            foreach (var relation in RelationManager.Instance.GetOutputs(root.GetId(), "contains"))
            {
                var node = NodeManager.Instance.GetById(relation.GetEndId());
                if (node.IsDisabled())
                {
                    continue;
                }

                //пропуск закрытых окон
                //if (node is Csd.CsdConnectionNode && !(node as Csd.CsdConnectionNode).InWindow(DateTime.Now)) continue;

                var paths = BuildPath(node);
                if (paths == null || !paths.Any())
                {
                    continue;
                }

                foreach (var path in paths)
                {
                    var newpath = new List <PollNodePathWrapper>()
                    {
                        new PollNodePathWrapper(root)
                    };
                    path.First().Left = relation.GetPort();
                    newpath.AddRange(path);
                    allPaths.Add(newpath);
                }
            }
            return(allPaths);
        }
Beispiel #3
0
        public void Update(dynamic msgChange)
        {
            string  status  = msgChange.status;
            dynamic content = msgChange.content;
            Guid    id      = Guid.Parse((string)content.id);

            switch (status)
            {
            case "update":
            {
                PollNode node = null;
                lock (nodes)
                {
                    if (nodes.ContainsKey(id))
                    {
                        node = nodes[id];
                    }
                }
                if (node != null)
                {
                    node.Update(content);
                    log.Warn(string.Format("нод '{0}' был обновлен", id));
                }

                break;
            }

            case "remove":
            {
                lock (nodes)
                {
                    if (nodes.ContainsKey(id))
                    {
                        nodes.Remove(id);
                        log.Warn(string.Format("нод '{0}' был удален", id));
                    }
                }
                break;
            }

            case "add":
            {
                var newNode = NodeFactory.Create(content);
                if (newNode != null)
                {
                    log.Warn(string.Format("добавлен новый нод {0}", content.type));
                    lock (nodes)
                    {
                        nodes.Add(newNode.GetId(), newNode);
                    }
                }
                else
                {
                    log.Debug(string.Format("не удалось добавить новый нод"));
                }
                break;
            }

            default:
            {
                log.Warn(string.Format("действие не опознано"));
                break;
            }
            }
        }