示例#1
0
        public async Task <ActionResult <PagedList <WorkflowDefinitionSummaryModel> > > Handle(
            [FromQuery] string?ids,
            [FromQuery] string?searchTerm = default,
            int?page               = default,
            int?pageSize           = default,
            VersionOptions?version = default,
            CancellationToken cancellationToken = default)
        {
            var tenantId = await _tenantAccessor.GetTenantIdAsync(cancellationToken);

            version ??= VersionOptions.Latest;
            var specification = GetSpecification(ids, version.Value).And(new TenantSpecification <WorkflowDefinition>(tenantId));

            if (!string.IsNullOrWhiteSpace(searchTerm))
            {
                specification = specification.And(new WorkflowDefinitionSearchTermSpecification(searchTerm));
            }

            var totalCount = await _workflowDefinitionStore.CountAsync(specification, cancellationToken);

            var paging                         = page == null || pageSize == null ? default : Paging.Page(page.Value, pageSize.Value);
                                     var items = await _workflowDefinitionStore.FindManyAsync(specification, new OrderBy <WorkflowDefinition>(x => x.Name !, SortDirection.Ascending), paging, cancellationToken);

                                     var summaries = _mapper.Map <IList <WorkflowDefinitionSummaryModel> >(items);
                                     var pagedList = new PagedList <WorkflowDefinitionSummaryModel>(summaries, page, pageSize, totalCount);

                                     return(Json(pagedList, SerializationHelper.GetSettingsForWorkflowDefinition()));
        }
示例#2
0
        public override async ValueTask <int> CountAsync(VersionOptions versionOptions, string?tenantId = default, CancellationToken cancellationToken = default)
        {
            var specification = (ISpecification <WorkflowDefinition>) new VersionOptionsSpecification(versionOptions);

            if (!string.IsNullOrWhiteSpace(tenantId))
            {
                specification = specification.WithTenant(tenantId);
            }

            return(await _workflowDefinitionStore.CountAsync(specification, cancellationToken));
        }
示例#3
0
文件: List.cs 项目: tle5/elsa-core
        public async Task <ActionResult <PagedList <WorkflowDefinitionSummaryModel> > > Handle(int?page = default, int?pageSize = default, VersionOptions?version = default, CancellationToken cancellationToken = default)
        {
            version ??= VersionOptions.Latest;
            var specification = new VersionOptionsSpecification(version.Value);
            var totalCount    = await _workflowDefinitionStore.CountAsync(specification, cancellationToken);

            var paging                         = page == null || pageSize == null ? default : Paging.Page(page.Value, pageSize.Value);
                                     var items = await _workflowDefinitionStore.FindManyAsync(specification, paging: paging, cancellationToken : cancellationToken);

                                     var summaries = _mapper.Map <IList <WorkflowDefinitionSummaryModel> >(items);
                                     var pagedList = new PagedList <WorkflowDefinitionSummaryModel>(summaries, page, pageSize, totalCount);

                                     return(Json(pagedList, _serializer.GetSettings()));
        }
 public Task <int> CountAsync(ISpecification <WorkflowDefinition> specification, CancellationToken cancellationToken = default) => _store.CountAsync(specification, cancellationToken);