Пример #1
0
        internal async Task <Execution> AddExecution(string action, Dictionary <string, object> parameters)
        {
            if (!_host.HasToken())
            {
                await _host.RefreshTokenAsync();
            }
            try
            {
                var executionRequest = new ExecutionRequest(action, parameters);
                var r = await _host.PostApiRequestAsync <Execution, ExecutionRequest>("v1/executions", executionRequest);

                return(await Resolve(r));
            }
            catch (Exception e)
            {
                _log.Error(e);
                return(null);
            }
        }
Пример #2
0
        internal async Task <Execution> AddExecution(string action, Dictionary <string, string> parameters)
        {
            if (!_host.HasToken())
            {
                await _host.RefreshTokenAsync();
            }
            try
            {
                var tempParameters = new Dictionary <string, string>();
                //delete any empty parameters
                if (parameters != null)
                {
                    foreach (var p in parameters)
                    {
                        if (!string.IsNullOrEmpty(p.Value))
                        {
                            tempParameters.Add(p.Key, p.Value);
                        }
                    }
                }

                var executionRequest = new ExecutionRequest(action, tempParameters);

                //var requestString = Newtonsoft.Json.JsonConvert.SerializeObject(executionRequest);
                //Console.WriteLine(requestString);

                var r = await _host.PostApiRequestAsync <Execution, ExecutionRequest>("v1/executions", executionRequest);

                return(await Resolve(r));
            }
            catch (Exception e)
            {
                _log.Error(e);
                return(null);
            }
        }