Example #1
0
        /// <summary>
        /// 修改知识库的类别( 某一类别下的所有知识库包括子类别的所有知识库 )
        /// </summary>
        public void ChangeArtCate(long cateId, long userId, int parentId)
        {
            var subArt  = _dal.GetArtByCate(cateId);
            var dgDal   = new d_general_dal();
            var gBll    = new GeneralBLL();
            var subMenu = dgDal.GetGeneralByParentId(cateId);

            if (subArt != null && subArt.Count > 0)
            {
                foreach (var art in subArt)
                {
                    subArt.ForEach(_ => {
                        _.kb_category_id = parentId;
                        UpdateKnow(_, userId);
                    });
                }
            }
            if (subMenu != null && subMenu.Count > 0)
            {
                foreach (var menu in subMenu)
                {
                    ChangeArtCate(menu.id, userId, parentId);
                    dgDal.SoftDelete(menu, userId);
                    OperLogBLL.OperLogAdd <d_general>(menu, menu.id, userId, OPER_LOG_OBJ_CATE.General_Code, "删除知识库目录");
                }
            }
        }
Example #2
0
        /// <summary>
        /// 编辑知识库目录
        /// </summary>
        public bool EditKnowMenu(long cateId, string name, int parentId, long userId, ref string failReason)
        {
            var dgDal = new d_general_dal();

            if (string.IsNullOrEmpty(name))
            {
                failReason = "为获取到相关名称";
                return(false);
            }
            var cate = dgDal.FindNoDeleteById(cateId);

            if (cate == null)
            {
                failReason = "该目录已经删除";
                return(false);
            }
            var isCanAdd = true;
            var subList  = dgDal.GetGeneralByParentId(parentId);

            if (subList != null && subList.Count > 0)
            {
                if (subList.Any(_ => name.Equals(_.name) && _.id != cateId))
                {
                    isCanAdd = false;
                }
            }
            if (!isCanAdd)
            {
                failReason = "同一级目录,名称不能相同!";
                return(false);
            }
            cate.name           = name;
            cate.parent_id      = parentId;
            cate.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            cate.update_user_id = userId;
            var oldCate = dgDal.FindNoDeleteById(cateId);

            dgDal.Update(cate);
            OperLogBLL.OperLogUpdate <d_general>(cate, oldCate, cate.id, userId, OPER_LOG_OBJ_CATE.General_Code, "编辑知识库目录");
            return(true);
        }
Example #3
0
        /// <summary>
        /// 新增知识库目录
        /// </summary>
        public bool AddKnowMenu(string name, int parentId, long userId, ref string failReason)
        {
            if (string.IsNullOrEmpty(name))
            {
                failReason = "为获取到相关名称";
                return(false);
            }
            var dgDal    = new d_general_dal();
            var isCanAdd = true;
            var subList  = dgDal.GetGeneralByParentId(parentId);

            if (subList != null && subList.Count > 0)
            {
                if (subList.Any(_ => name.Equals(_.name)))
                {
                    isCanAdd = false;
                }
            }
            if (!isCanAdd)
            {
                failReason = "同一级目录,名称不能相同!";
                return(false);
            }
            var timeNow  = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            var thisCate = new d_general()
            {
                id = (int)dgDal.GetNextIdCom(),
                general_table_id = (int)DTO.GeneralTableEnum.KNOWLEDGE_BASE_CATE,
                create_time      = timeNow,
                update_time      = timeNow,
                create_user_id   = userId,
                update_user_id   = userId,
                name             = name,
                parent_id        = parentId,
            };

            dgDal.Insert(thisCate);
            OperLogBLL.OperLogAdd <d_general>(thisCate, thisCate.id, userId, OPER_LOG_OBJ_CATE.General_Code, "新增知识库目录");
            return(true);
        }
Example #4
0
        public bool DeleteProductCate(long cateId, long userId)
        {
            d_general_dal dgDal   = new d_general_dal();
            var           proList = _dal.FindListBySql <ivt_product>($"SELECT * from ivt_product where delete_time = 0 and cate_id =" + cateId.ToString());

            if (proList != null && proList.Count > 0)
            {
                proList.ForEach(_ => {
                    _.cate_id = null;
                    EditProduct(_, userId);
                });
            }
            var childCateList = dgDal.GetGeneralByParentId(cateId);

            if (childCateList != null && childCateList.Count > 0)
            {
                GeneralBLL genBll = new GeneralBLL();
                childCateList.ForEach(_ => {
                    genBll.Delete(_.id, userId, (long)GeneralTableEnum.PRODUCT_CATE);
                });
            }
            return(true);
        }