예제 #1
0
파일: KnowledgeBLL.cs 프로젝트: evelh/Done
        /// <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);
        }
예제 #2
0
        /// <summary>
        /// 新增地域
        /// </summary>
        /// <param name="data"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE SaveTerritory(d_general data, long user_id, ref int id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            if (id > 0)
            {
                var res = new GeneralBLL().GetSingleGeneral(data.name, data.general_table_id);
                if (res != null && res.id != data.id)
                {
                    return(ERROR_CODE.EXIST);
                }
                var old = new GeneralBLL().GetSingleGeneral(data.id);
                data.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                data.update_user_id = user_id;
                if (!_dal.Update(data))
                {
                    return(ERROR_CODE.ERROR);
                }
                var add_log = new sys_oper_log()
                {
                    user_cate           = "用户",
                    user_id             = (int)user.id,
                    name                = user.name,
                    phone               = user.mobile == null ? "" : user.mobile,
                    oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                    oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, //
                    oper_object_id      = data.id,                             // 操作对象id
                    oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                    oper_description    = _dal.CompareValue(old, data),
                    remark              = "修改地域信息"
                };                                      // 创建日志
                new sys_oper_log_dal().Insert(add_log); // 插入日志
            }
            else
            {
                data.general_table_id = (int)GeneralTableEnum.TERRITORY;
                data.create_time      = data.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                data.create_user_id   = user_id;
                //唯一性校验
                var res = new GeneralBLL().GetSingleGeneral(data.name, data.general_table_id);
                if (res != null)
                {
                    return(ERROR_CODE.EXIST);
                }
                _dal.Insert(data);
                var re = _dal.FindSignleBySql <d_general>($"select * from d_general where name='{data.name}'");
                if (re != null)
                {
                    id = re.id;
                }
                var add_log = new sys_oper_log()
                {
                    user_cate           = "用户",
                    user_id             = (int)user.id,
                    name                = user.name,
                    phone               = user.mobile == null ? "" : user.mobile,
                    oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                    oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code,
                    oper_object_id      = data.id,// 操作对象id
                    oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                    oper_description    = _dal.AddValue(data),
                    remark              = "新增地域信息"
                };                                      // 创建日志
                new sys_oper_log_dal().Insert(add_log); // 插入日志
            }
            return(ERROR_CODE.SUCCESS);
        }
예제 #3
0
파일: ConfigTypeBLL.cs 프로젝트: evelh/Done
        /// <summary>
        /// 新增配置项类型
        /// </summary>
        /// <param name="data"></param>
        /// <param name="group"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE InsertConfigType(d_general data, List <ConfigUserDefinedFieldDto> group, long user_id)
        {
            int groupid;//自定义分组id
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            //新增自定义字段组47
            //groupid=data.id=(int)(_dal.GetNextIdCom());
            data.parent_id        = (int)DicEnum.UDF_CATE.CONFIGURATION_ITEMS;
            data.general_table_id = (int)GeneralTableEnum.UDF_FILED_GROUP;
            var res = new GeneralBLL().GetSingleGeneral(data.name, data.general_table_id);

            if (res != null)
            {
                return(ERROR_CODE.EXIST);
            }
            data.create_time    = data.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.create_user_id = data.update_user_id = user_id;
            _dal.Insert(data);
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, //
                oper_object_id      = data.id,                             // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                oper_description    = _dal.AddValue(data),
                remark              = "新增自定义字段组47"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志
            var k = _dal.FindSignleBySql <d_general>($"select * from d_general where name={data.name} and general_table_id={data.general_table_id} and delete_time=0");

            if (k == null)
            {
                return(ERROR_CODE.ERROR);
            }
            else
            {
                groupid = k.id;
            }
            //新增配置项类型(table=108)
            data.ext1             = groupid.ToString();
            data.general_table_id = (int)GeneralTableEnum.INSTALLED_PRODUCT_CATE;
            var res2 = new GeneralBLL().GetSingleGeneral(data.name, data.general_table_id);

            if (res2 != null)
            {
                return(ERROR_CODE.EXIST);
            }
            _dal.Insert(data);
            var add1_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, //
                oper_object_id      = data.id,                             // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                oper_description    = _dal.AddValue(data),
                remark              = "新增配置项类型"
            };                                       // 创建日志

            new sys_oper_log_dal().Insert(add1_log); // 插入日志
            //自定义字段组
            sys_udf_group_field groupfield = new sys_udf_group_field();

            groupfield.create_time    = groupfield.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            groupfield.create_user_id = groupfield.update_user_id = user.id;
            groupfield.group_id       = groupid;
            foreach (var t in group)
            {
                if (t.id != 0)
                {
                    groupfield.udf_field_id = t.id;
                    groupfield.is_required  = t.is_required;
                    groupfield.sort_order   = t.sort_order;
                    udf_group_dal.Insert(groupfield);
                    var add2_log = new sys_oper_log()
                    {
                        user_cate           = "用户",
                        user_id             = (int)user.id,
                        name                = user.name,
                        phone               = user.mobile == null ? "" : user.mobile,
                        oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                        oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, //
                        oper_object_id      = groupfield.id,                       // 操作对象id
                        oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                        oper_description    = _dal.AddValue(groupfield),
                        remark              = "新增自定义字段组"
                    };                                       // 创建日志
                    new sys_oper_log_dal().Insert(add2_log); // 插入日志
                }
            }
            return(ERROR_CODE.SUCCESS);
        }