Пример #1
0
        public async Task <ActionResult <BaseResponse> > AddTypeOverviewAsync(int typeId, [FromBody] TypeOverViewAddDto req)
        {
            string Account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;

            #region 检测类型
            var type = await _ts.CheckTypeAsync(typeId);

            if (!type.IsExist)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的类型编号不存在"
                });
            }
            if (type.Status == 0)
            {
                return(new BaseResponse {
                    Success = false, Message = "该类型为目录型节点,不允许添加数据"
                });
            }
            #endregion
            #region 检测数据定义标示是否存在
            var td = await _td.IsExist(a => a.Id == req.TypeDataDefineId);

            if (!td)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的类型数据定义不存在"
                });
            }
            #endregion
            var rm = await _tos.AddTypeOverviewAsync(Account, typeId, req);

            return(rm);
        }
Пример #2
0
        public async Task <ActionResult <BaseResponse> > CopyTo(string GroupId, [FromBody] TypeCopyDto req)
        {
            //var GId = User.Claims.FirstOrDefault(a => a.Type == "GroupId").Value;
            var Account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;
            //var Code = User.Claims.FirstOrDefault(a => a.Type == "Code").Value;
            //var isAdmin = User.Claims.FirstOrDefault(a => a.Type == "IsAdmin").Value.ToLower() == "true" ? true : false;
            //验证输入的groupid是否存在
            var ex = await _gs.IsExist(a => a.Id == GroupId);

            if (!ex)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的组织编号不存在"
                });
            }
            //验证类型编号是否存在
            var source = await _ts.CheckTypeAsync(a => a.Id == req.SourceId && a.GroupId == GroupId);

            if (source.IsExist == false)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的源类型标示不存在"
                });
            }
            if (source.Status == 0)
            {
                return(new BaseResponse {
                    Success = false, Message = "源类型不能为目录节点"
                });
            }
            var target = await _ts.CheckTypeAsync(a => a.Id == req.TargetId && a.GroupId == GroupId);

            if (target.IsExist == false)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的目标类型标示不存在"
                });
            }
            if (target.Status == 1)
            {
                return(new BaseResponse {
                    Success = false, Message = "目标类型不能为叶子节点"
                });
            }

            ////验证用户权限
            //if (!(isAdmin && (GId == GroupId || Code == _config["Group"])))
            //{
            //    return Unauthorized("没有权限");
            //}
            var rm = await _ts.CopyTypeAsync(Account, req.SourceId, req.TargetId);

            return(rm);
        }
Пример #3
0
        public async Task <ActionResult <BaseResponse> > AddTypeModuleFeedbackAsync(int typeId, TypeModuleFeedbackAddDto req)
        {
            string Account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;

            #region 检测类型
            var type = await _ts.CheckTypeAsync(typeId);

            if (!type.IsExist)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的类型编号不存在"
                });
            }
            if (type.Status == 0)
            {
                return(new BaseResponse {
                    Success = false, Message = "该类型为目录型节点,不允许添加数据"
                });
            }
            #endregion
            #region 检测数据定义标示是否存在
            var td = await _td.IsExist(a => a.Id == req.DataDefineId);

            if (!td)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的类型数据定义不存在"
                });
            }
            #endregion
            #region 检测相关的控制项是否存在
            var exist = await _tmcs.IsExist(a => a.Id == req.ModuleControlId);

            if (!exist)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的控制项不存在"
                });
            }
            #endregion
            var rm = await _tfs.AddTypeModuleFeedbaskAsync(Account, req);

            return(rm);
        }
Пример #4
0
        public async Task <ActionResult <BaseResponse> > AddDevice(string GroupId, DeviceAddDto req)
        {
            BaseResponse br   = new BaseResponse();
            bool         bRet = await _gs.IsExist(opt => opt.Id == GroupId);

            if (!bRet)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的组织编号不存在,请确认"
                });
            }
            var type = await _ts.CheckTypeAsync(req.TypeId);

            if (!type.IsExist)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的类型不存在,请确认"
                });
            }
            else if (type.Status == 0)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的类型不能添加设备,请确认"
                });
            }
            var    GId     = User.Claims.FirstOrDefault(a => a.Type == "GroupId").Value;
            var    isAdmin = User.Claims.FirstOrDefault(a => a.Type == "IsAdmin").Value.ToLower() == "true" ? true : false;
            string Code    = User.Claims.FirstOrDefault(a => a.Type == "Code").Value;
            string Account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;
            string Roles   = User.Claims.FirstOrDefault(a => a.Type == "Role").Value;

            if (req.ProjectId.HasValue && req.ProjectId.Value != 0)
            {
                //string pathId, groupId;
                var pc = await _ps.GetProjectCheckAsync(req.ProjectId.Value);

                if (!pc.IsExist)
                {
                    return(new BaseResponse {
                        Success = false, Message = "输入的项目或者场站不存在"
                    });
                }
                if (!pc.IsSite)
                {
                    return(new BaseResponse {
                        Success = false, Message = "设备只能添加在场站下面"
                    });
                }
                if (GroupId != pc.GroupId)
                {
                    return(new BaseResponse {
                        Success = false, Message = "输入的项目不存在或者项目与组织编号不匹配"
                    });
                }

                if (isAdmin)
                {
                    if (GroupId != GId && Code != _config["Group"])
                    {
                        return(new BaseResponse {
                            Success = false, Message = "用户所属的组织编号和该组织编号不匹配"
                        });
                    }
                }
                else
                {
                    pc.PathId = $"{pc.PathId}/{req.ProjectId.Value}";
                    bRet      = await _rp.IsAuth(Roles, pc.PathId, 3);

                    if (!bRet)
                    {
                        return(new BaseResponse {
                            Success = false, Message = "用户没有在该场站下添加设备的权限"
                        });
                    }
                }
            }
            else//无项目的设备,只有管理员才有权限添加
            {
                if (!(isAdmin && (GroupId == GId || Code == _config["Group"])))
                {
                    return(new BaseResponse {
                        Success = false, Message = "用户没有权限添加无项目的设备"
                    });
                }
            }
            var rm = await _ds.AddDeviceAsync(req, Account, GroupId);

            return(rm);
        }