Beispiel #1
0
        public int Synchronize(bool reviewOnly = false, bool rescanLocalFiles = true)
        {
            var  countChanged     = 0;
            bool moreChangesFound = false;

            lock (this)
            {
                OnSyncProgress(0, ProgressStatus.Analyzing);

                try
                {
                    countChanged = SyncMetadataStore(reviewOnly, _configuration.ConflictHandling, out moreChangesFound, rescanLocalFiles);

                    SyncResults = _metadataStore.GetResults();

                    OnSyncProgress(10, ProgressStatus.Analyzed, string.Format("Found {0} modified items", countChanged));

                    if (reviewOnly || countChanged < 1)
                    {
                        OnSyncProgress(100, ProgressStatus.Completed);
                        return(countChanged);
                    }

                    SyncChanges();

                    OnSyncProgress(100, ProgressStatus.Completed);
                }
                catch (Exception ex)
                {
                    //todo:
                    if (_configuration.AuthenticationType == AuthenticationType.ADFS) //&& ex is webexception 403
                    {
                        Adfs.AdfsHelper.InValidateCookie();
                    }
                    OnSyncProgress(100, ProgressStatus.Error, "An error has occured: " + ex.Message, ex);
                    return(-1);
                }
            }

            if (moreChangesFound)
            {
                countChanged += Synchronize(reviewOnly, rescanLocalFiles);
            }

            return(countChanged);
        }