Beispiel #1
0
        protected virtual void LoadSettings()
        {
            currentuser = SiteUtils.GetCurrentSiteUser();
            if (currentuser == null)
            {
                WebUtils.SetupRedirect(this, SiteRoot);
            }
            else
            {
                author = KLAuthor.GetKLAuthorByUserID(currentuser.UserId);
            }
            bookid = WebUtils.ParseInt32FromQueryString("BookID", bookid);
            if (bookid != -1)
            {
                book = new KLBook(bookid);
            }


            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p != null)
            {
                fileSystem = p.GetFileSystem();
            }
        }
Beispiel #2
0
        private void Btndelete_Click(object sender, EventArgs e)
        {
            try
            {
                bool isdeleted = false;

                foreach (GridDataItem data in grid.SelectedItems)
                {
                    int    bookid = Convert.ToInt32(data.GetDataKeyValue("BookID"));
                    KLBook book   = new KLBook(bookid);
                    if (book != null && book.BookID != -1)
                    {
                        KLBook.Delete(book.BookID);
                    }
                    isdeleted = true;
                }

                if (isdeleted)
                {
                    SiteUtils.QueueIndexing();
                    CurrentPage.UpdateLastModifiedTime();
                    grid.Rebind();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
 private void LoadParams()
 {
     pagenum  = WebUtils.ParseInt32FromQueryString("page", pagenum);
     authorID = WebUtils.ParseInt32FromQueryString("id", authorID);
     //xong
     if (authorID > -1)
     {
         book = KLBook.GetPageByAuthorid(pagenum, pageSize, out totalPage, authorID, "").ToList();
     }
 }
Beispiel #4
0
        private void Btnsearch_Click(object sender, EventArgs e)
        {
            grid.PagerStyle.EnableSEOPaging = false;
            bool isApplied     = gridPersister.IsAppliedSortFilterOrGroup;
            int  iCount        = KLBook.GetCount();
            int  startRowIndex = isApplied ? 1 : grid.CurrentPageIndex + 1;
            int  maximumRows   = isApplied ? iCount : grid.PageSize;

            grid.VirtualItemCount  = iCount;
            grid.AllowCustomPaging = !isApplied;
            grid.DataSource        = KLBook.GetPageByAuthorid(startRowIndex, maximumRows, out iCount, author.AuthorID, txtsearch.Text);
        }
Beispiel #5
0
        private string GetBooks()
        {
            KLBook books = new KLBook();

            try
            {
                books = new KLBook(int.Parse(postParams.Get("bookid")));
                return(StringHelper.ToJsonString(new
                {
                    success = true,
                    bookTitle = books.Title,
                    bookImageSrc = "/data/Sites/1/Book/" + books.BookID + "/" + books.Image,
                    bookDesc = books.Description,
                    bookUrl = books.Url
                }));
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }

            return(null);
        }
Beispiel #6
0
        private int Save()
        {
            Page.Validate("Books");

            if (!Page.IsValid)
            {
                return(-1);
            }

            if (currentuser == null)
            {
                return(-1);
            }
            if (book == null)
            {
                book            = new KLBook();
                book.AuthorID   = author.AuthorID;
                book.IsPublish  = true;
                book.IsDelected = false;
            }
            book.Title       = txttitle.Text;
            book.Url         = txtURl.Text;
            book.Description = fullcontent.Text;
            if (book.Save())
            {
                imageFolderPath = BookHelper.MediaFolderPath(siteSettings.SiteId, book.BookID);

                if (fileImages.UploadedFiles.Count > 0)
                {
                    BookHelper.VerifyBookFolders(fileSystem, imageFolderPath);

                    foreach (UploadedFile file in fileImages.UploadedFiles)
                    {
                        string ext = file.GetExtension();
                        if (SiteUtils.IsAllowedUploadBrowseFile(ext, WebConfigSettings.ImageFileExtensions))
                        {
                            ContentMedia media = new ContentMedia();
                            media.SiteGuid = siteSettings.SiteGuid;
                            //image.Title = txtImageTitle.Text;
                            media.DisplayOrder = 0;

                            string newFileName  = file.FileName.ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                            string newImagePath = VirtualPathUtility.Combine(imageFolderPath, newFileName);

                            if (media.MediaFile == newFileName)
                            {
                                // an existing image delete the old one
                                fileSystem.DeleteFile(newImagePath);
                            }
                            else
                            {
                                // this is a new newsImage instance, make sure we don't use the same file name as any other instance
                                int i = 1;
                                while (fileSystem.FileExists(VirtualPathUtility.Combine(imageFolderPath, newFileName)))
                                {
                                    newFileName = i.ToInvariantString() + newFileName;
                                    i          += 1;
                                }
                            }

                            newImagePath = VirtualPathUtility.Combine(imageFolderPath, newFileName);

                            file.SaveAs(Server.MapPath(newImagePath));

                            media.MediaFile     = newFileName;
                            media.ThumbnailFile = newFileName;

                            book.Image = newFileName;
                            media.Save();
                            BookHelper.ProcessImage(media, fileSystem, imageFolderPath, file.FileName);
                        }
                    }
                }
            }
            if (book.Save())
            {
                LogActivity.Write("Create new news", book.Title);
                message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "InsertSuccessMessage");
            }
            return(book.BookID);
        }