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

📄 submitarticlepanel.ascx.cs

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

	public abstract class SubmitArticlePanel : BaseUserControl
	{
		protected System.Web.UI.WebControls.TextBox Title;
		protected System.Web.UI.WebControls.TextBox Summary;
		protected System.Web.UI.WebControls.DropDownList ArticleType;
		protected System.Web.UI.WebControls.Button SaveButton;
		protected Interspire.ArticleLive.Web.MessageControl MessageControl1;
		protected Interspire.ArticleLive.Web.CategorySelect Categories;
		protected System.Web.UI.HtmlControls.HtmlInputFile File;
		protected Interspire.ArticleLive.Web.MessageControl MessageControl2;
		protected Interspire.ArticleLive.Web.ValidationAlerter ValidationAlerter1;
		protected CustomRequiredFieldValidator TitleReqVal;
		protected CustomRequiredFieldValidator SummaryReqVal;
		protected CustomRequiredFieldValidator CategoriesReqVal;
		protected CustomRequiredFieldValidator ArticleTypeReqVal;
		protected CustomRequiredFieldValidator FileReqVal;
		protected System.Web.UI.WebControls.TextBox ArticleUrl;
		protected CustomRegularExpressionValidator ArticleUrlRegExVal;
		protected Interspire.ArticleLive.Web.CustomRequiredFieldValidator ArticleUrlReqVal2;
		protected Interspire.ArticleLive.Web.CustomRequiredFieldValidator ArticleUrlReqVal;
		protected System.Web.UI.WebControls.Panel FormPanel;

		protected Article CurrentArticle
		{
			get { return (Article)ViewState["CurrentArticle"]; }
			set { ViewState["CurrentArticle"] = value; }
		}

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

		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!IsPostBack)
			{
				if (Action == "SubmitArticle")
				{
					if (!Request.IsAuthenticated)
						Response.Redirect(Config.Current.AuthorsPagePath + "?a=LogIn");
					else
					{
						if (!Security.Authorisation.UserHasPermission(UserPermissionsEnum.SubmitArticle))
						{
							if (Security.Authorisation.UserHasPermission(UserPermissionsEnum.CreateContent))
							{
								Response.Redirect(Config.Current.AdminPath + "/Articles.aspx?a=CreateArticle");
							}
							else
							{
								Response.Redirect(Config.Current.AuthorsPagePath + "?a=ViewAccount");
							}
						}

						SetDefaultButton(this.FormPanel, this.SaveButton);
						SetDefaultField(this.Title);

						Visible = true;
						WindowTitle = ResourceHelper.GetString("SubmitArticle");
						DataBind();
					}
				}
				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();

			this.Load += new System.EventHandler(this.Page_Load);
			this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);

			if (!IsPostBack)
			{
				ArticleType.Items.Add(new ListItem(ResourceHelper.GetString("FullArticle"), ((int)ArticleTypeEnum.FullArticle).ToString()));
				ArticleType.Items.Add(new ListItem(ResourceHelper.GetString("SummaryOnly"), ((int)ArticleTypeEnum.SummaryOnly).ToString()));
				ArticleType.Items.Add(new ListItem(ResourceHelper.GetString("SummaryLink"), ((int)ArticleTypeEnum.SummaryLink).ToString()));
			}

			base.OnInit(e);
		}
		
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void SaveButton_Click(object sender, System.EventArgs e)
		{
			if (IsValid)
			{
				Article article = new Article();
				article.AuthorID = ((Security.Identity)User.Identity).UserID;
				article.Title = Title.Text;
				article.Summary = Summary.Text;
				article.Type = (ArticleTypeEnum)Convert.ToInt32(ArticleType.SelectedItem.Value);
				article.ArticleUrl = ArticleUrl.Text;
				article.Status = ContentStatusEnum.Pending;
				article.CategoryIDs = Categories.SelectedCategoryIDs;
				article.Visible = true;

				ArticleEngine.SaveArticle(article, false);
				if (article.Type == ArticleTypeEnum.FullArticle)
				{
					article.File = FileHelper.UploadArticleFile(File.PostedFile, article.ArticleID);
					ArticleEngine.UpdateArticleFile(article);
				}

				MessageControl.Display(String.Format(ResourceHelper.GetString("SubmitArticleSuccess"), article.Title));

				Response.Redirect(Config.Current.AuthorsPagePath + "?a=ViewAccount");
			}
		}
	}
}

⌨️ 快捷键说明

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