Example #1
0
 protected void GetDataSource()
 {
     if (ViewState["Name"] != null)
     {
         rptAlbums.DataSource = module.GetAlbumService().GetAlbumList(true, ViewState["Name"].ToString());
     }
     else
     {
         rptAlbums.DataSource = module.GetAlbumService().GetAlbumList(true);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            _galleryModule = Module as GalleryModule;
            if (_galleryModule == null)
            {
                _galleryModule = _moduleLoader.GetModuleFromClassName("CMS.Modules.Gallery.GalleryModule") as GalleryModule;
            }
            _albumService = _galleryModule.GetAlbumService();
            _photoService = _galleryModule.GetPhotoService();

            if (Module != null)
            {
                btnCancel.Attributes.Add("onclick",
                                         String.Format("document.location.href='AdminGallery.aspx{0}'",
                                                       GetBaseQueryString()));
                btnMassImport.Click += btnMassImport_Click;

                if (Request.QueryString["AlbumId"] == null)
                {
                    return;
                }

                int albumId = Int32.Parse(Request.QueryString["AlbumId"]);

                if (albumId == 0 || albumId == -1)
                {
                    return;
                }

                _album = _albumService.GetAlbumById(albumId);

                if (!IsPostBack)
                {
                    BindAlbum();
                }

                btnDelete.Visible = true;
                btnDelete.Attributes.Add("onclick", "return confirm('Are you sure?');");

                if (!IsPostBack)
                {
                    DisplayFastImportPanel();
                }

                if (_album.Id > 0)
                {
                    FileUploaderAJAXPhotos.Visible = true;
                }
                else
                {
                    FileUploaderAJAXPhotos.Visible = false;
                }
                Session["GalleryPath"] = _galleryModule.PathBuilder.GetAlbumVirtualDirectory(_album.Id);
            }

            if (FileUploaderAJAXPhotos.IsPosting && Session["GalleryPath"] != null)
            {
                FileHelper.ManageAjaxPost(FileUploaderAJAXPhotos, 2000, Session["GalleryPath"] + "\\ToImport", HttpPostedFileAJAX.fileType.image, false, false);
            }
        }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _galleryModule = Module as GalleryModule;
     _album         = _galleryModule.GetAlbumService().GetAlbumById(_galleryModule.CurrentAlbumId);
     if (_album.PhotoCount == 0)
     {
         Visible = false;
         return;
     }
     rptReviews.DataSource = _album.Comments;
     rptReviews.DataBind();
     //GetXmlPath
 }
Example #4
0
        private void Page_Load(object sender, EventArgs e)
        {
            this._galleryModule = base.Module as GalleryModule;

            _albumService = _galleryModule.GetAlbumService();
            _photoService = _galleryModule.GetPhotoService();

            if (Request.QueryString["AlbumId"] != null)
            {
                this._albumId = Int32.Parse(Request.QueryString["AlbumId"]);
            }
            if (Request.QueryString["PhotoId"] != null)
            {
                this._photoId = Int32.Parse(Request.QueryString["PhotoId"]);
            }

            if (this._photoId > 0)
            {
                this._photo = _photoService.GetPhotoById(this._photoId);
                if (!this.IsPostBack)
                {
                    BindPhoto();
                }

                imThumb.ImageUrl = base.Page.ResolveUrl(
                    _galleryModule.VirtualPath(
                        _galleryModule.PathBuilder.GetThumbPath(_photo)));

                this.btnDelete.Visible = true;
                this.btnDelete.Attributes.Add("onclick", "return confirm('Are you sure?');");
            }
            else
            {
                // It is possible that a new file is already uploaded and in the database. The
                // tempPhotoId parameter in the viewstate should indicate this.
                if (ViewState["tempPhotoId"] != null)
                {
                    int tempPhotoId = (int)ViewState["tempPhotoId"];
                    this._photo = _photoService.GetPhotoById(tempPhotoId);
                }
                else
                {
                    // New file.
                    this._photo = new Photo();
                }

                this.btnDelete.Visible = false;
                this.imThumb.Visible   = false;
            }
        }
Example #5
0
        protected void pgrAlbums_CacheEmpty(object sender, EventArgs e)
        {
            AlbumService albumService = GalleryModule.GetAlbumService();

            if (_albumList == null)
            {
                _albumList = albumService.GetAlbumList(true);
            }


            if (_albumList != null)
            {
                AlbumDataList.DataSource = _albumList;
            }
        }
Example #6
0
        private void BindAlbums()
        {
            AlbumService albumService = GalleryModule.GetAlbumService();

            if (_albumList == null)
            {
                _albumList = albumService.GetAlbumList(true);
            }


            if (_albumList != null)
            {
                AlbumDataList.DataSource = _albumList;
                AlbumDataList.DataBind();
            }
        }
Example #7
0
        protected void buttonSubmit_Click(object sender, EventArgs e)
        {
            // Nếu đã đánh dấu I agree, có nội dung comment, có tên author, email hoặc đã đăng nhập
            if (chkAgree.Checked && !string.IsNullOrEmpty(textBoxComment.Text) && ((!string.IsNullOrEmpty(textBoxAuthor.Text) && !string.IsNullOrEmpty(textBoxEmail.Text)) || PageEngine.User.Identity is User))
            {
                if (textBoxVerifierCode.Text == imageVerifier.Text)
                {
                    AlbumComment comment = new AlbumComment();
                    comment.Deleted = false;
                    if (Page.User.Identity is User)
                    {
                        comment.Author   = ((User)Page.User.Identity).FullName;
                        comment.AuthorId = ((User)Page.User.Identity);
                        comment.Email    = ((User)Page.User.Identity).Email;
                    }
                    else
                    {
                        comment.Author   = textBoxAuthor.Text;
                        comment.AuthorId = null;
                        comment.Email    = textBoxEmail.Text;
                    }

                    comment.DateCreated  = DateTime.Now;
                    comment.DateModified = DateTime.Now;
                    comment.Comment      = textBoxComment.Text;
                    comment.Status       = 0;
                    comment.Album        = _album;
                    comment.IP           = Request.UserHostAddress;
                    chkAgree.Checked     = false;
                    textBoxComment.Text  = string.Empty;

                    _galleryModule.GetAlbumService().SaveOrUpdate(comment);

                    rptReviews.DataSource = _album.Comments;
                    rptReviews.DataBind();

                    imageVerifier.Refresh();
                }
                else
                {
                    labelFailedVerified.Visible = true;
                }
            }
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // The base page has already created the module, we only have to cast it here to the right type.
            _galleryModule = base.Module as GalleryModule;

            _albumService = _galleryModule.GetAlbumService();

            btnNew.Attributes.Add("onclick",
                                  String.Format("document.location.href='AdminAlbum.aspx{0}&AlbumId=-1'",
                                                base.GetBaseQueryString()));

            if (!IsPostBack)
            {
                textBoxTitle.Text    = Request.QueryString["title"];
                rptAlbums.DataSource = _albumService.GetAlbumList(false, Request.QueryString["title"]);
                rptAlbums.DataBind();
            }

            DefaultButton.SetDefault(Page, textBoxTitle, btnSearch);
        }
Example #9
0
        protected void ConvertAlbum(Album album)
        {
            // Tạo thư mục thumbnail
            DirectoryInfo thumb = new DirectoryInfo(_galleryModule.PathBuilder.GetAlbumDirectory(album.Id) + "\\thumbnails");

            if (!thumb.Exists)
            {
                thumb.Create();
            }

            foreach (Photo photo in album.Photos)
            {
                // Tạo thumbnail cho photo (copy từ thư mục gốc sang
                try
                {
                    FileInfo file = new FileInfo(_galleryModule.PathBuilder.GetOldThumbPath(photo));
                    file.MoveTo(thumb.FullName + @"\" + photo.FileName);
                }
                catch (FileNotFoundException)
                {
                    //_galleryModule.GetPhotoService().DeletePhoto(photo);
                    continue;
                }

                // Xóa trên thư mục gốc
                try
                {
                    FileInfo view = new FileInfo(_galleryModule.PathBuilder.GetPath(photo));
                    view.Delete();
                }
                catch (FileNotFoundException)
                {}
                catch (Exception ex)
                {
                    if (!(ex is FileNotFoundException))
                    {
                        ShowException(ex);
                        _logger.Error("Convert album failed", ex);
                        return;
                    }
                }

                // Đổi tên từ origin thành tên gốc
                try
                {
                    FileInfo origin = new FileInfo(_galleryModule.PathBuilder.GetOldPhotoOriginPath(photo));
                    origin.MoveTo(_galleryModule.PathBuilder.GetPath(photo));
                }
                catch (FileNotFoundException)
                {}
                catch (Exception ex)
                {
                    if (!(ex is FileNotFoundException))
                    {
                        ShowException(ex);
                        _logger.Error("Convert album failed", ex);
                        return;
                    }
                }
            }

            album.UseSimpleViewer = true;
            _galleryModule.GetAlbumService().SaveAlbumInfo(album);
            _logger.Error("Album converted successully");
        }