コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            // Send the specified media object to the output stream.
            // Expected format:
            // /dev/gs/handler/getmediaobject.ashx?moid=34&aid=8&mo=C%3A%5Cgs%5Cmypics%5Cbirthday.jpeg&mtc=1&dt=1&isp=false
            // OR getmediaobject.ashx?moid=101&aid=7&mo=C:\gs\mypics\birthday.jpg&mtc=1&dt=2&isp=false
            // moid: The media object ID. Is int.MinValue if object is an album.
            // aid: The album ID for the album containing the media object, or for the album if the object is an album.
            // mo: The absolute path to the media object, including the object's name.
            // mtc: The mime type category. It is an integer that can be converted to the MimeTypeCategory enum.
            // dt: The display type. It is an integer that maps to the enum GalleryServerPro.Business.DisplayObjectType.
            // (0=Unknown,1=Thumbnail,2=Optimized,3=Original) At present all values other than 3 (Original) are ignored. If 3,
            // a security check is done to make sure user is authorized to view original images.
            // If URL encryption is enabled (encryptMediaObjectUrlOnClient = true in galleryserverpro.config), then the entire query
            // string portion is encrypted.
            try
            {
                if (!AppSetting.Instance.IsInitialized)
                {
                    Util.InitializeApplication();
                }

                if (InitializeVariables(context) && IsUserAuthorized())
                {
                    ShowMediaObject();
                }
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes the request.
        /// </summary>
        /// <param name="context">The HTTP context.</param>
        /// <returns>
        /// Returns <c>true</c> when the method succeeds; otherwise <c>false</c>.
        /// </returns>
        public override bool InitializeRequest(HttpContext context)
        {
            bool isSuccessfullyInitialized = false;

            try
            {
                if (!GalleryController.IsInitialized)
                {
                    GalleryController.InitializeGspApplication();
                }

                if (InitializeVariables(context))
                {
                    isSuccessfullyInitialized = true;
                }
                else
                {
                    _context.Response.StatusCode = 404;
                }

                return(base.InitializeRequest(context) & isSuccessfullyInitialized);
            }
            catch (System.Threading.ThreadAbortException)
            {
                throw;                 // We don't want these to fall into the generic catch because we don't want them logged.
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
            }

            return(isSuccessfullyInitialized);
        }
コード例 #3
0
        /// <summary>
        /// Update the user account to indicate the e-mail address has been validated. If admin approval is required, send an e-mail
        /// to the administrators. If not required, activate the account. Display results to user.
        /// </summary>
        private void ValidateUser()
        {
            pnlCreateUser.Visible = false;

            try
            {
                string userName = HelperFunctions.Decrypt(Util.GetQueryStringParameterString("verify"));

                UserController.UserEmailValidatedAfterCreation(userName);

                string title = Resources.GalleryServerPro.CreateAccount_Verification_Success_Header_Text;

                string detail = GetEmailValidatedUserMessageDetail(userName);

                DisplaySuccessMessage(title, detail);
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);

                string failDetailText = String.Format(CultureInfo.CurrentCulture, "<p>{0}</p>", Resources.GalleryServerPro.CreateAccount_Verification_Fail_Detail_Text);

                DisplayErrorMessage(Resources.GalleryServerPro.CreateAccount_Verification_Fail_Header_Text, failDetailText);
            }
        }
コード例 #4
0
        public void DeleteMediaObject(int mediaObjectId)
        {
            IGalleryObject mo = null;

            try
            {
                mo = Factory.LoadMediaObjectInstance(mediaObjectId);
                if (Utils.IsUserAuthorized(SecurityActions.DeleteMediaObject, mo.Parent.Id, mo.GalleryId, mo.IsPrivate))
                {
                    mo.Delete();
                    HelperFunctions.PurgeCache();
                }
            }
            catch (Exception ex)
            {
                if (mo != null)
                {
                    AppErrorController.LogError(ex, mo.GalleryId);
                }
                else
                {
                    AppErrorController.LogError(ex);
                }
                throw;
            }
        }
コード例 #5
0
        private void ProcessMediaObjectWithWatermark()
        {
            // Send the specified file to the client with the watermark overlayed on top.
            IMimeType mimeType = MimeType.LoadInstanceByFilePath(this._filename);

            this._context.Response.Clear();
            this._context.Response.ContentType = mimeType.FullType;

            Image watermarkedImage = null;

            try
            {
                try
                {
                    watermarkedImage = ImageHelper.AddWatermark(this._filepath);
                }
                catch (Exception ex)
                {
                    // Can't apply watermark to image. Substitute an error image and send that to the user.
                    AppErrorController.LogError(ex);
                    watermarkedImage = Image.FromFile(this._context.Request.MapPath(String.Concat(Util.GalleryRoot, "/images/error_48x48.png")));
                }

                watermarkedImage.Save(this._context.Response.OutputStream, ImageFormat.Jpeg);
            }
            finally
            {
                if (watermarkedImage != null)
                {
                    watermarkedImage.Dispose();
                }
            }
        }
コード例 #6
0
ファイル: Gallery.asmx.cs プロジェクト: ericjbeltran/2009
        public void DeleteAlbums(int[] albumIds)
        {
            try
            {
                foreach (int albumId in albumIds)
                {
                    try
                    {
                        IGalleryObject album = Factory.LoadAlbumInstance(albumId, false);

                        if (GalleryPage.IsUserAuthorized(SecurityActions.DeleteAlbum, album.Id))
                        {
                            album.Delete();
                        }
                    }
                    catch (GalleryServerPro.ErrorHandler.CustomExceptions.InvalidAlbumException) { }
                }
                HelperFunctions.PurgeCache();
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
                throw;
            }
        }
コード例 #7
0
        private static void WriteFileToServerRobust(HttpPostedFile fileUpload, string filePath, bool isChunk)
        {
            // Write file to server. If IOException happens, wait 1 second and try again, up to 10 times.
            int counter = 0;

            while (true)
            {
                const int maxTries = 10;
                try
                {
                    WriteFileToServer(fileUpload, filePath, isChunk);
                    break;
                }
                catch (IOException ex)
                {
                    counter++;
                    ex.Data.Add("CannotWriteFile", string.Format("This error occurred while trying to save uploaded file '{0}' to '{1}'. This error has occurred {2} times. The system will try again up to a maximum of {3} attempts.", fileUpload.FileName, filePath, counter, maxTries));
                    ex.Data.Add("chunk", HttpContext.Current.Request["chunk"] != null ? int.Parse(HttpContext.Current.Request["chunk"]) : 0);
                    AppErrorController.LogError(ex);

                    if (counter >= maxTries)
                    {
                        throw;
                    }

                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
コード例 #8
0
        public void DeleteQueueItem(int[] mediaQueueIds)
        {
            try
            {
                foreach (int mediaQueueId in mediaQueueIds)
                {
                    MediaQueueDto item = MediaConversionQueue.Instance.Get(mediaQueueId);

                    if (item == null)
                    {
                        continue;
                    }

                    IGalleryObject mo;
                    try
                    {
                        mo = Factory.LoadMediaObjectInstance(item.FKMediaObjectId);
                    }
                    catch (InvalidMediaObjectException)
                    {
                        continue;
                    }

                    if (Utils.IsCurrentUserGalleryAdministrator(mo.GalleryId))
                    {
                        MediaConversionQueue.Instance.RemoveMediaQueueItem(mediaQueueId);
                    }
                }
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
            }
        }
コード例 #9
0
        public void PurgeCache(int albumId)
        {
            IAlbum album = null;

            try
            {
                album = AlbumController.LoadAlbumInstance(albumId, false);

                // Get a list of all actions that require purging the cache. User must have one of these
                // permissions in order to purge the cache.
                const SecurityActions securityActions = SecurityActions.AddChildAlbum | SecurityActions.EditAlbum | SecurityActions.DeleteChildAlbum | SecurityActions.AddMediaObject | SecurityActions.EditMediaObject | SecurityActions.DeleteMediaObject;
                if (Utils.IsUserAuthorized(securityActions, albumId, album.GalleryId, album.IsPrivate))
                {
                    HelperFunctions.PurgeCache();
                }
            }
            catch (Exception ex)
            {
                if (album != null)
                {
                    AppErrorController.LogError(ex, album.GalleryId);
                }
                else
                {
                    AppErrorController.LogError(ex);
                }
            }
        }
コード例 #10
0
ファイル: Gallery.asmx.cs プロジェクト: ericjbeltran/2009
        public string UpdateMediaObjectTitle(int mediaObjectId, string title)
        {
            try
            {
                IGalleryObject mo = Factory.LoadMediaObjectInstance(mediaObjectId);
                if (GalleryPage.IsUserAuthorized(SecurityActions.EditMediaObject, mo.Parent.Id))
                {
                    string previousTitle = mo.Title;
                    mo.Title = Util.CleanHtmlTags(title);

                    if (mo.Title != previousTitle)
                    {
                        GalleryObjectController.SaveGalleryObject(mo);
                    }

                    HelperFunctions.PurgeCache();
                }

                return(mo.Title);
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
                throw;
            }
        }
コード例 #11
0
        public List <MetadataItemWebEntity> GetMetadataItems(int mediaObjectId)
        {
            IGalleryObject mo = null;

            try
            {
                List <MetadataItemWebEntity> metadataItems = new List <MetadataItemWebEntity>();

                mo = Factory.LoadMediaObjectInstance(mediaObjectId);
                if (Utils.IsUserAuthorized(SecurityActions.ViewAlbumOrMediaObject, RoleController.GetGalleryServerRolesForUser(), mo.Parent.Id, mo.GalleryId, mo.Parent.IsPrivate))
                {
                    foreach (IGalleryObjectMetadataItem metadata in mo.MetadataItems.GetVisibleItems())
                    {
                        metadataItems.Add(new MetadataItemWebEntity(metadata.Description, metadata.Value));
                    }
                }

                return(metadataItems);
            }
            catch (Exception ex)
            {
                if (mo != null)
                {
                    AppErrorController.LogError(ex, mo.GalleryId);
                }
                else
                {
                    AppErrorController.LogError(ex);
                }
                throw;
            }
        }
コード例 #12
0
        public AlbumWebEntity GetAlbumInfo(int albumId)
        {
            IAlbum album = null;

            try
            {
                AlbumWebEntity albumEntity = new AlbumWebEntity();

                album = AlbumController.LoadAlbumInstance(albumId, false);

                if (Utils.IsUserAuthorized(SecurityActions.ViewAlbumOrMediaObject, albumId, album.GalleryId, album.IsPrivate))
                {
                    albumEntity.Title     = album.Title;
                    albumEntity.Summary   = album.Summary;
                    albumEntity.DateStart = album.DateStart;
                    albumEntity.DateEnd   = album.DateEnd;
                    albumEntity.IsPrivate = album.IsPrivate;
                }

                return(albumEntity);
            }
            catch (Exception ex)
            {
                if (album != null)
                {
                    AppErrorController.LogError(ex, album.GalleryId);
                }
                else
                {
                    AppErrorController.LogError(ex);
                }
                throw;
            }
        }
コード例 #13
0
        private Stream GetWatermarkedImageStream()
        {
            Image watermarkedImage = null;

            try
            {
                try
                {
                    watermarkedImage = ImageHelper.AddWatermark(MediaObjectFilePath, MediaObject.GalleryId);
                }
                catch (Exception ex)
                {
                    // Can't apply watermark to image. Substitute an error image and send that to the user.
                    if (!(ex is FileNotFoundException))
                    {
                        // Don't log FileNotFoundException exceptions. This helps avoid clogging the error log
                        // with entries caused by search engine retrieving media objects that have been moved or deleted.
                        AppErrorController.LogError(ex);
                    }
                    watermarkedImage = Image.FromFile(_context.Request.MapPath(String.Concat(Utils.GalleryRoot, "/images/error_48x48.png")));
                }

                MemoryStream stream = new MemoryStream();
                watermarkedImage.Save(stream, ImageFormat.Jpeg);
                return(stream);
            }
            finally
            {
                if (watermarkedImage != null)
                {
                    watermarkedImage.Dispose();
                }
            }
        }
コード例 #14
0
        private void ProcessMediaObject()
        {
            // Send the specified file to the client.
            try
            {
                this._context.Response.Clear();
                this._context.Response.AddHeader("Content-Disposition", string.Format("inline;filename=\"{0}\"", MakeFileNameDownloadFriendly(Path.GetFileName(MediaObjectFilePath))));
                this._context.Response.ContentType = MimeType.FullType;
                this._context.Response.Buffer      = false;

                HttpCachePolicy cachePolicy = this._context.Response.Cache;
                cachePolicy.SetExpires(DateTime.Now.AddSeconds(2592000));                 // 30 days
                cachePolicy.SetCacheability(HttpCacheability.Public);
                cachePolicy.SetValidUntilExpires(true);

                FileStream fileStream = null;
                try
                {
                    byte[] buffer = new byte[_bufferSize];

                    try
                    {
                        fileStream = File.OpenRead(MediaObjectFilePath);
                    }
                    catch (ArgumentException) { return; }                                // If the file or directory isn't found, just return. This helps avoid clogging the error log
                    catch (FileNotFoundException) { return; }                            // with entries caused by search engine retrieving media objects that have been moved or deleted.
                    catch (DirectoryNotFoundException) { return; }

                    // Required for Silverlight to properly work
                    this._context.Response.AddHeader("Content-Length", fileStream.Length.ToString(CultureInfo.InvariantCulture));

                    int byteCount;
                    while ((byteCount = fileStream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        if (this._context.Response.IsClientConnected)
                        {
                            this._context.Response.OutputStream.Write(buffer, 0, byteCount);
                            this._context.Response.Flush();
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                finally
                {
                    if (fileStream != null)
                    {
                        fileStream.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
            }
        }
コード例 #15
0
 public void PerformMaintenance()
 {
     try
     {
         Utils.PerformMaintenance();
     }
     catch (Exception ex)
     {
         AppErrorController.LogError(ex);
     }
 }
コード例 #16
0
 public List <ActionResult> AddMediaObject(AddMediaObjectSettings settings)
 {
     try
     {
         return(GalleryObjectController.AddMediaObject(settings));
     }
     catch (Exception ex)
     {
         AppErrorController.LogError(ex);
         throw;
     }
 }
コード例 #17
0
        private void ProcessMediaObject()
        {
            // Send the specified file to the client.
            try
            {
                IMimeType mimeType = MimeType.LoadInstanceByFilePath(this._filename);

                this._context.Response.Clear();
                this._context.Response.ContentType = mimeType.FullType;
                this._context.Response.Buffer      = false;

                HttpCachePolicy cachePolicy = this._context.Response.Cache;
                cachePolicy.SetExpires(DateTime.Now.AddSeconds(2592000));                 // 30 days
                cachePolicy.SetCacheability(HttpCacheability.Public);
                cachePolicy.SetValidUntilExpires(true);

                FileStream fileStream = null;
                try
                {
                    int    bufferSize = Config.GetCore().MediaObjectDownloadBufferSize;
                    byte[] buffer     = new byte[bufferSize];
                    fileStream = File.OpenRead(this._filepath);

                    // Required for Silverlight to properly work
                    this._context.Response.AddHeader("Content-Length", fileStream.Length.ToString());

                    int byteCount;
                    while ((byteCount = fileStream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        if (this._context.Response.IsClientConnected)
                        {
                            this._context.Response.OutputStream.Write(buffer, 0, byteCount);
                            this._context.Response.Flush();
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                finally
                {
                    if (fileStream != null)
                    {
                        fileStream.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
            }
        }
コード例 #18
0
ファイル: Gallery.asmx.cs プロジェクト: ericjbeltran/2009
 public AlbumWebEntity UpdateAlbumInfo(AlbumWebEntity albumEntity)
 {
     try
     {
         return(AlbumController.UpdateAlbumInfo(albumEntity));
     }
     catch (Exception ex)
     {
         AppErrorController.LogError(ex);
         throw;
     }
 }
コード例 #19
0
ファイル: Gallery.asmx.cs プロジェクト: ericjbeltran/2009
 public MediaObjectWebEntity GetMediaObjectHtml(int mediaObjectId, DisplayObjectType displayType)
 {
     try
     {
         return(GalleryPage.GetMediaObjectHtml(Factory.LoadMediaObjectInstance(mediaObjectId), displayType, true));
     }
     catch (Exception ex)
     {
         AppErrorController.LogError(ex);
         throw;
     }
 }
コード例 #20
0
ファイル: Gallery.asmx.cs プロジェクト: ericjbeltran/2009
 public void SetMetaDataVisibility(bool isVisible)
 {
     try
     {
         ProfileEntity profile = ProfileController.GetProfile();
         profile.ShowMediaObjectMetadata = isVisible;
         ProfileController.SaveProfile(profile);
     }
     catch (Exception ex)
     {
         AppErrorController.LogError(ex);
         throw;
     }
 }
コード例 #21
0
        public void TerminateTask(int galleryId, string taskId)
        {
            ISynchronizationStatus synchStatus = SynchronizationStatus.GetInstance(galleryId);

            try
            {
                synchStatus.CancelSynchronization(taskId);
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
                throw;
            }
        }
コード例 #22
0
        protected void btnRestore_Click(object sender, EventArgs e)
        {
            string filePath = ViewState["FilePath"].ToString();
            string msg;

            Page.MaintainScrollPositionOnPostBack = false;

            try
            {
                if (File.Exists(filePath))
                {
                    HelperFunctions.ImportGalleryData(File.ReadAllText(filePath), chkImportMembership.Checked, chkImportGalleryData.Checked);

                    this.wwMessage.CssClass = "wwErrorSuccess gsp_msgfriendly gsp_bold";
                    msg = Resources.GalleryServerPro.Admin_Backup_Restore_Db_Successfully_Restored_Msg;
                    wwMessage.ShowMessage(msg);
                }
                else
                {
                    wwMessage.CssClass = "wwErrorFailure gsp_msgwarning";
                    msg = String.Format(Resources.GalleryServerPro.Admin_Backup_Restore_Cannot_Restore_File_File_Not_Found_Msg, filePath);
                    wwMessage.ShowError(msg);
                }
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
                this.wwMessage.CssClass = "wwErrorFailure gsp_msgwarning";
                msg = String.Concat(Resources.GalleryServerPro.Admin_Backup_Restore_Cannot_Restore_File_Label, ex.Message);
                wwMessage.ShowError(msg);
            }
            finally
            {
                DeletePreviouslyUploadedFile();

                ConfigureBackupFileInfo(null);

                HelperFunctions.PurgeCache();

                try
                {
                    // Recycle the app to force the providers to re-initialize. This will query the application ID from the database, which
                    // may have changed during the restore.
                    Util.ForceAppRecycle();
                }
                catch (IOException) { }
                catch (PlatformNotSupportedException) { }
            }
        }
コード例 #23
0
        public void Synchronize(int albumId, string synchId, bool isRecursive, bool overwriteThumb, bool overwriteOpt, bool regenerateMetadata)
        {
            IAlbum album = null;

            try
            {
                #region Check user authorization

                bool isUserAuthenticated = Util.IsAuthenticated;
                if (!isUserAuthenticated)
                {
                    return;
                }

                album = Factory.LoadAlbumInstance(albumId, true, true, false);

                if (!Util.IsUserAuthorized(SecurityActions.Synchronize, RoleController.GetGalleryServerRolesForUser(), albumId, album.GalleryId, false))
                {
                    return;
                }

                #endregion

                SynchronizationManager synchMgr = new SynchronizationManager(album.GalleryId);

                synchMgr.IsRecursive        = isRecursive;
                synchMgr.OverwriteThumbnail = overwriteThumb;
                synchMgr.OverwriteOptimized = overwriteOpt;
                synchMgr.RegenerateMetadata = regenerateMetadata;

                synchMgr.Synchronize(synchId, album, Util.UserName);

                // Sueetie Modified - Fix missing media object titles from GSP sync process
                SueetieMedia.PopulateMediaObjectTitles();
            }
            catch (Exception ex)
            {
                if (album != null)
                {
                    AppErrorController.LogError(ex, album.GalleryId);
                }
                else
                {
                    AppErrorController.LogError(ex);
                }
                throw;
            }
        }
コード例 #24
0
ファイル: Gallery.asmx.cs プロジェクト: ericjbeltran/2009
 public void DeleteAppError(int appErrorId)
 {
     try
     {
         if (GalleryPage.UserIsAdministrator)
         {
             GalleryServerPro.ErrorHandler.Error.Delete(appErrorId);
             HelperFunctions.PurgeCache();
         }
     }
     catch (Exception ex)
     {
         AppErrorController.LogError(ex);
         throw;
     }
 }
コード例 #25
0
ファイル: Gallery.asmx.cs プロジェクト: ericjbeltran/2009
 public void DeleteMediaObject(int mediaObjectId)
 {
     try
     {
         IGalleryObject mo = Factory.LoadMediaObjectInstance(mediaObjectId);
         if (GalleryPage.IsUserAuthorized(SecurityActions.DeleteMediaObject, mo.Parent.Id))
         {
             mo.Delete();
             HelperFunctions.PurgeCache();
         }
     }
     catch (Exception ex)
     {
         AppErrorController.LogError(ex);
         throw;
     }
 }
コード例 #26
0
        public void SetMetaDataVisibility(bool isVisible, int galleryId)
        {
            try
            {
                IUserProfile profile = ProfileController.GetProfile();
                profile.GetGalleryProfile(galleryId).ShowMediaObjectMetadata = isVisible;
                ProfileController.SaveProfile(profile);
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);

#if DEBUG
                throw;
#endif
            }
        }
コード例 #27
0
        public void Synchronize(int albumId, string synchId, bool isRecursive, bool rebuildThumbnails, bool rebuildOptimized, bool regenerateMetadata)
        {
            IAlbum album = null;

            try
            {
                #region Check user authorization

                bool isUserAuthenticated = Utils.IsAuthenticated;
                if (!isUserAuthenticated)
                {
                    return;
                }

                album = AlbumController.LoadAlbumInstance(albumId, true, true, false);

                if (!Utils.IsUserAuthorized(SecurityActions.Synchronize, RoleController.GetGalleryServerRolesForUser(), albumId, album.GalleryId, false))
                {
                    return;
                }

                #endregion

                SynchronizationManager synchMgr = new SynchronizationManager(album.GalleryId);

                synchMgr.IsRecursive        = isRecursive;
                synchMgr.RebuildThumbnail   = rebuildThumbnails;
                synchMgr.RebuildOptimized   = rebuildOptimized;
                synchMgr.RegenerateMetadata = regenerateMetadata;

                synchMgr.Synchronize(synchId, album, Utils.UserName);
            }
            catch (Exception ex)
            {
                if (album != null)
                {
                    AppErrorController.LogError(ex, album.GalleryId);
                }
                else
                {
                    AppErrorController.LogError(ex);
                }
                throw;
            }
        }
コード例 #28
0
        public SynchStatusWebEntity GetCurrentStatus(int galleryId)
        {
            ISynchronizationStatus synchStatus = SynchronizationStatus.GetInstance(galleryId);

            try
            {
                SynchStatusWebEntity synchStatusWeb = new SynchStatusWebEntity();

                synchStatusWeb.SynchId          = synchStatus.SynchId;
                synchStatusWeb.TotalFileCount   = synchStatus.TotalFileCount;
                synchStatusWeb.CurrentFileIndex = synchStatus.CurrentFileIndex + 1;

                if ((synchStatus.CurrentFilePath != null) && (synchStatus.CurrentFileName != null))
                {
                    synchStatusWeb.CurrentFile = System.IO.Path.Combine(synchStatus.CurrentFilePath, synchStatus.CurrentFileName);
                }

                synchStatusWeb.Status          = synchStatus.Status.ToString();
                synchStatusWeb.StatusForUI     = GetFriendlyStatusText(synchStatus.Status);
                synchStatusWeb.PercentComplete = CalculatePercentComplete(synchStatus);

                // Update the Skipped Files, but only when the synch is complete.
                lock (synchStatus)
                {
                    if (synchStatus.Status == SynchronizationState.Complete)
                    {
                        if (synchStatus.SkippedMediaObjects.Count > GlobalConstants.MaxNumberOfSkippedObjectsToDisplayAfterSynch)
                        {
                            // We have a large number of skipped media objects. We don't want to send it all to the browsers, because it might take
                            // too long or cause an error if it serializes to a string longer than int.MaxValue, so let's trim it down.
                            synchStatus.SkippedMediaObjects.RemoveRange(GlobalConstants.MaxNumberOfSkippedObjectsToDisplayAfterSynch,
                                                                        synchStatus.SkippedMediaObjects.Count -
                                                                        GlobalConstants.MaxNumberOfSkippedObjectsToDisplayAfterSynch);
                        }
                        synchStatusWeb.SkippedFiles = synchStatus.SkippedMediaObjects;
                    }
                }
                return(synchStatusWeb);
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex, synchStatus.GalleryId);
                throw;
            }
        }
コード例 #29
0
ファイル: Gallery.asmx.cs プロジェクト: ericjbeltran/2009
 public void TerminateTask(string taskId)
 {
     try
     {
         lock (_synchStatus)
         {
             if (_synchStatus.SynchId == taskId)
             {
                 _synchStatus.ShouldTerminate = true;
             }
         }
     }
     catch (Exception ex)
     {
         AppErrorController.LogError(ex);
         throw;
     }
 }
コード例 #30
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        public void ProcessRequest(HttpContext context)
        {
            // Send the specified media object to the output stream.
            // Expected format:
            // /dev/gs/handler/getmediaobject.ashx?moid=34&amp;dt=1&amp;g=1
            // moid: The media object ID. Is int.MinValue if an empty image is to be returned.
            // dt: The display type. It is an integer that maps to the enum GalleryServerPro.Business.DisplayObjectType.
            // (0=Unknown,1=Thumbnail,2=Optimized,3=Original) At present all values other than 3 (Original) are ignored. If 3,
            // a security check is done to make sure user is authorized to view original images.
            // g: The gallery ID.
            // If URL encryption is enabled, then the entire query string portion is encrypted.
            try
            {
                if (!GalleryController.IsInitialized)
                {
                    GalleryController.InitializeGspApplication();
                }

                if (InitializeVariables(context))
                {
                    if (!IsUserAuthorized())
                    {
                        this._context.Response.StatusCode = 403;
                        this._context.Response.End();
                    }

                    if (IsMediaObjectRequest() && !DoesMediaObjectExist())
                    {
                        this._context.Response.StatusCode = 404;
                        this._context.Response.End();
                    }

                    ShowMediaObject();
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
                throw;                 // We don't want these to fall into the generic catch because we don't want them logged.
            }
            catch (Exception ex)
            {
                AppErrorController.LogError(ex);
            }
        }