public DataBase(string dbDirPath) { serializer = new Serializer (); dbName = Path.GetFileNameWithoutExtension (dbDirPath); dbPath = Path.Combine (dbDirPath, Path.GetFileName (dbDirPath)); this.dbDirPath = dbDirPath; if (!Directory.Exists (dbDirPath)) { Directory.CreateDirectory (dbDirPath); } if (File.Exists (dbPath)) { try { projectsDB = serializer.Load<LiteDB> (dbPath); projectsDB.DBPath = dbPath; } catch (Exception e) { Log.Exception (e); } } if (projectsDB == null) { Reload (); } DateTime now = DateTime.UtcNow; if (projectsDB.LastBackup + maxDaysWithoutBackup < now) { Backup (); } }
public void Reload() { projectsDB = new LiteDB(dbPath); DirectoryInfo dbDir = new DirectoryInfo(dbDirPath); foreach (FileInfo file in dbDir.GetFiles()) { if (file.FullName == dbPath) { continue; } try { Project project = Serializer.Load <Project> (file.FullName); projectsDB.Add(project.Description); } catch (Exception ex) { Log.Exception(ex); } } projectsDB.Save(); }
public void Reload() { projectsDB = new LiteDB (dbPath); DirectoryInfo dbDir = new DirectoryInfo (dbDirPath); foreach (FileInfo file in dbDir.GetFiles ()) { if (file.FullName == dbPath) { continue; } try { Project project = serializer.Load<Project> (file.FullName); projectsDB.Add (project.Description); } catch (Exception ex) { Log.Exception (ex); } } projectsDB.Save (); }