Beispiel #1
0
        protected override void SolveInstance(IGH_DataAccess dataAccess)
        {
            bool commitChanges = false;

            dataAccess.GetData <bool>("_Commit", ref commitChanges);
            if (_neo4jDB != null && !_wasCommitted && commitChanges)
            {
                _neo4jDB.Value.CommitAsync().RunSynchronously();
                _wasCommitted = !commitChanges;
                AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Changes committed");
                return;
            }


            string host     = string.Empty;
            string userName = string.Empty;
            string password = string.Empty;

            if (!dataAccess.GetData <string>("_neo4jHost", ref host))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Host required");
            }
            if (!dataAccess.GetData <string>("_neo4jUserName", ref userName))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Username required");
            }
            dataAccess.GetData <string>("_neo4jPassword", ref password);

            if (string.IsNullOrEmpty(host) || string.IsNullOrEmpty(userName))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Missing input data");
                return;
            }

            var driver = new Neo4jClient(new Uri(host), userName, password);
            var vstask = driver.VerifyConnectionAsync();

            vstask.RunSynchronously();

            if (vstask.Exception != null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Connection failed: " + vstask.Exception.Message);
            }

            if (_neo4jDB == null)
            {
                _neo4jDB = new Neo4jDatabase(driver);
            }
            else
            {
                var oldDb = _neo4jDB.Value;
                oldDb.CloseAsync().ContinueWith((d) => { oldDb.Dispose(); });
                _neo4jDB.Value = driver;
            }

            dataAccess.SetData("_neo4jDriver", _neo4jDB);
        }
        protected override void SolveInstance(IGH_DataAccess dataAccess)
        {
            Neo4jDatabase neo4jDB = null;

            if (!dataAccess.GetData("_neo4jDriver", ref neo4jDB))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "DB connection required");
                return;
            }


            //neo4jDB.Value.Push();
        }