예제 #1
0
        public static void CreateDatabase(ServerConnectionOptions serverConnectionOptions, string database, IOrientDBRecordSerializer <byte[]> serializer)
        {
            using (OrientDBBinaryServerConnection serverConnection = new OrientDBBinaryServerConnection(serverConnectionOptions, serializer))
            {
                serverConnection.Open();

                if (serverConnection.DatabaseExists(database, StorageType.PLocal))
                {
                    serverConnection.DropDatabase(database, StorageType.PLocal);
                }

                var databaseConnection = serverConnection.CreateDatabase(database, DatabaseType.Graph, StorageType.PLocal);
            }
        }
예제 #2
0
        public static void DeleteDatabase(ServerConnectionOptions serverConnectionOptions, string database, IOrientDBRecordSerializer <byte[]> serializer)
        {
            using (OrientDBBinaryServerConnection serverConnection = new OrientDBBinaryServerConnection(serverConnectionOptions, serializer))
            {
                serverConnection.Open();

                if (!serverConnection.DatabaseExists(database, StorageType.PLocal))
                {
                    return;
                }

                serverConnection.DropDatabase(database, StorageType.PLocal);
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            if (args.Length != 5)
            {
                throw new ArgumentException($"{args.Length} arguments present, only 5 are required: hostname username password port database");
            }

            // Create a new instance of an IOrientDBRecordSerializer of type byte[].
            IOrientDBRecordSerializer <byte[]> serializer = new OrientDBRecordCSVSerializer();

            // Instantiate and fill in the ServerConnectionOptions.
            ServerConnectionOptions options = new ServerConnectionOptions
            {
                HostName = args[0],
                UserName = args[1],
                Password = args[2],
                Port     = int.Parse(args[3]),
                PoolSize = 1
            };

            // Create a Server Connection.
            using (OrientDBBinaryServerConnection serverConnection = new OrientDBBinaryServerConnection(options, serializer))
            {
                // Check if the database exists.
                if (serverConnection.DatabaseExists(args[4], StorageType.PLocal))
                {
                    throw new Exception($"Database {args[4]} already exists!");
                }

                // Create a database.
                using (OrientDBBinaryConnection databaseConnection = serverConnection.CreateDatabase(args[4], DatabaseType.Graph, StorageType.PLocal))
                {
                    // Open database connection.
                    databaseConnection.Open();
                }

                // Drop the database.
                serverConnection.DropDatabase(args[4], StorageType.PLocal);
            }
        }