示例#1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (IsPost)
            {
                switch (AjaxAction)
                {
                    case "LibraryPage.save":
                        SaveArticle();
                        break;
                }
            }
            else
            {
                if (Request["id"] != null)
                {
                    CurrentArticle = Article.Get(Request["id"].Trim());
                }

                if (CurrentArticle == null)
                {
                    CurrentArticle = new Article();
                }
            }
        }
示例#2
0
        private void SaveArticle()
        {
            Response.Clear();
            try
            {
                int id = Convert.ToInt32(Request.Form["libId"]);
                CurrentArticle = new Article();
                CurrentArticle.Title = Request.Form["title"].Trim();
                CurrentArticle.ShortTitle = Request.Form["stitle"].Trim();
                CurrentArticle.Classes = Request.Form["classes"].Trim();
                CurrentArticle.Categories = Request.Form["categories"].Trim();
                CurrentArticle.Tags = Request.Form["tags"].Trim();
                CurrentArticle.Content = Request.Form["txtContent"].Trim();
                CurrentArticle.Save(id);

                Tag.AddTag(CurrentArticle.Tags.Split(new char[] { ',',' ',';','£¬'}));
                Tag.Save();

                //·¢²¼
                //PagePublisher.PublishArticleViewPage(new string[] { CurrentArticle.Guid });

                Response.Write(CurrentArticle.Id);
            }
            catch
            {
                //throw;
            }
            Response.End();
        }
示例#3
0
        public static Article Get(string guid,bool addHits)
        {
            /*
             LibraryGet
            @id varchar(32)
            @addHits bit
             */

            //[Id], Guid, Template, Classes, Categorys, Title, ShortTitle, Thumbnail,[Datetime], Tags, Content, Editor, Share,Hits

            Article article = null;

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "LibraryGet",
                    new SqlParameter[] { Database.MakeInParam("@id", SqlDbType.VarChar, 32, guid) });
                if (reader.Read())
                {
                    article = new Article();
                    article.id = reader.GetInt32(0);
                    article.guid = reader.GetString(1);
                    article.templateId = reader.GetString(2);
                    article.classes = reader.GetString(3);
                    article.categories = reader.GetString(4);
                    article.title = reader.GetString(5);
                    article.shortTitle = reader.GetString(6);
                    article.thumbnail = reader.GetString(7);
                    article.datetime = reader.GetDateTime(8);
                    article.tags = reader.GetString(9);
                    article.content = reader.GetString(10);
                    article.editor = reader.GetString(11);
                    article.share = reader.GetString(12) == "1";
                    article.hits = reader.GetInt32(13);
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return article;
        }
示例#4
0
 protected LibraryPage()
     : base()
 {
     CurrentArticle = new Article();
 }