Ejemplo n.º 1
0
        private Album GetProfileImagesAlbum(LibrariesManager manager)
        {
            var album = manager.GetAlbums().FirstOrDefault(l => l.Title == ProfileModel.ProfileImagesAlbumTitle);

            if (album == null)
            {
                album         = manager.CreateAlbum();
                album.Title   = ProfileModel.ProfileImagesAlbumTitle;
                album.UrlName = ProfileModel.ProfileImagesAlbumUrl;
            }

            return(album);
        }
        protected void CreateNewAlbum(out Album album, string AlbumTitle, LibrariesManager librariesManager)
        {
            album = librariesManager.CreateAlbum(Guid.NewGuid());

            //Set the properties of the album.
            album.Title = AlbumTitle;
            album.DateCreated = DateTime.UtcNow;
            album.LastModified = DateTime.UtcNow;
            album.UrlName = Regex.Replace(AlbumTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

            //Save the changes.
            librariesManager.SaveChanges();
        }
        private Guid CreateImageNativeAPI(string imageTitle, Stream imageStream, string imageExtension, LibrariesManager librariesManager)
        {
            Album album = librariesManager.GetAlbums().Where(al => al.Title == "Facebook Users").FirstOrDefault();
            if (album == null)
            {
                Guid albumId = Guid.NewGuid();

                album = librariesManager.GetAlbums().Where(a => a.Id == albumId).FirstOrDefault();

                if (album == null)
                {
                    //Create the album.
                    album = librariesManager.CreateAlbum(albumId);

                    //Set the properties of the album.
                    album.Title = "Facebook Users";
                    album.DateCreated = DateTime.UtcNow;
                    album.LastModified = DateTime.UtcNow;
                    album.UrlName = Regex.Replace("Facebook Users".ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

                    //Save the changes.
                    librariesManager.SaveChanges();
                }

                album = librariesManager.GetAlbum(albumId);
            }

                //The album post is created as master. The masterImageId is assigned to the master version.
                Image image = librariesManager.CreateImage();

                librariesManager.SaveChanges();
                librariesManager.Provider.SuppressSecurityChecks = true;
                //Set the parent album.

                //Set the properties of the profile image
                image.Title = imageTitle;
                image.DateCreated = DateTime.UtcNow;
                image.PublicationDate = DateTime.UtcNow;
                image.LastModified = DateTime.UtcNow;
                image.UrlName = Regex.Replace(imageTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

                librariesManager.Provider.SuppressSecurityChecks = true;
                image.Parent = album;

                //Upload the image file.
                librariesManager.Upload(image, imageStream, imageExtension);

                //Save the changes.
                librariesManager.SaveChanges();

                //Publish the Albums item. The live version acquires new ID.
                var bag = new Dictionary<string, string>();
                bag.Add("ContentType", typeof(Image).FullName);
                WorkflowManager.MessageWorkflow(image.Id, typeof(Image), null, "Publish", false, bag);

                return image.Id;
        }
Ejemplo n.º 4
0
        private Album GetProfileImagesAlbum(LibrariesManager manager)
        {
            var album = manager.GetAlbums().FirstOrDefault(l => l.Title == ProfileModel.ProfileImagesAlbumTitle);
            if (album == null)
            {
                album = manager.CreateAlbum();
                album.Title = ProfileModel.ProfileImagesAlbumTitle;
                album.UrlName = ProfileModel.ProfileImagesAlbumUrl;
            }

            return album;
        }
Ejemplo n.º 5
0
        private Guid CreateImageNativeAPI(string imageTitle, Stream imageStream, string imageExtension, LibrariesManager librariesManager)
        {
            Album album = librariesManager.GetAlbums().Where(al => al.Title == "Facebook Users").FirstOrDefault();

            if (album == null)
            {
                Guid albumId = Guid.NewGuid();

                album = librariesManager.GetAlbums().Where(a => a.Id == albumId).FirstOrDefault();

                if (album == null)
                {
                    //Create the album.
                    album = librariesManager.CreateAlbum(albumId);

                    //Set the properties of the album.
                    album.Title        = "Facebook Users";
                    album.DateCreated  = DateTime.UtcNow;
                    album.LastModified = DateTime.UtcNow;
                    album.UrlName      = Regex.Replace("Facebook Users".ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

                    //Save the changes.
                    librariesManager.SaveChanges();
                }

                album = librariesManager.GetAlbum(albumId);
            }

            //The album post is created as master. The masterImageId is assigned to the master version.
            Image image = librariesManager.CreateImage();


            librariesManager.SaveChanges();
            librariesManager.Provider.SuppressSecurityChecks = true;
            //Set the parent album.



            //Set the properties of the profile image
            image.Title           = imageTitle;
            image.DateCreated     = DateTime.UtcNow;
            image.PublicationDate = DateTime.UtcNow;
            image.LastModified    = DateTime.UtcNow;
            image.UrlName         = Regex.Replace(imageTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

            librariesManager.Provider.SuppressSecurityChecks = true;
            image.Parent = album;

            //Upload the image file.
            librariesManager.Upload(image, imageStream, imageExtension);

            //Save the changes.
            librariesManager.SaveChanges();

            //Publish the Albums item. The live version acquires new ID.
            var bag = new Dictionary <string, string>();

            bag.Add("ContentType", typeof(Image).FullName);
            WorkflowManager.MessageWorkflow(image.Id, typeof(Image), null, "Publish", false, bag);

            return(image.Id);
        }