Exemplo n.º 1
0
        public async Task <Result <QueryAllModel <BlobModel> > > GetAll(QueryInputModel query, CancellationToken token)
        {
            bool   ok      = false;
            string message = "";
            IEnumerable <BlobModel>   models = null;
            QueryAllModel <BlobModel> model  = new QueryAllModel <BlobModel>();
            string newContinuationToken      = null;

            try
            {
                var queryOptions = new QueryRequestOptions
                {
                    PartitionKey = new PartitionKey(_partitionId + "_" + _userInfo.UserId),
                    MaxItemCount = _contextCosmosDB.MaxItemCount
                };

                //await foreach (var page in RepositoryContainer.GetItemQueryIterator<BlobModel>(query.Query, query.ContinuationToken, queryOptions, token).AsPages())
                //{
                //    models = page.Values;
                //    newContinuationToken = page.ContinuationToken;
                //    break;
                //}

                model.ContinuationToken = newContinuationToken;
                model.models            = models;
                ok = true;
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return(_result.Create(ok, message, model));
        }
        public async Task <ActionResult <ApiResultViewModel <IEnumerable <AccountInvitationViewModel> > > > GetAll(
            [FromQuery] QueryInputModel <AccountInvitationFilterInputModel> query, CancellationToken cancellationToken)
        {
            var data = await _accountInvitationManager.GetAllAsync(query, cancellationToken);

            return(OkData(AccountInvitationViewModel.MapAll(data.Data), new DataMetaViewModel(data.TotalCount)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetAll(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "users/GetAll")] HttpRequestMessage req,
            HttpRequest request, ILogger log, CancellationToken cancellationToken)
        {
            var resultAuth = validAdmin(req, request, new List <string>()
            {
                "users.list"
            });

            if (!resultAuth.Success)
            {
                return(new BadRequestObjectResult(resultAuth.Message));
            }

            QueryInputModel data = await req.Content.ReadAsAsync <QueryInputModel>();

            var dataResult = await _controller.GetAll(data, cancellationToken);

            if (!dataResult.Success)
            {
                return(new BadRequestObjectResult(dataResult.Message));
            }

            return(new OkObjectResult(dataResult.Value));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetAll(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "Blobs/GetAll")] HttpRequestMessage req,
            HttpRequest request, ILogger log, CancellationToken cancellationToken)
        {
            var resultAuth = validAuthorized(req, request);

            if (!resultAuth.Success)
            {
                if (resultAuth.Message == _errors.NotAuthorized)
                {
                    return(new UnauthorizedResult());
                }
                else
                {
                    var objectResult = new ObjectResult(resultAuth.Message)
                    {
                        StatusCode = StatusCodes.Status401Unauthorized
                    };

                    return(objectResult);
                }
            }

            QueryInputModel data = await req.Content.ReadAsAsync <QueryInputModel>();

            var dataResult = await _controller.GetAll(data, cancellationToken);

            if (!dataResult.Success)
            {
                return(new BadRequestObjectResult(dataResult.Message));
            }

            return(new OkObjectResult(dataResult.Value));
        }
Exemplo n.º 5
0
        GetAchievementTypesAsync(QueryInputModel <AchievementTypeFilterInputModel> filter,
                                 CancellationToken cancellationToken)
        {
            var result = await _achievementTypeManager.GetAllAsync(filter, cancellationToken);

            return(OkData(AchievementTypeViewModel.MapAll(result.Data), result.TotalCount));
        }
Exemplo n.º 6
0
        public async Task <ActionResult <ApiResultViewModel <IEnumerable <AccountViewModel> > > > GetAccounts(
            QueryInputModel <AccountFilterInputModel> inputModel,
            CancellationToken cancellationToken)
        {
            var queryResult = await _accountManager.GetAllAsync(inputModel, cancellationToken);

            return(OkData(AccountViewModel.MapAll(queryResult.Data), new DataMetaViewModel(queryResult.TotalCount)));
        }
Exemplo n.º 7
0
 public async Task <QueryResult <TEntity> > GetAllAsync(QueryInputModel queryModel,
                                                        CancellationToken cancellationToken = default)
 {
     using (var db = CreateDbContext())
     {
         return(await QueryProcessor.ApplyAsync(db.Set <TEntity>().AsNoTracking(), queryModel, cancellationToken));
     }
 }
Exemplo n.º 8
0
        public async Task ShouldGetPagedListFromServer()
        {
            var studentgenerator = new AutoFaker <StudentEntity>()
                                   .RuleFor(p => p.StudentId, 0);
            var students = studentgenerator.Generate(2);

            students.ForEach(p => InsertAsync(p));
            var query     = new QueryInputModel();
            var viewmodel = await SendAsync(query);

            viewmodel.StudentList.Count().Should().BeGreaterOrEqualTo(2);
        }
Exemplo n.º 9
0
        public async Task <Result <UserQueryModel> > GetAll(QueryInputModel query, CancellationToken token)
        {
            bool             ok      = false;
            string           message = "";
            List <UserModel> models  = new List <UserModel>();
            UserQueryModel   model   = new UserQueryModel();
            string           newContinuationToken = null;

            try
            {
                var queryOptions = new QueryRequestOptions
                {
                    PartitionKey = new PartitionKey(_partitionId),
                    MaxItemCount = _contextCosmosDB.MaxItemCount
                };

                using (FeedIterator <UserModel> feedIterator = RepositoryContainer.GetItemQueryIterator <UserModel>(
                           query.Query,
                           query.ContinuationToken,
                           queryOptions))
                {
                    while (feedIterator.HasMoreResults)
                    {
                        FeedResponse <UserModel> response = await feedIterator.ReadNextAsync();

                        newContinuationToken = response.ContinuationToken;
                        foreach (var item in response.Resource)
                        {
                            models.Add(item);
                        }
                    }
                }

                model.ContinuationToken = newContinuationToken;
                model.models            = models;
                ok = true;
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return(_result.Create(ok, message, model));
        }
Exemplo n.º 10
0
        public async Task <ActionResult <ApiResultViewModel <FriendRequest> > > GetFriendRequests(
            [FromQuery] QueryInputModel <FriendRequestFilterInputModel> filterInputModel,
            CancellationToken cancellationToken)
        {
            var fromAccountId = filterInputModel.FilterParameters.FirstOrDefault(q =>
                                                                                 q.FieldName == nameof(FriendRequestFilterInputModel.FromAccountId));

            var toAccountId = filterInputModel.FilterParameters.FirstOrDefault(q =>
                                                                               q.FieldName == nameof(FriendRequestFilterInputModel.ToAccountId));

            if ((fromAccountId == null || !string.Equals(fromAccountId.Values[0], AccountId.ToString(),
                                                         StringComparison.OrdinalIgnoreCase)) &&
                (toAccountId == null || !string.Equals(toAccountId.Values[0], AccountId.ToString(),
                                                       StringComparison.OrdinalIgnoreCase)))
            {
                return(Forbidden());
            }

            var friendRequests = await _friendRequestManager.GetAllAsync(filterInputModel, cancellationToken);

            return(OkData(friendRequests.Data, friendRequests.TotalCount));
        }
Exemplo n.º 11
0
 public QueryPermissionChecker(string key, QueryInputModel value, string queryFieldName)
 {
     Key             = key;
     Value           = value;
     _queryFieldName = queryFieldName;
 }
Exemplo n.º 12
0
 public QueryPermissionChecker(string key, QueryInputModel value) : this(key, value, null)
 {
     Value = value;
 }
Exemplo n.º 13
0
        public async Task <ActionResult <ApiResultViewModel <ShopItemViewModel> > > GetAll([FromQuery] QueryInputModel <ShopItemFilterInputModel> query,
                                                                                           CancellationToken cancellationToken)
        {
            var result = await _shopItemManager.GetAllAsync(query, cancellationToken);

            return(OkData(ShopItemViewModel.MapAll(result.Data), result.TotalCount));
        }
Exemplo n.º 14
0
 public async Task <Result <UserQueryModel> > GetAll(QueryInputModel query, CancellationToken token)
 {
     return(await _services.GetAll(query, token));
 }
 public AccountIdQueryPermissionParameterChecker(QueryInputModel value) : base("CreatorAccountId", value)
 {
 }
 public AccountIdQueryPermissionParameterChecker(QueryInputModel value, string queryFieldName) : base(
         "CreatorAccountId", value, queryFieldName)
 {
 }
Exemplo n.º 17
0
        public async Task <ActionResult <ApiResultViewModel <IEnumerable <StatsViewModel> > > > GetAccountStatsAsync([FromQuery] QueryInputModel <StatsFilterInputModel> query, CancellationToken cancellationToken)
        {
            var stats = await _statsManager.GetAllAsync(query, cancellationToken);

            return(OkData(StatsViewModel.MapAll(stats.Data), new DataMetaViewModel(stats.TotalCount)));
        }
Exemplo n.º 18
0
        public async Task <ActionResult <ApiResultViewModel <CategoryViewModel> > > GetAllAsync([FromQuery] QueryInputModel <CategoryFilterInputModel> queryInputModel, CancellationToken cancellationToken)
        {
            var data = await _categoryManager.GetAllAsync(queryInputModel, cancellationToken);

            return(OkData(CategoryViewModel.MapAll(data.Data), new DataMetaViewModel(data.TotalCount)));
        }
Exemplo n.º 19
0
 public async Task <Result <QueryAllModel <BlobModel> > > GetAll(QueryInputModel query, CancellationToken token)
 {
     return(await _repository.GetAll(query, token));
 }
Exemplo n.º 20
0
        public string QueryData(QueryInputModel qim)
        {
            //输入参数
            string KeyWords = string.Empty;

            if (!string.IsNullOrEmpty(Request["keywords"]))
            {
                KeyWords = Request["keywords"].ToString().OfSql();
            }

            //构查询实体
            QueryDataSetModel dsm = new QueryDataSetModel();

            dsm.pageIndex = Convert.ToInt32(Request["pageIndex"]);
            dsm.pageSize  = Convert.ToInt32(Request["pageSize"]);

            //点击标题排序
            string OrderBy = string.Empty;

            if (Request.Form["sortField"].ToString().Length > 1)
            {
                string[] sortField = Request.Form["sortField"].ToString().Split(',');
                string[] sortOrder = Request.Form["sortOrder"].ToString().Split(',');
                for (int i = 0; i < sortField.Length; i++)
                {
                    OrderBy += "," + sortField[i] + " " + sortOrder[i];
                }
                OrderBy = OrderBy.Substring(1);
            }

            switch (qim.uri.ToLower())
            {
                #region 公共查询

            //表格配置
            case "pptableconfig":
                dsm.tableName = "view_table_config";
                dsm.orderBy   = "l_order";
                dsm.whereStr  = "vname='" + Request["vname"].ToString().OfSql() + "'";
                dsm.total     = false;
                break;

            //菜单
            case "ppmenu":
                dsm.tableName = "sys_menu";
                dsm.orderBy   = OrderBy == "" ? "m_order" : OrderBy;
                dsm.whereStr  = "m_pid=0";
                dsm.total     = true;
                break;

                #endregion

                #region Setting 控制器

            //角色查询
            case "pprole":
                dsm.tableName = "sys_role";
                dsm.orderBy   = OrderBy == "" ? "id" : OrderBy;
                dsm.total     = true;
                break;

            //操作日志
            case "pplog":
                dsm.tableName = "sys_log";
                dsm.orderBy   = OrderBy == "" ? "l_datetime desc" : OrderBy;
                dsm.whereStr  = KeyWords != "" ? string.Format("l_user like '{0}%' or l_action ='%{0}%' or l_content ='%{0}%' or l_ip ='%{0}%'", KeyWords) : "";
                dsm.total     = true;
                break;

            //列表配置
            case "ppcolumn":
                dsm.tableName = "sys_column";
                dsm.orderBy   = OrderBy == "" ? "id" : OrderBy;
                dsm.whereStr  = KeyWords != "" ? string.Format("vname like '{0}%' or field ='{0}'", KeyWords) : "";
                dsm.total     = true;
                break;

            //按钮列表
            case "ppbutton":
                dsm.tableName = "sys_button";
                dsm.orderBy   = OrderBy == "" ? "b_pid,b_order" : OrderBy;
                break;

            //用户查询
            case "ppuser":
                dsm.tableName = "view_sys_user";
                dsm.orderBy   = OrderBy == "" ? "u_state" : OrderBy;
                dsm.whereStr  = KeyWords != "" ? string.Format("u_name like '%{0}%'", KeyWords) : "";
                dsm.total     = true;
                break;
                #endregion
            }

            if (dsm.tableName.Length == 0 || dsm.orderBy.Length == 0)
            {
                throw new Exception("查询传参错误,缺失表名或排序列");
            }

            //得到数据集
            DataSet ds = QueryDS(dsm, DBT.sqllite);

            //输出数据
            QueryOutputModel qom = new QueryOutputModel();
            if (dsm.total)
            {
                qom.total = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
            }
            qom.data = ds.Tables[0];
            //第一次查询列配置
            if (Convert.ToInt32(Request["columnsExists"]) == 0)
            {
                qom.columns = QueryColumns(dsm.tableName);
            }
            //列配置表名
            qom.vname = dsm.tableName;

            return(qom.ToJson());
        }
Exemplo n.º 21
0
        public async Task <ActionResult <ApiResultViewModel <AccountItemViewModel> > > GetItems(QueryInputModel <AccountItemFilterInputModel> queryModel, CancellationToken cancellationToken)
        {
            var data = await _accountItemManager.GetAllAsync(queryModel, cancellationToken);

            return(OkData(data.Data, data.TotalCount));
        }