コード例 #1
0
        /// <summary>
        /// Adds the <paramref name="zipContentFile"/> as a media object to the <paramref name="album"/>.
        /// </summary>
        /// <param name="zipContentFile">A reference to a file in a ZIP archive.</param>
        /// <param name="album">The album to which the file should be added as a media object.</param>
        private void AddMediaObjectToGallery(ZipEntry zipContentFile, IAlbum album)
        {
            string zipFileName = Path.GetFileName(zipContentFile.Name).Trim();

            if (zipFileName.Length == 0)
            {
                return;
            }

            string uniqueFilename = HelperFunctions.ValidateFileName(album.FullPhysicalPathOnDisk, zipFileName);
            string uniqueFilepath = Path.Combine(album.FullPhysicalPathOnDisk, uniqueFilename);

            // Extract the file from the zip stream and save as the specified filename.
            ExtractFileFromZipStream(uniqueFilepath);

            // Get the file we just saved to disk.
            FileInfo mediaObjectFile = new FileInfo(uniqueFilepath);

            try
            {
                using (IGalleryObject mediaObject = Factory.CreateMediaObjectInstance(mediaObjectFile, album))
                {
                    HelperFunctions.UpdateAuditFields(mediaObject, this._userName);
                    mediaObject.Save();

                    if (_discardOriginalImage)
                    {
                        mediaObject.DeleteOriginalFile();
                        mediaObject.Save();
                    }

                    this._fileExtractionResults.Add(new ActionResult()
                    {
                        Title   = mediaObjectFile.Name,
                        Status  = ActionResultStatus.Success,
                        Message = String.Empty
                    });
                }
            }
            catch (ErrorHandler.CustomExceptions.UnsupportedMediaObjectTypeException ex)
            {
                this._fileExtractionResults.Add(new ActionResult()
                {
                    Title   = mediaObjectFile.Name,
                    Status  = ActionResultStatus.Error,
                    Message = ex.Message
                });

                File.Delete(mediaObjectFile.FullName);
            }
        }
コード例 #2
0
        private void UpdateExistingMediaObject(IAlbum album, IGalleryObject mediaObject)
        {
            if (mediaObject.Parent.Id != album.Id)
            {
                mediaObject.Parent = album;
            }

            // If the generated hash key is the same as the one already assigned, then do nothing. Otherwise,
            // generate a guaranteed unique hash key with the GetHashKeyUnique function.
            if (mediaObject.Hashkey != HelperFunctions.GetHashKey(mediaObject.Original.FileInfo))
            {
                mediaObject.Hashkey = HelperFunctions.GetHashKeyUnique(mediaObject.Original.FileInfo);
            }

            // Check for existence of thumbnail.
            if (!File.Exists(mediaObject.Thumbnail.FileNamePhysicalPath))
            {
                mediaObject.RegenerateThumbnailOnSave = true;
            }

            Image image = mediaObject as Image;

            if (image != null)
            {
                EvaluateOptimizedImage(image);
            }
            else
            {
                UpdateNonImageWidthAndHeight(mediaObject);
            }

            HelperFunctions.UpdateAuditFields(mediaObject, this._userName);
            mediaObject.Save();
            mediaObject.IsSynchronized = true;
        }
コード例 #3
0
        /// <summary>
        /// Persist the gallery object to the data store. This method updates the audit fields before saving. All gallery objects should be
        /// saved through this method rather than directly invoking the gallery object's Save method, unless you want to
        /// manually update the audit fields yourself.
        /// </summary>
        /// <param name="galleryObject">The gallery object to persist to the data store.</param>
        /// <param name="userName">The user name to be associated with the modifications. This name is stored in the internal
        /// audit fields associated with this gallery object.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="galleryObject" /> is null.</exception>
        public static void SaveGalleryObject(IGalleryObject galleryObject, string userName)
        {
            if (galleryObject == null)
            {
                throw new ArgumentNullException("galleryObject");
            }

            DateTime currentTimestamp = DateTime.Now;

            if (galleryObject.IsNew)
            {
                galleryObject.CreatedByUserName = userName;
                galleryObject.DateAdded         = currentTimestamp;
            }

            if (galleryObject.HasChanges)
            {
                galleryObject.LastModifiedByUserName = userName;
                galleryObject.DateLastModified       = currentTimestamp;
            }

            // Verify that any role needed for album ownership exists and is properly configured.
            RoleController.ValidateRoleExistsForAlbumOwner(galleryObject as IAlbum);

            // Persist to data store.
            galleryObject.Save();
        }
コード例 #4
0
        private void UpdateExistingMediaObject(IGalleryObject mediaObject)
        {
            mediaObject.RegenerateThumbnailOnSave = RebuildThumbnail;
            mediaObject.RegenerateOptimizedOnSave = RebuildOptimized;

            // Check for existence of thumbnail.
            if (!File.Exists(mediaObject.Thumbnail.FileNamePhysicalPath))
            {
                mediaObject.RegenerateThumbnailOnSave = true;
            }

            switch (mediaObject.GalleryObjectType)
            {
            case GalleryObjectType.Image:
                EvaluateOriginalImage((Image)mediaObject);
                EvaluateOptimizedImage((Image)mediaObject);
                break;

            case GalleryObjectType.Video:
            case GalleryObjectType.Audio:
                EvaluateOptimizedVideoAudio(mediaObject);
                break;

            default:
                UpdateNonImageWidthAndHeight(mediaObject);
                break;
            }

            UpdateMetadataFilename(mediaObject);

            HelperFunctions.UpdateAuditFields(mediaObject, UserName);
            mediaObject.Save();
            mediaObject.IsSynchronized = true;
        }
コード例 #5
0
        /// <summary>
        /// Performs post-processing tasks on the media object and media queue items. Specifically,
        /// if the file was successfully created, updates the media object instance with information
        /// about the new file. Updates the media queue instance and resets the status of the
        /// conversion queue. No action is taken if <paramref name="settings" /> is null.
        /// </summary>
        /// <param name="settings">An instance of <see cref="MediaConversionSettings" /> containing
        /// settings and results used in the conversion. When null, the function immediately returns.</param>
        private void OnMediaConversionComplete(MediaConversionSettings settings)
        {
            if (settings == null)
            {
                return;
            }

            // Update media object properties
            IGalleryObject mediaObject = Factory.LoadMediaObjectInstance(settings.MediaObjectId, true);

            if (settings.FileCreated)
            {
                string msg = String.Format(CultureInfo.CurrentCulture, "INFO (not an error): FFmpeg created video '{0}'.", Path.GetFileName(settings.FilePathDestination));
                RecordEvent(msg, settings);

                mediaObject.Optimized.FileName             = Path.GetFileName(settings.FilePathDestination);
                mediaObject.Optimized.FileNamePhysicalPath = settings.FilePathDestination;
                mediaObject.Optimized.Width  = mediaObject.Original.Width;
                mediaObject.Optimized.Height = mediaObject.Original.Height;

                int fileSize = (int)(mediaObject.Optimized.FileInfo.Length / 1024);

                mediaObject.Optimized.FileSizeKB   = (fileSize < 1 ? 1 : fileSize);               // Very small files should be 1, not 0.
                mediaObject.LastModifiedByUserName = "******";
                mediaObject.DateLastModified       = DateTime.Now;
                mediaObject.Save();

                HelperFunctions.PurgeCache();
            }

            CompleteProcessItem(settings);
        }
コード例 #6
0
        private void UpdateExistingMediaObject(IGalleryObject mediaObject)
        {
            mediaObject.RegenerateThumbnailOnSave = RebuildThumbnail;
            mediaObject.RegenerateOptimizedOnSave = RebuildOptimized;

            // Check for existence of thumbnail.
            if (!File.Exists(mediaObject.Thumbnail.FileNamePhysicalPath))
            {
                mediaObject.RegenerateThumbnailOnSave = true;
            }

            Image image = mediaObject as Image;

            if (image != null)
            {
                EvaluateOriginalImage(image);

                EvaluateOptimizedImage(image);
            }
            else
            {
                UpdateNonImageWidthAndHeight(mediaObject);
            }

            UpdateMetadataFilename(mediaObject);

            HelperFunctions.UpdateAuditFields(mediaObject, UserName);
            mediaObject.Save();
            mediaObject.IsSynchronized = true;
        }
コード例 #7
0
        private void CreateNewMediaObject(IAlbum album, FileInfo file)
        {
            try
            {
                IGalleryObject mediaObject = Factory.CreateMediaObjectInstance(file, album);
                HelperFunctions.UpdateAuditFields(mediaObject, UserName);
                mediaObject.Save();

                if (!GallerySettings.MediaObjectPathIsReadOnly && (GallerySettings.DiscardOriginalImageDuringImport))
                {
                    mediaObject.DeleteOriginalFile();
                    mediaObject.Save();
                }

                mediaObject.IsSynchronized = true;
            }
            catch (UnsupportedMediaObjectTypeException)
            {
                _synchStatus.SkippedMediaObjects.Add(new KeyValuePair <string, string>(file.FullName.Remove(0, _fullMediaObjectPathLength + 1), Resources.SynchronizationStatus_Disabled_File_Type_Msg));
            }
        }
コード例 #8
0
        private void CreateNewMediaObject(IAlbum album, FileInfo file)
        {
            try
            {
                IGalleryObject mediaObject = Factory.CreateMediaObjectInstance(file, album);
                HelperFunctions.UpdateAuditFields(mediaObject, this._userName);
                mediaObject.Save();

                Core core = ConfigManager.GetGalleryServerProConfigSection().Core;
                if (!core.MediaObjectPathIsReadOnly && (core.DiscardOriginalImageDuringImport) && (mediaObject is Business.Image))
                {
                    ((Business.Image)mediaObject).DeleteHiResImage();
                    mediaObject.Save();
                }

                mediaObject.IsSynchronized = true;

                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(mediaObject.Hashkey));
            }
            catch (GalleryServerPro.ErrorHandler.CustomExceptions.UnsupportedMediaObjectTypeException)
            {
                this._synchStatus.SkippedMediaObjects.Add(new KeyValuePair <string, string>(file.FullName.Remove(0, _mediaObjectPhysicalPathLength + 1), Resources.SynchronizationStatus_Disabled_File_Type_Msg));
            }
        }
コード例 #9
0
ファイル: ZipUtility.cs プロジェクト: ericjbeltran/2009
        /// <summary>
        /// Adds the <paramref name="zipContentFile"/> as a media object to the <paramref name="album"/>.
        /// </summary>
        /// <param name="zipContentFile">A reference to a file in a ZIP archive.</param>
        /// <param name="album">The album to which the file should be added as a media object.</param>
        private void AddMediaObjectToGallery(ZipEntry zipContentFile, IAlbum album)
        {
            string zipFileName = Path.GetFileName(zipContentFile.Name).Trim();

            if (zipFileName.Length == 0)
            {
                return;
            }

            string uniqueFilename = HelperFunctions.ValidateFileName(album.FullPhysicalPathOnDisk, zipFileName);
            string uniqueFilepath = Path.Combine(album.FullPhysicalPathOnDisk, uniqueFilename);

            // Extract the file from the zip stream and save as the specified filename.
            ExtractFileFromZipStream(uniqueFilepath);

            // Get the file we just saved to disk.
            FileInfo mediaObjectFile = new FileInfo(uniqueFilepath);

            try
            {
                IGalleryObject mediaObject = Factory.CreateMediaObjectInstance(mediaObjectFile, album);
                HelperFunctions.UpdateAuditFields(mediaObject, this._userName);
                mediaObject.Save();

                if ((_discardOriginalImage) && (mediaObject is Business.Image))
                {
                    ((Business.Image)mediaObject).DeleteHiResImage();
                    mediaObject.Save();
                }
            }
            catch (ErrorHandler.CustomExceptions.UnsupportedMediaObjectTypeException ex)
            {
                this._skippedFiles.Add(new KeyValuePair <string, string>(mediaObjectFile.Name, ex.Message));
                File.Delete(mediaObjectFile.FullName);
            }
        }
コード例 #10
0
		/// <summary>
		/// Persist the gallery object to the data store. This method updates the audit fields before saving. All gallery objects should be
		/// saved through this method rather than directly invoking the gallery object's Save method, unless you want to
		/// manually update the audit fields yourself.
		/// </summary>
		/// <param name="galleryObject">The gallery object to persist to the data store.</param>
		/// <param name="userName">The user name to be associated with the modifications. This name is stored in the internal
		/// audit fields associated with this gallery object.</param>
		public static void SaveGalleryObject(IGalleryObject galleryObject, string userName)
		{
			DateTime currentTimestamp = DateTime.Now;

			if (galleryObject.IsNew)
			{
				galleryObject.CreatedByUserName = userName;
				galleryObject.DateAdded = currentTimestamp;
			}

			if (galleryObject.HasChanges)
			{
				galleryObject.LastModifiedByUserName = userName;
				galleryObject.DateLastModified = currentTimestamp;
			}

			// Verify that any role needed for album ownership exists and is properly configured.
			RoleController.ValidateRoleExistsForAlbumOwner(galleryObject as IAlbum);

			// Persist to data store.
			galleryObject.Save();
		}
コード例 #11
0
ファイル: ZipUtility.cs プロジェクト: Pathfinder-Fr/Website
        /// <summary>
        /// Adds the <paramref name="zipContentFile"/> as a media object to the <paramref name="album"/>.
        /// </summary>
        /// <param name="zipContentFile">A reference to a file in a ZIP archive.</param>
        /// <param name="album">The album to which the file should be added as a media object.</param>
        /// // Sueetie Modified - passing i for single logging of action
        private void AddMediaObjectToGallery(ZipEntry zipContentFile, IAlbum album, int i)
        {
            string zipFileName = Path.GetFileName(zipContentFile.Name).Trim();

            if (zipFileName.Length == 0)
            {
                return;
            }

            string uniqueFilename = HelperFunctions.ValidateFileName(album.FullPhysicalPathOnDisk, zipFileName);
            string uniqueFilepath = Path.Combine(album.FullPhysicalPathOnDisk, uniqueFilename);

            // Extract the file from the zip stream and save as the specified filename.
            ExtractFileFromZipStream(uniqueFilepath);

            // Get the file we just saved to disk.
            FileInfo mediaObjectFile = new FileInfo(uniqueFilepath);

            try
            {
                IGalleryObject mediaObject = Factory.CreateMediaObjectInstance(mediaObjectFile, album);
                HelperFunctions.UpdateAuditFields(mediaObject, this._userName);

                // Sueetie Modified - Fixes a weird bug where zipped Image file titles are empty when zipped from my machine
                if (mediaObject.Title.Trim().Length == 0)
                {
                    mediaObject.Title = mediaObjectFile.Name;
                }

                mediaObject.Save();

                if ((_discardOriginalImage) && (mediaObject is Business.Image))
                {
                    ((Business.Image)mediaObject).DeleteHiResImage();
                    mediaObject.Save();
                }

                // Sueetie Modified - Add mediaobject to Sueetie_Content - Single File

                SueetieContent sueetieContent = new SueetieContent
                {
                    SourceID      = mediaObject.Id,
                    ContentTypeID = SueetieMedia.ConvertContentType((int)mediaObject.MimeType.TypeCategory),
                    ApplicationID = (int)SueetieApplications.Current.ApplicationID,
                    UserID        = SueetieContext.Current.User.UserID,
                    IsRestricted  = ((Album)mediaObject.Parent).IsPrivate,
                    Permalink     = SueetieMedia.SueetieMediaObjectUrl(mediaObject.Id, mediaObject.GalleryId)
                };
                SueetieCommon.AddSueetieContent(sueetieContent);

                // Add Sueetie-specific data to Sueetie_gs_MediaObject

                SueetieMediaObject _sueetieMediaObject = new SueetieMediaObject();
                _sueetieMediaObject.MediaObjectID    = mediaObject.Id;
                _sueetieMediaObject.ContentTypeID    = SueetieMedia.ConvertContentType((int)mediaObject.MimeType.TypeCategory);
                _sueetieMediaObject.AlbumID          = mediaObject.Parent.Id;
                _sueetieMediaObject.InDownloadReport = false;
                SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject);

                SueetieMediaAlbum   sueetieAlbum   = SueetieMedia.GetSueetieMediaAlbum(mediaObject.Parent.Id);
                SueetieMediaGallery sueetieGallery = SueetieMedia.GetSueetieMediaGallery(((Album)mediaObject.Parent).GalleryId);
                if (i == 0 && sueetieGallery.IsLogged)
                {
                    SueetieLogs.LogUserEntry((UserLogCategoryType)sueetieAlbum.AlbumMediaCategoryID, sueetieAlbum.ContentID, SueetieContext.Current.User.UserID);
                }

                SueetieMedia.ClearMediaPhotoListCache(0);
                SueetieMedia.ClearSueetieMediaObjectListCache(mediaObject.GalleryId);
            }
            catch (ErrorHandler.CustomExceptions.UnsupportedMediaObjectTypeException ex)
            {
                this._skippedFiles.Add(new KeyValuePair <string, string>(mediaObjectFile.Name, ex.Message));
                File.Delete(mediaObjectFile.FullName);
            }
        }
コード例 #12
0
        private void UpdateExistingMediaObject(IAlbum album, IGalleryObject mediaObject)
        {
            if (mediaObject.Parent.Id != album.Id)
            {
                mediaObject.Parent = album;
            }

            // If the generated hash key is the same as the one already assigned, then do nothing. Otherwise,
            // generate a guaranteed unique hash key with the GetHashKeyUnique function.
            if (mediaObject.Hashkey != HelperFunctions.GetHashKey(mediaObject.Original.FileInfo))
            {
                mediaObject.Hashkey = HelperFunctions.GetHashKeyUnique(mediaObject.Original.FileInfo);
            }

            // Check for existence of thumbnail.
            if (!File.Exists(mediaObject.Thumbnail.FileNamePhysicalPath))
            {
                mediaObject.RegenerateThumbnailOnSave = true;
            }

            Image image = mediaObject as Image;
            if (image != null)
            {
                EvaluateOriginalImage(image);

                EvaluateOptimizedImage(image);
            }
            else
            {
                UpdateNonImageWidthAndHeight(mediaObject);
            }

            HelperFunctions.UpdateAuditFields(mediaObject, this._userName);
            mediaObject.Save();
            mediaObject.IsSynchronized = true;
        }
コード例 #13
0
        /// <summary>
        /// Create a sample album and media object. This method is intended to be invoked once just after the application has been
        /// installed.
        /// </summary>
        /// <param name="galleryId">The ID for the gallery where the sample objects are to be created.</param>
        public static void CreateSampleObjects(int galleryId)
        {
            if (Factory.LoadGallerySetting(galleryId).MediaObjectPathIsReadOnly)
            {
                return;
            }

            DateTime currentTimestamp = DateTime.Now;
            IAlbum   sampleAlbum      = null;

            foreach (IAlbum album in Factory.LoadRootAlbumInstance(galleryId).GetChildGalleryObjects(GalleryObjectType.Album))
            {
                if (album.DirectoryName == "Samples")
                {
                    sampleAlbum = album;
                    break;
                }
            }
            if (sampleAlbum == null)
            {
                // Create sample album.
                sampleAlbum = Factory.CreateEmptyAlbumInstance(galleryId);

                sampleAlbum.Parent                 = Factory.LoadRootAlbumInstance(galleryId);
                sampleAlbum.Title                  = "Samples";
                sampleAlbum.DirectoryName          = "Samples";
                sampleAlbum.Summary                = "Welcome to Gallery Server Pro!";
                sampleAlbum.CreatedByUserName      = "******";
                sampleAlbum.DateAdded              = currentTimestamp;
                sampleAlbum.LastModifiedByUserName = "******";
                sampleAlbum.DateLastModified       = currentTimestamp;
                sampleAlbum.Save();
            }

            // Look for sample image in sample album.
            IGalleryObject sampleImage = null;

            foreach (IGalleryObject image in sampleAlbum.GetChildGalleryObjects(GalleryObjectType.Image))
            {
                if (image.Original.FileName == Constants.SAMPLE_IMAGE_FILENAME)
                {
                    sampleImage = image;
                    break;
                }
            }

            if (sampleImage == null)
            {
                // Sample image not found. Pull image from assembly and save to disk (if needed), then create a media object from it.
                string sampleDirPath       = Path.Combine(Factory.LoadGallerySetting(galleryId).FullMediaObjectPath, sampleAlbum.DirectoryName);
                string sampleImageFilepath = Path.Combine(sampleDirPath, Constants.SAMPLE_IMAGE_FILENAME);

                if (!File.Exists(sampleImageFilepath))
                {
                    Assembly asm = Assembly.GetExecutingAssembly();
                    using (Stream stream = asm.GetManifestResourceStream(String.Concat("GalleryServerPro.Web.gs.images.", Constants.SAMPLE_IMAGE_FILENAME)))
                    {
                        if (stream != null)
                        {
                            BinaryWriter bw     = new BinaryWriter(File.Create(sampleImageFilepath));
                            byte[]       buffer = new byte[stream.Length];
                            stream.Read(buffer, 0, (int)stream.Length);
                            bw.Write(buffer);
                            bw.Flush();
                            bw.Close();
                        }
                    }
                }

                if (File.Exists(sampleImageFilepath))
                {
                    // Temporarily change a couple settings so that the thumbnail and compressed images are high quality.
                    IGallerySettings gallerySettings = Factory.LoadGallerySetting(galleryId);
                    int optTriggerSizeKb             = gallerySettings.OptimizedImageTriggerSizeKb;
                    int thumbImageJpegQuality        = gallerySettings.ThumbnailImageJpegQuality;
                    gallerySettings.ThumbnailImageJpegQuality   = 95;
                    gallerySettings.OptimizedImageTriggerSizeKb = 200;

                    // Create the media object from the file.
                    IGalleryObject image = Factory.CreateImageInstance(new FileInfo(sampleImageFilepath), sampleAlbum);
                    image.Title                  = "Margaret, Skyler and Roger Martin (July 2010)";
                    image.CreatedByUserName      = "******";
                    image.DateAdded              = currentTimestamp;
                    image.LastModifiedByUserName = "******";
                    image.DateLastModified       = currentTimestamp;
                    image.Save();

                    // Restore the default settings.
                    gallerySettings.OptimizedImageTriggerSizeKb = optTriggerSizeKb;
                    gallerySettings.ThumbnailImageJpegQuality   = thumbImageJpegQuality;
                }
            }
        }
コード例 #14
0
ファイル: WebController.cs プロジェクト: haimon74/KanNaim
		/// <summary>
		/// Persist the gallery object to the data store. This method updates the audit fields before saving. All gallery objects should be
		/// saved through this method rather than directly invoking the gallery object's Save method, unless you want to 
		/// manually update the audit fields yourself.
		/// </summary>
		/// <param name="galleryObject">The gallery object to persist to the data store.</param>
		public static void SaveGalleryObject(IGalleryObject galleryObject)
		{
			string currentUser = HttpContext.Current.User.Identity.Name;
			DateTime currentTimestamp = DateTime.Now;

			if (galleryObject.IsNew)
			{
				galleryObject.CreatedByUserName = currentUser;
				galleryObject.DateAdded = currentTimestamp;
			}

			if (galleryObject.HasChanges)
			{
				galleryObject.LastModifiedByUserName = currentUser;
				galleryObject.DateLastModified = currentTimestamp;
			}

			galleryObject.Save();
		}
コード例 #15
0
        private void UpdateExistingMediaObject(IGalleryObject mediaObject)
        {
            mediaObject.RegenerateThumbnailOnSave = RebuildThumbnail;
            mediaObject.RegenerateOptimizedOnSave = RebuildOptimized;

            // Check for existence of thumbnail.
            if (!File.Exists(mediaObject.Thumbnail.FileNamePhysicalPath))
            {
                mediaObject.RegenerateThumbnailOnSave = true;
            }

            switch (mediaObject.GalleryObjectType)
            {
                case GalleryObjectType.Image:
                    EvaluateOriginalImage((Image)mediaObject);
                    EvaluateOptimizedImage((Image)mediaObject);
                    break;

                case GalleryObjectType.Video:
                case GalleryObjectType.Audio:
                    EvaluateOptimizedVideoAudio(mediaObject);
                    break;

                default:
                    UpdateNonImageWidthAndHeight(mediaObject);
                    break;
            }

            UpdateMetadataFilename(mediaObject);

            HelperFunctions.UpdateAuditFields(mediaObject, UserName);
            mediaObject.Save();
            mediaObject.IsSynchronized = true;
        }
コード例 #16
0
ファイル: UserController.cs プロジェクト: ericjbeltran/2009
        /// <summary>
        /// In certain cases, the web-based installer creates a text file in the App Data directory that is meant as a signal to this
        /// code that additional setup steps are required. If this file is found, carry out the additional actions. This file is
        /// created in the SetFlagForMembershipConfiguration() method of pages\install.ascx.cs.
        /// </summary>
        internal static void ProcessInstallerFile()
        {
            string filePath = Path.Combine(AppSetting.Instance.PhysicalApplicationPath, Path.Combine(GlobalConstants.AppDataDirectory, GlobalConstants.InstallerFileName));

            if (!File.Exists(filePath))
            {
                return;
            }

            string adminUserName;
            string adminPwd;
            string adminEmail;

            using (StreamReader sw = File.OpenText(filePath))
            {
                adminUserName = sw.ReadLine();
                adminPwd      = sw.ReadLine();
                adminEmail    = sw.ReadLine();
            }

            HelperFunctions.BeginTransaction();

            #region Create the Sys Admin role.

            // Create the Sys Admin role. If it already exists, make sure it has AllowAdministerSite permission.
            string sysAdminRoleName = Resources.GalleryServerPro.Installer_Sys_Admin_Role_Name;
            if (!RoleController.RoleExists(sysAdminRoleName))
            {
                RoleController.CreateRole(sysAdminRoleName);
            }

            IGalleryServerRole role = Factory.LoadGalleryServerRole(sysAdminRoleName);
            if (role == null)
            {
                role = Factory.CreateGalleryServerRoleInstance(sysAdminRoleName, true, true, true, true, true, true, true, true, true, true, false);
                role.RootAlbumIds.Add(Factory.LoadRootAlbumInstance().Id);
                role.Save();
            }
            else
            {
                // Role already exists. Make sure it has Sys Admin permission.
                if (!role.AllowAdministerSite)
                {
                    role.AllowAdministerSite = true;
                    role.Save();
                }
            }

            #endregion

            #region Create the Sys Admin user account.

            // Create the Sys Admin user account. Will throw an exception if the name is already in use.
            try
            {
                CreateUser(adminUserName, adminPwd, adminEmail);
            }
            catch (MembershipCreateUserException ex)
            {
                if (ex.StatusCode == MembershipCreateStatus.DuplicateUserName)
                {
                    // The user already exists. Update the password and email address to our values.
                    UserEntity user = GetUser(adminUserName, true);
                    ChangePassword(user.UserName, GetPassword(user.UserName), adminPwd);
                    user.Email = adminEmail;
                    UpdateUser(user);
                }
            }

            // Add the Sys Admin user to the Sys Admin role.
            if (!RoleController.IsUserInRole(adminUserName, sysAdminRoleName))
            {
                RoleController.AddUserToRole(adminUserName, sysAdminRoleName);
            }

            #endregion

            #region Create sample album and image

            if (!Config.GetCore().MediaObjectPathIsReadOnly)
            {
                DateTime currentTimestamp = DateTime.Now;
                IAlbum   sampleAlbum      = null;
                foreach (IAlbum album in Factory.LoadRootAlbumInstance().GetChildGalleryObjects(GalleryObjectType.Album))
                {
                    if (album.DirectoryName == "Samples")
                    {
                        sampleAlbum = album;
                        break;
                    }
                }
                if (sampleAlbum == null)
                {
                    // Create sample album.
                    sampleAlbum                        = Factory.CreateAlbumInstance();
                    sampleAlbum.Parent                 = Factory.LoadRootAlbumInstance();
                    sampleAlbum.Title                  = "Samples";
                    sampleAlbum.DirectoryName          = "Samples";
                    sampleAlbum.Summary                = "Welcome to Gallery Server Pro!";
                    sampleAlbum.CreatedByUserName      = adminUserName;
                    sampleAlbum.DateAdded              = currentTimestamp;
                    sampleAlbum.LastModifiedByUserName = adminUserName;
                    sampleAlbum.DateLastModified       = currentTimestamp;
                    sampleAlbum.Save();
                }

                // Look for sample image in sample album.
                IGalleryObject sampleImage = null;
                foreach (IGalleryObject image in sampleAlbum.GetChildGalleryObjects(GalleryObjectType.Image))
                {
                    if (image.Original.FileName == Constants.SAMPLE_IMAGE_FILENAME)
                    {
                        sampleImage = image;
                        break;
                    }
                }

                if (sampleImage == null)
                {
                    // Sample image not found. Pull image from assembly, save to disk, and create a media object from it.
                    string sampleDirPath       = Path.Combine(AppSetting.Instance.MediaObjectPhysicalPath, sampleAlbum.DirectoryName);
                    string sampleImageFilename = HelperFunctions.ValidateFileName(sampleDirPath, Constants.SAMPLE_IMAGE_FILENAME);
                    string sampleImageFilepath = Path.Combine(sampleDirPath, sampleImageFilename);

                    System.Reflection.Assembly asm = Assembly.GetExecutingAssembly();
                    using (Stream stream = asm.GetManifestResourceStream(String.Concat("GalleryServerPro.Web.gs.images.", Constants.SAMPLE_IMAGE_FILENAME)))
                    {
                        if (stream != null)
                        {
                            BinaryWriter bw     = new BinaryWriter(File.Create(sampleImageFilepath));
                            byte[]       buffer = new byte[stream.Length];
                            stream.Read(buffer, 0, (int)stream.Length);
                            bw.Write(buffer);
                            bw.Flush();
                            bw.Close();
                        }
                    }

                    if (File.Exists(sampleImageFilepath))
                    {
                        IGalleryObject image = Factory.CreateImageInstance(new FileInfo(sampleImageFilepath), sampleAlbum);
                        image.Title                  = "Margaret, Skyler and Roger Martin (December 2008)";
                        image.CreatedByUserName      = adminUserName;
                        image.DateAdded              = currentTimestamp;
                        image.LastModifiedByUserName = adminUserName;
                        image.DateLastModified       = currentTimestamp;
                        image.Save();
                    }
                }
            }

            #endregion

            HelperFunctions.CommitTransaction();
            HelperFunctions.PurgeCache();

            File.Delete(filePath);
        }