public void SetupTests()
        {
            _graphClient = new GraphClient(new Uri("http://localhost:7474/db/data"));
            _graphClient.Connect();

            _repository = new EntityRepository(_graphClient);
        }
 public Neo4jRestTransaction(ITransactionalGraphClient graphClient, string database)
 {
     Endpoint = null;
     IsOpen   = true;
     client   = graphClient;
     Database = database;
 }
 internal static Neo4jTransaction FromIdAndClient(int transactionId, ITransactionalGraphClient client)
 {
     return new Neo4jTransaction(client)
     {
         Endpoint = client.TransactionEndpoint.AddPath(transactionId.ToString())
     };
 }
            public void SimpleTransaction_RetrieveAndSerializeAnonymousResult()
            {
                ISession session;
                IDriver  driver;

                Neo4j.Driver.V1.ITransaction transaction;
                IGraphClient graphClient;

                GetAndConnectGraphClient(out graphClient, out driver, out session, out transaction);

                ITransactionalGraphClient txGc = (ITransactionalGraphClient)graphClient;

                using (var tx = txGc.BeginTransaction())
                {
                    var node = txGc.Cypher.Match("(n:Node)").Return(n => new { Node = n.As <MockNode>() }).Results.SingleOrDefault();

                    node.Node.Name.Should().Be("Value");

                    tx.Commit();
                }

                driver.Received(1).Session();
                session.Received(1).BeginTransaction();
                transaction.Received(1).Success();
            }
 public GraphStore(IGraphClient graphClient, bool isUnitOfWorkConfigured)
 {
     _graphClient = graphClient;
     _transactionalGraphClient = (ITransactionalGraphClient)_graphClient;
     _isUnitOfWorkConfigured   = isUnitOfWorkConfigured;
     _hasChanged = false;
 }
Esempio n. 6
0
 internal static Neo4jRestTransaction FromIdAndClient(int transactionId, ITransactionalGraphClient client)
 {
     return(new Neo4jRestTransaction(client)
     {
         Endpoint = client.TransactionEndpoint.AddPath(transactionId.ToString())
     });
 }
Esempio n. 7
0
        public static Task RegisterStepExecutorIndexes(this ITransactionalGraphClient graphClient)
        {
            if (graphClient == null)
            {
                throw new ArgumentNullException(nameof(graphClient));
            }

            return(Task.WhenAll(
                       graphClient.CreateIndex <LastTransaction, Guid>(arg => arg.IdempotentKey),
                       graphClient.CreateIndex <LastTransaction, DateTime>(arg => arg.Created)
                       ));
        }
Esempio n. 8
0
        public static Task CreateIndex <T, TU>(this ITransactionalGraphClient graphClient, Expression <Func <T, TU> > selector)
        {
            if (graphClient == null)
            {
                throw new ArgumentNullException(nameof(graphClient));
            }
            if (selector == null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            return(CreateIndexFromProps <T>(graphClient, selector.GetPropertyInfo().Name));
        }
        public TransactionManager(ITransactionalGraphClient client)
        {
            _client = client;
            // specifies that we are about to use variables that depend on OS threads
            Thread.BeginThreadAffinity();
            _scopedTransactions = new Stack<TransactionScopeProxy>();

            // this object enables the interacion with System.Transactions and MSDTC, at first by
            // letting us manage the transaction objects ourselves, and if we require to be promoted to MSDTC,
            // then it notifies the library how to do it.
            _promotable = new TransactionPromotableSinglePhaseNotification(client);
            _dtcContexts = new Dictionary<string, TransactionContext>();
        }
Esempio n. 10
0
        public TransactionManager(ITransactionalGraphClient client)
        {
            _client = client;
            // specifies that we are about to use variables that depend on OS threads
            Thread.BeginThreadAffinity();
            _scopedTransactions = new Stack <TransactionScopeProxy>();

            // this object enables the interacion with System.Transactions and MSDTC, at first by
            // letting us manage the transaction objects ourselves, and if we require to be promoted to MSDTC,
            // then it notifies the library how to do it.
            _promotable  = new TransactionPromotableSinglePhaseNotification(client);
            _dtcContexts = new Dictionary <string, TransactionContext>();
        }
Esempio n. 11
0
        public AdminSQLPanel()
        {
            InitializeComponent();
            dataBase = new DataBaseManager();
            string connectionString = "mongodb://192.168.99.100:27017";

            mongoclient = new MongoClient(connectionString);
            _client     = new GraphClient(new Uri("http://192.168.99.100.:7474/db/data"), "neo4j", "password");
            _client.Connect();
            elasticClient = new ElasticClient(new ConnectionSettings(new Uri("http://192.168.99.100:9200")).DefaultIndex("filmdesc"));
            LoadCountryList();
            LoadSubscriptionList();
            LoadPeopleList();
            LoadFilmList();
        }
Esempio n. 12
0
        public void Init(string url, string user, string password)
        {
            // Create graph client
            Client = new GraphClient(new Uri(url), user, password);
            Client.Connect();

            // Check if empty, if so, start setup process
            var query = Client.Cypher.Match("(n)")
                        .Return(n => n.As <object>())
                        .Limit(1);

            if (query.Results.Count() == 0)
            {
                Setup();
            }
        }
Esempio n. 13
0
        public async Task RegisterFTIndexes(ITransactionalGraphClient graphClient, CancellationToken cancellationToken)
        {
            if (graphClient == null)
            {
                throw new ArgumentNullException(nameof(graphClient));
            }

            try
            {
                await CreateIndexes(graphClient, cancellationToken);
            }
            catch (NeoException e) when(e.NeoMessage.StartsWith("There already exists an index"))
            {
                // nothing to do
            }
        }
Esempio n. 14
0
        private void _confirmPayment_Click(object sender, EventArgs e)
        {
            _client = new GraphClient(new Uri("http://192.168.99.100.:7474/db/data"), "neo4j", "password");
            _client.Connect();
            User newUser = new User {
                id = Convert.ToInt32(userId)
            };

            _client.Cypher
            .Merge("(user:User { id: {id} })")
            .OnCreate()
            .Set("user = {newUser}")
            .WithParams(new {
                id = newUser.id,
                newUser
            })
            .ExecuteWithoutResults();
            Film newFilm = new Film {
                _id = filmId
            };

            _client.Cypher.Merge("(film:Film { _id: {_id} })")
            .OnCreate()
            .Set("film = {newFilm}")
            .WithParams(new
            {
                newFilm._id,
                newFilm
            })
            .ExecuteWithoutResults();
            var newDate = DateTime.Now.ToString("yyyy-MM-dd");

            _client.Cypher
            .Match("(user:User)", "(film:Film)")
            .Where((User user) => user.id == newUser.id)
            .AndWhere((Film film) => film._id == filmId)
            .CreateUnique("(user)-[:BUY {date : {newDate}}]->(film)")
            .WithParams(new
            {
                newDate
            })
            .ExecuteWithoutResults();
            MessageBox.Show("Поздравляем с покупкой");
            _client.Dispose();
            Close();
        }
Esempio n. 15
0
        protected static async Task SafeCreateIndex(ITransactionalGraphClient graphClient, Func <ICypherFluentQuery, ICypherFluentQuery> query, CancellationToken cancellationToken)
        {
            if (graphClient == null)
            {
                throw new ArgumentNullException(nameof(graphClient));
            }
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            try
            {
                await query(graphClient.Cypher).ExecuteWithoutResultsAsync();
            }
            catch (NeoException e) when(e.NeoMessage.StartsWith("There already exists an index"))
            {
                // nothing to do
            }
        }
            public void SimpleTransaction_AsTransactionalGc_1Query()
            {
                ISession session;
                IDriver  driver;

                Neo4j.Driver.V1.ITransaction transaction;
                IGraphClient graphClient;

                GetAndConnectGraphClient(out graphClient, out driver, out session, out transaction);

                ITransactionalGraphClient txGc = (ITransactionalGraphClient)graphClient;

                using (var tx = txGc.BeginTransaction())
                {
                    txGc.Cypher.Match("(n)").Set("n.Value = 'test'").ExecuteWithoutResults();
                    tx.Commit();
                }

                driver.Received(1).Session();
                session.Received(1).BeginTransaction();
                transaction.Received(1).Success();
            }
Esempio n. 17
0
        public static Task CreateIndex <T, TU, TU1>(this ITransactionalGraphClient graphClient,
                                                    Expression <Func <T, TU> > selector, Expression <Func <T, TU1> > selector2)
        {
            if (graphClient == null)
            {
                throw new ArgumentNullException(nameof(graphClient));
            }
            if (selector == null)
            {
                throw new ArgumentNullException(nameof(selector));
            }
            if (selector2 == null)
            {
                throw new ArgumentNullException(nameof(selector2));
            }

            var propList = new[]
            {
                selector.GetPropertyInfo().Name,
                selector2.GetPropertyInfo().Name
            };

            return(CreateIndexFromProps <T>(graphClient, propList));
        }
 public Neo4jTransactionProxy(ITransactionalGraphClient client, TransactionContext transactionContext, bool newScope)
     : base(client, transactionContext)
 {
     _doCommitInScope = newScope;
 }
 public BoltSuppressTransactionProxy(ITransactionalGraphClient client)
     : base(client, null)
 {
 }
 public Neo4jTransactionProxy(ITransactionalGraphClient client, TransactionContext transactionContext, bool newScope)
     : base(client, transactionContext)
 {
     _doCommitInScope = newScope;
 }
Esempio n. 21
0
 protected TransactionScopeProxy(ITransactionalGraphClient client, TransactionContext transactionContext)
 {
     _client             = client;
     _disposing          = false;
     _transactionContext = transactionContext;
 }
 public TransactionPromotableSinglePhaseNotification(ITransactionalGraphClient client)
 {
     _client = client;
     //_resourceManager = new Neo4jTransactionResourceManager();
 }
 public Neo4JOutboxDataProvider(ITransactionalGraphClient graphClient, IOptions <OutboxOptions> outboxOptions)
 {
     _graphClient   = graphClient;
     _outboxOptions = outboxOptions.Value;
 }
 public SuppressTransactionProxy(ITransactionalGraphClient client)
     : base(client, null)
 {
 }
Esempio n. 25
0
 public Neo4jRestTransaction(ITransactionalGraphClient graphClient)
 {
     Endpoint = null;
     IsOpen   = true;
     client   = graphClient;
 }
 public TransactionPromotableSinglePhaseNotification(ITransactionalGraphClient client)
 {
     _client = client;
     //_resourceManager = new Neo4jTransactionResourceManager();
 }
 protected BoltTransactionScopeProxy(ITransactionalGraphClient client, BoltTransactionContext transactionContext)
 {
     this.client             = client;
     disposing               = false;
     this.transactionContext = transactionContext;
 }
 protected TransactionScopeProxy(ITransactionalGraphClient client, TransactionContext transactionContext)
 {
     _client = client;
     _disposing = false;
     _transactionContext = transactionContext;
 }
Esempio n. 29
0
 protected abstract Task CreateIndexes(ITransactionalGraphClient graphClient, CancellationToken cancellationToken);
 public EntityRepository(ITransactionalGraphClient graphClient)
 {
     _graphClient = graphClient;
 }
Esempio n. 31
0
 public Neo4jTransaction(ITransactionalGraphClient graphClient)
 {
     Endpoint = null;
     IsOpen = true;
     _client = graphClient;
 }
Esempio n. 32
0
 public OutboxDataProviderNeo4j(ITransactionalGraphClient graphClient, IOptions <OutboxOptions> outboxOptions)
 {
     _graphClient   = graphClient ?? throw new ArgumentNullException(nameof(graphClient));
     _outboxOptions = outboxOptions?.Value ?? throw new ArgumentNullException(nameof(outboxOptions));
 }
Esempio n. 33
0
 public BoltTransactionPromotableSinglePhasesNotification(ITransactionalGraphClient client)
 {
     this.client = client;
 }
Esempio n. 34
0
 public OnceExecutorNeo4j(ITransactionalGraphClient graphClient)
 {
     Context = graphClient ?? throw new ArgumentNullException(nameof(graphClient));
 }