示例#1
0
        /// <summary>
        /// 添加新闻分类
        /// </summary>
        /// <param name="category">新闻分类实体</param>
        /// <returns>返回操作是否成功 true:成功   false:不成功</returns>
        /// <remarks>2016-06-06 罗远康 创建</remarks>
        public override bool CreateCategory(FeNewsCategory category)
        {
            //接收新添加新闻分类的系统编号
            int result = 0;

            //启动事务
            using (var _context = Context.UseSharedConnection(true))
            {
                //添加新分类
                result = _context.Insert <FeNewsCategory>("FeNewsCategory", category)
                         .AutoMap(c => c.SysNo, c => c.ParentCategory)
                         .ExecuteReturnLastId <int>("SysNo");             //记录返还系统编号
                category.SysNo = result;

                //通过系统编号来判断是否添加成功
                if (result > 0)
                {
                    //设置分类路由
                    SetCateorySysNosBySysNo(category.SysNo);
                }
                else
                {
                    return(false);
                }
                //设置新添加的新闻分类到他父级分类末尾显示
                SetCategoryToLastShow(category, _context);
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// 将分类排在父分类的末尾显示
        /// </summary>
        /// <param name="category">新闻分类对象</param>
        /// <param name="context">供应数据库操作上线文</param>
        /// <returns>返回: true 成功 false 失败</returns>
        /// <remarks>2016-06-06 罗远康 创建</remarks>
        public override bool SetCategoryToLastShow(FeNewsCategory category, IDbContext context = null)
        {
            context = context ?? Context;

            return
                (context.Sql(
                     @"UPDATE FeNewsCategory SET displayorder = (select COUNT(sysno)+1 FROM FeNewsCategory WHERE parentsysno=@parentSysNo and sysno<>@sysno) where sysno=@sysno")
                 .Parameter("parentSysNo", category.ParentSysNo)
                 .Parameter("sysno", category.SysNo)
                 .Execute() > 0);
        }
示例#3
0
        /// <summary>
        /// 交换显示分类的显示排序
        /// </summary>
        /// <param name="originalSysNo">交换源对象系统编号</param>
        /// <param name="objectiveSysNo">要进行位置交换的目标对象系统编号</param>
        /// <returns>返回: true 操作成功  false 操作失败</returns>
        /// <remarks>注意:该方法值适用于在同一父级中进行移动变更</remarks>
        /// <remarks>2016-06-07 罗远康 创建</remarks>
        public bool SwapDisplayOrder(int originalSysNo, int objectiveSysNo)
        {
            bool           success   = false;
            FeNewsCategory original  = IFeNewsCategoryDao.Instance.GetCategory(originalSysNo);
            FeNewsCategory objective = IFeNewsCategoryDao.Instance.GetCategory(objectiveSysNo);

            //显示位置交换
            var objectIndex = objective.DisplayOrder;

            objective.DisplayOrder = original.DisplayOrder;
            original.DisplayOrder  = objectIndex;

            success = IFeNewsCategoryDao.Instance.Update(original);

            //源对象更是是否成功
            if (success)
            {
                //更新成功就更新目标对象
                success = IFeNewsCategoryDao.Instance.Update(objective);
            }
            else
            {
                //更新失败,数据还原
                original.DisplayOrder = objective.DisplayOrder;
                IFeNewsCategoryDao.Instance.Update(original);
            }

            if (success)
            {
                //用户操作日志
                BLL.Log.SysLog.Instance.Info(LogStatus.系统日志来源.后台,
                                             string.Format("新闻分类{0}与新闻分类{1}互换顺序", originalSysNo, objectiveSysNo),
                                             LogStatus.系统日志目标类型.新闻帮助管理, originalSysNo,
                                             AdminAuthenticationBo.Instance.Current.Base.SysNo);
            }
            else
            {
                //用户操作日志
                BLL.Log.SysLog.Instance.Error(LogStatus.系统日志来源.后台,
                                              string.Format("新闻分类{0}与新闻分类{1}互换顺序失败", originalSysNo, objectiveSysNo),
                                              LogStatus.系统日志目标类型.新闻帮助管理, originalSysNo,
                                              AdminAuthenticationBo.Instance.Current.Base.SysNo);
            }

            //返回结果
            return(success);
        }
示例#4
0
        /// <summary>
        /// 添加新闻分类
        /// </summary>
        /// <param name="category">分类实体</param>
        /// <param name="attributeGroups">属性列表</param>
        /// <returns>true:创建成功 false:创建失败</returns>
        /// <remarks>2016-06-07 罗远康 创建</remarks>
        public bool CreateNewsCategory(FeNewsCategory category)
        {
            bool success = false;

            category.CreatedBy      = AdminAuthenticationBo.Instance.GetAuthenticatedUser().SysNo;
            category.CreatedDate    = DateTime.Now;
            category.LastUpdateBy   = category.CreatedBy;
            category.LastUpdateDate = category.CreatedDate;
            category.Status         = (int)Model.WorkflowStatus.NewsStatus.新闻分类状态.效;
            category.DealerSysNo    = category.CreatedBy;


            //如果分类是子分类,则将继承父分类状态和显示样式
            if (category.ParentSysNo > 0)
            {
                category.SysNos = GetCategory(category.ParentSysNo).SysNos;
                FeNewsCategory parentCategory = IFeNewsCategoryDao.Instance.GetCategory(category.ParentSysNo);
                category.Status = parentCategory.Status;
            }


            success =
                IFeNewsCategoryDao.Instance.CreateCategory(category);

            //如果返回创建成功建提交事务
            if (success)
            {
                //用户操作日志
                BLL.Log.SysLog.Instance.Info(LogStatus.系统日志来源.后台,
                                             string.Format("新增新闻分类{0}基本信息", category.SysNo),
                                             LogStatus.系统日志目标类型.新闻帮助管理, category.SysNo,
                                             AdminAuthenticationBo.Instance.Current.Base.SysNo);
            }
            else
            {
                //用户操作日志
                BLL.Log.SysLog.Instance.Error(LogStatus.系统日志来源.后台,
                                              string.Format("新增新闻分类{0}基本信息失败", category.SysNo),
                                              LogStatus.系统日志目标类型.新闻帮助管理, category.SysNo,
                                              AdminAuthenticationBo.Instance.Current.Base.SysNo);
            }


            BLL.Cache.DeleteCache.NewsCategory(category.SysNo);

            return(success);
        }
示例#5
0
 /// <summary>
 /// 保存分类信息
 /// </summary>
 /// <param name="updateCategory">分类实体对象</param>
 /// <returns>返回: true 成功 false 失败</returns>
 /// <remarks>2016-06-06 罗远康 创建</remarks>
 public override bool Update(FeNewsCategory updateCategory)
 {
     return(Context.Sql(@"UPDATE FeNewsCategory SET 
                                     CategoryName = @CategoryName
                                     ,ParentSysNo=@ParentSysNo
                                     ,SeoDescription=@SeoDescription
                                     ,SeoKeyword=@SeoKeyword
                                     ,SeoTitle=@SeoTitle
                                     ,LastUpdateBy=@LastUpdateBy
                                     ,LastUpdateDate=@LastUpdateDate 
                                     ,DisplayOrder=@DisplayOrder 
                                     where SysNo =@SysNo")
            .Parameter("CategoryName", updateCategory.CategoryName)
            .Parameter("ParentSysNo", updateCategory.ParentSysNo)
            .Parameter("SeoDescription", updateCategory.SeoDescription)
            .Parameter("SeoKeyword", updateCategory.SeoKeyword)
            .Parameter("SeoTitle", updateCategory.SeoTitle)
            .Parameter("LastUpdateBy", updateCategory.LastUpdateBy)
            .Parameter("LastUpdateDate", updateCategory.LastUpdateDate)
            .Parameter("DisplayOrder", updateCategory.DisplayOrder)
            .Parameter("SysNo", updateCategory.SysNo)
            .Execute() > 0);
 }
示例#6
0
        /// <summary>
        /// 修改新闻分类
        /// </summary>
        /// <param name="category">新闻分类实体</param>
        /// <returns>返回操作是否成功 true:成功   false:不成功</returns>
        /// <remarks>2016-06-06 罗远康 创建</remarks>
        public override bool EditCategory(FeNewsCategory category)
        {
            //接收新添加新闻分类的系统编号
            int result = 0;

            using (var _context = Context.UseSharedConnection(true))
            {
                result = _context.Sql(@"UPDATE FeNewsCategory SET 
                                            CategoryImage = @CategoryImage
                                            ,CategoryName = @CategoryName
                                            ,DealerSysNo= @DealerSysNo
                                            ,ParentSysNo= @ParentSysNo
                                            ,Remarks= @Remarks
                                            ,SeoDescription=@SeoDescription
                                            ,SeoKeyword=@SeoKeyword
                                            ,SeoTitle=@SeoTitle
                                            ,LastUpdateBy=@LastUpdateBy
                                            ,LastUpdateDate=@LastUpdateDate 
                                            ,SysNos=@SysNos
                                            where SysNo = @SysNo")
                         .Parameter("CategoryImage", category.CategoryImage)
                         .Parameter("CategoryName", category.CategoryName)
                         .Parameter("DealerSysNo", category.DealerSysNo)
                         .Parameter("ParentSysNo", category.ParentSysNo)
                         .Parameter("Remarks", category.Remarks)
                         .Parameter("SeoDescription", category.SeoDescription)
                         .Parameter("SeoKeyword", category.SeoKeyword)
                         .Parameter("SeoTitle", category.SeoTitle)
                         .Parameter("LastUpdateBy", category.LastUpdateBy)
                         .Parameter("LastUpdateDate", category.LastUpdateDate)
                         .Parameter("SysNos", category.SysNos)
                         .Parameter("SysNo", category.SysNo)
                         .Execute();
            }

            return(result > 0);
        }
示例#7
0
 /// <summary>
 /// 保存分类信息
 /// </summary>
 /// <param name="updateCategory">分类实体对象</param>
 /// <returns>返回: true 成功 false 失败</returns>
 /// <remarks>2016-06-06 罗远康 创建</remarks>
 public abstract bool Update(FeNewsCategory updateCategory);
示例#8
0
 /// <summary>
 /// 修改新闻分类
 /// </summary>
 /// <param name="category">新闻分类实体</param>
 /// <param name="attributeGroupAso">新闻分类对应属性组</param>
 /// <returns>返回操作是否成功 true:成功   false:不成功</returns>
 /// <remarks>2016-06-06 罗远康 创建</remarks>
 public abstract bool EditCategory(FeNewsCategory category);
示例#9
0
 /// <summary>
 /// 添加新闻分类
 /// </summary>
 /// <param name="category">新闻分类实体</param>
 /// <param name="attributeGroupAso">新闻分类对应属性组</param>
 /// <returns>返回操作是否成功 true:成功   false:不成功</returns>
 /// <remarks>2016-06-06 罗远康 创建</remarks>
 public abstract bool CreateCategory(FeNewsCategory category);
示例#10
0
 /// <summary>
 /// 将分类排在父分类的末尾显示
 /// </summary>
 /// <param name="category">新闻分类对象</param>
 /// <param name="context">供应数据库操作上线文</param>
 /// <returns></returns>
 /// <returns>返回: true 成功 false 失败</returns>
 /// <remarks>2016-06-06 罗远康 创建</remarks>
 public abstract bool SetCategoryToLastShow(FeNewsCategory category, IDbContext context = null);
示例#11
0
        /// <summary>
        /// 修改新闻分类
        /// </summary>
        /// <param name="category">新闻分类实体</param>
        /// <param name="attributeGroups">新闻分类对应属性组</param>
        /// <returns>返回操作是否成功 true:成功   false:不成功</returns>
        /// <remarks>2016-06-07 罗远康 创建</remarks>
        public bool EditCategory(FeNewsCategory category)
        {
            int?   oldParentSysNo = null;
            string oldSysNos      = "";
            string newSysNos      = "";
            bool   success;
            //取得元数据
            FeNewsCategory updateCategory = GetCategory(category.SysNo);

            //判断是否需要格式化基础信息
            if (updateCategory.ParentSysNo != category.ParentSysNo)
            {
                oldParentSysNo        = updateCategory.ParentSysNo;
                oldSysNos             = updateCategory.SysNos;
                newSysNos             = IFeNewsCategoryDao.Instance.GetNewSysNos(category.ParentSysNo, category.SysNo);
                updateCategory.SysNos = newSysNos;
            }

            //赋新值
            updateCategory.CategoryImage  = category.CategoryImage;
            updateCategory.CategoryName   = category.CategoryName;
            updateCategory.LastUpdateBy   = category.LastUpdateBy;
            updateCategory.LastUpdateDate = category.LastUpdateDate;
            updateCategory.ParentSysNo    = category.ParentSysNo;
            updateCategory.Remarks        = category.Remarks;
            updateCategory.SeoDescription = category.SeoDescription;
            updateCategory.SeoKeyword     = category.SeoKeyword;
            updateCategory.SeoTitle       = category.SeoTitle;

            //更新新闻分类
            success = IFeNewsCategoryDao.Instance.EditCategory(updateCategory);

            //格式化信息
            if (success && oldParentSysNo != null)
            {
                //更新子分类系统编号路由
                success = success && IFeNewsCategoryDao.Instance.UpdateChildrenSysNos(oldSysNos, newSysNos, updateCategory.SysNo);
                //将该分类最近到新父分类末尾
                success = success && IFeNewsCategoryDao.Instance.SetCategoryToLastShow(updateCategory);
            }

            //提交事务
            if (success)
            {
                //用户操作日志
                BLL.Log.SysLog.Instance.Info(LogStatus.系统日志来源.后台,
                                             string.Format("更新新闻分类{0}基本信息", category.SysNo),
                                             LogStatus.系统日志目标类型.新闻帮助管理, category.SysNo,
                                             AdminAuthenticationBo.Instance.Current.Base.SysNo);
            }
            else
            {
                //用户操作日志
                BLL.Log.SysLog.Instance.Error(LogStatus.系统日志来源.后台,
                                              string.Format("更新新闻分类{0}基本信息失败", category.SysNo),
                                              LogStatus.系统日志目标类型.新闻帮助管理, category.SysNo,
                                              AdminAuthenticationBo.Instance.Current.Base.SysNo);
            }



            BLL.Cache.DeleteCache.NewsCategory(category.SysNo);

            return(true);
        }