Example #1
0
 public IHttpActionResult DeleteHostPolicyLogs([FromBody] Guid[] Ids) => Json(HostPolicyService.TryCatchAction(
                                                                                  action: m =>
 {
     Ids.CheckNotNullOrEmpty("Ids");
     var cacheUser = GetCacheUser;
     if (!cacheUser.Level.IsBetween(1, 2))
     {
         throw new Exception("id:你没有权限进行此项操作!");
     }
     return(m.DeleteHostPolicyLogs(Ids));
 }));
Example #2
0
 public IHttpActionResult Host_0x5B([FromBody] HostPolicy_0x5B_In x5B_In) => Json(HostPolicyService.TryCatchAction(m =>
 {
     return(m.Updataed_0x5B(x5B_In));
 }));
Example #3
0
        public IHttpActionResult AddHostPolicys([FromBody] params HostPolicyInputDto[] datas) => Json(HostPolicyService.TryCatchAction(
                                                                                                          action: m =>
        {
            datas.CheckNotNullOrEmpty("datas");
            var cacheUser = GetCacheUser;     //获取缓存判断

            // 不管信息是否添加成功?都执行删除当前对象页的缓存
            ICache cache = CacheManager.GetCacher <HostPolicy>();
            cache.Clear();
            // --------------------------------------------

            return(m.AddHostPolicys(cacheUser, datas));
        }));
Example #4
0
        public IHttpActionResult GetHostPolicys([FromBody] GridRequestsModel grid) => Json(HostPolicyService.TryCatchAction(
                                                                                               action: m =>
        {
            grid.CheckNotNull("grid");
            var cacheUser = GetCacheUser;     //获取缓存判断

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

            //查询用户所管理的组织机构下的主机信息
            var queryable1 = MyHostqueryable;
            //如果超级管理员查询全部信息
            if (cacheUser.IsAdministrator)
            {
                queryable1 = HostService.HostQueryable;
            }

            //查询管理主机关联的主机登陆参数
            var queryable2 = from c in m.HostPolicyQueryable
                             join d in queryable1
                             on c.Host_Id equals d.Id
                             select c;

            Expression <Func <HostPolicy, bool> > predicate = FilterHelper.GetExpression <HostPolicy>(request.FilterGroup);

            var data = queryable2.ToPageCache <HostPolicy, HostPolicyPageOutDto>(predicate, request.PageCondition);

            //缓存用户获取的主机列表主机,用于操作验证
            var cacheUserId = data.ListData.Select(b => b.Id);
            ICache iCache   = CacheManager.GetCacher("CacheHostPolicyId");
            iCache.Set(cacheUser.UserName.AESEncrypt128(), cacheUserId, TimeSpan.FromMinutes(30));
            //-------------------------------------------------------------------------------------
            return(new OperationResult(OperationResultType.Success, "操作成功", data));
        }));
Example #5
0
        public IHttpActionResult GetHostpolicyLogs([FromBody] GridRequestsModel grid) => Json(HostPolicyService.TryCatchAction(
                                                                                                  action: m =>
        {
            grid.CheckNotNull("grid");
            var cacheUser = GetCacheUser;     //获取缓存判断

            //查询条件
            GridRequests request = new GridRequests(grid);
            //添加默认排序,只有排序未设置的情况下生效
            request.AddDefaultSortCondition(new SortCondition("CreatedTime", ListSortDirection.Descending));
            var queryable1 = from a in m.HostPolicyLogQueryable
                             join b in ListOrganizeId
                             on a.Organzie_Id equals b
                             select(new HostPolicyLogView
            {
                CreatedTime         = a.CreatedTime,
                DataItemDetailIndex = a.DataItemDetailOne.Index,
                DataItemDetailName  = a.DataItemDetailOne.FullName,
                HostName            = a.HostOne.FullName,
                HostRegPacket       = a.HostOne.RegPackage,
                HostPolicyName      = a.HostPolicyOne.FullName,
                HostPolicyNum       = a.HostPolicyOne.Number,
                Id           = a.Id,
                OrganizeName = a.OrganizeOne.FullName,
                UserName     = a.UserLoginOne.UserName
            });
            //如果超级管理员查询全部信息
            if (cacheUser.IsAdministrator)
            {
                queryable1 = m.HostPolicyLogQueryable.Select(a => new HostPolicyLogView
                {
                    CreatedTime         = a.CreatedTime,
                    DataItemDetailIndex = a.DataItemDetailOne.Index,
                    DataItemDetailName  = a.DataItemDetailOne.FullName,
                    HostName            = a.HostOne.FullName,
                    HostRegPacket       = a.HostOne.RegPackage,
                    HostPolicyName      = a.HostPolicyOne.FullName,
                    HostPolicyNum       = a.HostPolicyOne.Number,
                    Id           = a.Id,
                    OrganizeName = a.OrganizeOne.FullName,
                    UserName     = a.UserLoginOne.UserName
                });
            }

            Expression <Func <HostPolicyLogView, bool> > predicate = FilterHelper.GetExpression <HostPolicyLogView>(request.FilterGroup);

            var data = queryable1.ToPage <HostPolicyLogView, HostPolicyLogOutDto>(predicate, request.PageCondition);
            return(new OperationResult(OperationResultType.Success, "操作成功", data));
        }));
Example #6
0
        public IHttpActionResult DeleteHostpolicys([FromBody] params Guid[] ids) => Json(HostPolicyService.TryCatchAction(
                                                                                             action: m =>
        {
            ids.CheckNotNullOrEmpty("ids");
            var cacheUser = GetCacheUser;    //获取缓存判断

            if (!cacheUser.Level.IsBetween(1, 2))
            {
                throw new Exception("id:你没有权限进行此项操作!");
            }

            // 不管信息是否添加成功?都执行删除当前对象页的缓存
            ICache cache = CacheManager.GetCacher <HostPolicy>();
            cache.Clear();
            // --------------------------------------------

            ICache iCache    = CacheManager.GetCacher("CacheHostPolicyId");
            var cachePageIds = (iCache.Get(cacheUser.UserName.AESEncrypt128()) as IEnumerable <Guid>).ToArray();
            if (cachePageIds.Length == 0)
            {
                throw new Exception($"id:未能找到准备删除的缓存数据!");
            }
            return(m.DeleteHostpolicys(cachePageIds, ids));
        }));
Example #7
0
        public IHttpActionResult EditHostPolicys([FromBody] params HostPolicyInputDto[] datas) => Json(HostPolicyService.TryCatchAction(
                                                                                                           action: m =>
        {
            datas.CheckNotNullOrEmpty("datas");
            var cacheUser = GetCacheUser;    //获取缓存判断

            // 不管信息是否添加成功?都执行删除当前对象页的缓存
            ICache cache = CacheManager.GetCacher <HostPolicy>();
            cache.Clear();
            // --------------------------------------------
            ICache iCache    = CacheManager.GetCacher("CacheHostPolicyId");
            var cachePageIds = (iCache.Get(cacheUser.UserName.AESEncrypt128()) as IEnumerable <Guid>).ToArray();
            return(m.EditHostPolicys(cachePageIds, cacheUser, datas));
        }));