// Shared initialization code
 void Initialize()
 {
     count = 0;
     repoDao = new SQLiteRepositoryDAO();
     repoIgnore = new SQLiteRepositoryIgnoreDAO();
     //netTraffic = new NetworkTraffic (Process.GetCurrentProcess().Id);
 }
Example #2
0
 public void InitializeSynchronizers(bool recovery = false)
 {
     if (recovery) {
         repo.Recovering = true;
         SQLiteRepositoryDAO dao = new SQLiteRepositoryDAO();
         dao.Update(repo);
     }
     if (recovery || repo.Recovering)
     {
         SQLiteEventDAO eventDao = new SQLiteEventDAO(this.repo);
         eventDao.RemoveAllUnsynchronized();
         recoverySynchronizer.Start();
     }
     else
     {
         recoverySynchronizer.Skip();
     }
     localSynchronizer.Start ();
     remoteSynchronizer.Start ();
     synchronizerResolver.Start();
 }
 public void InitializeSynchronizers(bool recovery)
 {
     SQLiteRepositoryDAO repoRaven = new SQLiteRepositoryDAO();
     List<LocalRepository> repos = repoRaven.AllActived;
     foreach (LocalRepository repo in repos)
     {
         CreateRepoFolder(repo);
         InitializeSynchronizers(repo, recovery);
     }
 }
        public void UIHasLoaded()
        {
            new Thread(() => CreateMenuItem()).Start();
            checkConnection.Start();

            //TODO REFATORAR URGENTEs
            if (!File.Exists(RuntimeSettings.DatabaseFile))
            {
                if (!Directory.Exists(RuntimeSettings.DatabaseFolder))
                    Directory.CreateDirectory(RuntimeSettings.DatabaseFolder);
                SQLiteDatabase.Instance().CreateDataBase();
                File.WriteAllText(RuntimeSettings.DatabaseInfoFile, RuntimeSettings.DatabaseVersion);
            }
            else
            {
                if (!File.Exists(RuntimeSettings.DatabaseInfoFile))
                {
                    File.Delete(RuntimeSettings.DatabaseFile);
                }
                else
                {
                    string version = File.OpenText(RuntimeSettings.DatabaseInfoFile).ReadLine();
                    if (Double.Parse(version) < Double.Parse(RuntimeSettings.DatabaseVersion))
                    {
                        File.Delete(RuntimeSettings.DatabaseInfoFile);
                        File.Delete(RuntimeSettings.DatabaseFile);
                    }
                }
                if (!File.Exists(RuntimeSettings.DatabaseFile))
                {
                    SQLiteDatabase.Instance().CreateDataBase();
                    File.WriteAllText(RuntimeSettings.DatabaseInfoFile, RuntimeSettings.DatabaseVersion);
                }
            }

            CalcTimeDiff();
            if (firstRun)
            {
                ShowSetupWindow(PageType.Login);
            }
            else
            {
                SQLiteRepositoryDAO rpoDAO = new SQLiteRepositoryDAO();
                if (rpoDAO.AllActived.Count == 0)
                {
                    ShowSetupWindow(PageType.ConfigureFolders);
                } else {
                    InitializeSynchronizers(true);
                }
            }
            verifyConfigRequirements();
        }
 public void StopSynchronizers()
 {
     SQLiteRepositoryDAO repoRaven = new SQLiteRepositoryDAO();
     List<LocalRepository> repos = repoRaven.AllActived;
     foreach (LocalRepository repo in repos)
     {
         StopSynchronizers(repo);
     }
 }
 public void InitializeSynchronizers(LocalRepository repo, bool recovery)
 {
     SQLiteRepositoryDAO repoDAO = new SQLiteRepositoryDAO();
     Thread startSync;
     startSync = new Thread(delegate()
     {
         try
         {
             Logger.LogInfo("INFO INITIALIZE SYNC", "Initializing Synchronizers!");
             SynchronizerUnit unit = SynchronizerUnit.GetByRepo(repo);
             if (unit == null)
             {
                 unit = new SynchronizerUnit(repo);
                 SynchronizerUnit.Add(repo, unit);
             }
             unit.InitializeSynchronizers(recovery);
             Logger.LogInfo("INFO INITIALIZE SYNC", "Synchronizers Ready!");
             ErrorType = ERROR_TYPE.NULL;
             OnIdle();
         }
         catch (Exception e)
         {
             Logger.LogInfo("ERROR ON INITIALIZATION SYNC", e);
         }
     });
     startSync.Start();
 }
 public void CreateDefaultRepo(string sqFolder, List<string> ignoreKeys) 
 {
     SQLiteRepositoryDAO repoDao = new SQLiteRepositoryDAO();
     LocalRepository repo = new LocalRepository(sqFolder, "", true);
     repoDao.Create(repo);
     CreateIgnoredList(ignoreKeys, repo);
 }
 public void MoveSQFolder(string pathTo)
 {
     SQLiteRepositoryDAO repoDao = new SQLiteRepositoryDAO();
     LocalRepository repo = repoDao.RootRepo();
     PhysicalRepositoryController controller = new PhysicalRepositoryController(repo);
     KillSynchronizers();
     controller.MoveDir(repo.Path, pathTo);
     repo.Path = pathTo;
     repoDao.Update(repo);
     InitializeSynchronizers(false);
     Program.Controller.Alert("SQFolder moved to "+ pathTo);
 }
Example #9
0
        public void InitializeSynchronizers(bool initRecovery = false)
        {
            SQLiteRepositoryDAO repoDAO = new SQLiteRepositoryDAO();
            LocalRepository repo = repoDAO.FindOrCreateByRootName(RuntimeSettings.HomePath);
            if (initRecovery || repo.Recovering)
            {
                initRecovery = true;
                repo.Recovering = true;
                repoDAO.Update(repo);
            }
            Thread.Sleep(5000);
            Thread startSync;
            startSync = new Thread(delegate()
            {
                try
                {
                    Logger.LogInfo("INFO", "Initializing Synchronizers!");

                    synchronizerResolver = SynchronizerResolver.GetInstance();
                    recoverySynchronizer = RecoverySynchronizer.GetInstance();
                    remoteSynchronizer = RemoteEventsSynchronizer.GetInstance();
                    localSynchronizer = LocalEventsSynchronizer.GetInstance();

                    if (initRecovery)
                    {
                        recoverySynchronizer.Start();
                        while (!((RecoverySynchronizer)recoverySynchronizer).StartedSync)
                            Thread.Sleep(1000);
                        synchronizerResolver.Start();

                        while (!recoverySynchronizer.FinishedSync)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                    else
                    {
                        synchronizerResolver.Start();
                    }
                    localSynchronizer.Start();
                    remoteSynchronizer.Start();


                    loadedSynchronizers = true;
                    Logger.LogInfo("INFO", "Synchronizers Ready!");
                    if (initRecovery || repo.Recovering)
                    {
                        repo.Recovering = false;
                        repoDAO.Update(repo);
                    }
                    ErrorType = ERROR_TYPE.NULL;
                    OnIdle();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            });
            startSync.Start();
        }