Add() 공개 메소드

public Add ( ProjectDescription desc ) : bool
desc LongoMatch.Core.Store.ProjectDescription
리턴 bool
예제 #1
0
파일: FileDB.cs 프로젝트: kuggaa/longomatch
        public void AddProject(Project project)
        {
            string projectFile;

            projectFile = Path.Combine(dbDirPath, project.ID.ToString());
            project.Description.LastModified = DateTime.UtcNow;
            projectsDB.Add(project.Description);
            try {
                if (File.Exists(projectFile))
                {
                    File.Delete(projectFile);
                }
                Serializer.Save(project, projectFile);
            } catch (Exception ex) {
                Log.Exception(ex);
                projectsDB.Delete(project.Description.ID);
            }
        }
예제 #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 AddProject(Project project)
        {
            string projectFile;
            bool   update = false;

            Log.Debug(string.Format("Add project {0}", project.ID));
            projectFile = Path.Combine(dbDirPath, project.ID.ToString());
            string tmpProjectFile = projectFile + ".tmp";

            project.Description.LastModified = DateTime.UtcNow;
            if (projectsDB.ProjectsDict.ContainsKey(project.Description.ProjectID))
            {
                update = true;
            }

            projectsDB.Add(project.Description);
            try {
                serializer.Save(project, tmpProjectFile);
                if (File.Exists(projectFile))
                {
                    File.Replace(tmpProjectFile, projectFile, null);
                }
                else
                {
                    File.Move(tmpProjectFile, projectFile);
                }
            } catch (Exception ex) {
                Log.Exception(ex);
                // FIXME: This is dirty, but I can't find another way right now.
                if (!update)
                {
                    projectsDB.Delete(project.Description.ProjectID);
                }
                throw;
            }
        }
예제 #4
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 ();
 }