예제 #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
파일: FileDB.cs 프로젝트: kuggaa/longomatch
        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 ();
 }