Exemplo n.º 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);
        }
Exemplo n.º 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);
        }