Ejemplo n.º 1
0
        /// <summary>
        /// 获取商城模板信息
        /// </summary>
        /// <param name="entId">企业Id</param>
        /// <param name="htmlType">html页面类型</param>
        /// <returns></returns>
        public JsonResult HtmlTemplate(string entId)
        {
            try
            {
                if (string.IsNullOrEmpty(entId))
                {
                    entId = BaseConfiguration.EntId;
                }

                List <Template> list = new List <Template>();
                Template        t    = new Template();
                ////获取页面配置信息
                TemplateDal dal_t = new TemplateDal();
                t.List_Sz = dal_t.GetSystemBase(entId);
                //获取药品分类
                ImgInfoDal dal_i = new ImgInfoDal();
                t.List_Fl = dal_i.GetCategory(entId, 7);
                //底部资讯
                ArticleDal dal_a = new ArticleDal();
                t.List_Zx = dal_a.GetArticle(entId, 11, "Mt");
                ///商品轮播图片
                t.List_Lb = dal_i.GetImgInfo(10, "LB", entId, "PC", "");
                list.Add(t);


                return(Json(new { success = true, list = list }));
            }
            catch (Exception ex)
            {
                LogQueue.Write(LogType.Error, "Template/HtmlTemplate", ex.Message.ToString());
                return(Json(new { success = false, message = "模板信息加载失败!" }));
            }
        }
Ejemplo n.º 2
0
 public JsonResult GetArticle(int channel_Id, string entId, string type)
 {
     if (channel_Id <= 0)
     {
         return(Json(new { success = false, message = "参数无效" }));
     }
     else
     {
         try
         {
             if (entId == null || entId == "")
             {
                 entId = BaseConfiguration.EntId;
             }
             ArticleDal     dal  = new ArticleDal();
             List <Article> list = dal.GetArticle(entId, channel_Id, type);
             return(Json(new { success = true, list = list }));
         }
         catch (Exception ex)
         {
             LogQueue.Write(LogType.Error, "Article/GetArticle", ex.Message);
             return(Json(new { success = false, message = "文章/咨询加载失败!" }));
         }
     }
 }
Ejemplo n.º 3
0
        public static bool UpsertYxArticle(YouXuanArticle article, string user)
        {
            var result    = false;
            var articleId = 0;

            try
            {
                var conn = ConfigurationManager.ConnectionStrings["Tuhu_Discovery_Db"].ConnectionString;
                if (SecurityHelp.IsBase64Formatted(conn))
                {
                    conn = SecurityHelp.DecryptAES(conn);
                }
                using (var dbhelper = new SqlDbHelper(conn))
                {
                    dbhelper.BeginTransaction();
                    if (article.PKID > 0)
                    {
                        articleId = article.PKID;
                        ArticleDal.UpdateYxArticle(dbhelper, article);
                    }
                    else
                    {
                        articleId = ArticleDal.InsertYxArticle(dbhelper, article);
                    }
                    article.CoverConfig.ArticleId = articleId;
                    ArticleDal.DeleteYxArticleCoverConfig(dbhelper, articleId);
                    ArticleDal.DeleteArticleCategoryTag(dbhelper, articleId);
                    if (!string.IsNullOrEmpty(article.CategoryTags))
                    {
                        var categoryIds = JsonConvert.DeserializeObject <List <JObject> >(article.CategoryTags).Select(t => t.Value <int>("key"));
                        foreach (var id in categoryIds)
                        {
                            ArticleDal.InsertArticleCategoryTag(dbhelper, articleId, id);
                        }
                    }
                    ArticleDal.InsertYxArticleCoverConfig(dbhelper, article.CoverConfig);
                    dbhelper.Commit();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            if (result)
            {
                if (article.PKID > 0)
                {
                    LoggerManager.InsertOplog(user, "ArticleTblNew", articleId, "新增优选文章,文章状态:" + article.Status);
                }
                else
                {
                    LoggerManager.InsertOplog(user, "ArticleTblNew", articleId, "修改优选文章,文章状态:" + article.Status);
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 博客浏览页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Blog(int id)
        {
            ArticleDal.ArticlePvAdd(id);
            var article = ArticleDal.GetArticle(id);

            return(View(new BlogVM {
                Article = article
            }));
        }
Ejemplo n.º 5
0
        //
        // GET: /Home/

        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var model            = new HomeIndexVM();
            var ArticleList      = ArticleDal.SelectArticleList(new SelectArticleRequest());
            var ArticleLabelList = ArticleDal.GetAllLabelAndArticle();

            model.ArticleList      = ArticleList;
            model.ArticleLabelList = ArticleLabelList;
            return(View(model));
        }
Ejemplo n.º 6
0
 public static bool UpdateAuthor(CoverAuthor model)
 {
     try
     {
         return(ArticleDal.UpdateAuthor(ProcessConnection.OpenMarketing, model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 7
0
 public static bool DeleteByPKID(int PKID)
 {
     try
     {
         return(ArticleDal.DeleteByPKID(ProcessConnection.OpenMarketing, PKID));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 8
0
 public static bool IsExistByName(string authorName)
 {
     try
     {
         return(ArticleDal.IsExistByName(ProcessConnection.OpenMarketing, authorName));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 9
0
 public static bool UpdateFieldByPKID(string fieldName, string fieldValue, int PKID)
 {
     try
     {
         return(ArticleDal.UpdateFieldByPKID(ProcessConnection.OpenMarketing, fieldName, fieldValue, PKID));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 10
0
 public static bool IsExistByName2(string oldName, string newName)
 {
     try
     {
         return(ArticleDal.IsExistByName2(ProcessConnection.OpenMarketing, oldName, newName));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 11
0
 public static List <CoverAuthor> SelectAll()
 {
     try
     {
         DataTable dt = ArticleDal.SelectAllAuthor(ProcessConnection.OpenMarketing);
         return(DTConvertCoverAuthor(dt.Rows.Cast <DataRow>().ToList()));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 12
0
        public ActionResult Index(int id)
        {
            Article article = new ArticleDal().GetArticle(id);

            ViewBag.Article  = article;
            ViewBag.Comments = new CommentDal().GetComments(id);
            UserDal users = new UserDal();

            ViewBag.Name = users.GetUser(article.UserId).Name;

            return(View());
        }
Ejemplo n.º 13
0
 public static List <CoverAuthor> SelectAuthorList(PagerModel pager, string strWhere)
 {
     try
     {
         DataTable dt = ArticleDal.SelectAuthorList(ProcessConnection.OpenMarketing, pager, strWhere);
         return(DTConvertCoverAuthor(dt.Rows.Cast <DataRow>().ToList()));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 14
0
 public static List <ArticleTemp> SelectArticleShow(int top = 10)
 {
     try
     {
         DataTable dt = ArticleDal.SelectArticleShow(ProcessConnection.OpenMarketing, top);
         return(DTConvertArticleData(dt.Rows.Cast <DataRow>().ToList()));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 15
0
 public static List <ArticleTemp> SelectArticleByWords(string keyword = "")
 {
     try
     {
         DataTable dt = ArticleDal.SelectArticleByWords(ProcessConnection.OpenMarketing, keyword);
         return(DTConvertArticleData(dt.Rows.Cast <DataRow>().ToList()));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 16
0
 public static List <ArticleTemp> SelectArticleByPKIDs(List <ColumnArticle> cas)
 {
     try
     {
         DataTable dt = ArticleDal.SelectArticleByPKIDs(ProcessConnection.OpenMarketing, cas);
         return(DTConvertArticleData(dt.Rows.Cast <DataRow>().ToList()));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 置顶或取消置顶文章
        /// </summary>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public static bool UpdateArticleTopMost(int articleId, string op)
        {
            var result = false;

            try
            {
                result = ArticleDal.UpdateArticleTopMost(ProcessConnection.OpenMarketing, articleId, op == "top" ? true : false);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            return(result);
        }
Ejemplo n.º 18
0
        //删除文章/商品
        private void DeleteArticleById()
        {
            long       Id = Convert.ToInt64(HttpContext.Current.Request["ArticleId"]);
            ArticleDal db = new ArticleDal();

            if (db.Delete(Id))
            {
                result = "OK";
            }
            else
            {
                result = "NO";
            }
        }
Ejemplo n.º 19
0
 public static CoverAuthor SelectAuthorModelByPKID(int PKID)
 {
     try
     {
         DataRow dr = ArticleDal.SelectAuthorModelByPKID(ProcessConnection.OpenMarketing, PKID);
         return(DTConvertCoverAuthor(new List <DataRow>()
         {
             dr
         }).FirstOrDefault());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 20
0
        public static bool UpsertDaoGouArticle(YouXuanArticle article, string user)
        {
            var result    = false;
            var articleId = 0;

            try
            {
                var conn = ConfigurationManager.ConnectionStrings["Tuhu_Discovery_Db"].ConnectionString;
                if (SecurityHelp.IsBase64Formatted(conn))
                {
                    conn = SecurityHelp.DecryptAES(conn);
                }
                using (var dbhelper = new SqlDbHelper(conn))
                {
                    dbhelper.BeginTransaction();
                    if (article.PKID > 0)
                    {
                        articleId = article.PKID;
                        ArticleDal.UpdateDaoGouArticle(dbhelper, article);
                    }
                    else
                    {
                        articleId = ArticleDal.InsertDaoGouArticle(dbhelper, article);
                    }
                    dbhelper.Commit();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            if (result)
            {
                if (article.PKID > 0)
                {
                    LoggerManager.InsertOplog(user, "ArticleTblNew", articleId, "新增导购文章,文章状态:" + article.Status);
                }
                else
                {
                    LoggerManager.InsertOplog(user, "ArticleTblNew", articleId, "修改导购文章,文章状态:" + article.Status);
                }
            }
            return(result);
        }
Ejemplo n.º 21
0
 public JsonResult GetTopArticle(string entId, string channel, string category, int num = 0, int pageIndex = 1, int pageSize = 15, string articleId = "")
 {
     try
     {
         if (string.IsNullOrEmpty(entId))
         {
             entId = BaseConfiguration.EntId;
         }
         ArticleDal     dal  = new ArticleDal();
         List <Article> list = dal.GetTopArticle(entId, num, pageIndex, pageSize, channel, category, articleId, out int pageCount, out int recordCount);
         return(Json(new { success = true, pageCount = pageCount, recordCount = recordCount, list = list }));
     }
     catch (Exception ex)
     {
         LogQueue.Write(LogType.Error, "Article/GetTopArticle", ex.Message);
         return(Json(new { success = false, message = "文章/咨询加载失败!" }));
     }
 }
Ejemplo n.º 22
0
        public void UpdateArticle(int articleId, ArticleDal articleDal)
        {
            var article = _unitOfWork.Articles.Get(articleId);

            article.Title         = articleDal.Title;
            article.Content       = articleDal.Content;
            article.PlainContent  = articleDal.Content;
            article.CategoryId    = articleDal.CategoryId;
            article.IsDraft       = articleDal.IsDraft;
            article.UrlIdentifier = articleDal.UrlIdentifier;

            if (article.FirstPublishedDate == null && !articleDal.IsDraft)
            {
                article.FirstPublishedDate = DateTime.Now;
            }

            _unitOfWork.SaveChanges();
        }
Ejemplo n.º 23
0
        private void Bind()
        {
            int            pageindex = Convert.ToInt32(Request["page"]);
            int            pagesize  = Convert.ToInt32(Request["pagesize"]) == 0 ? 10 : Convert.ToInt32(Request["pagesize"]);
            int            pagecount = 0;
            List <Article> list      = new List <Article>();
            ArticleDal     db        = new ArticleDal();

            list = db.FindPagingList(ref pagecount, pageindex, pagesize);
            if (list.Count == 0 && pageindex > 1)
            {
                //大于一页的最后一条被删除,页数-1 重新加载
                list = db.FindPaging(ref pagecount, pageindex - 1, pagesize);
            }
            hfcount.Value      = pagecount.ToString();
            rptlist.DataSource = list;
            rptlist.DataBind();
        }
Ejemplo n.º 24
0
        public ActionResult BlogEditor(int id = noArticleId)
        {
            var labelList = ArticleDal.GetAllLabel();

            if (id == noArticleId)
            {
                return(View(new BlogEditorVM {
                    SelectLabelList = labelList
                }));
            }
            else
            {
                var article = ArticleDal.GetArticle(id);

                return(View(new BlogEditorVM {
                    Article = article, SelectLabelList = labelList
                }));
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 更新文章状态
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static async Task <Article> UpdateArticleStatus(int articleId, ArticleStatus status)
        {
            Article article = null;

            try
            {
                var result = ArticleDal.UpdateArticleStatus(ProcessConnection.OpenMarketing, articleId, status, status == ArticleStatus.Published ? 1 : 0);
                article = await GetArticleDetailById(articleId);

                if (result && article.Type == 5)
                {
                    await InsertOrUpdateES(article);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(article);
        }
Ejemplo n.º 26
0
 public JsonResult SaveArticle(string title, string tags, string newsType, string sortId, string dates, string zhaiYao, string content, int id = 0)
 {
     try
     {
         ArticleDal article = new ArticleDal();
         string     message = article.SaveArticle(title, tags, newsType, sortId, dates, zhaiYao, content, out bool flag, id);
         int        bs      = flag == true ? 0 : 1;
         if (flag)
         {
             return(Json(new { flag = bs, message = message }));
         }
         else
         {
             return(Json(new { flag = bs, message = message }));
         }
     }
     catch (Exception ex)
     {
         Log.Error("错误:新闻资讯存盘", ex.Message);
         LogQueue.Write(LogType.Error, "Article/SaveArticle", ex.Message);
         return(Json(new { success = false, message = "新闻资讯存盘失败!" }));
     }
 }
Ejemplo n.º 27
0
        public int AddArticle(ArticleDal articleDal)
        {
            var article = new Article
            {
                Title         = articleDal.Title,
                Content       = articleDal.Content,
                PlainContent  = articleDal.Content,
                CategoryId    = articleDal.CategoryId,
                IsDraft       = articleDal.IsDraft,
                UrlIdentifier = articleDal.UrlIdentifier
            };

            if (!articleDal.IsDraft)
            {
                article.FirstPublishedDate = DateTime.Now;
            }

            _unitOfWork.Articles.Add(article);

            _unitOfWork.SaveChanges();

            return(article.Id);
        }
Ejemplo n.º 28
0
        //[ValidateInput(false)]
        public ActionResult SubmitBlogEditor(SubmitBlogEditorRequest request)
        {
            Article article = new Article();


            if (request.Id != null)
            {
                article.Id = request.Id.Value;
            }

            article.ArticleLabel    = AnalyzeLabelString(request.LabelString);
            article.Title           = request.Title.Trim();
            article.Content         = request.Content;
            article.PublicationTime = DateTime.Now;
            if (request.Id == null)
            {
                ArticleDal.AddArticle(article);
            }
            else
            {
                ArticleDal.UpdateArticle(article);
            }
            return(Redirect("Index"));
        }
Ejemplo n.º 29
0
        //删除栏目
        private void DeleteColumnById()
        {
            long       Id  = Convert.ToInt64(HttpContext.Current.Request["ColumnId"]);
            ColumnDal  db  = new ColumnDal();
            int        zlm = db.FindCountByPID(Id);
            ArticleDal db2 = new ArticleDal();
            int        z2  = db2.FindCountByCID(Id);

            if (zlm == 0 && z2 == 0)//是否有子栏目或者文章/产品
            {
                if (db.Delete(Id))
                {
                    result = "OK";
                }
                else
                {
                    result = "NO";
                }
            }
            else
            {
                result = "NO";
            }
        }
Ejemplo n.º 30
0
 public IList<VwArticle> GetAllList()
 {
     using (ArticleDal dal = new ArticleDal())
     {
         return dal.GetAllVwList();
     }
 }
Ejemplo n.º 31
0
        /// <summary>
        /// 获取最新的文章信息
        /// </summary>
        /// <param name="topNum"></param>
        /// <param name="categoryID"></param>
        /// <returns></returns>
        public IList<VwArticle> GetNewList(int topNum, string categoryID, string filter)
        {
            if (topNum < 0)
            {
                return null;
            }

            using (ArticleDal dal = new ArticleDal())
            {
                return dal.GetNewList(topNum, categoryID, filter);
            }
        }
Ejemplo n.º 32
0
        public ReturnValue AddOrEdit(Article entity)
        {
            ReturnValue retValue = new ReturnValue();
            if (string.IsNullOrEmpty(entity.Subject))
            {
                retValue.IsExists = false;
                retValue.Message = "标题不能为空";
                return retValue;
            }
            if (string.IsNullOrEmpty(entity.Body))
            {
                retValue.IsExists = false;
                retValue.Message = "正文不能为空";
                return retValue;
            }
            VwArticle old = null;
            using (ArticleDal dal = new ArticleDal())
            {

                if (entity.ID > 0)
                {
                    old = dal.GetVw(entity.ID);
                }
                if (old == null)
                {
                    if (dal.Add(entity))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "保存成功";
                        old = dal.GetVw(entity.ID);
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "保存失败";
                    }
                }
                else //修改
                {
                    if (dal.Modify(entity))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "修改成功";
                        old = dal.GetVw(entity.ID);
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "修改失败";
                    }
                }
            }

            if (retValue.IsExists)
            {
                //TODO: 修改Html
                HtmlManager htmMg = new HtmlManager();
                htmMg.CreateHtml(old);
            }
            retValue.PutValue("vw", old);

            return retValue;
        }
Ejemplo n.º 33
0
 public static ArticleCoverConfig SelectArticleCoverConfig(int ArticleId)
 {
     return(ArticleDal.GetYxArticleCoverConfig(ProcessConnection.OpenMarketingReadOnly, ArticleId));
 }
Ejemplo n.º 34
0
 public VwArticle Get(int articleID)
 {
     if (articleID < 1)
     {
         return null;
     }
     using (ArticleDal dal = new ArticleDal())
     {
         return dal.GetVw(articleID);
     }
 }
Ejemplo n.º 35
0
 /// <summary>
 /// 获取文章列表分页
 /// </summary>
 /// <param name="page"></param>
 /// <param name="pageSize"></param>
 /// <param name="filter"></param>
 /// <returns></returns>
 public PageList<VwArticle> GetList(int page, int pageSize, string filter)
 {
     PageList<VwArticle> pa = new PageList<VwArticle>();
     using (ArticleDal dal = new ArticleDal())
     {
         int rowCount = 0;
         pa.CurPage = page;
         pa.PageSize = pageSize;
         pa.Data = dal.GetList(page, pageSize, filter, ref rowCount);
         pa.RecordCount = rowCount;
     }
     return pa;
 }