⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewarticlepanel.ascx.cs

📁 Portal C# Article Live
💻 CS
字号:
namespace Interspire.ArticleLive.Web.Templates.DefaultStretched.Panels
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;
	using System.Web.Mail;

	public abstract class ViewArticlePanel : BaseUserControl
	{
		protected System.Web.UI.WebControls.Repeater RelatedLinksList;
		protected System.Web.UI.WebControls.Repeater RelatedArticlesList;
		protected System.Web.UI.WebControls.PlaceHolder Placeholder1;
		protected System.Web.UI.WebControls.PlaceHolder Placeholder2;
		protected System.Web.UI.WebControls.PlaceHolder Placeholder3;
		protected System.Web.UI.WebControls.Repeater SeriesList;
		protected System.Web.UI.WebControls.Button FeedbackSubmitButton;
		protected Interspire.ArticleLive.Web.RatingControl ArticleRating;
		protected System.Web.UI.WebControls.TextBox ArticleComment;
		protected System.Web.UI.WebControls.Repeater PageNumberList;
		protected System.Web.UI.WebControls.LinkButton NextPageButton;
		protected System.Web.UI.WebControls.Repeater CommentsList;
		protected System.Web.UI.WebControls.Repeater CategoryTrails;
		protected System.Web.UI.WebControls.Repeater Repeater1;
		protected System.Web.UI.WebControls.Panel ArticleFeedbackPanel;
		protected System.Web.UI.WebControls.Panel ArticleFeedbackSubmittedPanel;
		protected RatingDisplayControl VisitorRating;
		protected RatingDisplayControl AverageRating;
		protected RatingDisplayControl RatingDisplay;
		protected System.Web.UI.WebControls.PlaceHolder Placeholder4;
		protected System.Web.UI.WebControls.Repeater Repeater2;
		protected Interspire.ArticleLive.Web.ValidationAlerter ValidationAlerter1;
		protected CustomRadioButtonListRequiredFieldValidator ArticleRatingReqVal;
		protected System.Web.UI.WebControls.CheckBoxList FeedbackRecipient;
		protected Interspire.ArticleLive.Web.CustomCheckBoxListRequiredFieldValidator FeedbackRecipientReqVal;
		protected System.Web.UI.WebControls.Repeater Repeater3;
		protected System.Web.UI.WebControls.HyperLink Hyperlink1;
	
		#region Data
		protected int CurrentPageIndex
		{
			get 
			{
				if (ViewState["CurrentPageIndex"] == null)
					ViewState["CurrentPageIndex"] = 0;
				return (int)ViewState["CurrentPageIndex"];
			}
			set 
			{
				ViewState["CurrentPageIndex"] = value;
				//PageList.SelectedIndex = value;
				//PageNumberList.DataBind();
				try
				{
					DataBind();
				}
				catch (ArgumentOutOfRangeException)
				{
					// Do nothing...last page
				}
			}
		}

		private ArticleEngine articleEngine;
		public ArticleEngine ArticleEngine
		{
			get 
			{
				if (articleEngine == null)
					articleEngine = new ArticleEngine(Config.Current);
				return articleEngine; }
		}

		private UserEngine authorEngine;
		public UserEngine AuthorEngine
		{
			get 
			{
				if (authorEngine == null)
					authorEngine = new UserEngine(Config.Current);
				return authorEngine; }
		}

		private CommentEngine commentEngine;
		public CommentEngine CommentEngine
		{
			get 
			{
				if (commentEngine == null)
					commentEngine = new CommentEngine(Config.Current);
				return commentEngine; }
		}

		private Article currentArticle;
		protected Article CurrentArticle
		{
			get { return currentArticle; }
			set { currentArticle = value; }
		}

		private ArticleSet articleSeries;
		protected ArticleSet ArticleSeries
		{
			get { return articleSeries; }
			set { articleSeries = value; }
		}

		private CategorySet[] currentTrails;
		protected CategorySet[] CurrentTrails
		{
			get { return currentTrails; }
			set { currentTrails = value; }
		}

		private Comment currentComment;
		protected Comment CurrentComment
		{
			get { return currentComment; }
			set { currentComment = value; }
		}

		protected int SeriesPartNumber
		{
			get 
			{
				foreach (Article article in ArticleSeries)
				{
					if (article.ArticleID == CurrentArticle.ArticleID)
						return ArticleSeries.IndexOf(article)+1;
				}
				return 0;
			}
		}
		#endregion

		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!Page.IsClientScriptBlockRegistered("helpTip.js"))
				Page.RegisterClientScriptBlock("helpTip.js", "<script language='javascript' src='" + Config.Current.ApplicationPath + "/Javascript/helpTip.js'></script>");

			if (Action == "ViewArticle")
			{
				int articleID = Convert.ToInt32(Request.QueryString["ArticleID"]);//QueryStringHelper.GetInt32("ArticleID", 1);
				if (articleID <= 0)
					Visible = false;
				else
				{
					int pageIndex = 0;
					if (Request.QueryString["Page"] != null)
					{
						if (QueryStringHelper.GetString("Page") == "Last")
							pageIndex = CurrentArticle.Pages.Count-1;
						else
						{
							try
							{
								pageIndex = QueryStringHelper.GetInt32("Page")-1;
							}
							catch
							{
								// Ignore
							}
						}
					}
					Visible = true;
					ViewArticle(articleID, pageIndex);
				}
			}
			else
				Visible = false;
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();

			RelatedLinksList.EnableViewState = false;
			RelatedArticlesList.EnableViewState = false;
			SeriesList.EnableViewState = false;

			this.Load += new System.EventHandler(this.Page_Load);
			this.FeedbackSubmitButton.Click += new System.EventHandler(this.FeedbackSubmitButton_Click);

			if (!IsPostBack)
			{
				this.FeedbackRecipient.Items.Add(new ListItem(ResourceHelper.GetString("SendToAuthor"), ((int)FeedbackRecipientEnum.Author).ToString()));
				this.FeedbackRecipient.Items.Add(new ListItem(ResourceHelper.GetString("PostOnSite"), ((int)FeedbackRecipientEnum.Site).ToString()));
				foreach (ListItem item in this.FeedbackRecipient.Items)
				{
					item.Selected = true;
				}
			}

			base.OnInit(e);
		}
	
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{

		}
		#endregion

		private void ViewArticle(int articleID)
		{
			ViewArticle(articleID, 0);
		}

		private void ViewArticle(int articleID, int pageIndex)
		{
			CurrentArticle = ArticleEngine.GetArticle(articleID, true, true, true, true, true, true);

			if (CurrentArticle == null)
				MessageControl.RedirectError(ResourceHelper.GetString("ArticleNotFound"));

			WindowTitle = CurrentArticle.Title;

			// Record the article view and add to history
			if (!UserFunctions.ArticleIsInHistory(articleID))
				ArticleEngine.RecordArticleView(articleID);
			UserFunctions.AddArticleToHistory(CurrentArticle.ArticleID);

			if (CurrentArticle.Type == ArticleTypeEnum.SummaryLink)
			{
				Response.Redirect(CurrentArticle.ArticleUrl);
			}
			else
			{
				ArticleSeries = ArticleEngine.GetArticleSeries(CurrentArticle.ArticleID);
				CurrentTrails = (new CategoryEngine(Config.Current)).GetCategoryTrails(0, CurrentArticle.ArticleID);
				CurrentComment = (new CommentEngine(Config.Current)).GetArticleReaderComment(CurrentArticle.ArticleID, UserFunctions.GetCommentIDs());
				CurrentPageIndex = pageIndex;
				DataBind();
			}
		}

		private void FeedbackSubmitButton_Click(object sender, System.EventArgs e)
		{
			if (Util.RenderIE())
			{
				Page.RegisterClientScriptBlock(Guid.NewGuid().ToString(), "<script>document.location.href = '#FeedbackPanel';</script>");
			}

			FeedbackRecipientEnum recipient = FeedbackRecipientEnum.NotSet;
			if (FeedbackRecipient.Items[0].Selected)
				recipient = recipient | FeedbackRecipientEnum.Author;
			if (FeedbackRecipient.Items[1].Selected)
				recipient = recipient | FeedbackRecipientEnum.Site;
			CurrentComment = new Comment();
			CurrentComment.Date = DateTime.Now;
			CurrentComment.ContentID = CurrentArticle.ArticleID;
			CurrentComment.Details = ArticleComment.Text;
			CurrentComment.Rating = ArticleRating.SelectedRating;
			CurrentComment.Status = ContentStatusEnum.Pending;
			CurrentComment.Type = CommentTypeEnum.Article;
			ArticleEngine.RateArticle(CurrentArticle, CurrentComment.Rating);
			if ((recipient & FeedbackRecipientEnum.Author) == FeedbackRecipientEnum.Author)
			{
				string webSiteLink = "<a href='" + Config.Current.WebSiteUrl + "'>" + Config.Current.WebSiteName + "</a>";
				string contentLink = "<a href='" + LinkHelper.CreateArticleLink((Article)CurrentArticle, true) + "'>" + LinkHelper.CreateArticleLink(CurrentArticle, true) + "</a>";
				string subject = String.Format(ResourceHelper.GetString("SendCommentSubject"), Config.Current.WebSiteName);
				string body = String.Format(ResourceHelper.GetString("SendArticleCommentBody"), webSiteLink, CurrentArticle.Title, contentLink, CurrentComment.Rating, CurrentComment.Details);
				(new UserEngine(Config.Current)).SendUserEmail(CurrentArticle.AuthorID, subject, body);

				ArticleFeedbackPanel.Visible = false;
				ArticleFeedbackSubmittedPanel.Visible = true;

				DataBind();

			}
			if ((recipient & FeedbackRecipientEnum.Site) == FeedbackRecipientEnum.Site)
			{
				if (CurrentComment.Details != String.Empty)
					CommentEngine.SaveComment(CurrentComment);

				UserFunctions.AddComment(CurrentComment.CommentID);

				ArticleFeedbackPanel.Visible = false;
				ArticleFeedbackSubmittedPanel.Visible = true;

				DataBind();
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -