Exemple #1
0
        public async Task <OrchestrationQueryResult> GetOrchestrationsAsync(OrchestrationQuery query, CancellationToken cancellationToken = default)
        {
            var request = new GetOrchestrationsRequest
            {
                Top = query.Top,
                ContinuationToken = query.ContinuationToken,
                InstanceId        = query.InstanceId,
                Name            = query.Name,
                CreatedTimeFrom = ToTimestamp(query.CreatedTimeFrom),
                CreatedTimeTo   = ToTimestamp(query.CreatedTimeTo)
            };

            if (query.RuntimeStatus != null)
            {
                request.RuntimeStatus.AddRange(query.RuntimeStatus.Select(s => (int)s));
            }

            var callOptions = new CallOptions(cancellationToken: cancellationToken);

            var response = await _client.GetOrchestrationsAsync(request, callOptions);

            return(new OrchestrationQueryResult
            {
                Orchestrations = response.States
                                 .Select(s => _options.DataConverter.Deserialize <OrchestrationState>(s))
                                 .ToArray(),
                Count = response.Count,
                ContinuationToken = response.ContinuationToken
            });
        }
Exemple #2
0
        public override async Task <GetOrchestrationsResponse> GetOrchestrations(GetOrchestrationsRequest request, ServerCallContext context)
        {
            var query = new OrchestrationQuery
            {
                Top = request.Top,
                ContinuationToken = request.ContinuationToken,
                InstanceId        = request.InstanceId,
                Name            = request.Name,
                CreatedTimeFrom = request.CreatedTimeFrom?.ToDateTime(),
                CreatedTimeTo   = request.CreatedTimeTo?.ToDateTime(),
                RuntimeStatus   = request.RuntimeStatus.Select(s => (OrchestrationStatus)s).ToArray()
            };

            var queryResult = await _extendedOrchestrationServiceClient.GetOrchestrationsAsync(query, context.CancellationToken);

            var response = new GetOrchestrationsResponse
            {
                States            = { queryResult.Orchestrations.Select(s => _options.DataConverter.Serialize(s)) },
                Count             = queryResult.Count,
                ContinuationToken = queryResult.ContinuationToken
            };

            return(response);
        }