Esempio n. 1
0
        public override List <SueetieMediaObject> GetSueetieMediaObjectsToIndex(DateTime pubDate)
        {
            List <SueetieMediaObject> sueetieMediaObjects = new List <SueetieMediaObject>();

            using (SqlConnection cn = GetSqlConnection())
            {
                using (SqlCommand cmd = new SqlCommand("Sueetie_Search_MediaObjects_Get", cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@pubDate", SqlDbType.DateTime, 8).Value = pubDate == DateTime.MinValue
                        ? new DateTime(1900, 1, 1)
                        : pubDate;
                    cn.Open();
                    using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        SueetieMediaObject _SueetieMediaObject = null;
                        while (dr.Read())
                        {
                            _SueetieMediaObject = new SueetieMediaObject();
                            PopulateSueetieMediaObjectList(dr, _SueetieMediaObject);
                            sueetieMediaObjects.Add(_SueetieMediaObject);
                        }

                        dr.Close();
                        cn.Close();
                    }
                }
            }
            return(sueetieMediaObjects);
        }
Esempio n. 2
0
        private static SueetieSearchDoc ConvertSueetieMediaObjectToSearchDoc(SueetieMediaObject sueetieMediaObject)
        {
            string _body        = string.IsNullOrEmpty(sueetieMediaObject.MediaObjectDescription) ? sueetieMediaObject.MediaObjectTitle : sueetieMediaObject.MediaObjectDescription;
            string _tags        = !string.IsNullOrEmpty(sueetieMediaObject.Tags) ? sueetieMediaObject.Tags.Replace('|', ' ') : string.Empty;
            string _displayTags = !string.IsNullOrEmpty(sueetieMediaObject.Tags) ? SueetieTags.TagUrls(sueetieMediaObject.Tags) : string.Empty;

            SueetieSearchDoc doc = new SueetieSearchDoc()
            {
                App               = "Media",
                ContentID         = sueetieMediaObject.ContentID,
                Title             = sueetieMediaObject.MediaObjectTitle,
                Tags              = _tags,
                DisplayTags       = _displayTags,
                AppID             = sueetieMediaObject.ApplicationID,
                IsRestricted      = sueetieMediaObject.IsRestricted,
                PublishDate       = sueetieMediaObject.DateTimeCreated,
                ContainerName     = sueetieMediaObject.AlbumTitle,
                GroupID           = sueetieMediaObject.GroupID,
                GroupKey          = string.IsNullOrEmpty(sueetieMediaObject.GroupKey) ? "na" : sueetieMediaObject.GroupKey,
                ContentTypeID     = sueetieMediaObject.ContentTypeID,
                Categories        = string.Empty,
                ApplicationTypeID = sueetieMediaObject.ApplicationTypeID,
                ApplicationKey    = sueetieMediaObject.ApplicationKey,
                PermaLink         = "/" + sueetieMediaObject.ApplicationKey + "/default.aspx?moid=" + sueetieMediaObject.MediaObjectID,
                Author            = sueetieMediaObject.DisplayName,
                Username          = sueetieMediaObject.UserName,
                Body              = _body + RaquoIt(sueetieMediaObject.MediaObjectTitle) + RaquoIt(_tags) + RaquoIt(sueetieMediaObject.UserName)
            };

            return(doc);
        }
Esempio n. 3
0
        private void ConfigureControls()
        {
            this.TaskHeaderText  = Resources.GalleryServerPro.Task_Edit_Captions_Header_Text;
            this.TaskBodyText    = Resources.GalleryServerPro.Task_Edit_Captions_Body_Text;
            this.OkButtonText    = SueetieLocalizer.GetString("process_updates", "MediaGallery.xml");
            this.OkButtonToolTip = Resources.GalleryServerPro.Task_Edit_Captions_Ok_Button_Tooltip;

            this.PageTitle = Resources.GalleryServerPro.Task_Edit_Captions_Page_Title;

            // Sueetie Modified - Converting GSP galleryObjects into SueetieGalleryObjects
            List <SueetieMediaObject> sueetieMediaObjects = new List <SueetieMediaObject>();

            IGalleryObjectCollection albumChildren = this.GetAlbum().GetChildGalleryObjects(GalleryObjectType.MediaObject, true);

            foreach (IGalleryObject _galleryObject in albumChildren)
            {
                SueetieMediaObject _sueetieMediaObject = SueetieMedia.GetSueetieMediaObject(this.CurrentSueetieGalleryID, _galleryObject.Id);
                MediaHelper.PopulateMediaObject(_sueetieMediaObject, _galleryObject);
                sueetieMediaObjects.Add(_sueetieMediaObject);
            }

            if (albumChildren.Count > 0)
            {
                const int textareaWidthBuffer  = 30;                // Extra width padding to allow room for the caption.
                const int textareaHeightBuffer = 72;                // Extra height padding to allow room for the caption.
                SetThumbnailCssStyle(albumChildren, textareaWidthBuffer, textareaHeightBuffer);

                rptr.DataSource = sueetieMediaObjects;
                rptr.DataBind();
            }
            else
            {
                this.RedirectToAlbumViewPage("msg={0}", ((int)Message.CannotEditCaptionsNoEditableObjectsExistInAlbum).ToString(CultureInfo.InvariantCulture));
            }
        }
        protected string GenerateUrl(SueetieMediaObject sueetieMediaObject)
        {
            string rv;

            if (sueetieMediaObject.IsAlbum)
            {
                // We have an album.
                rv = String.Concat(Util.GetUrl(PageId.album, "aid={0}", sueetieMediaObject.MediaObjectID));
            }
            else if (sueetieMediaObject.IsImage)
            {
                // We have an image.
                if (ViewOriginal)
                {
                    rv = String.Concat(Util.GetUrl(PageId.mediaobject, "moid={0}&hr=1", sueetieMediaObject.MediaObjectID));
                }
                else
                {
                    rv = String.Concat(Util.GetUrl(PageId.mediaobject, "moid={0}", sueetieMediaObject.MediaObjectID));
                }
            }
            else
            {
                rv = String.Concat(Util.GetUrl(PageId.mediaobject, "moid={0}", sueetieMediaObject.MediaObjectID));
            }

            if (String.IsNullOrEmpty(rv))
            {
                throw new WebException("Unsupported media object type: " + sueetieMediaObject.GetType());
            }

            return(rv);
        }
 protected static string GetThumbnailCssClass(SueetieMediaObject sueetieMediaObject)
 {
     if (sueetieMediaObject.IsImage)
     {
         return("ListThumbnailImage");
     }
     else
     {
         return("ListThumbnail");
     }
 }
 public static void PopulateSueetieMediaObjectList(IDataReader dr, SueetieMediaObject _sueetieMediaObject)
 {
     _sueetieMediaObject.MediaObjectID          = (int)dr["mediaobjectid"];
     _sueetieMediaObject.AlbumID                = (int)dr["albumid"];
     _sueetieMediaObject.ContentID              = (int)dr["contentid"];
     _sueetieMediaObject.SourceID               = (int)dr["sourceid"];
     _sueetieMediaObject.ContentTypeID          = (int)dr["contenttypeid"];
     _sueetieMediaObject.ContentTypeDescription = dr["contenttypedescription"] as string;
     _sueetieMediaObject.SueetieUserID          = (int)dr["sueetieuserid"];
     _sueetieMediaObject.Permalink              = dr["permalink"] as string;
     _sueetieMediaObject.DateTimeCreated        = (DateTime)dr["datetimecreated"];
     _sueetieMediaObject.IsRestricted           = (bool)dr["isrestricted"];
     _sueetieMediaObject.ApplicationID          = (int)dr["applicationid"];
     _sueetieMediaObject.ApplicationKey         = dr["applicationkey"] as string;
     _sueetieMediaObject.ApplicationDescription = dr["applicationdescription"] as string;
     _sueetieMediaObject.MediaObjectTitle       = dr["mediaobjecttitle"] as string;
     _sueetieMediaObject.AlbumTitle             = dr["albumtitle"] as string;
     _sueetieMediaObject.GroupID                = (int)dr["groupid"];
     _sueetieMediaObject.GroupKey               = dr["groupkey"] as string;
     _sueetieMediaObject.GroupName              = dr["groupname"] as string;
     _sueetieMediaObject.UserName               = dr["username"] as string;
     _sueetieMediaObject.Email                  = dr["email"] as string;
     _sueetieMediaObject.DisplayName            = dr["displayname"] as string;
     _sueetieMediaObject.MediaObjectUrl         = dr["mediaobjecturl"] as string;
     _sueetieMediaObject.GalleryID              = (int)dr["galleryid"];
     _sueetieMediaObject.GalleryName            = dr["galleryname"] as string;
     _sueetieMediaObject.MediaObjectDescription = dr["mediaobjectdescription"] as string;
     _sueetieMediaObject.InDownloadReport       = (bool)dr["indownloadreport"];
     _sueetieMediaObject.ApplicationTypeID      = (int)dr["applicationtypeid"];
     _sueetieMediaObject.Abstract               = dr["abstract"] as string;
     _sueetieMediaObject.Authors                = dr["authors"] as string;
     _sueetieMediaObject.Location               = dr["location"] as string;
     _sueetieMediaObject.Series                 = dr["series"] as string;
     _sueetieMediaObject.DocumentType           = dr["documenttype"] as string;
     _sueetieMediaObject.Keywords               = dr["keywords"] as string;
     _sueetieMediaObject.Misc             = dr["misc"] as string;
     _sueetieMediaObject.Number           = dr["number"] as string;
     _sueetieMediaObject.Version          = dr["version"] as string;
     _sueetieMediaObject.Organization     = dr["organization"] as string;
     _sueetieMediaObject.Conference       = dr["conference"] as string;
     _sueetieMediaObject.ISxN             = dr["isxn"] as string;
     _sueetieMediaObject.PublicationDate  = dr["publicationdate"] as string;
     _sueetieMediaObject.Publisher        = dr["publisher"] as string;
     _sueetieMediaObject.IsAlbum          = (bool)dr["isalbum"];
     _sueetieMediaObject.OriginalFilename = dr["originalfilename"] as string;
     _sueetieMediaObject.CreatedBy        = dr["createdby"] as string;
     _sueetieMediaObject.DateAdded        = (DateTime)dr["dateadded"];
     _sueetieMediaObject.LastModifiedBy   = dr["lastmodifiedby"] as string;
     _sueetieMediaObject.DateLastModified = (DateTime)dr["datelastmodified"];
     _sueetieMediaObject.ThumbnailWidth   = (int)dr["thumbnailwidth"];
     _sueetieMediaObject.ThumbnailHeight  = (int)dr["thumbnailheight"];
     _sueetieMediaObject.IsImage          = (bool)dr["isimage"];
     _sueetieMediaObject.Tags             = dr["tags"] as string;
 }
Esempio n. 7
0
 public static SueetieMediaObject PopulateMediaObject(SueetieMediaObject _sueetieMediaObject, IGalleryObject galleryObject)
 {
     _sueetieMediaObject.IsImage = galleryObject is GalleryServerPro.Business.Image;
     if (_sueetieMediaObject.IsImage)
     {
         _sueetieMediaObject.ThumbnailHeight = galleryObject.Thumbnail.Height;
         _sueetieMediaObject.ThumbnailWidth  = galleryObject.Thumbnail.Width;
     }
     else
     {
         _sueetieMediaObject.ThumbnailWidth  = SueetieConfiguration.Get().Media.ThumbnailWidth;
         _sueetieMediaObject.ThumbnailHeight = SueetieConfiguration.Get().Media.ThumbnailHeight;
     }
     return(_sueetieMediaObject);
 }
Esempio n. 8
0
        protected void rptr_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                SueetieMediaObject sueetieMediaObject = ((SueetieMediaObject)e.Item.DataItem);
                PlaceHolder        phTagsControl      = (PlaceHolder)e.Item.FindControl("phTagsControl");
                tagControl = new TagControl();
                tagControl.TagSueetieMediaObject = sueetieMediaObject;
                phTagsControl.Controls.Add(tagControl);


                PlaceHolder phCalendarControl = (PlaceHolder)e.Item.FindControl("phCalendarControl");
                calendarControl = new CalendarControl();
                calendarControl.CalendarSueetieMediaObject = sueetieMediaObject;
                phCalendarControl.Controls.Add(calendarControl);
            }
        }
        protected string GetHovertip(SueetieMediaObject sueetieMediaObject)
        {
            // Return the text to be used as the hovertip in standards compliant browsers. This is the
            // summary text for albums, and the title text for objects.
            string hoverTip = sueetieMediaObject.MediaObjectTitle;

            //if (sueetieMediaObject.IsAlbum)
            //IAlbum album = galleryObject as IAlbum;
            //if (album != null)
            //{
            //    if (album.Summary.Trim().Length > 0)
            //        hoverTip = album.Summary;
            //}

            string hoverTipClean = Util.HtmlEncode(Util.RemoveHtmlTags(hoverTip));

            return(hoverTipClean);
        }
        protected void rptr_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                SueetieMediaObject _sueetieMediaObject = ((SueetieMediaObject)e.Item.DataItem);
                SueetieMediaAlbum  _album = SueetieMedia.GetSueetieMediaAlbum(CurrentSueetieGalleryID, _sueetieMediaObject.MediaObjectID);

                PlaceHolder phTagsControl = (PlaceHolder)e.Item.FindControl("phTagsControl");
                tagControl = new TagControl();
                tagControl.DisplayTagsPanel = false;
                if (_sueetieMediaObject.IsAlbum)
                {
                    tagControl.TagSueetieMediaAlbum = _album;
                }
                else
                {
                    tagControl.TagSueetieMediaObject = _sueetieMediaObject;
                }

                phTagsControl.Controls.Add(tagControl);
            }
        }
Esempio n. 11
0
        private Message saveCaptions()
        {
            // Iterate through all the textboxes, saving any captions that have changed.
            // The media object IDs are stored in a hidden input tag.
            HtmlInputText   ta;
            HtmlTextArea    tdesc;
            HtmlInputHidden gc;
            IGalleryObject  mo;
            string          newTitle, previousTitle, previousTags, previousDescription;
            Message         msg = Message.None;

            if (!IsUserAuthorized(SecurityActions.EditMediaObject))
            {
                return(msg);
            }

            try
            {
                HelperFunctions.BeginTransaction();

                // Loop through each item in the repeater control. If an item is checked, extract the ID.
                foreach (RepeaterItem rptrItem in rptr.Items)
                {
                    ta    = (HtmlInputText)rptrItem.Controls[1];   // The <input TEXT> tag
                    tdesc = (HtmlTextArea)rptrItem.Controls[3];    // The <TEXTAREA> tag
                    gc    = (HtmlInputHidden)rptrItem.Controls[5]; // The hidden <input> tag

                    // Retrieve new title. Since the Value property of <TEXTAREA> HTML ENCODEs the text,
                    // and we want to store the actual text, we must decode to get back to the original.
                    newTitle = Util.HtmlDecode(ta.Value);

                    mo            = Factory.LoadMediaObjectInstance(Convert.ToInt32(gc.Value, CultureInfo.InvariantCulture), true);
                    previousTitle = mo.Title;

                    mo.Title = Util.RemoveHtmlTags(newTitle);

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

                    SueetieMediaObject _sueetieMediaObject = SueetieMedia.GetSueetieMediaObject(CurrentSueetieGalleryID, mo.Id);
                    previousDescription = _sueetieMediaObject.MediaObjectDescription;
                    _sueetieMediaObject.MediaObjectDescription = tdesc.Value;

                    if (_sueetieMediaObject.MediaObjectTitle != newTitle || _sueetieMediaObject.MediaObjectDescription != previousDescription)
                    {
                        SueetieMedia.UpdateSueetieMediaObject(_sueetieMediaObject);
                    }
                }

                HelperFunctions.CommitTransaction();
            }
            catch
            {
                HelperFunctions.RollbackTransaction();
                throw;
            }

            HelperFunctions.PurgeCache();
            SueetieMedia.ClearSueetieMediaObjectListCache(CurrentSueetieGalleryID);
            return(msg);
        }
        /// <summary>
        /// Displays thumbnail versions of the specified <paramref name="galleryObjects"/>.
        /// </summary>
        /// <param name="galleryObjects">The gallery objects to display.</param>
        /// <param name="showAddObjectsLink">If set to <c>true</c> show a message and a link allowing the user to add objects to the
        /// current album as specified in the query string. Set to false when displaying objects that may belong to more than one
        /// album.</param>
        private void DisplayThumbnails(IGalleryObjectCollection galleryObjects, bool showAddObjectsLink)
        {
            string msg;

            if (galleryObjects.Count > 0)
            {
                // At least one album or media object in album.
                //msg = String.Format(CultureInfo.CurrentCulture, "<p class='gsp_addtopmargin2'>{0}</p>", Resources.GalleryServerPro.UC_ThumbnailView_Intro_Text_With_Objects);
                //phMsg.Controls.Add(new LiteralControl(msg));
            }
            else if ((showAddObjectsLink) && (this.GalleryPage.UserCanAddMediaObject) && (!this.GalleryPage.GallerySettings.MediaObjectPathIsReadOnly))
            {
                // We have no objects to display. The user is authorized to add objects to this album and the gallery is writeable, so show
                // message and link to add objects page.
                string innerMsg = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.UC_ThumbnailView_Intro_Text_No_Objects_User_Has_Add_MediaObject_Permission, Util.GetUrl(PageId.task_addobjects, "aid={0}", this.GalleryPage.GetAlbumId()));
                msg = String.Format(CultureInfo.CurrentCulture, "<p class='gsp_addtopmargin2 gsp_msgfriendly'>{0}</p>", innerMsg);
                phMsg.Controls.Add(new LiteralControl(msg));
            }
            else
            {
                // No objects and/or user doesn't have permission to add media objects.
                msg = String.Format(CultureInfo.CurrentCulture, "<p class='gsp_addtopmargin2 gsp_msgfriendly'>{0}</p>", Resources.GalleryServerPro.UC_ThumbnailView_Intro_Text_No_Objects);
                phMsg.Controls.Add(new LiteralControl(msg));
            }

            this.GalleryPage.SetThumbnailCssStyle(galleryObjects);

            // Sueetie Modified - Converting GSP galleryObjects into SueetieGalleryObjects
            SueetieConfiguration      config = SueetieConfiguration.Get();
            List <SueetieMediaObject> sueetieMediaObjects = new List <SueetieMediaObject>();


            foreach (IGalleryObject _galleryObject in galleryObjects)
            {
                if (_galleryObject is Album)
                {
                    SueetieMediaAlbum _album = SueetieMedia.GetSueetieMediaAlbum(CurrentSueetieGalleryID, _galleryObject.Id);
                    sueetieMediaObjects.Insert(0, new SueetieMediaObject
                    {
                        MediaObjectID          = _galleryObject.Id,
                        MediaObjectTitle       = _galleryObject.Title,
                        AlbumID                = _galleryObject.Id,
                        IsAlbum                = true,
                        MediaObjectUrl         = String.Concat(Util.GetUrl(PageId.album, "aid={0}", _galleryObject.Id)),
                        MediaObjectDescription = _album.AlbumDescription,
                        DisplayName            = _album.DisplayName,
                        ThumbnailHeight        = config.Media.ThumbnailHeight,
                        ThumbnailWidth         = config.Media.ThumbnailWidth,
                        DateTimeCreated        = _album.DateTimeCreated,
                        SueetieUserID          = _album.SueetieUserID
                    });
                }
                else
                {
                    SueetieMediaObject _sueetieMediaObject = SueetieMedia.GetSueetieMediaObject(this.CurrentSueetieGalleryID, _galleryObject.Id);
                    MediaHelper.PopulateMediaObject(_sueetieMediaObject, _galleryObject);
                    _sueetieMediaObject.MediaObjectUrl = GenerateUrl(_galleryObject);
                    sueetieMediaObjects.Add(_sueetieMediaObject);
                }
            }

            if (PagingEnabled)
            {
                rptr.DataSource = CreatePaging(sueetieMediaObjects);

                RegisterPagingScript();
            }
            else
            {
                rptr.DataSource = sueetieMediaObjects;
            }
            rptr.DataBind();
        }
Esempio n. 13
0
        /// <summary>
        /// Adds the uploaded files to the gallery. This method is called when the application is operating under full trust. In this case,
        /// the ComponentArt Upload control is used. The logic is nearly identical to that in AddUploadedFilesLessThanFullTrust - the only
        /// differences are syntax differences arising from the different file upload control.
        /// </summary>
        /// <param name="files">The files to add to the gallery.</param>
        private void AddUploadedFilesForFullTrust(UploadedFileInfoCollection files)
        {
            // Clear the list of hash keys so we're starting with a fresh load from the data store.
            try
            {
                MediaObjectHashKeys.Clear();

                string albumPhysicalPath = this.GetAlbum().FullPhysicalPathOnDisk;

                HelperFunctions.BeginTransaction();

                UploadedFileInfo[] fileInfos = new UploadedFileInfo[files.Count];
                files.CopyTo(fileInfos, 0);
                Array.Reverse(fileInfos);

                foreach (UploadedFileInfo file in fileInfos)
                {
                    if (String.IsNullOrEmpty(file.FileName))
                    {
                        continue;
                    }

                    if ((System.IO.Path.GetExtension(file.FileName).Equals(".zip", StringComparison.OrdinalIgnoreCase)) && (!chkDoNotExtractZipFile.Checked))
                    {
                        #region Extract the files from the zipped file.

                        lock (file)
                        {
                            if (File.Exists(file.TempFileName))
                            {
                                using (ZipUtility zip = new ZipUtility(Util.UserName, GetGalleryServerRolesForUser()))
                                {
                                    this._skippedFiles.AddRange(zip.ExtractZipFile(file.GetStream(), this.GetAlbum(), chkDiscardOriginalImage.Checked));
                                }
                            }
                            else
                            {
                                // When one of the files causes an OutOfMemoryException, this can cause the other files to disappear from the
                                // temp upload directory. This seems to be an issue with the ComponentArt Upload control, since this does not
                                // seem to happen with the ASP.NET FileUpload control. If the file doesn't exist, make a note of it and move on
                                // to the next one.
                                this._skippedFiles.Add(new KeyValuePair <string, string>(file.FileName, Resources.GalleryServerPro.Task_Add_Objects_Uploaded_File_Does_Not_Exist_Msg));
                                continue;                                 // Skip to the next file.
                            }
                        }

                        // Sueetie Modified - Add contents of ZIP file - All

                        List <SueetieMediaObject> sueetieMediaObjects = SueetieMedia.GetSueetieMediaUpdateList(this.GetAlbumId());
                        int i = 0;
                        foreach (SueetieMediaObject _sueetieMediaObject in sueetieMediaObjects)
                        {
                            int            _moid          = _sueetieMediaObject.MediaObjectID;
                            IGalleryObject mo             = Factory.LoadMediaObjectInstance(_moid);
                            SueetieContent sueetieContent = new SueetieContent
                            {
                                SourceID        = _sueetieMediaObject.MediaObjectID,
                                ContentTypeID   = MediaHelper.ConvertContentType(mo.MimeType.TypeCategory),
                                ApplicationID   = (int)SueetieApplications.Current.ApplicationID,
                                UserID          = _sueetieMediaObject.SueetieUserID,
                                DateTimeCreated = mo.DateAdded,
                                IsRestricted    = mo.IsPrivate,
                                Permalink       = MediaHelper.SueetieMediaObjectUrl(_moid, this.GalleryId)
                            };

                            // Add Sueetie-specific data to Sueetie_gs_MediaObject
                            _sueetieMediaObject.ContentTypeID    = MediaHelper.ConvertContentType(mo.MimeType.TypeCategory);
                            _sueetieMediaObject.AlbumID          = this.GetAlbum().Id;
                            _sueetieMediaObject.InDownloadReport = false;
                            SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject);
                            SueetieCommon.AddSueetieContent(sueetieContent);
                            i++;
                        }


                        #endregion
                    }
                    else
                    {
                        #region Add the file

                        string filename = HelperFunctions.ValidateFileName(albumPhysicalPath, file.FileName);
                        string filepath = Path.Combine(albumPhysicalPath, filename);

                        lock (file)
                        {
                            if (File.Exists(file.TempFileName))
                            {
                                file.SaveAs(filepath);
                            }
                            else
                            {
                                // When one of the files causes an OutOfMemoryException, this can cause the other files to disappear from the
                                // temp upload directory. This seems to be an issue with the ComponentArt Upload control, since this does not
                                // seem to happen with the ASP.NET FileUpload control. If the file doesn't exist, make a note of it and move on
                                // to the next one.
                                this._skippedFiles.Add(new KeyValuePair <string, string>(file.FileName, Resources.GalleryServerPro.Task_Add_Objects_Uploaded_File_Does_Not_Exist_Msg));
                                continue;                                 // Skip to the next file.
                            }
                        }

                        try
                        {
                            IGalleryObject go = Factory.CreateMediaObjectInstance(filepath, this.GetAlbum());
                            GalleryObjectController.SaveGalleryObject(go);

                            if ((chkDiscardOriginalImage.Checked) && (go is Business.Image))
                            {
                                ((Business.Image)go).DeleteHiResImage();
                                GalleryObjectController.SaveGalleryObject(go);
                            }


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

                            SueetieContent sueetieContent = new SueetieContent
                            {
                                SourceID      = go.Id,
                                ContentTypeID = MediaHelper.ConvertContentType(go.MimeType.TypeCategory),
                                ApplicationID = (int)SueetieApplications.Current.ApplicationID,
                                UserID        = CurrentSueetieUserID,
                                IsRestricted  = this.GetAlbum().IsPrivate,
                                Permalink     = MediaHelper.SueetieMediaObjectUrl(go.Id, this.GalleryId)
                            };
                            SueetieCommon.AddSueetieContent(sueetieContent);

                            // Add Sueetie-specific data to Sueetie_gs_MediaObject

                            SueetieMediaObject _sueetieMediaObject = new SueetieMediaObject();
                            _sueetieMediaObject.MediaObjectID    = go.Id;
                            _sueetieMediaObject.ContentTypeID    = MediaHelper.ConvertContentType(go.MimeType.TypeCategory);
                            _sueetieMediaObject.AlbumID          = this.GetAlbum().Id;
                            _sueetieMediaObject.InDownloadReport = false;
                            SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject);

                            SueetieMediaAlbum sueetieAlbum = SueetieMedia.GetSueetieMediaAlbum(this.GetAlbum().Id);
                            if (CurrentSueetieGallery.IsLogged)
                            {
                                SueetieLogs.LogUserEntry((UserLogCategoryType)sueetieAlbum.AlbumMediaCategoryID, sueetieAlbum.ContentID, CurrentSueetieUserID);
                            }
                        }
                        catch (UnsupportedMediaObjectTypeException ex)
                        {
                            try
                            {
                                File.Delete(filepath);
                            }
                            catch (UnauthorizedAccessException) { }                             // Ignore an error; the file will end up getting deleted during cleanup maintenance

                            this._skippedFiles.Add(new KeyValuePair <string, string>(filename, ex.Message));
                        }

                        #endregion
                    }
                }

                SueetieMedia.ClearMediaPhotoListCache(0);
                SueetieMedia.ClearSueetieMediaObjectListCache(this.CurrentSueetieGalleryID);

                HelperFunctions.CommitTransaction();
            }
            catch
            {
                HelperFunctions.RollbackTransaction();
                throw;
            }
            finally
            {
                // Delete the uploaded temporary files, as by this time they have been saved to the destination directory.
                foreach (UploadedFileInfo file in files)
                {
                    try
                    {
                        System.IO.File.Delete(file.TempFileName);
                    }
                    catch (UnauthorizedAccessException) { }                     // Ignore an error; the file will end up getting deleted during cleanup maintenance
                }

                // Clear the list of hash keys to free up memory.
                MediaObjectHashKeys.Clear();

                HelperFunctions.PurgeCache();
            }
        }
        protected string GenerateUrl(IGalleryObject _galleryObject)
        {
            SueetieMediaObject sueetieMediaObject = SueetieMedia.GetSueetieMediaObject(CurrentSueetieGalleryID, _galleryObject.Id);

            return(GenerateUrl(sueetieMediaObject));
        }
 protected string GetThumbnailUrl(SueetieMediaObject sueetieMediaObject)
 {
     return(this.GalleryPage.GetThumbnailUrl(sueetieMediaObject));
 }
Esempio n. 16
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>
        /// // 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);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Adds the uploaded files to the gallery. This method is called when the application is operating at lesss than full trust. In this case,
        /// the ASP.NET FileUpload control is used. The logic is nearly identical to that in AddUploadedFilesForFullTrust - the only
        /// differences are syntax differences arising from the different file upload control.
        /// </summary>
        private void AddUploadedFilesLessThanFullTrust()
        {
            // Clear the list of hash keys so we're starting with a fresh load from the data store.
            try
            {
                MediaObjectHashKeys.Clear();

                string albumPhysicalPath = this.GetAlbum().FullPhysicalPathOnDisk;

                HelperFunctions.BeginTransaction();

                for (int i = 0; i < 5; i++)
                {
                    FileUpload file = (FileUpload)phUpload.FindControl("fuUpload" + i);

                    if (!file.HasFile)
                    {
                        continue;
                    }

                    if ((System.IO.Path.GetExtension(file.FileName).Equals(".zip", StringComparison.OrdinalIgnoreCase)) && (!chkDoNotExtractZipFile.Checked))
                    {
                        #region Extract the files from the zipped file.

                        // Extract the files from the zipped file.
                        using (ZipUtility zip = new ZipUtility(Util.UserName, GetGalleryServerRolesForUser()))
                        {
                            this._skippedFiles.AddRange(zip.ExtractZipFile(file.FileContent, this.GetAlbum(), chkDiscardOriginalImage.Checked));
                        }

                        #endregion
                    }
                    else
                    {
                        #region Add the file

                        string filename = HelperFunctions.ValidateFileName(albumPhysicalPath, file.FileName);
                        string filepath = Path.Combine(albumPhysicalPath, filename);

                        file.SaveAs(filepath);

                        try
                        {
                            IGalleryObject go = Factory.CreateMediaObjectInstance(filepath, this.GetAlbum());

                            // Sueetie Modified - Fix Blank Title on individual uploads
                            if (go.Title.Trim().Length == 0)
                            {
                                go.Title = go.Original.FileName;
                            }

                            GalleryObjectController.SaveGalleryObject(go);

                            if ((chkDiscardOriginalImage.Checked) && (go is Business.Image))
                            {
                                ((Business.Image)go).DeleteHiResImage();
                                GalleryObjectController.SaveGalleryObject(go);
                            }

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

                            SueetieContent sueetieContent = new SueetieContent
                            {
                                SourceID      = go.Id,
                                ContentTypeID = MediaHelper.ConvertContentType(go.MimeType.TypeCategory),
                                ApplicationID = (int)SueetieApplications.Current.ApplicationID,
                                UserID        = CurrentSueetieUserID,
                                IsRestricted  = this.GetAlbum().IsPrivate,
                                Permalink     = MediaHelper.SueetieMediaObjectUrl(go.Id, this.GalleryId)
                            };
                            SueetieCommon.AddSueetieContent(sueetieContent);

                            // Add Sueetie-specific data to Sueetie_gs_MediaObject

                            SueetieMediaObject _sueetieMediaObject = new SueetieMediaObject();
                            _sueetieMediaObject.MediaObjectID    = go.Id;
                            _sueetieMediaObject.ContentTypeID    = MediaHelper.ConvertContentType(go.MimeType.TypeCategory);
                            _sueetieMediaObject.AlbumID          = this.GetAlbum().Id;
                            _sueetieMediaObject.InDownloadReport = false;
                            SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject);

                            SueetieMediaAlbum sueetieAlbum = SueetieMedia.GetSueetieMediaAlbum(this.GetAlbum().Id);
                            if (CurrentSueetieGallery.IsLogged)
                            {
                                SueetieLogs.LogUserEntry((UserLogCategoryType)sueetieAlbum.AlbumMediaCategoryID, sueetieAlbum.ContentID, CurrentSueetieUserID);
                            }
                            SueetieMedia.ClearMediaPhotoListCache(0);
                            SueetieMedia.ClearSueetieMediaObjectListCache(this.CurrentSueetieGalleryID);
                        }
                        catch (UnsupportedMediaObjectTypeException ex)
                        {
                            try
                            {
                                File.Delete(filepath);
                            }
                            catch (UnauthorizedAccessException) { }                             // Ignore an error; the file will end up getting deleted during cleanup maintenance

                            this._skippedFiles.Add(new KeyValuePair <string, string>(filename, ex.Message));
                        }

                        #endregion
                    }
                }

                HelperFunctions.CommitTransaction();
            }
            catch
            {
                HelperFunctions.RollbackTransaction();
                throw;
            }
            finally
            {
                // Clear the list of hash keys to free up memory.
                MediaObjectHashKeys.Clear();

                HelperFunctions.PurgeCache();
            }
        }