Пример #1
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="mod">ArticleInfo</param>
        /// <returns>受影响行数</returns>
        public int Update(ArticleInfo mod)
        {
           using (DbConnection conn = db.CreateConnection())
			{
				conn.Open();
				using (DbTransaction tran = conn.BeginTransaction())
				{ 
					try
					{ 
						using (DbCommand cmd = db.GetStoredProcCommand("SP_Article_Update"))
						{
							db.AddInParameter(cmd, "@ArticleID", DbType.Int32, mod.ArticleID); 
							db.AddInParameter(cmd, "@Title", DbType.String, mod.Title); 
							db.AddInParameter(cmd, "@State", DbType.Int32, mod.State); 
							db.AddInParameter(cmd, "@IsDeleted", DbType.Int32, mod.IsDeleted); 
							db.AddInParameter(cmd, "@Sort", DbType.Int32, mod.Sort); 
							tran.Commit();
							return db.ExecuteNonQuery(cmd);
						} 
					}
					catch (Exception e)
					{
						tran.Rollback();
						throw e;
					}
					finally
					{
						conn.Close();
					}
				}
			}
        }  
    //Handles insert article
    public void Add_Article(Object s, EventArgs e)
    {
        //Instantiate article information object.
        ArticleInfo AddArticle = new ArticleInfo();

        AddArticle.Title = Request.Form["Title"];
        AddArticle.Content = Request.Form["Content"];
        AddArticle.Author = Request.Form["Author"];
        AddArticle.CatID = (int)Util.Val(Request.QueryString["catid"]);
        AddArticle.Keyword = Request.Form["Keyword"];
        AddArticle.Summary = Request.Form["Summary"];

        //Notify user if error occured.
        if (AddArticle.Add() != 0)
        {
            JSLiteral.Text = "Error occured while processing your submit.";
            return;
        }

        //Release allocated memory
        AddArticle = null;
        Util = null;

        int getlastID;
        getlastID = int.Parse(Label1.Text) + 1;

        //If success, redirect to confirmation and thank you page.
        Response.Redirect("articlepreview.aspx?aid=" + getlastID);
    }
Пример #3
0
 private void SerializeInternal(ArticleInfo model, IDictionary<string, object> result)
 { 
     result.Add("articleid", model.ArticleID);
     result.Add("title", model.Title);
     result.Add("state", model.State);
     result.Add("isdeleted", model.IsDeleted);
     result.Add("sort", model.Sort);
 }
Пример #4
0
 /// <summary>
 /// Тест для возрата статьи по Идентификатору и проверка наименования и рубрики
 /// </summary>
 /// <param name="id">Идентификатор</param>
 /// <param name="headingID">Ссылка на рубрику</param>
 /// <param name="checkName">Наименвание</param>
 private void GetIDAnCheckNameTest(int id, int headingID, string checkName)
 {
     using (var dataProvider = new DataProvider())
     {
         ArticleInfo articleInfo = dataProvider.Article.GetByID(id);
         Assert.IsNotNull(articleInfo);
         Assert.AreEqual(checkName, articleInfo.Name);
         Assert.AreEqual(headingID, articleInfo.HeadingID);
     }
 }
Пример #5
0
 public static Article Convert(ArticleInfo articleInfo)
 {
     return(new Article()
     {
         Id = articleInfo.Id,
         Title = articleInfo.Title,
         Text = articleInfo.Text,
         Author = articleInfo.Author
     });
 }
Пример #6
0
 //[ExpectedException(typeof(ArgumentException))]
 public void EditTestThrowsExceptionIfEmpty()
 {
     using (var dataProvider = new DataProvider())
     {
         ArticleInfo articleInfo = dataProvider.Article.GetByID(15);
         Assert.IsNotNull(articleInfo);
         Assert.ThrowsException <ArgumentException>(() =>
                                                    dataProvider.Article.Edit(1, "", "", "", 0, "", null, false));
     }
 }
Пример #7
0
 private void btnAddArticle_Click(object sender, EventArgs e)
 {
     if (!dropArticleCategory.SelectedValue.HasValue)
     {
         ShowMsg("请选择文章分类", false);
     }
     else
     {
         ArticleInfo article = ArticleHelper.GetArticle(articleId);
         if (fileUpload.HasFile)
         {
             try
             {
                 ResourcesHelper.DeleteImage(article.IconUrl);
                 article.IconUrl = ArticleHelper.UploadArticleImage(fileUpload.PostedFile);
                 imgPic.ImageUrl = article.IconUrl;
             }
             catch
             {
                 ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
                 return;
             }
         }
         article.ArticleId       = articleId;
         article.CategoryId      = dropArticleCategory.SelectedValue.Value;
         article.Title           = txtArticleTitle.Text.Trim();
         article.MetaDescription = txtMetaDescription.Text.Trim();
         article.MetaKeywords    = txtMetaKeywords.Text.Trim();
         article.Description     = txtShortDesc.Text.Trim();
         article.Content         = fcContent.Text;
         article.AddedDate       = DateTime.Now;
         article.IsRelease       = ckrrelease.Checked;
         ValidationResults results = Hishop.Components.Validation.Validation.Validate <ArticleInfo>(article, new string[] { "ValArticleInfo" });
         string            msg     = string.Empty;
         if (results.IsValid)
         {
             if (ArticleHelper.UpdateArticle(article))
             {
                 ShowMsg("已经成功修改当前文章", true);
             }
             else
             {
                 ShowMsg("修改文章失败", false);
             }
         }
         else
         {
             foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             ShowMsg(msg, false);
         }
     }
 }
 protected override void AttachChildControls()
 {
     this.itemID     = Globals.RequestQueryNum("iid");
     this.singleID   = Globals.RequestQueryNum("sid");
     this.imgUrl     = (HiImage)this.FindControl("imgUrl");
     this.litContent = (Literal)this.FindControl("litContent");
     this.LitJs      = (Literal)this.FindControl("LitJs");
     if (this.singleID > 0)
     {
         ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(this.singleID);
         if (articleInfo != null)
         {
             this.htmlTitle       = articleInfo.Title;
             this.imgUrl.ImageUrl = articleInfo.ImageUrl;
             this.litContent.Text = articleInfo.Content;
             string imageUrl = articleInfo.ImageUrl;
             if (!imageUrl.ToLower().StartsWith("http"))
             {
                 imageUrl = Globals.GetWebUrlStart() + imageUrl;
             }
             string str2 = Globals.ReplaceHtmlTag(articleInfo.Memo, 50);
             this.LitJs.Text = "<script>wxinshare_title ='" + this.Page.Server.HtmlEncode(this.htmlTitle.Replace("\n", "").Replace("\r", "")) + "';wxinshare_desc = '" + this.Page.Server.HtmlEncode(str2.Replace("\n", "").Replace("\r", "")) + "';wxinshare_link = location.href;wxinshare_imgurl = '" + imageUrl + "';</script>";
         }
         else
         {
             base.GotoResourceNotFound("");
         }
     }
     else if (this.itemID > 0)
     {
         ArticleItemsInfo articleItemsInfo = ArticleHelper.GetArticleItemsInfo(this.itemID);
         if (articleItemsInfo != null)
         {
             this.htmlTitle       = articleItemsInfo.Title;
             this.imgUrl.ImageUrl = articleItemsInfo.ImageUrl;
             this.litContent.Text = articleItemsInfo.Content;
             string str3 = articleItemsInfo.ImageUrl;
             if (!str3.ToLower().StartsWith("http"))
             {
                 str3 = Globals.GetWebUrlStart() + str3;
             }
             string str4 = Globals.ReplaceHtmlTag(articleItemsInfo.Content, 50);
             this.LitJs.Text = "<script>wxinshare_title ='" + this.Page.Server.HtmlEncode(this.htmlTitle.Replace("\n", "").Replace("\r", "")) + "';wxinshare_desc = '" + this.Page.Server.HtmlEncode(str4.Replace("\n", "").Replace("\r", "")) + "';wxinshare_link = location.href;wxinshare_imgurl = '" + str3 + "';</script>";
         }
         else
         {
             base.GotoResourceNotFound("");
         }
     }
     else
     {
         base.GotoResourceNotFound("");
     }
     PageTitle.AddSiteNameTitle(this.htmlTitle);
 }
Пример #9
0
        public void GetArticleOk()
        {
            var mockArticleRepository = new Mock <IArticleRepository>();
            var articleId             = Guid.NewGuid();
            var articleTitle          = "article title";
            var articleText           = "article text";
            var articleAuthor         = "bob";

            mockArticleRepository.Setup(x => x.Get(articleId)).Returns(
                new Article
            {
                Id     = articleId,
                Title  = articleTitle,
                Text   = articleText,
                Author = articleAuthor
            }.ToOption()
                );
            var mockCommentsRepository = new Mock <ICommentRepository>();
            var commentId     = Guid.NewGuid();
            var commentText   = "comment text";
            var commentAuthor = "bob";

            mockCommentsRepository.Setup(x => x.GetForArticle(articleId)).Returns(
                new List <Comment>
            {
                new Comment
                {
                    Id        = commentId,
                    ArticleId = articleId,
                    Text      = commentText,
                    Author    = commentAuthor
                }
            }
                );
            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.Setup(x => x.GetRepository <ICommentRepository>()).Returns(mockCommentsRepository.Object);
            mockUnitOfWork.Setup(x => x.GetRepository <IArticleRepository>()).Returns(mockArticleRepository.Object);
            var mockUnitOfWorkFactory = new Mock <IUnitOfWorkFactory>();

            mockUnitOfWorkFactory.Setup(x => x.Create()).Returns(mockUnitOfWork.Object);
            var articleProcessor = new ArticleProcessorUoW(mockUnitOfWorkFactory.Object);

            ArticleInfo result        = articleProcessor.GetArticleInfo(articleId);
            var         resultComment = result.Comments.FirstOrDefault();

            Assert.NotNull(result);
            Assert.AreEqual(articleTitle, result.Title);
            Assert.AreEqual(articleAuthor, result.Author);
            Assert.AreEqual(articleText, result.Text);
            Assert.AreEqual(1, result.Comments.Count);
            Assert.NotNull(resultComment);
            Assert.AreEqual(commentText, resultComment.Text);
            Assert.AreEqual(commentAuthor, resultComment.Author);
        }
Пример #10
0
        public ArticleInfo GetDataByAid(int id)
        {
            ArticleInfo info   = new ArticleInfo();
            IDataReader reader = db.GetDataByA_Id(id).CreateDataReader();

            if (reader.Read())
            {
                info = ArticleInfo.Populate(reader);
            }
            return(info);
        }
Пример #11
0
 public static int AddArticle(ArticleInfo article)
 {
     article.ID = dal.AddArticle(article);
     UploadBLL.UpdateUpload(TableID, 0, article.ID, Cookies.Admin.GetRandomNumber(false));
     if (article.ClassID.IndexOf("|" + 2 + "|") > -1)
     {
         CacheHelper.Remove(cacheKey);
     }
     FirstArticleDc = null;
     return(article.ID);
 }
Пример #12
0
        public List <ArticleInfo> getAllByShow(bool show)
        {
            List <ArticleInfo> infos  = new List <ArticleInfo>();
            IDataReader        reader = db.GetDataByShow(show).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(ArticleInfo.Populate(reader));
            }
            return(infos);
        }
Пример #13
0
        public ArticleInfo GetDataOrderIdDESC()
        {
            ArticleInfo info   = new ArticleInfo();
            IDataReader reader = db.GetDataOrderIdDESC().CreateDataReader();

            if (reader.Read())
            {
                info = ArticleInfo.Populate(reader);
            }
            return(info);
        }
Пример #14
0
 /// <summary>
 /// 添加扩展信息,主要生成文章URL
 /// </summary>
 /// <param name="model"></param>
 /// <param name="language"></param>
 private static void LoadExtensionInfo(ArticleInfo model)
 {
     if (!string.IsNullOrEmpty(model.LinkUrl))
     {
         model.Url = model.LinkUrl;
     }
     else
     {
         model.Url = string.Format("/n/{0}.html", model.FullTimespan);
     }
 }
Пример #15
0
        public IActionResult Update(string id, ArticleInfo articleIn)
        {
            var article = _articleService.Get(id);

            if (article == null)
            {
                return(NotFound());
            }
            _articleService.Update(id, articleIn);
            return(NoContent());
        }
Пример #16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack && (this.LocalArticleID > 0))
     {
         ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(this.LocalArticleID);
         if (articleInfo != null)
         {
             this.htmlJs = string.Concat(new object[] { "closeModal('#MyPictureIframe', 'txtContent', '", articleInfo.Url, "', '", base.Server.HtmlEncode(articleInfo.Title), "', '", base.Server.HtmlEncode(articleInfo.Memo), "', '", base.Server.HtmlEncode(articleInfo.ImageUrl), "', ", articleInfo.ArticleId, ")" });
         }
     }
 }
Пример #17
0
 /// <summary>
 /// 添加扩展信息,主要生成文章URL
 /// </summary>
 /// <param name="model"></param>
 /// <param name="language"></param>
 private static void LoadExtensionInfo(ArticleInfo model, WebLanguage language = WebLanguage.zh_cn)
 {
     if (!string.IsNullOrEmpty(model.LinkUrl))
     {
         model.Url = model.LinkUrl;
     }
     else
     {
         model.Url = string.Format("{2}/{0}/{1}.html", "n", model.GUID.ToString().ToLower(), language == WebLanguage.zh_cn ? string.Empty : "/" + language.ToString());
     }
 }
Пример #18
0
        public List <ArticleInfo> GetDataById(int id)
        {
            List <ArticleInfo> infos  = new List <ArticleInfo>();
            IDataReader        reader = db.GetDataByA_Id(id).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(ArticleInfo.Populate(reader));
            }
            return(infos);
        }
Пример #19
0
        public List <ArticleInfo> GetDataByCategoryOrderSort(int ac_id)
        {
            List <ArticleInfo> infos  = new List <ArticleInfo>();
            IDataReader        reader = db.GetDataByCategoryOrderSort(ac_id).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(ArticleInfo.Populate(reader));
            }
            return(infos);
        }
Пример #20
0
        /// <summary>
        /// 删除文章
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="serverPath"></param>
        public void Delete(int articleId, string serverPath)
        {
            ArticleInfo article = GetById(articleId);

            article.isDeleted = true;
            string content = article.content.Replace("*gt;", ">").Replace("*lt;", "<").Replace("*amp", "&");

            string[] imgs = GetImgPath(content);
            Update(article);
            DeleteImgFile(imgs, serverPath);
        }
Пример #21
0
 // Construction From ArticleInfo
 public ArticleModel(ArticleInfo a)
 {
     Id          = a.Id;
     Title       = a.Title;
     FeedId      = a.FeedId;
     Description = a.Description;
     Source      = new Uri(a.Source);
     PubDate     = a.PubDate;
     _isStarred  = a.Isstarred;
     _unread     = a.Unread;
 }
Пример #22
0
        public void UpdateArticleDisplaySequence(long id, long displaySequence)
        {
            ArticleInfo articleInfo = context.ArticleInfo.FindById <ArticleInfo>(id);

            if (articleInfo == null)
            {
                throw new HimallException(string.Concat("未找到id为", id, "的文章"));
            }
            articleInfo.DisplaySequence = displaySequence;
            context.SaveChanges();
        }
Пример #23
0
        /// <summary>
        /// 根据节点id获取文章详细信息
        /// </summary>
        /// <param name="nodeId">节点id</param>
        /// <returns>文章详细内容</returns>
        public DataEntity <Articles> GetDatailByNodeId(int nodeId)
        {
            DataEntity <Articles> data = new DataEntity <Articles>();
            Articles art = new Articles();

            try
            {
                List <ArticleDetail> detailList = db.ArticleDetail.Where(p => p.nodeId == nodeId).OrderBy(p => p.orders).ToList();
                if (detailList == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }

                Node node = db.Nodes.Find(nodeId);

                List <ArticleInfo> infoList = new List <ArticleInfo>();

                foreach (ArticleDetail ad in detailList)
                {
                    ArticleInfo info = new ArticleInfo();

                    info.detailType = ad.detailType;

                    if (ad.detailType == "image" || ad.detailType == "video")
                    {
                        info.detailContent = Util.GetBlobUrl(ad.detailContent);
                    }
                    else
                    {
                        info.detailContent = ad.detailContent;
                    }

                    infoList.Add(info);
                }

                art.title        = node.nodeName;
                art.createPerson = node.createPerson;
                art.createDate   = node.createDate;
                art.detailList   = infoList;

                data.StatusCode = 200;
                data.ErrorMsg   = "";
                data.Data       = art;
            }
            catch (Exception ex)
            {
                data.StatusCode = 500;
                data.ErrorMsg   = ex.Message;
                data.Data       = null;
            }

            return(data);
        }
Пример #24
0
 public IActionResult Update([FromBody] ArticleInfo articleInfo)
 {
     try
     {
         _articleDal.Update(articleInfo);
         return(Ok(articleInfo));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Пример #25
0
 public IActionResult Add([FromBody] ArticleInfo articleInfo)
 {
     try
     {
         _articleDal.Add(articleInfo);
         return(new StatusCodeResult(201));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Пример #26
0
        /// <summary>
        /// 修改ArticleInfo
        /// </summary>
        /// <param name="article"></param>
        /// <returns></returns>
        public static int UpdateArticle(ArticleInfo article)
        {
            string sql = @"UPDATE  [Article] SET 
						Title=@Title,
						Content=@Content,
						Type=@Type,
						CommentNum=@CommentNum,
						Dot=@Dot,
						CreateTime=@CreateTime,
						UserId=@UserId,
						ImgNum=@ImgNum,
						AttachmentNum=@AttachmentNum,
						LastEditUserId=@LastEditUserId,
						LastEditTime=@LastEditTime,
						Guid=@Guid,
						IsDelete=@IsDelete,
						State=@State,
						RefuseReason=@RefuseReason,
						BType=@BType,
						DianZanNum=@DianZanNum,
						Score=@Score,
						IsStick=@IsStick,
						IsJiaJing=@IsJiaJing,
						IsCloseComment=@IsCloseComment,
						CloseCommentReason=@CloseCommentReason
 WHERE Id=@Id";
            var    par = new DynamicParameters();

            par.Add("@Id", article.Id, DbType.Int64);
            par.Add("@Title", article.Title, DbType.String);
            par.Add("@Content", article.Content, DbType.AnsiString);
            par.Add("@Type", article.Type, DbType.Int32);
            par.Add("@CommentNum", article.CommentNum, DbType.Int32);
            par.Add("@Dot", article.Dot, DbType.Int32);
            par.Add("@CreateTime", article.CreateTime, DbType.DateTime);
            par.Add("@UserId", article.UserId, DbType.Int32);
            par.Add("@ImgNum", article.ImgNum, DbType.Int32);
            par.Add("@AttachmentNum", article.AttachmentNum, DbType.Int32);
            par.Add("@LastEditUserId", article.LastEditUserId, DbType.Int32);
            par.Add("@LastEditTime", article.LastEditTime, DbType.DateTime);
            par.Add("@Guid", article.Guid, DbType.Guid);
            par.Add("@IsDelete", article.IsDelete, DbType.Boolean);
            par.Add("@State", article.State, DbType.Int16);
            par.Add("@RefuseReason", article.RefuseReason, DbType.String);
            par.Add("@BType", article.BType, DbType.Int16);
            par.Add("@DianZanNum", article.DianZanNum, DbType.Int32);
            par.Add("@Score", article.Score, DbType.Int32);
            par.Add("@IsStick", article.IsStick, DbType.Boolean);
            par.Add("@IsJiaJing", article.IsJiaJing, DbType.Boolean);
            par.Add("@IsCloseComment", article.IsCloseComment, DbType.Boolean);
            par.Add("@CloseCommentReason", article.CloseCommentReason, DbType.String);
            return(DapWrapper.InnerExecuteSql(DbConfig.ArticleManagerConnString, sql, par));
        }
Пример #27
0
    /// <summary>
    /// 根据文章ID获取文章信息表信息
    /// </summary>
    /// <param name="articleId"></param>
    /// <returns></returns>
    public static ArticleInfo GetArticleInfoById(int articleId)
    {
        ArticleInfo article = null;

        lock (mLockObj)
        {
            mdb.Connect();
            article = ArticleInfoData.GetArticleInfoByArticleId(articleId, mdb.GetConn);
            mdb.Disconnect();
        }
        return(article);
    }
Пример #28
0
        public void BtnAdd_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            var articleId = Convert.ToInt32(Request.QueryString["articleId"]);

            if (articleId > 0)
            {
                try
                {
                    var articleInfo = ArticleDao.GetArticleInfo(articleId);

                    articleInfo.Title   = TbTitle.Text;
                    articleInfo.IsFree  = Convert.ToBoolean(DdlIsFree.SelectedValue);
                    articleInfo.Content = TbContent.Text;

                    ArticleDao.Update(articleInfo);

                    isChanged = true;
                }
                catch (Exception ex)
                {
                    LtlModalAddMessage.Text = Utils.GetMessageHtml("信息修改失败:" + ex.Message, false);
                }
            }
            else
            {
                try
                {
                    var articleInfo = new ArticleInfo
                    {
                        SiteId    = _siteId,
                        ContentId = _contentId,
                        Title     = TbTitle.Text,
                        IsFree    = Convert.ToBoolean(DdlIsFree.SelectedValue),
                        Content   = TbContent.Text
                    };

                    ArticleDao.Insert(articleInfo);

                    isChanged = true;
                }
                catch (Exception ex)
                {
                    LtlModalAddMessage.Text = Utils.GetMessageHtml("信息添加失败:" + ex.Message, false);
                }
            }

            if (isChanged)
            {
                Response.Redirect(GetRedirectUrl(_siteId, _contentId));
            }
        }
Пример #29
0
 public static void LoadExtensionInfo(ArticleInfo model, WebLanguage language = WebLanguage.zh_cn)
 {
     //
     if (!string.IsNullOrEmpty(model.LinkUrl))
     {
         model.Url = model.LinkUrl;
     }
     else
     {
         model.Url = string.Format("{2}/{0}/{1}.html", model.CreateDateTime.ToString("yyyy-MM-dd"), model.Timespan, language == WebLanguage.zh_cn ? string.Empty : "/" + language.ToString());
     }
 }
        /// <summary>
        /// 获取杂志详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ArticleDetile GetArticleByID(int id)
        {
            ArticleDetile article = new ArticleDetile();
            ArticleInfo   info    = ChuanDong.Robot.BLL.Article.GetArticle(id);

            article.id      = info.ID;
            article.mid     = info.CategoryID;
            article.time    = info.Joindate.ToString();
            article.title   = info.Title;
            article.content = info.Content;
            return(article);
        }
Пример #31
0
 private static ArticleViewModel MapToViewModel(Article article, ArticleInfo articleInfo)
 {
     return(new ArticleViewModel
     {
         Id = article.Id,
         Title = article.Title,
         Created = article.Created,
         Published = article.Published,
         ViewsCount = articleInfo != null ? articleInfo.ViewsCount : 0,
         CommentsCount = articleInfo != null ? articleInfo.CommentsCount : 0
     });
 }
Пример #32
0
        /// <summary>
        /// 添加日志--文章
        /// </summary>
        /// <param name="articleInfo"></param>
        /// <param name="title"></param>
        public static void AddLog(ArticleInfo articleInfo, string title, string ip)
        {
            //添加日志
            LogInfo logInfo = new LogInfo();

            logInfo.Title      = title;
            logInfo.CreateTime = DateTime.Now;
            logInfo.UserName   = articleInfo.Author;
            logInfo.Content    = title + "-" + articleInfo.Title;
            logInfo.Ip         = ip;
            Log.Add(logInfo);
        }
Пример #33
0
    /// <summary>
    /// 根据用户ID更新文章信息表信息
    /// </summary>
    /// <param name="articleId"></param>
    /// <param name="articleInfo"></param>
    /// <returns></returns>
    public static bool UpdateArticleInfoById(int articleId, ArticleInfo articleInfo)
    {
        bool result = false;

        lock (mLockObj)
        {
            mdb.Connect();
            result = ArticleInfoData.UpdateArticleInfoById(articleId, articleInfo, mdb.GetConn);
            mdb.Disconnect();
        }
        return(result);
    }
Пример #34
0
 protected override void Page_Show()
 {
     int articleid = Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString["id"]);
     if (articleid <= 0)
     {
         articleid = 1;
     }
     articleinfo = Articles.GetArticleInfo(articleid);
     if (articleinfo == null)
     {
         System.Web.HttpContext.Current.Response.Write("不存在的文章!");
         System.Web.HttpContext.Current.Response.End();
     }
     pagetitle = string.Format("{0} - {1} - iTCA 重庆工学院计算机协会", Utils.RemoveHtml(articleinfo.Title), articleinfo.Columnname);
 }
Пример #35
0
 protected void Page_Load(object sender, EventArgs e)
 {
     articleid = Convert.ToInt32(Request.QueryString["articleid"]);
     articleinfo = Articles.GetArticleInfo(articleid);
     if (articleinfo != null)
     {
         lbMessage.Text = string.Format("确定删除文章: {0} 吗?", articleinfo.Title);
     }
     else
     {
         lbMessage.Text = "不存在此文章,请返回!";
         btnYes.Visible = false;
         btnCancel.Visible = false;
     }
 }
Пример #36
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     ArticleInfo articleinfo = new ArticleInfo();
     articleinfo.Columnid = Convert.ToInt32(ddlColumns.SelectedValue);
     articleinfo.Title = tbxTitle.Text.Trim();
     articleinfo.Highlight = ddlHightlight.SelectedValue;
     articleinfo.Content = tbxContent.Text.TrimEnd();
     articleinfo.Postdate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
     articleinfo.Uid = 1;
     articleinfo.Username = "******";
     if (articleid > 0)
     {
         articleinfo.Articleid = articleid;
         Articles.EditArticle(articleinfo);
     }
     else
     {
         Articles.CreateArticle(articleinfo);
     }
     Response.Redirect("articlelist.aspx?cid=" + articleinfo.Columnid);
 }
Пример #37
0
 /// <summary>
 /// 将DataReader的Article转换为ArticleInfo泛型列表
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 private static ArticleInfo DataReader2ArticleInfo(IDataReader reader)
 {
     ArticleInfo info = new ArticleInfo();
     info.Articleid = Convert.ToInt32(reader["articleid"]);
     info.Columnid = Convert.ToInt32(reader["columnid"]);
     info.Title = reader["title"].ToString();
     info.Badcount = Convert.ToInt32(reader["badcount"]);
     info.Goodcount = Convert.ToInt32(reader["goodcount"]);
     info.Commentcount = Convert.ToInt32(reader["commentcount"]);
     info.Viewcount = Convert.ToInt32(reader["viewcount"]);
     info.Sort = Convert.ToInt32(reader["sort"]);
     info.Highlight = reader["highlight"].ToString();
     info.Summary = reader["summary"].ToString();
     info.Content = reader["content"].ToString();
     info.Image = reader["image"].ToString();
     info.Uid = Convert.ToInt32(reader["uid"]);
     info.Username = reader["username"].ToString();
     info.Ip = reader["ip"].ToString();
     info.Postdate = Convert.ToDateTime(reader["postdate"]).ToString("yyyy-MM-dd");
     info.Del = Convert.ToInt32(reader["del"]);
     //高亮主题
     if (info.Highlight != "")
     {
         info.Title = string.Format("<span style=\"{0}\">{1}</span>", info.Highlight, info.Title);
     }
     //文章的栏目前缀
     if (info.Columnid > 0)
     {
         info.Columnname = GetColumnName(info.Columnid);
     }
     else
     {
         info.Columnname = "";
     }
     return info;
 }
Пример #38
0
        public void EditArticle(ArticleInfo articleinfo)
        {
            DbParameter[] prams = 
		    {
			    DbHelper.MakeInParam("@title", DbType.String, 100,articleinfo.Title),
			    DbHelper.MakeInParam("@columnid", DbType.Int32, 4,articleinfo.Columnid),
			    DbHelper.MakeInParam("@highlight", DbType.String, 20,articleinfo.Highlight),
			    DbHelper.MakeInParam("@content", DbType.String, 5000,articleinfo.Content),
			    DbHelper.MakeInParam("@postdate", DbType.DateTime, 8,articleinfo.Postdate),
			    DbHelper.MakeInParam("@uid", DbType.Int32, 4,articleinfo.Uid),
			    DbHelper.MakeInParam("@username", DbType.String, 20,articleinfo.Username),
			    DbHelper.MakeInParam("@articleid", DbType.Int32, 4,articleinfo.Articleid)
		    };
            DbHelper.ExecuteNonQuery(CommandType.Text, "UPDATE wy_articles SET title=@title,columnid=@columnid,highlight=@highlight,content=@content,postdate=@postdate,uid=@uid,username=@username WHERE articleid=@articleid", prams);
        }
Пример #39
0
 /// <summary>
 /// 发布新文章
 /// </summary>
 /// <param name="articleinfo"></param>
 public static void CreateArticle(ArticleInfo articleinfo)
 {
     DatabaseProvider.GetInstance().CreateArticle(articleinfo);
 }
Пример #40
0
 /// <summary>
 /// 取得文章内容
 /// </summary>
 /// <param name="articleid">文章id</param>
 /// <returns>AritlceInfo</returns>
 public static ArticleInfo GetArticleInfo(int articleid)
 {
     ArticleInfo info = new ArticleInfo();
     IDataReader reader = DatabaseProvider.GetInstance().GetArticleInfo(articleid);
     if (reader.Read())
     {
         info = DataReader2ArticleInfo(reader);
     }
     else
     {
         info = null;
     }
     reader.Close();
     return info;
 }
Пример #41
0
        public void CreateArticle(ArticleInfo articleinfo)
        {
            DbParameter[] prams = 
		    {
			    DbHelper.MakeInParam("@title", DbType.String, 100,articleinfo.Title),
			    DbHelper.MakeInParam("@columnid", DbType.Int32, 4,articleinfo.Columnid),
			    DbHelper.MakeInParam("@highlight", DbType.String, 20,articleinfo.Highlight),
			    DbHelper.MakeInParam("@content", DbType.String, 5000,articleinfo.Content),
			    DbHelper.MakeInParam("@postdate", DbType.DateTime, 8,articleinfo.Postdate),
			    DbHelper.MakeInParam("@uid", DbType.Int32, 4,articleinfo.Uid),
			    DbHelper.MakeInParam("@username", DbType.String, 20,articleinfo.Username)
		    };
            DbHelper.ExecuteNonQuery(CommandType.Text, "INSERT INTO wy_articles(title,columnid,highlight,content,postdate,uid,username) VALUES(@title,@columnid,@highlight,@content,@postdate,@uid,@username)", prams);
        }
Пример #42
0
        /// <summary>
        /// 根据分页获得数据列表
        /// </summary>
        /// <param name="TbFields">返回字段</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="OrderField">排序字段</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页尺寸</param> 
        /// <param name="TotalCount">返回总记录数</param>
        /// <returns>IList<ArticleInfo></returns>
        public IList<ArticleInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount)
        {
			IList<ArticleInfo> list = new List<ArticleInfo>();
			using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation"))
			{
				db.AddInParameter(cmd, "@TbName", DbType.String, "Article");
				db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields);
				db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere);
				db.AddInParameter(cmd, "@OrderField", DbType.String, orderField);
				db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex);
				db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize);
				db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue);
				using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
				{
					if (dt.Rows.Count > 0)
					{
						foreach (DataRow dr in dt.Rows)
						{
							ArticleInfo model = new ArticleInfo();
							model.LoadFromDataRow(dr);
							list.Add(model);
						}
					}
				}

				totalCount = (int)db.GetParameterValue(cmd, "@Total");
				return list;
			}
		} 
        private void UpdateArticle()
        {
		try{
            ArticleInfo objArticle = new ArticleInfo();
            objArticle.Id = ArticleId;
            objArticle.PortalId = PortalId;
			objArticle.PublishTime = PublishHour.SelectedItem.Text + ":" + PublishMinute.SelectedItem.Text + " " + PublishAMPM.SelectedItem.Text;
            //Normal 
            objArticle.Title = txtTitle.Text;
            objArticle.Author = txtAuthor.Text;
			objArticle.Keywords = txtKeywords.Text;
			
			objArticle.Image = txtImage.Text;
            objArticle.Thumbnail = txtImage.Text;

            /*if (drpThumbnailImage.SelectedItem.Text != "")
            {
                objArticle.Image = "/Portals/"+customTransactions.PortalId+"/" + drpThumbnailImage.SelectedItem.Text;
                objArticle.Thumbnail = "/Portals/"+customTransactions.PortalId+"/" + drpThumbnailImage.SelectedItem.Text;
            }
            else
            {
                objArticle.Image = null;
                objArticle.Thumbnail = null;
            }*/
            //objArticle.TopStoriesImage = "/Portals/0/" + drpTopStoriesPosition.SelectedItem.Text;

			objArticle.TopStoriesImage = null;
			/*
            if (d1.SelectedItem.Text != "")
            {
                objArticle.TopStoriesImage = "/Portals/0/" + d1.SelectedItem.Text;
            }
            else
            {
                objArticle.TopStoriesImage = null;
            }
			*/
            //Add Categories
            objArticle.Categories = RecursiveHelper.GetAspNetTreeCheckList(tvCategory);

            //Add Tags
            objArticle.Tags = "";
            TagInfo objTag = new TagInfo();
            listData.InnerText = "";
            List<int> tagList = new List<int>();
            foreach (ListItem li in CheckBoxList1.Items)
            {
                if (li.Selected)
                {
                    if (listData.InnerText == "")
                    {
                        objTag = TagController.GetByTag(li.Value.Trim());
                        tagList.Add(objTag.Id);
                    }
                }
            }

            var newTaglist = (from p in tagList select p).Distinct();//remove the  repeated tag item.

            foreach (int item in newTaglist)
            {
                objArticle.Tags += item.ToString() + ",";
            }
            objArticle.Tags = Utils.RemoveSeperator(objArticle.Tags, ",");
            //Tags end

            //date
            if ((txtPublishDate.Text != null) && (txtPublishDate.Text != ""))
            {
                objArticle.PublishDate = Convert.ToDateTime(txtPublishDate.Text);
            }
            else
            {
                objArticle.PublishDate = DateTime.Now;
            }
            if (txtExpireDate.Text != "")
            {
                objArticle.ExpireDate = Convert.ToDateTime(txtExpireDate.Text);
            }

            objArticle.ViewRoles = Utils.GetCheckedItems(cblViewRoles, PortalSettings.AdministratorRoleId);
            //Rating
            objArticle.AllowRating = chkAllowRating.Checked;
            objArticle.RatingRoles = Utils.GetCheckedItems(cblRatingRoles, PortalSettings.AdministratorRoleId);

            //Recommend
            objArticle.AllowRecommend = chkAllowRecommend.Checked;
            objArticle.RecommendRoles = Utils.GetCheckedItems(cblRecommendRoles, PortalSettings.AdministratorRoleId);


            //Comment
            objArticle.AllowComment = chkAllowComment.Checked;
            objArticle.CommentRoles = Utils.GetCheckedItems(cblCommentRoles, PortalSettings.AdministratorRoleId);
            objArticle.AutoAuthComment = chkAutoAuthComment.Checked;
            //Download roles
            objArticle.DownloadRoles = Utils.GetCheckedItems(cblDownloadRoles, PortalSettings.AdministratorRoleId);

            objArticle.Summary = LocalUtils.RemoveAllHtmlTags(txtSummary.Text);
            objArticle.Article = Editor1.Text.Replace("src=&quot;Portals", "src=&quot;/Portals");
            objArticle.UserId = UserId;
            objArticle.Authed = chkPublish.Checked;
            //Now processing attachment
            int newArticleId = -1;
			objBusinessLogic.ArticleID = ArticleId;
            objBusinessLogic.IsPagingEnable = chkPaging.Checked;
            //Page.ClientScript.RegisterStartupScript(this.GetType(), 			 
            //"mKey","alert("+ArticleController.Get(ArticleId).ToString()+")" , true);       

			
            if (ArticleId == -1)
            {                
                newArticleId = ArticleController.Add(objArticle);                
                ArticleId = newArticleId;
				objBusinessLogic.ArticleID = newArticleId;
                objBusinessLogic.UpdateExtraFieldArticle();
            }
            else
            {
                ArticleController.Update(objArticle);
                newArticleId = ArticleId;
				objBusinessLogic.UpdateExtraFieldArticle();
                AttachmentController.DeleteByArticle(ArticleId); //delete attachment first.
            }
            AttachmentInfo ai = new AttachmentInfo();
            foreach (AttachmentInfo item in AttachmentList)
            {
                ai.ArticleId = newArticleId;
                ai.FilePath = item.FilePath;
                AttachmentController.Add(ai);
            }
            //Reset all 
            //ArticleId = -1;
            AttachmentList = new List<AttachmentInfo>();
            gvAttachment.DataSource = AttachmentList;
			
            gvAttachment.DataBind();
			}
			
			catch(Exception Ex)
			{
						Response.Write(Ex.ToString());
			}
        }
    //Handle the delete button click event
    public void Delete_Article(Object sender, RepeaterCommandEventArgs e)
    {
        if ((e.CommandName == "Delete"))
        {
            //Instantiate article delete object
            ArticleInfo DeleteArticle = new ArticleInfo();

            DeleteArticle.ID = Convert.ToInt32(e.CommandArgument);

            Caching.PurgeCacheItems("Newest_Articles");
            Caching.PurgeCacheItems("ArticleCategory_SideMenu");

            //Perform delete
            DeleteArticle.Delete();

            //Release allocated memory
            DeleteArticle = null;

            //Redirect to confirm delete page
            Response.Redirect("articlemanager.aspx");
        }
    }
Пример #45
0
        private void CollectArticles()
        {
            if (RunTime._articles != null)
                foreach (ArticleInfo i in RunTime._articles)
                    if (i != null && i._model != null && _targetModels.Contains(i._model))
                        RemoveTarget(i._model);

            if (Manager.Moveset != null && Manager.Moveset.Data != null)
            {
                RunTime._articles = new ArticleInfo[Manager.Moveset.Data._articles.Count];
                foreach (ArticleEntry article in Manager.Moveset.Data._articles.Values)
                {
                    ArticleInfo articleInfo = new ArticleInfo(article, null, false);

                    int groupID = article.ARCGroupID;
                    if (groupID >= 0)
                    {
                        //First load models in the recolor pac
                        //These models are always visible
                        LoadArticles(Manager.SelectedInfo._characterFiles, groupID, articleInfo, true);

                        //Now load extra articles that will be called later
                        LoadArticles(Manager.SelectedInfo._characterEtcFiles, groupID, articleInfo, false);
                    }
                    RunTime._articles[article.Index] = articleInfo;
                }
            }
        }
Пример #46
0
        private void LoadArticles(Dictionary<int, Dictionary<ARCFileType, List<ARCEntryNode>>> t1, int groupID, ArticleInfo info, bool addTarget)
        {
            if (t1.ContainsKey(groupID))
            {
                var t2 = t1[groupID];
                if (t2.ContainsKey(ARCFileType.ModelData))
                {
                    List<ARCEntryNode> entries = t2[ARCFileType.ModelData];
                    foreach (ARCEntryNode e in entries)
                    {
                        //Don't load shadow models or main models
                        if (e.FileIndex == 10 || e.GroupID == 0)
                            continue;

                        MDL0Node model = e.Children[0].Children[0] as MDL0Node;
                        info._model = model;

                        MDL0BoneNode cBone = info._article.CharBoneNode;
                        if (cBone != null && info._article.ArticleBoneNode != null)
                        {
                            MDL0BoneNode aBone = info._article.ArticleBoneNode;
                            aBone.OverrideBone = cBone;
                        }

                        if (addTarget)
                        {
                            info.Running = true;
                            info._etcModel = false;
                            AddTarget(info._model);
                        }
                    }
                }
                if (t2.ContainsKey(ARCFileType.AnimationData))
                {
                    List<ARCEntryNode> entries = t2[ARCFileType.AnimationData];
                    foreach (ARCEntryNode u in entries)
                        foreach (BRESGroupNode b in u.Children)
                        {
                            AnimationNode anim = b.Children[0] as AnimationNode;
                            switch (b.Type)
                            {
                                case BRESGroupNode.BRESGroupType.CHR0:
                                    info._chr0List.Add(anim as CHR0Node);
                                    break;
                                case BRESGroupNode.BRESGroupType.SRT0:
                                    info._srt0List.Add(anim as SRT0Node);
                                    break;
                                case BRESGroupNode.BRESGroupType.SHP0:
                                    info._shp0List.Add(anim as SHP0Node);
                                    break;
                                case BRESGroupNode.BRESGroupType.VIS0:
                                    info._vis0List.Add(anim as VIS0Node);
                                    break;
                                case BRESGroupNode.BRESGroupType.PAT0:
                                    info._pat0List.Add(anim as PAT0Node);
                                    break;
                                case BRESGroupNode.BRESGroupType.CLR0:
                                    info._clr0List.Add(anim as CLR0Node);
                                    break;
                            }
                        }
                }

            }
        }
Пример #47
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <param name="keyValue">编号</param>
        /// <returns>ArticleInfo</returns>
        public ArticleInfo Get(int keyValue)
        {
            ArticleInfo model = null;
			using (DbCommand cmd = db.GetStoredProcCommand("SP_GetRecord"))
			{
				db.AddInParameter(cmd, "@TableName", DbType.String, "Article");
				db.AddInParameter(cmd, "@KeyName", DbType.String, "ArticleID");
				db.AddInParameter(cmd, "@KeyValue", DbType.Int32, keyValue);
				using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
				{
					if (dt.Rows.Count > 0)
					{
						model = new ArticleInfo();
						model.LoadFromDataRow(dt.Rows[0]);
					}
				}
				return model;
			}
        } 
Пример #48
0
 /// <summary>
 /// 编辑文章
 /// </summary>
 /// <param name="articleinfo"></param>
 public static void EditArticle(ArticleInfo articleinfo)
 {
     DatabaseProvider.GetInstance().EditArticle(articleinfo);
 }