コード例 #1
0
        /// <summary>
        /// Verify various tables have required records. For example, the album table must have a root album for each gallery, the gallery
        /// settings table must have a set of gallery settings, the MIME type gallery table must have a set of MIME types for each
        /// gallery, and the synch table has a record for each gallery and its values are reset to default values. Also propogate any new
        /// gallery settings or MIME types to all galleries. This function works by iterating through each gallery and calling the
        /// CreateGallery routine.
        /// </summary>
        private static void ValidateDataIntegrity()
        {
            using (IDataReader drGalleries = GalleryData.GetDataReaderGalleries())
            {
                while (drGalleries.Read())
                {
                    int galleryId = drGalleries.GetInt32(0);

                    GalleryData.ConfigureGallery(galleryId);
                }
            }
        }
コード例 #2
0
ファイル: Util.cs プロジェクト: zbw911/GalleryServerProWeb
        /// <summary>
        /// Gets the version of the objects in the database as reported by the database. Example: "2.3.3421"
        /// </summary>
        /// <returns>Returns the version of the objects in the database as reported by the database.</returns>
        internal static string GetDataSchemaVersionString()
        {
            foreach (AppSettingDto appSetting in GalleryData.GetAppSettings())
            {
                if (appSetting.SettingName.Equals("DataSchemaVersion", StringComparison.OrdinalIgnoreCase))
                {
                    return(appSetting.SettingValue);
                }
            }

            return(String.Empty);
        }
コード例 #3
0
        /// <summary>
        /// Retrieve the most recent synchronization information from the data store.
        /// </summary>
        /// <param name="galleryId">The gallery ID.</param>
        /// <param name="factory">An instance of <see cref="IFactory"/>. It is used to instantiate a <see cref="ISynchronizationStatus"/> object.</param>
        /// <returns>
        /// Returns an <see cref="ISynchronizationStatus"/> object with the most recent synchronization information from the data store.
        /// </returns>
        public static ISynchronizationStatus RetrieveStatus(int galleryId, IFactory factory)
        {
            ISynchronizationStatus updatedSynchStatus = null;

            using (IDataReader dr = GetDataReaderSynchronizeSelect(galleryId))
            {
                while (dr.Read())
                {
                    string synchId = dr["SynchId"].ToString();
                    SynchronizationState synchState = (SynchronizationState)Enum.Parse(typeof(SynchronizationState), dr["SynchState"].ToString());
                    int totalFileCount   = Convert.ToInt32(dr["TotalFiles"], CultureInfo.InvariantCulture);
                    int currentFileIndex = Convert.ToInt32(dr["CurrentFileIndex"], CultureInfo.InvariantCulture);

                    updatedSynchStatus = factory.CreateSynchronizationStatus(galleryId, synchId, synchState, totalFileCount, String.Empty, currentFileIndex, String.Empty);

                    break;
                }
            }

            if (updatedSynchStatus == null)
            {
                // The gs_Synchronize table didn't have a record for this gallery. Configure the gallery, which will
                // insert the missing record, then call this method again.
                IGallery gallery = GalleryData.GetGalleries(factory.CreateGalleryCollection()).FindById(galleryId);
                if (gallery != null)
                {
                    gallery.Configure();
                }
                else
                {
                    throw new InvalidGalleryException(galleryId);
                }

                return(RetrieveStatus(galleryId, factory));
            }

            return(updatedSynchStatus);
        }