示例#1
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);
        }
示例#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
        /// <summary>
        /// 更新配置项类型
        /// </summary>
        /// <param name="data"></param>
        /// <param name="group"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE UpdateConfigType(d_general data, List <ConfigUserDefinedFieldDto> group, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            //新增自定义字段组47
            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.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.update_user_id = user_id;
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            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      = data.id,                             // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = _dal.AddValue(data),
                remark              = "修改自定义字段组"
            };                                       // 创建日志

            new sys_oper_log_dal().Insert(add2_log); // 插入日志
            //新增配置项类型(table=108)
            var res2 = new GeneralBLL().GetSingleGeneral(data.name, data.general_table_id);

            if (res2 != null)
            {
                return(ERROR_CODE.EXIST);
            }
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            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.UPDATE,
                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.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            groupfield.update_user_id = user.id;
            var oldgroup = GetUdfGroup(data.id).ToDictionary(d => d.id);

            foreach (var t in group)
            {
                if (t.id != 0)
                {
                    if (!oldgroup.ContainsKey(t.id))//如果原本的字段组不包含这个字段的id,则说明,这个字段是新增的
                    //var rere = udf_group_dal.FindSignleBySql<sys_udf_group_field>($"select * from sys_udf_group_field where group_id={data.id} and udf_field_id={t.id} and delete_time=0");
                    //if (rere == null)
                    {//新增
                        groupfield.udf_field_id = t.id;
                        groupfield.is_required  = t.is_required;
                        groupfield.sort_order   = t.sort_order;
                        udf_group_dal.Insert(groupfield);
                        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      = groupfield.id,                       // 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                            oper_description    = _dal.AddValue(groupfield),
                            remark              = "新增自定义字段组"
                        };                                      // 创建日志
                        new sys_oper_log_dal().Insert(add_log); // 插入日志
                    }
                    else
                    {
                        //修改
                        groupfield.is_required = t.is_required;
                        groupfield.sort_order  = t.sort_order;
                        if (!udf_group_dal.Update(groupfield))
                        {
                            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      = groupfield.id,                       // 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                            oper_description    = _dal.AddValue(groupfield),
                            remark              = "修改自定义字段组"
                        };                                      // 创建日志
                        new sys_oper_log_dal().Insert(add_log); // 插入日志
                    }
                    //记录失去的自定义字段
                    oldgroup.Remove(t.id);
                }
            }
            //删除失去的自定义字段
            foreach (var old in oldgroup)
            {
                old.Value.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                old.Value.delete_user_id = user.id;
                if (!udf_group_dal.Update(old.Value))
                {
                    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      = groupfield.id,                       // 操作对象id
                    oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                    oper_description    = _dal.AddValue(groupfield),
                    remark              = "删除自定义字段组"
                };                                      // 创建日志
                new sys_oper_log_dal().Insert(add_log); // 插入日志
            }
            return(ERROR_CODE.SUCCESS);
        }