/// <summary>
        /// Persist the current state of this instance to the data store.
        /// </summary>
        private void Save()
        {
            lock (_lockObject)
              {
            //Factory.GetDataProvider().Synchronize_SaveStatus(this);
            using (var repo = new SynchronizeRepository())
            {
              var sDto = repo.Find(GalleryId);

              if (sDto != null)
              {
            if ((sDto.SynchId != SynchId) && ((sDto.SynchState == SynchronizationState.SynchronizingFiles) || (sDto.SynchState == SynchronizationState.PersistingToDataStore)))
            {
              throw new Events.CustomExceptions.SynchronizationInProgressException();
            }
            else
            {
              sDto.SynchId = SynchId;
              sDto.SynchState = Status;
              sDto.TotalFiles = TotalFileCount;
              sDto.CurrentFileIndex = CurrentFileIndex;
            }
              }
              else
              {
            sDto = new SynchronizeDto
            {
              SynchId = SynchId,
              FKGalleryId = GalleryId,
              SynchState = Status,
              TotalFiles = TotalFileCount,
              CurrentFileIndex = CurrentFileIndex
            };

            repo.Add(sDto);
              }

              repo.Save();
            }
              }
        }
        /// <summary>
        /// Retrieve the most recent synchronization information from the data store.
        /// </summary>
        /// <param name="galleryId">The gallery ID.</param>
        /// <returns>
        /// Returns an <see cref="ISynchronizationStatus"/> object with the most recent synchronization information from the data store.
        /// </returns>
        private ISynchronizationStatus GetFromDataStore(int galleryId)
        {
            using (var repo = new SynchronizeRepository())
              {
            SynchronizeDto sDto = repo.Find(galleryId);

            if (sDto == null)
            {
              sDto = new SynchronizeDto { FKGalleryId = galleryId, SynchId = String.Empty, SynchState = SynchronizationState.Complete, CurrentFileIndex = 0, TotalFiles = 0 };
              repo.Add(sDto);
              repo.Save();
            }

            return new SynchronizationStatus(galleryId, sDto.SynchId, sDto.SynchState, sDto.TotalFiles, String.Empty, sDto.CurrentFileIndex, String.Empty);
              }
        }