Exemple #1
0
        /// <summary>
        /// 更改文章状态
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static bool UpdateTopicStatus(TopicInfo topicInfo, CurrentUser user)
        {
            //AjaxResult ajaxResult = new AjaxResult() { Success = true, Message=string.Empty};
            bool result = true;

            #region check

            var topic = LoadTopicInfoBySysNo(topicInfo.SysNo.Value);
            if (topicInfo.TopicStatus == TopicStatus.Published && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline)
            {
                throw new BusinessException(LangHelper.GetText("只有草稿和撤下状态才能发布!"));
                //ajaxResult.Success = false;
                //ajaxResult.Message = "只有草稿和撤下状态才能发布!";
                //return ajaxResult;
            }

            #endregion

            topicInfo.EditUserSysNo = user.UserSysNo;
            topicInfo.EditUserName  = user.UserDisplayName;
            topicInfo.EditDate      = DateTime.Now;
            if (topicInfo.TopicStatus == TopicStatus.Published)
            {
                result = TopicDA.PublishTopic(topicInfo);
            }
            else
            {
                result = TopicDA.UpdateTopicStatus(topicInfo);
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 批量修改文章状态
        /// </summary>
        /// <param name="?"></param>
        /// <param name="status"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool BatchUpdateTopicStatus(List <int> topicSysNoList, TopicStatus status, CurrentUser user)
        {
            //AjaxResult ajaxResult = new AjaxResult() { Success = true, Message = string.Empty };
            List <TopicInfo> topicList = new List <TopicInfo>();

            #region check
            foreach (int topicSysNo in topicSysNoList)
            {
                var topic = LoadTopicInfoBySysNo(topicSysNo);
                if (status == TopicStatus.Published && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline)
                {
                    throw new BusinessException(LangHelper.GetText("只有草稿和撤下状态才能发布!"));
                    //ajaxResult.Success = false;
                    //ajaxResult.Message = "只有草稿和撤下状态才能发布!";
                    //return ajaxResult;
                }
                if (status == TopicStatus.Void && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline)
                {
                    throw new BusinessException(LangHelper.GetText("只有草稿和撤下状态才能作废!"));
                    //ajaxResult.Success = false;
                    //ajaxResult.Message = "只有草稿和撤下状态才能发布!";
                    //return ajaxResult;
                }
                if (status == TopicStatus.Delete && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline && topic.TopicStatus != TopicStatus.Void)
                {
                    throw new BusinessException(LangHelper.GetText("只有草稿,撤下以及作废状态才能删除!"));
                    //ajaxResult.Success = false;
                    //ajaxResult.Message = "只有草稿和撤下状态才能发布!";
                    //return ajaxResult;
                }
                topicList.Add(new TopicInfo()
                {
                    SysNo         = topicSysNo,
                    TopicStatus   = status,
                    EditUserSysNo = user.UserSysNo,
                    EditUserName  = user.UserDisplayName,
                    EditDate      = DateTime.Now
                });
            }

            #endregion

            using (ITransaction transaction = TransactionManager.Create())
            {
                foreach (var topic in topicList)
                {
                    if (status == TopicStatus.Published)
                    {
                        TopicDA.PublishTopic(topic);
                    }
                    else
                    {
                        TopicDA.UpdateTopicStatus(topic);
                    }
                }
                transaction.Complete();
            }

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// 创建新闻类别
        /// </summary>
        /// <param name="topicCategory"></param>
        /// <returns></returns>
        public static int InsertTopicCategory(TopicCategory topicCategory, CurrentUser user)
        {
            int sysNo = 0;

            using (ITransaction transaction = TransactionManager.Create())
            {
                bool nameExist = TopicDA.CheckNameIsExist(topicCategory);
                if (nameExist)
                {
                    throw new BusinessException(LangHelper.GetText("类别名称已存在!"));
                }
                string pCategoryID = string.IsNullOrEmpty(topicCategory.ParentCategoryID) ? "" : topicCategory.ParentCategoryID;
                string categoryID  = pCategoryID + "01";

                List <TopicCategory> list = QueryAllTopicCategoryListByParentID(pCategoryID);

                if (list != null && list.Count > 0)
                {
                    TopicCategory tc    = list.OrderByDescending(p => p.SysNo).FirstOrDefault();
                    int           index = int.Parse(tc.CategoryID.Substring(tc.CategoryID.Length - 2, 2)) + 1;
                    categoryID = pCategoryID + (index < 10 ? "0" + index.ToString() : index.ToString());
                }

                topicCategory.ParentCategoryID = pCategoryID;
                topicCategory.CategoryID       = categoryID;
                sysNo = TopicDA.InsertTopicCategory(topicCategory);
                transaction.Complete();
            }
            return(sysNo);
        }
Exemple #4
0
        /// <summary>
        /// 创建文章
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public static int CreateTopicInfo(TopicInfo topic)
        {
            ValidTopicInfo(topic);
            int sysNo = 0;

            topic.Content = topic.Content ?? "";
            sysNo         = TopicDA.CreateTopicInfo(topic);
            return(sysNo);
        }
Exemple #5
0
 public static void SaveTopicCategoryPriority(List <TopicCategory> list)
 {
     if (list != null && list.Count > 0)
     {
         foreach (var item in list)
         {
             TopicDA.SaveTopicCategoryPriority(item);
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// 保存内容默认图片
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool SaveTopicDefaultImage(TopicInfo topic, CurrentUser user)
        {
            bool flag = false;

            topic.EditUserSysNo = user.UserSysNo;
            topic.EditUserName  = user.UserDisplayName;
            topic.EditDate      = DateTime.Now;
            flag = TopicDA.SaveTopicDefaultImage(topic);
            return(flag);
        }
Exemple #7
0
        /// <summary>
        /// 根据编号获取文章信息
        /// </summary>
        /// <param name="sysNo"></param>
        /// <returns></returns>
        public static TopicInfo LoadTopicInfoBySysNo(int sysNo)
        {
            TopicInfo info = TopicDA.LoadTopicInfoBySysNo(sysNo);

            if (info == null)
            {
                throw new BusinessException("未找到文章。");
            }
            return(info);
        }
Exemple #8
0
        /// <summary>
        /// 获取指定数量,指定页面,指定位置的Topic
        /// </summary>
        /// <param name="newsType"></param>
        /// <param name="refSysNo"></param>
        /// <param name="topNum"></param>
        /// <param name="pageShowInheritance"></param>
        /// <returns></returns>
        public static List <NewsInfo> GetTopTopicList(NewsType newsType, int?refSysNo, int?pageShowInheritance, int topNum)
        {
            string cacheKey = CommonFacade.GenerateKey("GetTopTopicList", newsType.ToString(), refSysNo.HasValue ? refSysNo.ToString() : "N", pageShowInheritance.HasValue ? pageShowInheritance.ToString() : "N", topNum.ToString());

            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return((List <NewsInfo>)HttpRuntime.Cache[cacheKey]);
            }

            List <NewsInfo> result = TopicDA.GetTopTopicList(newsType, refSysNo, pageShowInheritance, topNum);

            HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration);
            return(result);
        }
Exemple #9
0
        /// <summary>
        /// 获取首页新闻公告信息
        /// </summary>
        /// <returns></returns>
        public static List <NewsInfo> GetHomePageNews(NewsType newsType, int topNum = 5)
        {
            string cacheKey = CommonFacade.GenerateKey("GetHomePageNews", newsType.ToString());

            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return((List <NewsInfo>)HttpRuntime.Cache[cacheKey]);
            }

            List <NewsInfo> entityList = TopicDA.GetNewsInfoByNewsType(newsType, topNum);

            HttpRuntime.Cache.Insert(cacheKey, entityList, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration);

            return(entityList);
        }
Exemple #10
0
        /// <summary>
        /// 更新文章
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public static int SaveTopicInfo(TopicInfo topic)
        {
            int sysNo = 0;

            ValidTopicInfo(topic);
            topic.Content = topic.Content ?? "";
            TopicInfo info = LoadTopicInfoBySysNo(topic.SysNo.Value);

            if (info.TopicStatus == TopicStatus.Init || info.TopicStatus == TopicStatus.Void)
            {
                topic.TopicStatus = info.TopicStatus;
            }
            sysNo = TopicDA.SaveTopicInfo(topic);
            return(sysNo);
        }
Exemple #11
0
        /// <summary>
        /// 删除文章类别
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public static bool DeleteTopicCategory(TopicCategory topicCategory)
        {
            topicCategory = TopicDA.LoadTopicCategory(topicCategory.SysNo.Value);
            //查询当前分类下是否有关联文章
            List <TopicInfo> topicList = TopicDA.LoadTopicInfoListByCategory(topicCategory.SysNo.Value);

            if (topicList != null && topicList.Count > 0)
            {
                throw new BusinessException("当前类别下有关联文章,不能删除此类别!");
            }
            else
            {
                bool result = true;
                result = TopicDA.DeleteTopicCategory(topicCategory);
                return(result);
            }
        }
Exemple #12
0
 public static void InsertSubscriptionEmail(List <int> subscriptionCategorySysNos, string email)
 {
     if (subscriptionCategorySysNos == null || subscriptionCategorySysNos.Count == 0 || string.IsNullOrWhiteSpace(email))
     {
         throw new BusinessException("Please input subscription category id and email address!");
     }
     foreach (int no in subscriptionCategorySysNos)
     {
         Subscription entity = new Subscription()
         {
             CompanyCode = ConstValue.CompanyCode,
             Email       = email,
             SubscriptionCategorySysNo = no,
             StoreCompanyCode          = ConstValue.CompanyCode,
             Status       = "A",
             LanguageCode = ConstValue.LanguageCode,
             IPAddress    = HttpContext.Current.Request.UserHostAddress
         };
         TopicDA.SetSubscription(entity);
     }
 }
Exemple #13
0
        private static IEnumerable <string> BuildTopic()
        {
            var urlTemp = Path.Combine(Domain, "Topic/TopicDetail/{0}");
            var result  = new List <string>();

            var filter = new NewsQueryFilter
            {
                PageInfo = new PageInfo
                {
                    PageIndex = 1,
                    PageSize  = 10000
                }
            };

            var news = TopicDA.QueryNewsInfo(filter);

            foreach (NewsInfo item in news.ResultList)
            {
                result.Add(string.Format(urlTemp, item.SysNo));
            }

            return(result);
        }
Exemple #14
0
 /// <summary>
 ///  根据编号获取帮助中心新闻
 /// </summary>
 /// <param name="sysNo">新闻编号</param>
 /// <returns>帮助中心新闻</returns>
 public static NewsInfo GetTopHelperCenterBySysNo(int sysNo)
 {
     return(TopicDA.GetTopHelperCenterBySysNo(sysNo));
 }
Exemple #15
0
 /// <summary>
 ///  获取指定数量帮助中心新闻
 /// </summary>
 /// <param name="categorySysNo">新闻类型</param>
 /// <param name="topNum">获取数量</param>
 /// <returns>帮助中心新闻</returns>
 public static List <NewsInfo> GetTopHelperCenterList(string categorySysNo, int topNum)
 {
     return(TopicDA.GetTopHelperCenterList(categorySysNo, topNum));
 }
Exemple #16
0
 /// <summary>
 /// 获取帮助中心新闻类型
 /// </summary>
 /// <param name="newsType">要获取的帮助中心新闻类型</param>
 /// <returns>帮助中心新闻类型列表</returns>
 public static List <NewsInfo> GetHelperCenterCategory()
 {
     return(TopicDA.GetHelperCenterCategory());
 }
Exemple #17
0
 /// <summary>
 /// 查询所有的文章类别根据MasterName
 /// </summary>
 /// <returns></returns>
 public static List <TopicCategory> QueryAllTopicCategoryListByMasterName(string masterName)
 {
     return(TopicDA.QueryAllTopicCategoryListByMasterName(masterName));
 }
Exemple #18
0
 public static TopicCategory LoadTopicCategory(int sysNo)
 {
     return(TopicDA.LoadTopicCategory(sysNo));
 }
Exemple #19
0
 /// <summary>
 /// 分页查询新闻公告
 /// </summary>
 /// <param name="filter"></param>
 /// <param name="totalCount"></param>
 /// <returns></returns>
 public static QueryResult <NewsInfo> QueryNewsInfo(NewsQueryFilter filter)
 {
     return(TopicDA.QueryNewsInfo(filter));
 }
Exemple #20
0
 public static QueryResult <QR_Topic> QueryTopicList(QF_Topic filter)
 {
     return(TopicDA.QueryTopicList(filter));
 }
Exemple #21
0
 /// <summary>
 /// 更新新闻类别
 /// </summary>
 /// <param name="topicCategory"></param>
 /// <returns></returns>
 public static int UpdateTopicCategory(TopicCategory topicCategory, CurrentUser user)
 {
     return(TopicDA.UpdateTopicCategory(topicCategory));
 }
Exemple #22
0
 /// <summary>
 /// 根据编号获取新闻信息
 /// </summary>
 /// <param name="sysNo">新闻编号</param>
 /// <returns>新闻信息</returns>
 public static NewsInfo GetNewsInfoBySysNo(int sysNo)
 {
     return(TopicDA.GetNewsInfoBySysNo(sysNo));
 }
Exemple #23
0
 /// <summary>
 /// 查询所有的文章类别
 /// </summary>
 /// <returns></returns>
 public static List <TopicCategory> QueryAllTopicCategoryListByParentID(string parentID)
 {
     parentID = string.IsNullOrEmpty(parentID) ? "" : parentID;
     return(TopicDA.QueryAllTopicCategoryListByParentID(parentID));
 }