Пример #1
0
        public string SaveChain(Object guid, String chain, String name)
        {
            var                jss        = new JavaScriptSerializer();
            D3Node             rootD3Node = jss.Deserialize <D3Node>(chain);
            Node               rootNode   = new Node(rootD3Node);
            List <ServiceFlow> sfs;
            String             errorMessage;

            if (GetServiceFlows(out sfs, out errorMessage))
            {
                ServiceFlow serviceflow = new ServiceFlow(rootNode, name);
                return(jss.Serialize(SaveServiceFlow(sfs, serviceflow)));
            }
            return(jss.Serialize(errorMessage));
        }
Пример #2
0
        public async Task <D3Graph> FetchD3Graph(int limit)
        {
            var session = _driver.AsyncSession(WithDatabase);

            try
            {
                return(await session.ReadTransactionAsync(async transaction =>
                {
                    var cursor = await transaction.RunAsync(@"
                        MATCH (m:Movie)<-[:ACTED_IN]-(p:Person)
                        WITH m, p
                        ORDER BY m.title, p.name
                        RETURN m.title AS title, COLLECT(p.name) AS cast
                        LIMIT $limit",
                                                            new { limit }
                                                            );
                    var nodes = new List <D3Node>();
                    var links = new List <D3Link>();
                    var records = await cursor.ToListAsync(); //Dictionary
                    foreach (var record in records)
                    {
                        var movie = new D3Node(record["title"].As <string>(), "movie"); // label: movie; title: Filmtitel
                        var movieIndex = nodes.Count;
                        nodes.Add(movie);
                        foreach (var actorName in record["cast"].As <IList <string> >())
                        {
                            var actor = new D3Node(actorName, "actor"); // label: actor; title: ActorName
                            var actorIndex = nodes.IndexOf(actor);
                            actorIndex = actorIndex == -1 ? nodes.Count : actorIndex;
                            nodes.Add(actor);
                            links.Add(new D3Link(actorIndex, movieIndex)); // Verbindung zwischen Nodes wird gesetzt
                        }
                    }
                    return new D3Graph(nodes, links);
                }));
            }
            finally
            {
                await session.CloseAsync();
            }
        }
Пример #3
0
 public ConditionNode(D3Node child)
     : base(child)
 {
     Condition = ServiceManager.ConditionList[child.global_guid];
 }
Пример #4
0
 public ServiceNode(D3Node child)
     : base(child)
 {
     Service = ServiceManager.ServiceList[child.global_guid];
 }