Exemplo n.º 1
0
 public async Task <IHttpActionResult> UserAdds([FromBody] params UserLoginInputDto[] UserSet) => Json(await UserLoginService.TryCatchActionAsync(
                                                                                                           action: async m =>
 {
     UserSet.CheckNotNullOrEmpty("UserSet");
     var cacheUser = GetCacheUser;
     if (!cacheUser.IsAdministrator)
     {
         foreach (var i in UserSet)
         {
             if (!ListOrganizeId.Contains(i.Organize_Id) && i.Organize_Id != cacheUser.Organize_Id)
             {
                 throw new Exception($"id:添加用户的组织机构归属不在权限范围内");
             }
             foreach (var a in i.PermissionList.Split(','))
             {
                 if (!IntPermissionList.Contains(a))
                 {
                     throw new Exception($"id:添加的用户的操作权限归属不在权限范围内");
                 }
             }
         }
     }
     // 不管信息是否添加成功?都执行删除当前对象页的缓存
     ICache cache = CacheManager.GetCacher <UserPageView>();
     cache.Clear();
     // --------------------------------------------
     return(await UserLoginService.AddUserLogin(GetCacheUser, UserSet));
 }));
Exemplo n.º 2
0
 public IHttpActionResult SumHourPower(int Year, int Month, int Day, Guid DataItemDetailId, Guid OrganizeId) => Json(Sum_PowerService.TryCatchAction(
                                                                                                                         action: m =>
 {
     var cacheUser = GetCacheUser;
     if (!cacheUser.IsAdministrator && !ListOrganizeId.Contains(OrganizeId))
     {
         throw new Exception($"id:没有权限操作该组织机构");
     }
     return(m.Sum_HourPower(DataItemDetailId, OrganizeId, Year, Month, Day));
 }));
Exemplo n.º 3
0
        public IHttpActionResult GridData([FromBody] GridRequestsModel grid) => Json(UserLoginService.TryCatchAction(
                                                                                         action: m =>
        {
            grid.CheckNotNull("grid");
            var cacheUser = GetCacheUser;
            if (!cacheUser.Level.IsBetween(1, 2))
            {
                throw new Exception($"id:你的操作权限等级过低");
            }

            //查询条件
            GridRequests request = new GridRequests(grid);
            //添加默认排序,只有排序未设置的情况下生效
            request.AddDefaultSortCondition(new SortCondition("CreatedTime", ListSortDirection.Descending));

            //获取查询集合
            IQueryable <UserPageView> queryable = (from n in m.IQUserLogins
                                                   join b in m.IQUsers
                                                   on n.Id equals b.UserLogin_Id
                                                   where n.IsAdministrator == false
                                                   select(new UserPageView
            {
                Id = n.Id,
                UserName = n.UserName,
                IsLocked = n.IsLocked,
                LockoutEnabled = n.LockoutEnabled,
                OrganizeName = n.OrganizeOne.FullName,
                NickName = b.NickName,
                RealName = b.RealName,
                Email = b.Email,
                PhoneNumber = b.PhoneNumber,
                CreatedTime = b.CreatedTime,
                Organize_Id = n.Organize_Id,
                LoginCount = n.LoginCount,
                IsAdministrator = n.IsAdministrator,
                Level = n.Level,
                PermissionList = n.PermissionList,
            })).AsQueryable();
            Expression <Func <UserPageView, bool> > predicate = FilterHelper.GetExpression <UserPageView>(request.FilterGroup);
            if (!cacheUser.IsAdministrator)
            {
                predicate = predicate.And(b => ListOrganizeId.Contains(b.Organize_Id));
            }

            var data = queryable.ToPageCache <UserPageView, UserPageOutDto>(predicate, request.PageCondition);

            //把用户获取的用户信息主键缓存起来,留待修改时校正
            var cacheUserId = data.ListData.Select(b => b.Id);
            ICache iCache   = CacheManager.GetCacher("CacheUserPageId");
            iCache.Set(cacheUser.UserName.AESEncrypt128(), cacheUserId, TimeSpan.FromMinutes(30));

            return(new OperationResult(OperationResultType.Success, "获取数据成功", data));
        }));
Exemplo n.º 4
0
        public async Task <IHttpActionResult> EditData([FromBody] params UserPageOutDto[] user) => Json(await UserLoginService.TryCatchActionAsync(
                                                                                                            action: async m =>
        {
            Logger.Debug(user.ToJsonString());
            user.CheckNotNullOrEmpty("user");
            UserPageIn[] InputUser = new UserPageIn[user.Length];
            await Task.Run(() =>
            {
                var cacheUser = GetCacheUser;
                ICache iCache = CacheManager.GetCacher("CacheUserPageId");
                var cacheIds  = iCache.Get(cacheUser.UserName.AESEncrypt128()) as IEnumerable <Guid>;
                for (int n = 0; n < user.Length; n++)
                {
                    var i = user[n];
                    if (!cacheUser.IsAdministrator)
                    {
                        if (cacheIds == null)
                        {
                            throw new Exception("id:请先获取数据再进行操作!");
                        }
                        if (!cacheIds.Contains(i.Id))
                        {
                            throw new Exception($"id:值主键{i.Id}不在范围内,请尝试重新获取数据后在操作...");
                        }
                        if (!ListOrganizeId.Contains(i.Organize_Id))
                        {
                            throw new Exception($"id:用户主键{i.Id}的组织机构归属不在权限范围内");
                        }
                        if (i.Level <= cacheUser.Level)
                        {
                            throw new Exception($"id:用户主键{i.Id}的权限等级归属不在权限范围内");
                        }
                        foreach (var a in i.PermissionList.Split(','))
                        {
                            if (!IntPermissionList.Contains(a))
                            {
                                throw new Exception($"id:用户主键{i.Id}的操作权限归属不在权限范围内");
                            }
                        }
                    }

                    UserPageIn userPageIn        = i.MapTo <UserPageIn>();
                    userPageIn.LastUpdatorUserId = cacheUser.UserName;
                    InputUser[n] = userPageIn;
                }
            });
            //不管用户是否更新成功,都执行删除当前对象页的缓存
            ICache cache = CacheManager.GetCacher <UserPageView>();
            cache.Clear();
            //----------------------------------------------
            return(await m.EditUserData(InputUser));
        }));
Exemplo n.º 5
0
        public IHttpActionResult FindHostOne(Guid id) => Json(HostService.TryCatchAction(
                                                                  action: m =>
        {
            id.CheckNotEmpty("id");
            var cacheUser = GetCacheUser;

            Host queryable = m.HostQueryable.FirstOrDefault(mx => mx.Id == id && ListOrganizeId.Contains(mx.Organize_Id));
            if (cacheUser.IsAdministrator)
            {
                queryable = m.HostQueryable.FirstOrDefault(mx => mx.Id == id);
            }
            HostPageOutDto host = queryable.MapTo <HostPageOutDto>();
            return(new OperationResult(OperationResultType.Success, "请求数据成功", host));
        }));
Exemplo n.º 6
0
        public IHttpActionResult GetDataItemDetailById(Guid Id) => Json(DataItemService.TryCatchAction(
                                                                            action: m =>
        {
            var cacheUser = GetCacheUser;

            var queryable1 = from a in m.DataItemDetailQueryable
                             join b in m.DataItemQueryable
                             on a.DataItem_Id equals b.Id
                             where a.DataItem_Id == Id && (a.Organzie_Id == null || ListOrganizeId.Contains(a.Organzie_Id.Value)) && b.IsPublic == true
                             select new
            {
                Id           = a.Id,
                FullName     = a.FullName,
                QueryCoding  = a.QueryCoding,
                IsLocked     = a.IsLocked,
                IsPublic     = a.IsPublic,
                Remark       = a.Remark,
                CreatedTime  = a.CreatedTime,
                Index        = a.Index,
                IsSystem     = a.IsSystem,
                OrganizeName = a.OrganizeOne.FullName
            };
            if (cacheUser.IsAdministrator)
            {
                queryable1 = m.DataItemDetailQueryable.Where(b => b.DataItem_Id == Id)
                             .Select(a => new
                {
                    Id           = a.Id,
                    FullName     = a.FullName,
                    QueryCoding  = a.QueryCoding,
                    IsLocked     = a.IsLocked,
                    IsPublic     = a.IsPublic,
                    Remark       = a.Remark,
                    CreatedTime  = a.CreatedTime,
                    Index        = a.Index,
                    IsSystem     = a.IsSystem,
                    OrganizeName = a.OrganizeOne.FullName
                });
            }

            var result = queryable1.ToArray();
            return(new OperationResult(OperationResultType.Success, "获取结果成功", result));
        }));
Exemplo n.º 7
0
 public IHttpActionResult GetSubNum([FromBody] params Guid[] Ids) => Json(SubControlService.TryCatchAction(
                                                                              action: m => {
     if (!Ids.IsEmpty())
     {
         var user = GetCacheUser;
         if (!GetCacheUser.IsAdministrator)
         {
             foreach (Guid id in Ids)
             {
                 if (!ListOrganizeId.Contains(id))
                 {
                     throw new Exception($"id:没有权限查询组织机构信息:{id}");
                 }
             }
         }
         return(m.GetSubCount(Ids));
     }
     else
     {
         return(m.GetSubCount(ListOrganizeId.ToArray()));
     }
 }));
Exemplo n.º 8
0
        public IHttpActionResult GetAppointType(string EnQuerying) => Json(DataItemService.TryCatchAction(
                                                                               action: m =>
        {
            EnQuerying.CheckNotNullOrEmpty("EnQuerying");

            string unQuerying = EnQuerying.AESDecrypt();

            var cacheUser = GetCacheUser;

            var queryable1 = from a in m.DataItemDetailQueryable
                             where a.QueryCoding == unQuerying &&
                             (a.Organzie_Id == null || ListOrganizeId.Contains(a.Organzie_Id.Value)) &&
                             a.IsLocked == false
                             orderby a.Index ascending
                             select new { Id = a.Id, FullName = a.FullName, Index = a.Index };

            if (cacheUser.IsAdministrator)
            {
                queryable1 = m.DataItemDetailQueryable.Where(b => b.QueryCoding == unQuerying && b.IsPublic == true && b.IsLocked == false)
                             .Select(a => new { Id = a.Id, FullName = a.FullName, Index = a.Index });
            }
            var result = queryable1.ToArray();
            return(new OperationResult(OperationResultType.Success, "获取结果成功", result));
        }));
Exemplo n.º 9
0
        public IHttpActionResult FindSubOne(Guid id) => Json(SubControlService.TryCatchAction(
                                                                 action: m =>
        {
            id.CheckNotEmpty("id");
            var cacheUser = GetCacheUser;

            SubControl queryable = m.SubControlQueryable.FirstOrDefault(mx => mx.Id == id && ListOrganizeId.Contains(mx.LigthPoleOne.HostOne.Organize_Id));
            if (cacheUser.IsAdministrator)
            {
                queryable = m.SubControlQueryable.FirstOrDefault(mx => mx.Id == id);
            }
            SubControlView subv = queryable.MapTo <SubControlView>();
            return(new OperationResult(OperationResultType.Success, "请求数据成功", subv));
        }));