Пример #1
0
        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 ();
            }
        }
Пример #2
0
        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();
        }
Пример #3
0
 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 ();
 }