Example #1
0
 public static IEnumerable <Genre> GetAllGenres()
 {
     Client.Connect();
     return(Client.Cypher
            .Match("(genre: Genre)")
            .Return(genre => genre.As <Genre>())
            .Results);
 }
 public NetworkContext(IOptions<AppSettings> options)
 {
     var appSettings = options.Options;
     _db = new GraphClient(new Uri(appSettings.Neo4jConnection));//, appSettings.Neo4jUserName,
        // appSettings.Neo4jPassword);
     _db.Connect();
 }
Example #3
0
        public NetworkContext(IOptions <AppSettings> options)
        {
            var appSettings = options.Options;

            _db = new GraphClient(new Uri(appSettings.Neo4jConnection));//, appSettings.Neo4jUserName,
            // appSettings.Neo4jPassword);
            _db.Connect();
        }
Example #4
0
 private void Connect()
 {
     try
     {
         client.Connect();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
 public IEnumerable Find()
 {
     Client.Connect();
     return(Client.WithAnnotations().Cypher.Match(p =>
                                                  p.Pattern <Team, WorkdsInRelationship, Company>("t", "r", "c", RelationshipDirection.Outgoing)
                                                  .Constrain((t) => t.Name == "engineering"))
            .Return((t, r, c) => new WorkdsInRelationship
     {
         Team = t.As <Team>(),
         Company = c.As <Company>()
     }).Results);
 }
Example #6
0
        public JsonResult Welcome()
        {
            //TODO get IVR Graph from database
            AlchemyIVRModel        model    = new AlchemyIVRModel();
            IList <AlchemyIVRNode> nodeList = new List <AlchemyIVRNode>();
            IList <AlchemyIVREdge> edgeList = new List <AlchemyIVREdge>();

            _neo4jClient.Connect();
            var queryResults = _neo4jClient.Cypher
                               .Match("(welcome:WELCOME)") //-[HAS_OPTION]-(message:MESSAGE)")
                               .OptionalMatch("(welcome:WELCOME)-[HAS_OPTION]-(message:MESSAGE)")
                               .Return((welcome, message) =>
                                       new
            {
                Welcome = welcome.As <IVRMessage>(),
                Message = message.As <IVRMessage>()
            }).Results;

            //TODO if no next messages just get the welcome message or do an optional match?

            //BUILD the JSON for Alchemy


            foreach (var rel in queryResults)
            {
                //check that there is a next message first and then build the alchemy model
                if (rel.Message != null)
                {
                    if (!nodeList.Where(n => n.id == rel.Message.id).Any())
                    {
                        nodeList.Add(new AlchemyIVRNode
                        {
                            id      = rel.Message.id.Value,
                            type    = "message",
                            caption = rel.Message.message
                        });
                    }

                    edgeList.Add(new AlchemyIVREdge
                    {
                        source  = rel.Welcome.id.Value,
                        target  = rel.Message.id.Value,
                        caption = "OPTION"
                    });
                }
                if (!nodeList.Where(n => n.id == rel.Welcome.id).Any())
                {
                    nodeList.Add(new AlchemyIVRNode {
                        id      = rel.Welcome.id.Value,
                        type    = "welcome", root = true,
                        caption = rel.Welcome.message
                    });
                }
            }
            model.edges = edgeList;
            model.nodes = nodeList;

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Example #7
0
        public FilmInfo(string filmID, int userID)
        {
            InitializeComponent();
            userId = userID;
            filmId = filmID;
            neo4j  = new GraphClient(new Uri("http://192.168.99.100.:7474/db/data"), "neo4j", "password");
            neo4j.Connect();
            string connectionString = "mongodb://192.168.99.100:27017";

            mongoclient   = new MongoClient(connectionString);
            mongodb       = mongoclient.GetDatabase("cinemastore");
            dataBase      = new DataBaseManager();
            elasticClient = new ElasticClient(new ConnectionSettings(new Uri("http://192.168.99.100:9200")).DefaultIndex("filmdesc"));
        }
Example #8
0
        public Neo4J(string connectionString, out string connectionError)
        {
            connectionError = string.Empty;

            try
            {
                _graphClient = new GraphClient(new Uri(connectionString));
                _graphClient.Connect();
            }
            catch (Exception ex)
            {
                connectionError = string.Format("Error: {0};StackTrace: {1}; InnerException: {2}", ex.Message, ex.StackTrace, ex.InnerException);
            }
        }
Example #9
0
 public static IEnumerable <Venue> GetAllVenues()
 {
     Console.WriteLine("Loading Neo4j data");
     Client.Connect();
     return(Client.Cypher
            .Match("(venue:Venue)")
            .Return(venue => venue.As <Venue>())
            .Results);
 }
Example #10
0
 public static IEnumerable <Band> GetAllBands()
 {
     Console.WriteLine("Loading Neo4j data");
     Client.Connect();
     return(Client.Cypher
            .Match("(band:Band)")
            .Return(band => band.As <Band>())
            .Results);
 }
Example #11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.authMenu.Hide();
            this._userControlPanel.Hide();
            this._mySubsPanel.Hide();
            this._myFilmsPanel.Hide();
            dataBase = new DataBaseManager();
            neo4j    = new GraphClient(new Uri("http://192.168.99.100.:7474/db/data"), "neo4j", "password");
            neo4j.Connect();

            redis   = ConnectionMultiplexer.Connect("192.168.99.100:6379"); //просто подключение к редис, без входа в redis-cli
            redisdb = redis.GetDatabase(0);                                 //в redis от 0 до 15 баз данных, по умолчанию всегда в 0
            redisdb.StringSet("demo", "helloworld");                        //https://stackexchange.github.io/StackExchange.Redis/Basics.html -- redis

            elasticClient = new ElasticClient(new ConnectionSettings(new Uri("http://192.168.99.100:9200")).DefaultIndex("filmdesc"));

            string connectionString = "mongodb://192.168.99.100:27017";

            mongoclient             = new MongoClient(connectionString);
            mongodb                 = mongoclient.GetDatabase("cinemastore");
            _lookMode.SelectedIndex = 0;
        }
Example #12
0
 public PersonRepositoryNeo4j()
 {
     client = new GraphClient(new Uri("http://*****:*****@localhost:7474/db/data"), "neo4j", "10g428");
     client.Connect();
 }
Example #13
0
 public GraphRepository()
 {
     _graphClient = new GraphClient(new Uri("http://localhost:7474/db/data"), "neo4j", "socialnetwork");
     _graphClient.Connect();
 }
Example #14
0
        public void Connect()
        {
            _logger.LogInformation("Connecting to graph database");

            _client.Connect();
        }
Example #15
0
 public UserDALn()
 {
     _client = new GraphClient(new Uri("http://localhost:7474"), "neo4j", "1111");
     _client.Connect();
 }
 static PermissionableTests()
 {
     _client.Connect();
 }
Example #17
0
 public IGraphClient GetConnection()
 {
     _provider = new GraphClient(new Uri(_apiConfig.Value.Url), _apiConfig.Value.UserId, _apiConfig.Value.Password);
     _provider.Connect();
     return(_provider);
 }
Example #18
0
 public VisNet()
 {
     _graphClient = new GraphClient(new Uri("http://localhost:7474/db/data"), "neo4j", "12345");
     _graphClient.Connect();
     //clearTheGraph();
 }
Example #19
0
        public DataManager(Uri path, string user, string pass)
        {
            this.client = new Neo4jClient.GraphClient(path, user, pass);

            client.Connect();
        }
Example #20
0
        static void Main(string[] args)
        {
            NeoClient    client = NeoClient.Create();
            IGraphClient cl2    = client.Client;

            cl2.Connect();

            #region fill db
            //Product p1 = new Product() {Id = Guid.NewGuid(), Name = "Молоко", Measure = "л"};
            //Product p1 = new Product() { Id = Guid.NewGuid(), Name = "Индейка", Measure = "кг" };
            //Product p2 = new Product() {Id = Guid.NewGuid(), Name = "Сыр", Measure = "гр"};
            //Shop s1 = new Shop() {Id = Guid.NewGuid(), Latitude = "53.90827", Longitude = "27.46999", Name = "Green", Street = "ул. Петра Глебки", Number = "5"};
            //Shop s2 = new Shop() { Id = Guid.NewGuid(), Latitude = "53.67188", Longitude = "23.79859", Name = "Алми", Street = "ул. Советских Пограничников", Number = "110a"};
            //Shop s3 = new Shop() { Id = Guid.NewGuid(), Latitude = "53.92650", Longitude = "27.51747", Name = "Корона Техно", Street = "пр-т. Победителей", Number = "65" };
            //City c1 = new City() {Id = Guid.NewGuid(), Name = "Минск"};
            //City c2 = new City() { Id = Guid.NewGuid(), Name = "Гродно" };
            //Country co1 = new Country() {Id = Guid.NewGuid(), Name = "Беларусь"};

            //cl2.Cypher
            //    .Create("(product:Product {p1})")
            //    .WithParam("p1", p1)
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Create("(product:Product {p2})")
            //    .WithParam("p2", p2)
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Create("(shop:Shop {s1})")
            //    .WithParam("s1", s1)
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Create("(shop:Shop {s2})")
            //    .WithParam("s2", s2)
            //    .ExecuteWithoutResults();

            //Shop s3 = new Shop() { Id = Guid.NewGuid(), Latitude = "53.89479", Longitude = "27.52162", Name = "Евроопт", Street = "ул. Харьковская", Number = "72" };
            //Shop s4 = new Shop() { Id = Guid.NewGuid(), Latitude = "53.89348", Longitude = "27.58170", Name = "Евроопт", Street = "ул. Менделеева", Number = "1" };

            //cl2.Cypher
            //    .Create("(shop:Shop {s3})")
            //    .WithParam("s3", s3)
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Create("(shop:Shop {s4})")
            //    .WithParam("s4", s4)
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Match("(s:Shop)", "(c:City)")
            //    .Where((Shop s) => s.Id == s3.Id)
            //    .AndWhere((City c) => c.Name == "Минск")
            //    .Create("(s)-[:" + Relation.LocatedAt + "]->(c)")
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Match("(s:Shop)", "(c:City)")
            //    .Where((Shop s) => s.Id == s4.Id)
            //    .AndWhere((City c) => c.Name == "Минск")
            //    .Create("(s)-[:" + Relation.LocatedAt + "]->(c)")
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Create("(city:City {c1})")
            //    .WithParam("c1", c1)
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Create("(city:City {c2})")
            //    .WithParam("c2", c2)
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Create("(country:Country {co1})")
            //    .WithParam("co1", co1)
            //    .ExecuteWithoutResults();

            //ContainedIn link1 = new ContainedIn() { Amount = 5, Price = 10.5M };
            //cl2.Cypher
            //    .Match("(p:Product)", "(s:Shop)")
            //    .Where((Product p) => p.Name == "Индейка")
            //    .AndWhere((Shop s) => s.Name == "Green")
            //    .Create("(p)-[:" + link1.ToCreateRelation() + "]->(s)")
            //    .ExecuteWithoutResults();

            //ContainedIn link1 = new ContainedIn() { Amount = 330, Price = 1.4M };
            //cl2.Cypher
            //    .Match("(p:Product)", "(s:Shop)")
            //    .Where((Product p) => p.Name == "Молоко")
            //    .AndWhere((Shop s) => s.Name == "Алми")
            //    .Create("(p)-[:" + link1.ToCreateRelation() + "]->(s)")
            //    .ExecuteWithoutResults();

            //ContainedIn link2 = new ContainedIn() { Amount = 100, Price = 2.5M };
            //cl2.Cypher
            //    .Match("(p:Product)", "(s:Shop)")
            //    .Where((Product p) => p.Name == "Сыр")
            //    .AndWhere((Shop s) => s.Name == "Алми")
            //    .Create("(p)-[:" + link2.ToCreateRelation() + "]->(s)")
            //    .ExecuteWithoutResults();

            //ContainedIn link3 = new ContainedIn() { Amount = 50, Price = 3.1M };
            //cl2.Cypher
            //    .Match("(p:Product)", "(s:Shop)")
            //    .Where((Product p) => p.Name == "Сыр")
            //    .AndWhere((Shop s) => s.Name == "Green")
            //    .Create("(p)-[:" + link3.ToCreateRelation() + "]->(s)")
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Match("(s:Shop)", "(c:City)")
            //    .Where((Shop s) => s.Name == "Green")
            //    .AndWhere((City c) => c.Name == "Минск")
            //    .Create("(s)-[:" + Relation.LocatedAt + "]->(c)")
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Match("(s:Shop)", "(c:City)")
            //    .Where((Shop s) => s.Name == "Алми")
            //    .AndWhere((City c) => c.Name == "Гродно")
            //    .Create("(s)-[:" + Relation.LocatedAt + "]->(c)")
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Match("(s:Shop)", "(c:City)")
            //    .Where((Shop s) => s.Name == "Корона Техно")
            //    .AndWhere((City c) => c.Name == "Минск")
            //    .Create("(s)-[:" + Relation.LocatedAt + "]->(c)")
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Match("(c:City)", "(co:Country)")
            //    .Where((City c) => c.Name == "Минск")
            //    .AndWhere((Country co) => co.Name == "Беларусь")
            //    .Create("(c)-[:" + Relation.LocatedAt + "]->(co)")
            //    .ExecuteWithoutResults();

            //cl2.Cypher
            //    .Match("(c:City)", "(co:Country)")
            //    .Where((City c) => c.Name == "Гродно")
            //    .AndWhere((Country co) => co.Name == "Беларусь")
            //    .Create("(c)-[:" + Relation.LocatedAt + "]->(co)")
            //    .ExecuteWithoutResults();

            //Product p3 = new Product() {Id = Guid.NewGuid(), Measure = "шт", Name = "Холодильник"};

            //cl2.Cypher
            //    .Create("(product:Product {p3})")
            //    .WithParam("p3", p3)
            //    .ExecuteWithoutResults();

            //ContainedIn link2 = new ContainedIn() { Amount = 2, Price = 995.9M };
            //cl2.Cypher
            //    .Match("(p:Product)", "(s:Shop)")
            //    .Where((Product p) => p.Name == "Холодильник")
            //    .AndWhere((Shop s) => s.Name == "Корона Техно")
            //    .Create("(p)-[:" + link2.ToCreateRelation() + "]->(s)")
            //    .ExecuteWithoutResults();
            #endregion

            //var r1 =
            //cl2.Cypher.Match("(p:Product) -[r: Located_At]->(s: Shop)")
            //    .Where((Product p, ContainedIn r, Shop s) => p.Name == "Milk" && s.Name=="Walmart" && r.Price<2).Return((p, r, s) => new
            //    {
            //        Product = p.As<Product>(),
            //        Location = r.As<ContainedIn>(),
            //        Shop = s.As<Shop>()
            //    }).Results;

            //create(p: Product { Id: "7312754D-7582-4BA7-B42B-009DFDFF5EC6", Measure: "1 кг", Name: "Курица"})

            //var rty = new UriBuilder() {Scheme = Uri.UriSchemeFile, Host = "", Path = @"C:\Users\user\Desktop\Product.csv" }.Uri;

            //cl2.Cypher.LoadCsv( rty, "line", true)
            //    .Create($"(:Product {{ Id: \"{Guid.NewGuid()}\", Name: line.Name, Measure: line.Measure}})").ExecuteWithoutResults();



            //using (StreamReader r = new StreamReader("D:\\univer\\webService\\taaffeite\\NeoDatabase\\Product.json"))
            //{
            //    string json = r.ReadToEnd();
            //    List<Product> items = JsonConvert.DeserializeObject<List<Product>>(json);

            //    for (int i = 0; i < items.Count; i++)
            //    {
            //        items[i].Id = Guid.NewGuid();

            //        cl2.Cypher
            //            .Create("(product:Product {p1})")
            //            .WithParam("p1", items[i])
            //            .ExecuteWithoutResults();
            //    }
            //}

            using (StreamReader r = new StreamReader("D:\\univer\\webService\\taaffeite\\NeoDatabase\\Connection.json"))
            {
                string json  = r.ReadToEnd();
                var    array = JsonConvert.DeserializeObject <List <Connection> >(json);

                foreach (var item in array)
                {
                    ORMContainedIn link1 = new ORMContainedIn {
                        Amount = item.Amount, Price = item.Price
                    };
                    cl2.Cypher
                    .Match("(p:Product)", "(s:Shop)")
                    .Where((ORMProduct p) => p.Name == item.ProductName)
                    .AndWhere((ORMShop s) => s.Id == item.ShopId)
                    .Create("(p)-[:" + link1.ToCreateRelation() + "]->(s)")
                    .ExecuteWithoutResults();
                }
            }


            //using (StreamReader r = new StreamReader("D:\\univer\\webService\\taaffeite\\NeoDatabase\\Shop.json"))
            //{
            //    string json = r.ReadToEnd();
            //    List<Shop> items = JsonConvert.DeserializeObject<List<Shop>>(json);

            //    for (int i = 0; i < items.Count; i++)
            //    {
            //        items[i].Id = Guid.NewGuid();

            //        cl2.Cypher
            //            .Create("(shop:Shop {p1})")
            //            .WithParam("p1", items[i])
            //            .ExecuteWithoutResults();
            //    }
            //}


            Console.WriteLine("ready");
        }
Example #21
0
 public Social()
 {
     _graphClient = new GraphClient(new Uri("http://localhost:7474/db/data"), "user", "pass");
     _graphClient.Connect();
 }
 public DataContext(string dbUri, string user, string pass)
 {
     GraphDb = new GraphClient(new Uri(dbUri), user, pass);
     GraphDb.Connect();
 }