Inheritance: IDatabase
Example #1
0
 public void TestCreateEmptyDatabase()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     Assert.IsTrue (Directory.Exists (dbdir));
     Assert.IsTrue (File.Exists (Path.Combine (dbdir, "test.ldb")));
     Assert.AreEqual (db.Count, 0);
 }
Example #2
0
        public static void Main(string[] args)
        {
            /* Start DB services */
            Core.Init();
            var db = new DataBase(Path.Combine(Config.DBDir(),Constants.DB_FILE));
            Project p = db.GetProject(db.GetAllProjects()[0].UUID);

            ExcelExporter ee = new ExcelExporter();
            ee.ExportProject(p,  "/home/andoni/test.xls");
        }
Example #3
0
 public void TestAddProject()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch ();
     ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1};
     Assert.IsTrue (db.AddProject (p1));
     Assert.IsTrue (File.Exists (Path.Combine (dbdir, p1.ID.ToString())));
     Assert.IsTrue (db.AddProject (p1));
     Assert.AreEqual (db.Count, 1);
     db = new DataBase (dbdir);
     Assert.AreEqual (db.Count, 1);
 }
Example #4
0
        public static void StartServices(IGUIToolkit guiToolkit, IMultimediaToolkit multimediaToolkit)
        {
            ProjectsManager projectsManager;

            /* Start TemplatesService */
            ts = new TemplatesService(Config.configDirectory);
            Core.mainWindow.TemplatesService = ts;

            /* Start DB services */
            db = new DataBase(Path.Combine(Config.DBDir(),Constants.DB_FILE));

            /* Start the events manager */
            eManager = new EventsManager(guiToolkit);

            /* Start the hotkeys manager */
            hkManager = new HotKeysManager(guiToolkit.MainWindow);
            hkManager.newMarkEvent += eManager.OnNewTag;

            /* Start the rendering jobs manager */
            videoRenderer = new RenderingJobsManager(multimediaToolkit, guiToolkit);

            /* Start Game Units manager */
            guManager = new GameUnitsManager(mainWindow, mainWindow.Player);

            /* Start playlists manager */
            plManager = new PlaylistManager(guiToolkit, videoRenderer);

            projectsManager = new ProjectsManager(guiToolkit, multimediaToolkit);
            projectsManager.OpenedProjectChanged += OnOpenedProjectChanged;
        }
Example #5
0
        public void UpdateDatabases()
        {
            Databases = new List<IDatabase> ();
            DirectoryInfo dbdir = new DirectoryInfo (DBDir);

            foreach (DirectoryInfo subdir in dbdir.GetDirectories()) {
                if (subdir.FullName.EndsWith (".ldb")) {
                    IDatabase db = new DataBase (subdir.FullName);
                    if (db != null) {
                        Log.Information ("Found database " + db.Name);
                        Databases.Add (db);
                    }
                }
            }
        }
Example #6
0
        public void SetActiveByName(string name)
        {
            foreach (IDatabase db in Databases) {
                if (db.Name == name) {
                    Log.Information ("Selecting active database " + db.Name);
                    ActiveDB = db;
                    return;
                }
            }

            IDatabase newdb = new DataBase (NameToFile (name));
            Log.Information ("Creating new database " + newdb.Name);
            Databases.Add (newdb);
            ActiveDB = newdb;
        }
Example #7
0
 public IDatabase Add(string name)
 {
     if (Databases.Where (db => db.Name == name).Count () != 0) {
         throw new Exception ("A database with the same name already exists");
     }
     try {
         IDatabase newdb = new DataBase (NameToFile (name));
         Log.Information ("Creating new database " + newdb.Name);
         Databases.Add (newdb);
         return newdb;
     } catch (Exception ex) {
         Log.Exception (ex);
         return null;
     }
 }
Example #8
0
 public void TestDBWithErrorProject()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     db.AddProject (new ProjectLongoMatch {Description = new ProjectDescriptionLongoMatch()});
     var writer = File.CreateText (Path.Combine (dbdir, "wrongfile"));
     writer.WriteLine("TEST&%&$&%");
     writer.WriteLine("}~4");
     writer.Flush();
     writer.Close();
     File.Delete (Path.Combine (dbdir, "test.ldb"));
     db = new DataBase (dbdir);
     Assert.AreEqual (db.Count, 1);
 }
Example #9
0
 public void TestUpdateProject()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch ();
     ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1};
     DateTime lastModified = p1.Description.LastModified;
     Assert.IsTrue (db.AddProject (p1));
     Assert.IsTrue (db.UpdateProject (p1));
     Assert.AreNotEqual (p1.Description.LastModified, lastModified);
 }
Example #10
0
 public void TestReloadDB()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     db.AddProject (new ProjectLongoMatch {Description = new ProjectDescriptionLongoMatch()});
     File.Delete (Path.Combine (dbdir, "test.ldb"));
     db = new DataBase (dbdir);
     Assert.IsTrue (File.Exists (Path.Combine (dbdir, "test.ldb")));
     Assert.AreEqual (db.Count, 1);
 }
Example #11
0
 public void TestLoadExistingDatabase()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     DataBase newdb = new DataBase (dbdir);
     Assert.AreEqual (db.LastBackup, newdb.LastBackup);
 }
Example #12
0
 public void TestGetProject()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch ();
     ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1};
     db.AddProject (p1);
     ProjectLongoMatch p2 = db.GetProject (p1.ID);
     Assert.AreEqual (p1.ID, p2.ID);
     Assert.IsNull (db.GetProject (new Guid()));
 }
Example #13
0
 public void TestGetAllProjects()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch ();
     ProjectDescriptionLongoMatch pd2 = new ProjectDescriptionLongoMatch ();
     ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1};
     ProjectLongoMatch p2 = new ProjectLongoMatch {Description = pd2};
     db.AddProject (p1);
     db.AddProject (p2);
     Assert.AreEqual (db.Count, 2);
     List<ProjectDescriptionLongoMatch> projects = db.GetAllProjects ();
     Assert.AreEqual (db.Count, 2);
     Assert.AreEqual (projects.Count, 2);
     Assert.AreEqual (projects[0], pd1);
     Assert.AreEqual (projects[1], pd2);
 }
Example #14
0
 public void TestExists()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch ();
     ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1};
     Assert.IsFalse (db.Exists (p1));
     db.AddProject (p1);
     Assert.IsTrue (db.Exists (p1));
 }
Example #15
0
 public void TestDelete()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     Assert.IsTrue (Directory.Exists (dbdir));
     db.Delete ();
     Assert.IsFalse (Directory.Exists (dbdir));
     db.Delete ();
 }
Example #16
0
 public void TestRemoveProject()
 {
     string dbdir = Path.Combine (tmpdir, "test.ldb");
     DataBase db = new DataBase (dbdir);
     ProjectDescription pd1 = new ProjectDescription ();
     Project p1 = new Project {Description = pd1};
     Assert.IsTrue (db.AddProject (p1));
     Assert.IsTrue (File.Exists (Path.Combine (dbdir, p1.ID.ToString())));
     Assert.AreEqual (db.Count, 1);
     Assert.IsTrue (db.RemoveProject (p1.ID));
     Assert.IsFalse (File.Exists (Path.Combine (dbdir, p1.ID.ToString())));
     Assert.AreEqual (db.Count, 0);
     Assert.IsFalse (db.RemoveProject (p1.ID));
     db = new DataBase (dbdir);
     Assert.AreEqual (db.Count, 0);
 }