void btnUpdate_Click(object sender, EventArgs e) { try { bool isUpdated = false; foreach (GridDataItem data in grid.Items) { CheckBox cbActive = (CheckBox)data.FindControl("cbActive"); int authorID = Convert.ToInt32(data.GetDataKeyValue("AuthorID")); bool active = Convert.ToBoolean(data.GetDataKeyValue("IsActive")); if (cbActive.Checked != active) { KLAuthor author = new KLAuthor(authorID); if (author != null && author.AuthorID != -1) { author.IsActive = cbActive.Checked; author.Save(); isUpdated = true; } } } if (isUpdated) { grid.Rebind(); message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage"); } } catch (Exception ex) { log.Error(ex); } }
private int SendComments() { if (txtcomment.Text.Trim() != "") { newcomment = new KLNewsComment(); try { newcomment.Comment = txtcomment.Text; newcomment.CreateDate = DateTime.Now; newcomment.Email = txtEmail.Text; newcomment.Name = txtFullName.Text; newcomment.UserID = currentUser.UserId; newcomment.NewsID = newsID; newcomment.Save(); KLNotify notify = new KLNotify(); KLAuthor author = new KLAuthor(news.AuthorID); notify.AuthorID = author.UserID; notify.UserName_Action = txtFullName.Text; notify.DateCreate = DateTime.Now; notify.NotifyType = "Comment"; notify.Viewed = false; News newsKL = new News(siteSettings.SiteId, news.NewsID); notify.Notify = ResourceFile.GetResourceString("CustomResources", "NotifyComment") + newsKL.Title; notify.NotifyLink = SiteRoot + "/news-detail?newsID=" + news.NewsID; notify.Save(); } catch (Exception ex) { log.Error(ex.Message); } return(newcomment.CommentID); } return(-1); }
protected KLAuthor GetAuthor(int newsID) { var News = KLNews.GetAll().Where(n => n.NewsID == newsID).SingleOrDefault(); var author = new KLAuthor(News.AuthorID); return(author); }
void btnDelete_Click(object sender, EventArgs e) { try { bool isDeleted = false; foreach (GridDataItem data in grid.SelectedItems) { int authorID = Convert.ToInt32(data.GetDataKeyValue("AuthorID")); //CheckBox cbDelete = (CheckBox)data.FindControl("cbDelete"); //bool isDel = Convert.ToBoolean(data.GetDataKeyValue("IsDel")); KLAuthor author = new KLAuthor(authorID); if (author != null && author.AuthorID != -1) { author.IsDel = true; author.Save(); isDeleted = true; } } if (isDeleted) { SiteUtils.QueueIndexing(); grid.Rebind(); message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage"); } } catch (Exception ex) { log.Error(ex); } }
protected virtual void LoadSettings() { FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider]; if (p != null) { fileSystem = p.GetFileSystem(); } current = SiteUtils.GetCurrentSiteUser(); if (current != null) { author = KLAuthor.GetKLAuthorByUserID(current.UserId); GeneralVariables.NameAuthor = current.Name; GeneralVariables.Level = author.LevelAuthor; if (author != null) { txtfb.Text = author.LinkFacebook; txtinstagram.Text = author.LinkInstagram; txtpinterest.Text = author.LinkPinterest; txttwinter.Text = author.LinkTwitter; txtFullName.Text = author.Name; txtEmail.Text = current.Email; editDescription.Content = current.Signature; ImageAvatar.ImageUrl = AuthorHepper.GetAvatarAuthor(siteSettings.SiteId, author.UserID); } } else { WebUtils.SetupRedirect(this, SiteRoot); } }
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(); } }
protected virtual void LoadSettings() { SiteUser site = SiteUtils.GetCurrentSiteUser(); author = KLAuthor.GetKLAuthorByUserID(site.UserId); if (author == null) { WebUtils.SetupRedirect(this, SiteRoot); } GeneralVariables.NameAuthor = site.Name; GeneralVariables.Level = author.LevelAuthor; search = WebUtils.ParseStringFromQueryString("search", search); status = WebUtils.ParseStringFromQueryString("status", status); switch (status) { case "": all = true; break; case "draft": isdraft = true; isapproved = false; break; case "posted": isapproved = true; isdraft = false; break; case "pending": isapproved = false; break; } }
protected string getName(int authorid) { KLAuthor author = new KLAuthor(authorID); SiteUser user = new SiteUser(siteSettings, author.UserID); return(user.Name); }
//protected string getBlockName(string id) //{ // GNBlock gb = new GNBlock(int.Parse(id)); // return gb.Name; //} #region "RadGrid Event" void grid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { bool isApplied = gridPersister.IsAppliedSortFilterOrGroup; int iCount = KLAuthor.GetCount(); int startRowIndex = isApplied ? 1 : grid.CurrentPageIndex + 1; int maximumRows = isApplied ? iCount : grid.PageSize; grid.DataSource = KLAuthor.GetPage(startRowIndex, maximumRows, out iCount).Where(a => a.IsDel == false).OrderByDescending(or => or.JoinDate).ToList(); }
private void LoadParams() { currentUser = SiteUtils.GetCurrentSiteUser(); if (currentUser != null) { author = KLAuthor.GetKLAuthorByUserID(currentUser.UserId); } else { WebUtils.SetupRedirect(this, SiteRoot); } }
protected void Page_Load(object sender, EventArgs e) { currentUser = SiteUtils.GetCurrentSiteUser(); siteSettings = CacheHelper.GetCurrentSiteSettings(); newsID = WebUtils.ParseInt32FromQueryString("newsID", newsID); if (isUpdated) { updateViewCount(newsID); isUpdated = false; } ListImageSlider = GetListImageSlider(newsID); Author = GetAuthor(newsID); HotNews = GetHotNews(); News = new News(siteSettings.SiteId, newsID); }
protected void Page_Load(object sender, EventArgs e) { LoadSettings(); //totalPages = News.GetCountBySearch(siteSettings.SiteId, zoneId.ToString(), config.NewsType, -1, null, -1, -1, -1, null, null, null, null, null, string.Empty); int totalRow = News.GetCount(siteSettings.SiteId, -1, -1, -1, -1); lstNewsTop5 = News.GetPageBySearch(siteSettings.SiteId, null, 0, 1, null, -1, -1, -1, null, null, null, null, null, -1, -1, string.Empty, 1, totalRow).OrderByDescending(n => n.Viewed).Take(5).ToList(); lstNewsMostOfWeek = GetNewsMostOfWeek(); lstAuthorMostArticle = KLAuthor.GetAll().Where(a => a.IsActive == true).OrderByDescending(n => n.ArticleCount).Take(10).ToList(); if (like > 0) { KLNews news = KLNews.GetAll().Where(n => n.NewsID == like).SingleOrDefault(); news.LikeCount += 1; news.Save(); } }
private void LoadSettings() { currentUser = SiteUtils.GetCurrentSiteUser(); newsID = WebUtils.ParseInt32FromQueryString("newsID", newsID); siteSettings = CacheHelper.GetCurrentSiteSettings(); timeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); if (currentUser == null) { imgAvatar.ImageUrl = "/Data/Sites/1/Author/Authordefault.png"; currentUser = SiteUser.GetByEmail(siteSettings, "*****@*****.**"); } else { author = KLAuthor.GetKLAuthorByUserID(currentUser.UserId); imgAvatar.ImageUrl = AuthorHepper.MediaFolderPath(1, author.UserID) + author.Avatar; txtEmail.Text = currentUser.Email; txtFullName.Text = currentUser.Name; } news = new KLNews(newsID, 0); }
protected void rptComments_ItemCommand(object source, RepeaterCommandEventArgs e) { TextBox txtsubname = (TextBox)e.Item.FindControl("txtsubname"); TextBox txtsubemail = (TextBox)e.Item.FindControl("txtsubemail"); TextBox txtsubcomment = (TextBox)e.Item.FindControl("txtsubcomment"); HiddenField commentid = (HiddenField)e.Item.FindControl("hdcommentid"); KLNewsComment subcomment = null; if (txtsubcomment.Text.Trim() != "") { subcomment = new KLNewsComment(); try { subcomment.Comment = txtsubcomment.Text; subcomment.CreateDate = DateTime.Now; subcomment.Email = txtsubemail.Text; subcomment.Name = txtsubname.Text; subcomment.UserID = currentUser.UserId; subcomment.NewsID = newsID; subcomment.CommentParentID = int.Parse(commentid.Value); subcomment.Save(); KLNotify notify = new KLNotify(); KLAuthor author = new KLAuthor(news.AuthorID); notify.AuthorID = author.UserID; notify.UserName_Action = txtsubname.Text; notify.DateCreate = DateTime.Now; notify.NotifyType = "Comment"; notify.Viewed = false; News newsKL = new News(siteSettings.SiteId, news.NewsID); notify.Notify = ResourceFile.GetResourceString("CustomResources", "NotifyComment") + newsKL.Title; notify.NotifyLink = SiteRoot + "/news-detail?newsID=" + news.NewsID; notify.Save(); divmessagecomment.InnerHtml = AlertSuccess(); } catch (Exception ex) { log.Error(ex.Message); } } }
protected virtual void LoadSettings() { currentuser = SiteUtils.GetCurrentSiteUser(); author = KLAuthor.GetKLAuthorByUserID(currentuser.UserId); currentuser = SiteUtils.GetCurrentSiteUser(); if (currentuser == null) { WebUtils.SetupRedirect(this, SiteRoot); } else { author = KLAuthor.GetKLAuthorByUserID(currentuser.UserId); } guestid = WebUtils.ParseInt32FromQueryString("GuestID", guestid); if (guestid != -1) { gratitude = new KLGratitude(guestid); txtgratitude.Text = gratitude.Comment; } }