コード例 #1
0
        public JsonResult PubArticle([FromBody] ArticleParam msg)
        {
            ReplyModel reply = new ReplyModel();

            try
            {
                Users users = _userRepository.Get(msg.UserId);
                if (users != null)
                {
                    msg.Password = MD5Encrypt.Encrypt(msg.Password);
                    Article.Add(_articleRepository, msg);
                    UserArticleEventExtend.TriggerAlterUserAritlceCountEvent(users, ServiceProvider);
                    bool result = ServiceProvider.GetService <IUnitOfWork>().Commit();
                    if (result)
                    {
                        reply.Status = "002";
                        reply.Msg    = "保存文章成功";
                    }
                    else
                    {
                        reply.Msg = "保存文章失败";
                    }
                }
                else
                {
                    reply.Msg = "未找到用户信息";
                }
            }
            catch (Exception ex)
            {
                reply.Msg = "文章发布或保存草稿失败,请重试";
                // _Logger.LogError($"文章发布或保存草稿失败,请重试{JsonConvert.SerializeObject(ex)}");
            }
            return(Json(reply));
        }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Log log = MainMasterPage.InitPage(this);

//			ucArticles.InitControl(ArticleType.Article, 3, false);
        try
        {
            ucPositions.InitControl("Positions", 8, false);
            Article article = null;
            using (var conn = Global.CreateConnection())
            {
                article = Article.GetArticle(conn, "Default");
                if (article != null)
                {
                    ArticleParam.GetArticleParams(conn, article.Id, sd);
                }
            }

            //			ucDigests.InitControl(ArticleType.Digest, 2, false);
        }
        catch (Exception ex)
        {
            log.Exception(ex);
        }
    }
コード例 #3
0
        public string GetArticleParam(ArticleParam param)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("where 1=1 ");



            if (!string.IsNullOrEmpty(param.ArticleType))
            {
                string[] strArr = param.ArticleType.Split(',');
                if (strArr.Length > 0)
                {
                    for (int i = 0; i < strArr.Length; i++)
                    {
                        sb.AppendFormat(" and ArticleType like '%,{0},%' ", strArr[i]);
                    }
                }
            }

            if (!string.IsNullOrEmpty(param.ArticleName))
            {
                sb.AppendFormat(" and ArticleName like '%{0}%' ", Utils.SqlSafe(param.ArticleName));
            }

            if (!DateTime.MinValue.Equals(param.PublishDate))  //0001/1/1 0:00:00
            {
                sb.AppendFormat(" and PublishDate >= '{0}' ", param.PublishDate);
            }

            return(sb.ToString());
        }
コード例 #4
0
ファイル: ContentsService.cs プロジェクト: zjftuzi/iBlogs
        public Page <Contents> findArticles(ArticleParam articleParam)
        {
            var query = _repository.GetAll();

            if (articleParam.Categories != null)
            {
                query = query.Where(p => p.Categories.Contains(articleParam.Categories));
            }


            if (articleParam.Status != null)
            {
                query = query.Where(p => p.Status == articleParam.Status);
            }

            if (articleParam.Title != null)
            {
                query = query.Where(p => p.Title.Contains(articleParam.Title));
            }

            if (articleParam.Type != null)
            {
                query = query.Where(p => p.Type == articleParam.Type);
            }

            return(_repository.Page(query, articleParam));
        }
コード例 #5
0
ファイル: NewService.cs プロジェクト: yanh19930226/yunExpress
        //获取新闻列表
        public IPagedList <ArticleExt> GetNewsPageList(ArticleParam param, out int totalCount)
        {
            Expression <Func <Article, bool> > filter = p => true;

            filter = filter.And(p => p.Status == 1);
            filter = filter.AndIf(p => p.Title.Contains(param.Title), !string.IsNullOrWhiteSpace(param.Title));

            filter = filter.AndIf(p => p.PublishedTime >= param.PublishedTime, param.PublishedTime.Date.ToString() != "0001/1/1 0:00:00");
            filter = filter.AndIf(p => p.PublishedTime <= param.PublishedEndTime, param.PublishedEndTime.Date.ToString() != "0001/1/1 0:00:00");
            string idList = String.Empty;
            var    list   = _articleRepository.GetFiltered(filter).OrderBy(p => p.ArticleID);

            if (param.CategoryID != null && param.CategoryID != 0 && !String.IsNullOrEmpty(param.CategoryID.ToString()))
            {
                idList = GetChildCategoryID(param.CategoryID.Value).TrimEnd(',');
                list   = list.Where(p => idList.Contains(p.CategoryID.ToString())).OrderBy(p => p.ArticleID);
            }
            totalCount = list.Count();
            PagedList <Article> pagedList = list.ToPagedList(param.Page, param.PageSize);

            IPagedList <ArticleExt> articleExtList = new PagedList <ArticleExt>();

            pagedList.Each(p =>
            {
                ArticleExt extModel = new ArticleExt();
                p.Detail            = "";
                p.CopyTo(extModel);
                var category          = _categoryRepository.Single(e => e.CategoryID == p.CategoryID);
                var user              = _customerRepository.Single(e => e.CustomerCode == p.CreatedBy);
                extModel.CategoryName = category != null ? category.Name : "";
                extModel.UserName     = user != null ? user.Name : "";
                articleExtList.InnerList.Add(extModel);
            });
            return(articleExtList);
        }
コード例 #6
0
        public ApiResponse <Page <Contents> > PageList(ArticleParam articleParam)
        {
            articleParam.Type = Types.PAGE;
            articleParam.Page--;
            Page <Contents> articles = _contentsService.findArticles(articleParam);

            return(ApiResponse <Page <Contents> > .Ok(articles));
        }
コード例 #7
0
    void LoadData()
    {
        int id = RequestUtils.GetArticleParamId(this);

        if (id != 0)
        {
            using (GmConnection conn = Global.CreateConnection())
            {
                articleParam = ArticleParam.GetArticleParam(conn, id);
            }
        }
        else
        {
            int ar = RequestUtils.GetArticleId(this);
            articleParam = new ArticleParam(ar);
        }
    }
コード例 #8
0
ファイル: Article.cs プロジェクト: zlzgt/Community.Api
        /// <summary>
        /// 添加文章
        /// </summary>
        /// <param name="articleParam"></param>
        public static void Add(IArticleRepository articleRepository, ArticleParam articleParam)
        {
            Article article = new Article();

            article.UserId          = articleParam.UserId;
            article.NickName        = articleParam.NickName;
            article.Title           = articleParam.Title;
            article.IsDraft         = articleParam.IsDraft;
            article.Content         = articleParam.Content;
            article.Summary         = articleParam.Summary;
            article.Img             = articleParam.Img;
            article.Config          = articleParam.Config;
            article.EntryName       = articleParam.EntryName;
            article.ArticleCategory = articleParam.ArticleCategory;
            article.ReadCount       = 0;
            article.Password        = articleParam.Password;
            article.PubTime         = DateTime.Now;
            article.AddTime         = DateTime.Now;
            articleRepository.Set(article);
        }
コード例 #9
0
ファイル: NewService.cs プロジェクト: yanh19930226/yunExpress
        public IPagedList <Article> GetArticleList(ArticleParam param)
        {
            if (param == null)
            {
                param = new ArticleParam();
            }
            Func <IQueryable <Article>, IOrderedQueryable <Article> > orderBy = x => x.OrderByDescending(x2 => x2.ArticleID);

            Expression <Func <Article, bool> > filter = x => true;

            filter = filter.AndIf(x => x.Title.Contains(param.Title), !string.IsNullOrWhiteSpace(param.Title))
                     .AndIf(x => x.CategoryID == param.CategoryID, param.CategoryID != null)
                     .AndIf(x => x.Author == param.Author, !string.IsNullOrWhiteSpace(param.Author))
                     .AndIf(x => x.Source.Contains(param.Source), !string.IsNullOrWhiteSpace(param.Source))
                     .AndIf(x => x.PublishedTime >= param.StartPublishedTime, param.StartPublishedTime != null)
                     .AndIf(x => x.PublishedTime <= param.EndPublishedTime, param.EndPublishedTime != null)
                     .AndIf(x => x.Status == param.Status, param.Status != null);

            IPagedList <Article> articles = _articleRepository.FindPagedList(param, filter, orderBy);

            return(articles);
        }
コード例 #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(PageTag))
     {
         int articleId = articleIds.ContainsKey(PageTag) ? articleIds[PageTag] : 0;
         using (var conn = Global.CreateConnection())
         {
             if (articleId == 0)
             {
                 var article = Article.GetArticle(conn, PageTag);
                 if (article != null)
                 {
                     articleId           = article.Id;
                     articleIds[PageTag] = articleId;
                 }
             }
             if (articleId != 0)
             {
                 ArticleParam.GetArticleParams(conn, articleId, sd);
             }
         }
     }
 }