/// <summary>
        /// Finds the endpoint and executes the request onto it.
        /// Handles errors and disposes of the endpoint when completed.
        /// </summary>
        public async Task InvokeAsync(IHttpRequestReader requestReader, IHttpRequestResponder responder, IRequestContext context)
        {
            var response = new Response(requestReader.ResourcePath);
            var builder  = new ResponseBuilder(response, _services.Modifiers);

            var reader = new RequestReader(requestReader, _services.NameSwitcher, _services.QueryCreator);
            var writer = new ResponseWriter(responder, response, _services.NameSwitcher);

            try
            {
                var           navigator = new EndpointNavigator(context, _startResourceFactory, _services);
                IRestEndpoint endpoint  = navigator.GetEndpointFromPath(requestReader.ResourcePath);
                IExecutor     executor  = _services.ExecutorFactory.GetExecutor(endpoint);

                await executor.ExecuteAsync(reader, builder);

                await writer.WriteAsync();
            }
            catch (Exception ex)
            {
                var errorInfo = new ExceptionErrorInfo(ex);
                builder.AddError(errorInfo);

                await writer.WriteAsync();
            }
            finally
            {
                context.Dispose();
            }
        }
        /// <summary>
        /// Alamacena la información de un usuario.
        /// </summary>
        /// <param name="item">objeto usuario info.</param>
        /// <returns>ok transaccion</returns>
        public bool RegistrarException(ExceptionErrorInfo item)
        {
            try
            {
                return(module.RegistrarException(item));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("NIVI Error: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                return(false);
            }
        }
        public override void OnException(HttpActionExecutedContext context)
        {
            var controller = context.ActionContext.ControllerContext.Controller as FirestormController;

            if (controller == null)
            {
                throw new ArgumentException("RestApiExceptionFilterAttribute should only be applied to FirestormController.");
            }

            var exceptionInfo = new ExceptionErrorInfo(context.Exception);

            controller.ResponseBuilder.AddError(exceptionInfo);

            context.Response = context.Request.CreateResponse(controller.Response.StatusCode, controller.Response.GetFullBody());
        }
Пример #4
0
        public bool RegistrarException(ExceptionErrorInfo item)
        {
            bool transOk = false;

            IDataReader dr = null;

            try
            {
                db.SetParameterValue(commandExceptionError, "i_operation", 'I');
                db.SetParameterValue(commandExceptionError, "i_option", 'A');
                db.SetParameterValue(commandExceptionError, "i_eer_id", item.Id);
                db.SetParameterValue(commandExceptionError, "i_eer_componente", item.Componente);
                db.SetParameterValue(commandExceptionError, "i_eer_metodo", item.Metodo);
                db.SetParameterValue(commandExceptionError, "i_eer_descripcion", item.Descripcion);
                db.SetParameterValue(commandExceptionError, "i_eer_usuario", item.Usuario);

                dr = db.ExecuteReader(commandExceptionError);

                transOk = true;
            }
            catch (Exception ex)
            {
                transOk = false;

                System.Diagnostics.Trace.WriteLine(string.Format("NIVI Error: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                bool rethrow = ExceptionPolicy.HandleException(ex, "DataAccess Policy");

                if (rethrow)
                {
                    throw;
                }
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }
            return(transOk);
        }
Пример #5
0
        public ExceptionErrorInfo RegistrarException(ExceptionErrorInfo ObjExceptionErrorInfo)
        {
            ExceptionError     objExceptionError     = new ExceptionError("conexion");
            ExceptionErrorInfo objExceptionErrorInfo = new ExceptionErrorInfo();

            objExceptionErrorInfo.Id          = ObjExceptionErrorInfo.Id;
            objExceptionErrorInfo.Componente  = ObjExceptionErrorInfo.Componente;
            objExceptionErrorInfo.Metodo      = ObjExceptionErrorInfo.Metodo;
            objExceptionErrorInfo.Descripcion = ObjExceptionErrorInfo.Descripcion;
            objExceptionErrorInfo.Usuario     = ObjExceptionErrorInfo.Usuario;

            try
            {
                objExceptionError.RegistrarException(objExceptionErrorInfo);
            }
            catch (Exception)
            {
                //throw;
            }
            return(ObjExceptionErrorInfo);
        }