public ResultTO Execute(string data) { ResultTO RetValue = new ResultTO(); var step = this.GetCurrent(); step.Data.Value = data; foreach (var procedure in step.Procedures.OrderBy(i => i.Index)) { procedure.Parameters = FetchParameters(procedure.Parameters); RetValue = ProcedureDAO.Execute(procedure); if (RetValue.Result == Result.Fail) { break; } } return(RetValue); }
protected ResultTO DbCommandProcedure(ProcedureTO to) { var resultTO = new ResultTO(); using (var connection = CreateDbConnection()) { using (var command = connection.CreateCommand()) { command.CommandText = "FXUSER." + to.Name; command.CommandType = CommandType.StoredProcedure; connection.Open(); foreach (var item in to.Parameters) { switch (item.Direction) { case ProcedureParameterDirection.In: command.AddInputParameter(item.Name, item.Value, item.Type); break; case ProcedureParameterDirection.Out: command.AddOutputParameter(item.Name, item.Type); break; } } command.ExecuteNonQuery(); resultTO.Message = command.Parameters[to.Parameters .Where(i => i.Direction == ProcedureParameterDirection.Out) .FirstOrDefault().Name].Value.ToString(); resultTO.Result = (resultTO.Message == "OK") ? Result.Pass : Result.Fail; } } return(resultTO); }
private ResultTO GoNextStep(ResultTO result) { var currentStep = StepBO.GetCurrent(); if (result.Result == Result.Pass) { var secondStep = GetSecondStep(currentStep); if (secondStep == null) { throw new ApplicationException("Second Step nao encontrado"); } StepBO.SetCurrent(secondStep); } else if (currentStep.Fork > 0) { var stepData = currentStep.Data.Value; var forkStep = GetForkStep(currentStep); if (forkStep == null) { throw new ApplicationException("Fork Step nao encontrado"); } StepBO.SetCurrent(forkStep); } else if (!string.IsNullOrEmpty(currentStep.Special) && currentStep.Special != "N/A" && result.Message.Contains("JUMP=")) { var jumpStep = GetJumpStep(currentStep, result.Message); if (jumpStep == null) { throw new ApplicationException("Jump Step nao encontrado"); } StepBO.SetCurrent(jumpStep); } if (result.Result == Result.Pass) { if (currentStep.Last) { SessionBO.GetInstance().ClearUntilLastInput(); } else if (currentStep.Rule == Rule.KeepInMemory || currentStep.Rule == Rule.UntilLastInput) { SessionBO.GetInstance().AddVariable(new SessionTO { Name = currentStep.Data.Name, Value = currentStep.Data.Value, Rule = currentStep.Rule }); } } return(new ResultTO { Result = Result.Pass, Message = StepBO.GetCurrent().Data.Prompt }); }