public string Transfer(string tnxId, string fromAccountNumber, int fromBankId, string toAccountNumber, int toBankId, decimal amount, string content, string callBackUrl) { try { this.CallBackURL = callBackUrl; this.tnxId = tnxId; StepContext stepContext = new StepContext(fromBankId); stepContext.InitTransactionModel(fromAccountNumber, fromBankId, toAccountNumber, toBankId, amount, content); Worker worker = new Worker(stepContext); worker.OnStart += OnTransactionStart; worker.OnSuccess += OnTransactionSuccess; worker.OnFail += OnTransactionFail; worker.OnInprogress += OnTransactionInprogress; worker.Execute(); return(string.Join("-", tnxId, fromAccountNumber, fromBankId, toAccountNumber, toBankId, amount, content)); } catch (Exception ex) { Debug.WriteLine(ex.Message); throw new WebFaultException(HttpStatusCode.BadRequest);// Use it for REST } //catch (Exception ex) //{ // //throw new FaultException<ProductFault>(new ProductFault(ex.Message), "unknown reason"); // throw new FaultException(ex.Message, new FaultCode("internal error"));// Use it for SOAP //} }
static void Main(string[] args) { int bankId = 1; StepContext stepContext = new StepContext(bankId); stepContext.InitTransactionModel("123456789", 1, "987654321", 1, 10000, "transfer money"); worker = new Worker(stepContext); worker.OnStart += OnTransactionStart; worker.OnSuccess += OnTransactionSuccess; worker.OnFail += OnTransactionFail; worker.OnInprogress += OnTransactionInprogress; worker.Execute(); }