/// <summary> /// Ensures that the database locations system database file knows that the all the /// database files are in the current database folder, in case this is a copy of a /// database created in another folder, which may have been on another computer. /// </summary> public static void Localise(string databaseFolderPath) { Debug.WriteLine("DatabaseLocationHelper.Localise"); Session = new SessionNoServer(databaseFolderPath); var defaultDatabaseLocation = Session.DefaultDatabaseLocation(); if (!IsDatabaseLocationLocal(defaultDatabaseLocation)) { Debug.WriteLine(" Localising default database location"); Session.RelocateDefaultDatabaseLocation(); } Session.BeginUpdate(); foreach (var database in Session.Databases) { if (!IsDatabaseLocationLocal(database.Location)) { Debug.WriteLine($" Localising database location {database.Location}"); Session.RelocateDatabaseLocationFor( database.DatabaseNumber, SessionBase.LocalHost, Session.SystemDirectory); } } Session.Commit(); }
public void SandeepGraph(bool useServerSession) { bool dirExist = Directory.Exists(systemDir); try { if (Directory.Exists(systemDir)) { Directory.Delete(systemDir, true); // remove systemDir from prior runs and all its databases. } Directory.CreateDirectory(systemDir); File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb")); } catch { File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb")); } using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir)) { session.BeginUpdate(); session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.None; Graph g = new Graph(session); session.Persist(g); // SCHEMA VertexType userType = g.NewVertexType("User"); // Add a node type for the movies, with a unique identifier and two indexed Propertys VertexType movieType = g.NewVertexType("MOVIE"); PropertyType movieTitleType = g.NewVertexProperty(movieType, "TITLE", DataType.String, PropertyKind.Indexed); PropertyType movieYearType = g.NewVertexProperty(movieType, "YEAR", DataType.Integer, PropertyKind.Indexed); PropertyType objectPropertyType = g.NewVertexProperty(movieType, "object", DataType.Object, PropertyKind.NotIndexed); PropertyType objectPropertyTypeIndexed = g.NewVertexProperty(movieType, "object2", DataType.IOptimizedPersistable, PropertyKind.Indexed); Vertex mVickyCB = movieType.NewVertex(); mVickyCB.SetProperty(movieTitleType, "Vicky Cristina Barcelona"); mVickyCB.SetProperty(movieYearType, (int)(2008)); OptimizedPersistable pObj = new OptimizedPersistable(); session.Persist(pObj); mVickyCB.SetProperty(objectPropertyType, pObj); pObj = new OptimizedPersistable(); session.Persist(pObj); mVickyCB.SetProperty(objectPropertyTypeIndexed, pObj); Vertex mMatsCB = movieType.NewVertex(); mMatsCB.SetProperty(movieTitleType, "Mats Cristina Barcelona"); mMatsCB.SetProperty(movieYearType, (int)(2008)); pObj = new OptimizedPersistable(); session.Persist(pObj); mMatsCB.SetProperty(objectPropertyType, pObj); session.Commit(); session.BeginUpdate(); try { mMatsCB.SetProperty(objectPropertyTypeIndexed, null); throw new UnexpectedException(); } catch (NullObjectException) { } mMatsCB.Remove(); session.Commit(); //session.Persist(g); //session.Commit(); } using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir)) { session.BeginUpdate(); Graph g = Graph.Open(session); VertexType movieType = g.FindVertexType("MOVIE"); Assert.NotNull(movieType); } Task taskB = new Task(() => WatchUser()); taskB.Start(); Task taskA = new Task(() => CreateUser()); taskA.Start(); taskB.Wait(); taskA.Wait(); }
public void createDatabaseLocations(SessionBase session) { session.BeginUpdate(); Person person = new Person("Mats", "Persson", 54); session.Persist(person); var otherLocation = new DatabaseLocation(session.SystemHostName, otherDbDir, otherStartdbId, session.DefaultDatabaseLocation().EndDatabaseNumber, session); Placement place = new Placement(otherStartdbId); Person person2 = new Person("Mats", "Persson", 27); session.Persist(place, person2); session.Commit(); verifyDatabaseLocations(session); }