Rank: Administration
Joined: 3/08/2007(UTC) Posts: 3,300 Location: Fort Atkinson, WI
|
Sorry for the delay in responding, but I was running a test. I enabled autosync on the demo site to run every 3 hours. There are over 60,000 media files, and it took about 4 minutes to run a sync. I watched it over the last few days, and it worked like a charm. I also looked at the source code (see below) and noticed that if an error occurs during the sync, a log entry will be made with the error details but you will still get a *subsequent* log entry that says it successfully completed. So I would look at the log between the start and finish notifications to see if there are any entries. Code:
/// <summary>
/// Perform a synchronize according to the specified <paramref name="syncSettingsObject" />.
/// When complete, update the <see cref="IGallerySettings.LastAutoSync" /> property to the current date/time and persist
/// to the data store. The <paramref name="syncSettingsObject" /> is specified as <see cref="Object" /> so that this method can
/// be invoked on a separate thread using <see cref="System.Threading.Thread" />. Any exceptions that occur during the
/// sync are caught and logged to the event log. NOTE: This method does not perform any security checks; the calling
/// code must ensure the requesting user is authorized to run the sync.
/// </summary>
/// <param name="syncSettingsObject">The synchronize settings object. It must be of type <see cref="SynchronizeSettingsEntity" />.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="syncSettingsObject" /> is null.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="syncSettingsObject" /> is not of type
/// <see cref="SynchronizeSettingsEntity" />.</exception>
public static void Synchronize(object syncSettingsObject)
{
if (syncSettingsObject == null)
throw new ArgumentNullException("syncSettingsObject");
SynchronizeSettingsEntity syncSettings = syncSettingsObject as SynchronizeSettingsEntity;
if (syncSettings == null)
{
throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, "The parameter must be an instance of SynchronizeSettingsEntity. Instead, it was {0}.", syncSettingsObject.GetType()));
}
IAlbum album = syncSettings.AlbumToSynchronize;
AppErrorController.LogEvent(String.Format(CultureInfo.CurrentCulture, "INFO (not an error): {0} synchronization of album '{1}' (ID {2}) and all child albums has started.", syncSettings.SyncInitiator, album.Title, album.Id), album.GalleryId);
try
{
SynchronizationManager synchMgr = new SynchronizationManager(album.GalleryId);
synchMgr.IsRecursive = syncSettings.IsRecursive;
synchMgr.RebuildThumbnail = syncSettings.RebuildThumbnails;
synchMgr.RebuildOptimized = syncSettings.RebuildOptimized;
synchMgr.RegenerateMetadata = syncSettings.RegenerateMetadata;
synchMgr.Synchronize(Guid.NewGuid().ToString(), album, "Admin");
if (syncSettings.SyncInitiator == SyncInitiator.AutoSync)
{
// Update the date/time of this auto-sync and save to data store.
IGallerySettings gallerySettings = Factory.LoadGallerySetting(album.GalleryId, true);
gallerySettings.LastAutoSync = DateTime.Now;
gallerySettings.Save(false);
// The above Save() only updated the database; now we need to update the in-memory copy of the settings.
// We have to do this instead of simply calling gallerySettings.Save(true) because that overload causes the
// gallery settings to be cleared and reloaded, and the reloading portion done by the AddMembershipDataToGallerySettings
// function fails in DotNetNuke because there isn't a HttpContext.Current instance at this moment (because this code is
// run on a separate thread).
IGallerySettings gallerySettingsReadOnly = Factory.LoadGallerySetting(album.GalleryId, false);
gallerySettingsReadOnly.LastAutoSync = gallerySettings.LastAutoSync;
}
}
catch (Exception ex)
{
AppErrorController.LogError(ex, album.GalleryId);
}
AppErrorController.LogEvent(String.Format(CultureInfo.CurrentCulture, "INFO (not an error): {0} synchronization of album '{1}' (ID {2}) and all child albums is complete.", syncSettings.SyncInitiator, album.Title, album.Id), album.GalleryId);
}
Roger Martin Creator and Lead Developer of Gallery Server Pro
|