/// <summary> /// Executes the specified request. /// </summary> /// <typeparam name="TRequest">The type of the request.</typeparam> /// <typeparam name="TResponse">The type of the response.</typeparam> /// <param name="request">The request.</param> /// <param name="wrapperName">Name of the wrapper.</param> /// <param name="action">The action.</param> /// <param name="executionResult">The execution result.</param> /// <returns> /// The response type /// </returns> /// <exception cref="CaGenException">is thrown when cics returns error status.</exception> public TResponse Execute <TRequest, TResponse>(TRequest request, string wrapperName, string action, out CaGenExecutionResult executionResult) { #if DEBUG var step = MiniProfiler.Current.Step("CaGenService.Execute: " + wrapperName + " " + action); try { #endif CicsExecutionResult genResult; var response = CicsClient.Execute <TRequest, TResponse>(request, wrapperName, action, out genResult); executionResult = new CaGenExecutionResult(); executionResult.ErrorCode = genResult.ErrorCode; executionResult.ExitStatusNumber = genResult.ExitStatusNumber; executionResult.Message = genResult.Message; executionResult.UnMatchedProperties = genResult.UnMatchedProperties; if (genResult.CicsApplicationError != null) { executionResult.GenApplicationError = new CaGenApplicationError(); executionResult.GenApplicationError.Attribute = genResult.CicsApplicationError.Attribute; executionResult.GenApplicationError.Date = genResult.CicsApplicationError.Date; executionResult.GenApplicationError.Number = genResult.CicsApplicationError.Number; executionResult.GenApplicationError.Text = genResult.CicsApplicationError.Text; executionResult.GenApplicationError.TextValue = genResult.CicsApplicationError.TextValue; } if (genResult.CicsSystemError != null) { executionResult.GenSystemError = new CaGenSystemError(); executionResult.GenSystemError.ActionBlockName = genResult.CicsSystemError.ActionBlockName; executionResult.GenSystemError.ExitState = genResult.CicsSystemError.ExitState; executionResult.GenSystemError.StatementNumber = genResult.CicsSystemError.StatementNumber; executionResult.GenSystemError.Type = genResult.CicsSystemError.Type; executionResult.GenSystemError.UserId = genResult.CicsSystemError.UserId; } switch (genResult.MessageType) { case CicsExecuteStatus.Error: executionResult.MessageType = CaGenExecuteStatus.Error; break; case CicsExecuteStatus.Information: executionResult.MessageType = CaGenExecuteStatus.Information; break; case CicsExecuteStatus.Normal: executionResult.MessageType = CaGenExecuteStatus.Normal; break; case CicsExecuteStatus.Warning: executionResult.MessageType = CaGenExecuteStatus.Warning; break; } switch (genResult.RollbackStatus) { case RollbackStatus.Aborted: executionResult.RollbackStatus = CaGenRollbackStatus.Aborted; break; case RollbackStatus.Committed: executionResult.RollbackStatus = CaGenRollbackStatus.Committed; break; case RollbackStatus.RolledBack: executionResult.RollbackStatus = CaGenRollbackStatus.RolledBack; break; } if (executionResult.MessageType == CaGenExecuteStatus.Error) { throw new CaGenException(executionResult); } return(response); #if DEBUG } finally { if (step != null) { step.Dispose(); } } #endif }
/// <summary> /// Initializes a new instance of the <see cref="CaGenException"/> class. /// </summary> /// <param name="result">The result.</param> public CaGenException(CaGenExecutionResult result) : base(string.Format("Gen execution error. Code:{0} Message:{1} Type:{2}", result.ErrorCode, result.Message, result.MessageType.GetDescription())) { ExecutionResult = result; }