public void Execute(ExternalTask externalTask, ref Dictionary <string, object> resultVariables)
            {
                string customerId    = (string)externalTask.Variables["customerId"].Value;
                long   amount        = (long)externalTask.Variables["amount"].Value;
                String transactionId = circuitBreakerPolicy.Execute <String>(
                    () => RestApiClient.InvokeRestApi(customerId, amount, TimeSpan.FromSeconds(1)).transactionId);

                resultVariables.Add("transactionId", transactionId);
            }
            public void Execute(ExternalTask externalTask, ref Dictionary <string, object> resultVariables)
            {
                string customerId             = (string)externalTask.Variables["customerId"].Value;
                long   amount                 = (long)externalTask.Variables["amount"].Value;
                CreateChargeResponse response = circuitBreakerPolicy.Execute <CreateChargeResponse>(
                    () => RestApiClient.InvokeRestApi(customerId, amount, TimeSpan.FromSeconds(1)));

                if (!string.IsNullOrEmpty(response.errorCode))
                {
                    // raise error to be handled in BPMN model in case there was an error in credit card handling
                    throw new UnrecoverableBusinessErrorException("Error_CreditCardError", "Could not charge credit card");
                }

                resultVariables.Add("transactionId", response.transactionId);

                string traceId = (string)externalTask.Variables["traceId"].Value;

                if (semaphors.ContainsKey(traceId))
                {
                    semaphors[traceId].Release();
                }
            }
 public String ChargeCreditCard(string customerId, int amount)
 {
     return(RestApiClient.InvokeRestApi(customerId, amount).transactionId);
 }
 public String ChargeCreditCard(string customerId, int amount)
 {
     return(circuitBreakerPolicy.Execute <String>(
                () => RestApiClient.InvokeRestApi(customerId, amount, TimeSpan.FromSeconds(1)).transactionId
                ));
 }