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(); }
public EnterInputStep(int currentStepId, StepContext context) { Initialize(currentStepId, context); }
public GetOTPStep(int currentStepId, StepContext context) { Initialize(currentStepId, context); }
public HttpPostStep(int currentStepId, StepContext context) { Initialize(currentStepId, context); }
public MatchingStep(int currentStepId, StepContext context) { Initialize(currentStepId, context); }
public ClickStep(int currentStepId, StepContext context) { Initialize(currentStepId, context); }
public Worker(StepContext stepContext) { Step firstStep = new EnterPageStep(1, stepContext); this.Step = firstStep; }
public void Initialize(int currentStepId, StepContext context) { using (var db = new Entities()) { var step = db.Steps.Where(x => x.Bank.Id == context.BankId && x.CurrentStepId == currentStepId).FirstOrDefault(); if (step != null) { this.Context = context; this.CurrentStepId = currentStepId; this.Name = step.Name; this.Url = step.Url; this.PreviousStepId = step.PreviousStepId; this.Sign = step.Sign; this.Pattern = step.Pattern; this.XPath = step.XPath; this.XPathAttribute = step.XPathAttribute; this.NextStepId = step.NextStepId0;// default next step this.SecondNextStepId = step.NextStepId1;// default next step this.InputType = step.InputType.Name; this.QueryStrings = step.QueyStrings.InitHttpRequestParams(';'); this.Params = step.Params.InitHttpRequestParams(';'); } } }