예제 #1
0
        /// <summary>
        /// Sync and wait, several times until a particular condition is satisfied.
        /// </summary>
        /// <returns>
        /// True if the condition got satisfied, false if the condition did not get satisfied within the time limit.
        /// </returns>
        /// <param name='synchronizedFolder'>
        /// Folder to synchronize.
        /// </param>
        /// <param name='checkStop'>
        /// If returns <c>true</c> wait returns true, otherwise a retry will be executed until reaching maxTries.
        /// </param>
        /// <param name='maxTries'>
        /// Number of retries, until false is returned, if checkStop could not be true.
        /// </param>
        /// <param name='pollInterval'>
        /// Sleep interval duration in miliseconds between synchronization calls.
        /// </param>
        public static bool SyncAndWaitUntilCondition(SynchronizedFolder synchronizedFolder, Func <bool> checkStop, int maxTries = 4, int pollInterval = 5000)
        {
            int i = 0;

            while (i < maxTries)
            {
                try
                {
                    synchronizedFolder.Sync();
                }
                catch (DotCMIS.Exceptions.CmisRuntimeException e)
                {
                    Console.WriteLine("{0} Exception caught and swallowed, retry.", e);
                    System.Threading.Thread.Sleep(pollInterval);
                    continue;
                }
                if (checkStop())
                {
                    return(true);
                }
                Console.WriteLine(String.Format("Retry Sync in {0}ms", pollInterval));
                System.Threading.Thread.Sleep(pollInterval);
                i++;
            }
            Console.WriteLine("Sync call was not successful");
            return(false);
        }
예제 #2
0
파일: CmisRepo.cs 프로젝트: j2m2/CmisSync
 /// <summary>
 /// Constructor.
 /// </summary>
 public CmisRepo(RepoInfo repoInfo, IActivityListener activityListener)
     : base(repoInfo, activityListener)
 {
     this.synchronizedFolder = new SynchronizedFolder(repoInfo, this, activityListener);
     this.Watcher.ChangeEvent += OnFileActivity;
     this.Watcher.EnableEvent = true;
     Logger.Info(synchronizedFolder);
 }
예제 #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public CmisRepo(RepoInfo repoInfo, IActivityListener activityListener)
     : base(repoInfo, activityListener)
 {
     this.synchronizedFolder   = new SynchronizedFolder(repoInfo, this, activityListener);
     this.Watcher.ChangeEvent += OnFileActivity;
     this.Watcher.EnableEvent  = true;
     Logger.Info(synchronizedFolder);
 }
예제 #4
0
 public CmisRepo(RepoInfo repoInfo, ActivityListener activityListener)
     : base(repoInfo)
 {
     cmis = new SynchronizedFolder(repoInfo, activityListener, this);
     Logger.Info("CmisRepo | " + cmis);
 }
예제 #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public CmisRepo(RepoInfo repoInfo, IActivityListener activityListener)
     : base(repoInfo)
 {
     this.synchronizedFolder = new SynchronizedFolder(repoInfo, activityListener, this);
     Logger.Info(synchronizedFolder);
 }
예제 #6
0
파일: CmisRepo.cs 프로젝트: errotu/CmisSync
 /// <summary>
 /// Constructor.
 /// </summary>
 public CmisRepo(RepoInfo repoInfo, IActivityListener activityListener, bool enableWatcher)
     : base(repoInfo, activityListener, enableWatcher)
 {
     this.synchronizedFolder = new SynchronizedFolder(repoInfo, this, activityListener);
     Logger.Info(synchronizedFolder);
 }
예제 #7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public CmisRepo(RepoInfo repoInfo, IActivityListener activityListener)
     : base(repoInfo)
 {
     this.synchronizedFolder = new SynchronizedFolder(repoInfo, activityListener, this);
     Logger.Info(synchronizedFolder);
 }
예제 #8
0
파일: CmisRepo.cs 프로젝트: pzsysa/CmisSync
 /// <summary>
 /// Update repository settings.
 /// </summary>
 public override void UpdateSettings(string password, int pollInterval)
 {
     base.UpdateSettings(password, pollInterval);
     this.synchronizedFolder = new SynchronizedFolder(RepoInfo, this);
     Logger.Info(synchronizedFolder);
 }