public async Task <IActionResult> Handle( [FromQuery(Name = "workflow")] string?workflowDefinitionId = default, [FromQuery(Name = "status")] WorkflowStatus?workflowStatus = default, [FromQuery] string?correlationId = default, [FromQuery] OrderBy?orderBy = default, [FromQuery] string?searchTerm = default, int page = 0, int pageSize = 25, CancellationToken cancellationToken = default) { _stopwatch.Restart(); var specification = Specification <WorkflowInstance> .Identity; if (!string.IsNullOrWhiteSpace(workflowDefinitionId)) { specification = specification.WithWorkflowDefinition(workflowDefinitionId); } if (!string.IsNullOrWhiteSpace(correlationId)) { specification = specification.WithCorrelationId(correlationId); } if (workflowStatus != null) { specification = specification.WithStatus(workflowStatus.Value); } if (!string.IsNullOrWhiteSpace(searchTerm)) { specification = specification.WithSearchTerm(searchTerm); } var orderBySpecification = default(OrderBy <WorkflowInstance>); if (orderBy != null) { orderBySpecification = orderBy switch { OrderBy.Started => OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.CreatedAt), OrderBy.LastExecuted => OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.LastExecutedAt !), OrderBy.Finished => OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.FinishedAt !), _ => OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.FinishedAt !) }; } var totalCount = await _workflowInstanceStore.CountAsync(specification, cancellationToken : cancellationToken); var paging = Paging.Page(page, pageSize); var workflowInstances = await _workflowInstanceStore.FindManyAsync(specification, orderBySpecification, paging, cancellationToken).ToList(); var items = _mapper.Map <ICollection <WorkflowInstanceSummaryModel> >(workflowInstances); _stopwatch.Stop(); _logger.LogDebug("Handle took {TimeElapsed}", _stopwatch.Elapsed); var model = new PagedList <WorkflowInstanceSummaryModel>(items, page, pageSize, totalCount); return(Json(model, _contentSerializer.GetSettings())); } }
public async Task <IActionResult> Handle([FromBody] RuntimeSelectListContextHolder model, CancellationToken cancellationToken = default) { var type = Type.GetType(model.ProviderTypeName) !; var provider = ActivatorUtilities.GetServiceOrCreateInstance(_serviceProvider, type); var context = model.Context; var serializerSettings = _contentSerializer.GetSettings(); var selectList = await GetSelectList(provider, context, cancellationToken); return(Json(selectList, serializerSettings)); }
public async Task <IActionResult> Handle([FromBody] RuntimeSelectListItemsContextHolder model, CancellationToken cancellationToken = default) { var type = Type.GetType(model.ProviderTypeName) !; var provider = (IRuntimeSelectListItemsProvider)ActivatorUtilities.GetServiceOrCreateInstance(_serviceProvider, type); var context = model?.Context; var items = (await provider.GetItemsAsync(context, cancellationToken)).ToList(); var serializerSettings = _contentSerializer.GetSettings(); return(Json(items, serializerSettings)); }
public async Task <ActionResult <WorkflowBlueprintModel> > Handle(string id, VersionOptions?versionOptions = default, CancellationToken cancellationToken = default) { versionOptions ??= VersionOptions.Latest; var workflowBlueprint = await _workflowRegistry.GetAsync(id, null, versionOptions.Value, cancellationToken, true); if (workflowBlueprint == null) { return(NotFound()); } var model = await _workflowBlueprintMapper.MapAsync(workflowBlueprint, cancellationToken); return(Json(model, _contentSerializer.GetSettings())); }
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 async Task <ActionResult <WorkflowDefinitionSummaryModel[]> > Handle([RequiredFromQuery] string?ids, VersionOptions?version = default, CancellationToken cancellationToken = default) { IList <WorkflowDefinitionSummaryModel> summaries = new List <WorkflowDefinitionSummaryModel>(); if (!string.IsNullOrWhiteSpace(ids)) { version ??= VersionOptions.Latest; var splitIds = ids.Split(',', StringSplitOptions.RemoveEmptyEntries); var specification = new VersionOptionsSpecification(version.Value).And(new ManyWorkflowDefinitionIdsSpecification(splitIds)); var items = await _workflowDefinitionStore.FindManyAsync(specification, cancellationToken : cancellationToken); summaries = _mapper.Map <IList <WorkflowDefinitionSummaryModel> >(items); } return(Json(new ListModel <WorkflowDefinitionSummaryModel>(summaries), _serializer.GetSettings())); }
public async Task <IActionResult> Handle(string id, CancellationToken cancellationToken = default) { var workflowInstance = await _workflowInstanceStore.FindByIdAsync(id, cancellationToken); if (workflowInstance == null) { return(NotFound()); } var tenantId = await _tenantAccessor.GetTenantIdAsync(cancellationToken); var workflowBlueprint = await _workflowRegistry.FindByDefinitionVersionIdAsync(workflowInstance.DefinitionVersionId, tenantId, cancellationToken); await _publisher.Publish(new RequestingWorkflowInstance(workflowInstance, workflowBlueprint !), cancellationToken); return(Json(workflowInstance, _contentSerializer.GetSettings())); }
public async Task <IActionResult> Handle(string workflowDefinitionId, VersionOptions versionOptions, CancellationToken cancellationToken = default) { var workflowDefinition = await _workflowDefinitionStore.FindAsync(new WorkflowDefinitionIdSpecification(workflowDefinitionId).WithVersionOptions(versionOptions), cancellationToken); return(workflowDefinition == null ? (IActionResult)NotFound() : Json(workflowDefinition, _serializer.GetSettings())); }
private IEnumerable <TriggerFinderResult> SelectResults(IEnumerable <Trigger> triggers) => from trigger in triggers let triggerType = Type.GetType(trigger.ModelType) let model = (IBookmark)JsonConvert.DeserializeObject(trigger.Model, triggerType, (JsonSerializerSettings)_contentSerializer.GetSettings()) ! select new TriggerFinderResult(trigger.WorkflowDefinitionId, trigger.ActivityId, model);