Esempio n. 1
0
        public async Task <Message> GetMessageAsync(string messageId)
        {
            var result = await _httpClientProxy.GetAsync($"/v1/messages/{messageId}").ConfigureAwait(false);

            var message = JsonConvert.DeserializeObject <Message>(result, _defaultJsonSerializerSettings);

            return(message);
        }
        /// <inheritdoc />
        public async Task <ActionResult <BpmnModel> > GetBpmnModel(string id)
        {
            HttpResponseMessage response = await httpProxy.GetAsync <HttpResponseMessage>($"{serviceUrl}/{id}/bpmnmodel").ConfigureAwait(false);

            string data = AsyncHelper.RunSync <string>(() => response.Content.ReadAsStringAsync());

            BpmnModel model = JsonConvert.DeserializeObject <BpmnModel>(data, new JsonSerializerSettings
            {
                TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
                TypeNameHandling      = TypeNameHandling.All,
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            ActionResult <BpmnModel> result = new ObjectResult(model);

            return(result);
        }
Esempio n. 3
0
        private void ExecuteGet(IExecutionEntity execution, string url, object request, string dataObj, IHttpClientProxy httpProxy)
        {
            url = QueryParameter(execution, url, request, true);

            if (string.IsNullOrWhiteSpace(dataObj))
            {
                httpProxy.GetAsync(url).GetAwaiter().GetResult();
            }
            else
            {
                HttpResponseMessage response = httpProxy.GetAsync <HttpResponseMessage>(url, CancellationToken.None).GetAwaiter().GetResult();

                response.EnsureSuccessStatusCode();
                object data = ToObject(response).GetAwaiter().GetResult();

                execution.SetVariable(dataObj, data);
            }
        }
Esempio n. 4
0
        public async Task SaveCurseAsync(CurseRequest request)
        {
            if (request.From == request.To)
            {
                await _context.Curses.AddAsync(new Curse
                                               { Value = 1, CurrenciesFrom = request.From, CurrenciesTo = request.To });

                await _context.SaveChangesAsync();

                return;
            }

            var query = $"{_url}{request.ToStringCurse()}&compact=ultra&apiKey={_apiKey}";

            var result = await _httpClientProxy.GetAsync <CurseFromConverterResponse>(query);

            await _context.Curses.AddAsync(new Curse
                                           { Value = result.Value, CurrenciesFrom = request.From, CurrenciesTo = request.To });

            await _context.SaveChangesAsync();
        }
Esempio n. 5
0
        public async Task <KeyValuePair <string, (double lat, double lon)> > GetPositionByAddressAsync(string address)
        {
            var result = await _httpClientProxy.GetAsync <SputnikPositionByAddressResponse>(_uri + address);

            if (!result.Result.Any())
            {
                return(new KeyValuePair <string, (double lat, double lon)>(address, (0, 0)));
            }

            return(new KeyValuePair <string, (double lat, double lon)>(address,
                                                                       (result.Result.First().Position.Lat, result.Result.First().Position.Lon)));
        }
Esempio n. 6
0
        private void ExecuteGet(IExecutionEntity execution, string url, object request, string dataObj, IHttpClientProxy httpProxy)
        {
            url = QueryParameter(execution, url, request, true);

            if (string.IsNullOrWhiteSpace(dataObj))
            {
                AsyncHelper.RunSync(() => httpProxy.GetAsync(url));
            }
            else
            {
                HttpResponseMessage response = AsyncHelper.RunSync(() => httpProxy.GetAsync <HttpResponseMessage>(url, CancellationToken.None));

                object data = null;
                if (response is null == false)
                {
                    response.EnsureSuccessStatusCode();
                    data = AsyncHelper.RunSync(() => ToObject(response));
                }

                execution.SetVariable(dataObj, data);
            }
        }
Esempio n. 7
0
 private async void WhenGettingAMessage(string response)
 {
     _httpClientProxy.GetAsync(Arg.Any <string>()).Returns(Task.FromResult(response));
     _messageResponse = await _subject.GetMessageAsync(_messageId);
 }
Esempio n. 8
0
 /// <inheritdoc />
 public async Task <HistoricInstance> GetProcessInstanceById(string processInstanceId)
 {
     return(await httpProxy.GetAsync <HistoricInstance>($"{serviceUrl}/{processInstanceId}").ConfigureAwait(false));
 }
 /// <inheritdoc />
 public async Task <Resources <ProcessInstanceVariable> > GetVariables(string processInstanceId)
 {
     return(await httpProxy.GetAsync <Resources <ProcessInstanceVariable> >($"{serviceUrl.Replace("{processInstanceId}", processInstanceId)}").ConfigureAwait(false));
 }
Esempio n. 10
0
 public async Task <TaskVariableResource> GetVariable(string taskId, string variableName)
 {
     return(await httpProxy.GetAsync <TaskVariableResource>($"{serviceUrl.Replace("{taskId}", taskId)}/{variableName}").ConfigureAwait(false));
 }
Esempio n. 11
0
 /// <inheritdoc />
 public async Task <TaskModel> GetTaskById(string taskId)
 {
     return(await httpProxy.GetAsync <TaskModel>($"{serviceUrl}/{taskId}").ConfigureAwait(false));
 }