private void CheckForDB()
        {
            try
            {
                var url    = ConfigurationManager.AppSettings["neo4j-url"];
                var client = new Neo4jClient.GraphClient(rootUri: new Uri(url));
                client.Connect();
                var query = client.Cypher.Match("(m:MatrixConnection {imei:{imei}})").WithParams(new { imei = Imei }).Return(m => m.Node <string>());
                var res   = query.Results;

                if (!res.Any())
                {
                    logger.Info("новый контроллер, imei: {0}", Imei);
                }
                else
                {
                    var node = res.First().ToDynamic();
                    Id = Guid.Parse(node.id);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "ошибка при поиске имея базе");
            }
        }
Exemple #2
0
        public void JustEmitsThePathToTheDatabase()
        {
            var db = new Neo4jClient.GraphClient(new Uri("http://localhost:7474/db/data"));

            db.Connect();
            Assert.IsNotNull(db);
        }
Exemple #3
0
 private async static Task DeleteNode(Neo4jClient.GraphClient client, PersonFamilyTreeNode personFamilyTreeNode)
 {
     await client.Cypher.Match("(a:Person)")
     .Where("a.Id = $id")
     .WithParam("id", personFamilyTreeNode.Id)
     .DetachDelete("a")
     .ExecuteWithoutResultsAsync();
 }
Exemple #4
0
 private async static Task CreateNode(Neo4jClient.GraphClient client, PersonFamilyTreeNode personFamilyTreeNode)
 {
     await client.Cypher.Create("(n:Person { Id: $id, Name: $name, FatherId: $fatherId, MotherId: $motherId })")
     .WithParam("id", personFamilyTreeNode.Id)
     .WithParam("name", personFamilyTreeNode.Name)
     .WithParam("fatherId", personFamilyTreeNode.FatherId)
     .WithParam("motherId", personFamilyTreeNode.MotherId)
     .ExecuteWithoutResultsAsync();
 }
Exemple #5
0
        private static async Task AddNewNode(Neo4jClient.GraphClient client, PersonFamilyTreeNode personFamilyTreeNode)
        {
            var idFather = personFamilyTreeNode.FatherId;
            var idMother = personFamilyTreeNode.MotherId;
            var idChild  = personFamilyTreeNode.Id;

            await CreateNode(client, personFamilyTreeNode);
            await CreateParentRelationship(client, idFather, idChild);
            await CreateChildRelationship(client, idFather, idChild);
            await CreateParentRelationship(client, idMother, idChild);
            await CreateChildRelationship(client, idMother, idChild);
        }
Exemple #6
0
        private async static Task CreateChildRelationship(Neo4jClient.GraphClient client, string idParent, string idChild)
        {
            if (String.IsNullOrEmpty(idParent))
            {
                return;
            }

            await client.Cypher.Match("(a:Person),(b:Person)")
            .Where("a.Id = $idParent AND b.Id = $idChild")
            .WithParam("idParent", idParent)
            .WithParam("idChild", idChild)
            .Create("(b)-[r:CHILD]->(a)")
            .ExecuteWithoutResultsAsync();
        }
Exemple #7
0
        public IEnumerable <Guid> GetMaquetteIds()
        {
            var url = ConfigurationManager.AppSettings["neo4j-url"];
            var cli = new Neo4jClient.GraphClient(new Uri(url));

            cli.Connect();

            var mqs = cli.Cypher.Match("(a:Task {id:{id}})").
                      OptionalMatch("(a)<--(m:Maquette)").
                      With("collect(m.id) as ids unwind ids as id").
                      WithParams(new { id = Id }).Return(id => id.As <Guid>());
            var haa = mqs.Results;

            return(haa);
        }
Exemple #8
0
        /// <summary>
        /// загрузка задач
        /// </summary>
        public void Start()
        {
            tasks.Clear();
            var url = ConfigurationManager.AppSettings["neo4j-url"];
            var cli = new Neo4jClient.GraphClient(new Uri(url));

            cli.Connect();
            var dbTasks = cli.Cypher.Match("(t:Task)").Return(t => t.Node <string>()).Results.ToDynamic();

            foreach (var dbTask in dbTasks)
            {
                var task = new Task(dbTask);
                tasks.Add(task);
            }

            logger.Info("менеджер задач запущен, {0} задач", tasks.Count);
        }
Exemple #9
0
        //public DateTime NextOccurrence
        //{
        //    get
        //    {
        //        return Cron == ""? DateTime.MinValue : CrontabSchedule.Parse(Cron).GetNextOccurrence(DateTime.Now);
        //    }
        //}

        public IEnumerable <Guid> GetTubeIds()
        {
            var url = ConfigurationManager.AppSettings["neo4j-url"];
            var cli = new Neo4jClient.GraphClient(new Uri(url));

            cli.Connect();

            var tbs = cli.Cypher.Match("(a:Task {id:{id}})").
                      OptionalMatch("(a)<--(t1:Tube)").
                      OptionalMatch("(a)<--(f:Folder)-[*]->(t2:Tube)").
                      With("collect(t1.id)+collect(t2.id) as ids unwind ids as id").
                      WithParams(new { id = Id }).Return(id => id.As <Guid>());
            var haa = tbs.Results;

            return(haa);

            //var dbTasks = cli.Cypher.Match("(ts:Task)<--(foo)-[r*0..]->(tb:Tube)").With("tb.id as tbeId,ts.id as tskId,length(r) as len").Return((tbeId, tskId, len) => new { tubeId = tbeId.As<Guid>(), taskId = tskId.As<Guid>(), len = len.As<int>() }).Results;
            //var foo = dbTasks.GroupBy(t => t.tubeId).Select(g => new { tubeId = g.Key, taskId = g.OrderBy(t => t.len).First().taskId }).Where(t => t.taskId == Id).Select(t => t.tubeId).ToList();
            //return foo;
        }
Exemple #10
0
 public void JustEmitsThePathToTheDatabase()
 {
     var db = new Neo4jClient.GraphClient(new Uri("http://localhost:7474/db/data"));
     db.Connect();
     Assert.IsNotNull(db);
 }
Exemple #11
0
 private static async Task ReacreateRelationships(PersonFamilyTreeNode newNode, Neo4jClient.GraphClient client, List <string> children)
 {
     foreach (var child in children)
     {
         await CreateParentRelationship(client, newNode.Id, child);
         await CreateChildRelationship(client, newNode.Id, child);
     }
 }