Exemplo n.º 1
0
        protected virtual void Log(HttpActionExecutedContext actionExecutedContext)
        {
            try
            {
                Exception exception = actionExecutedContext.Exception;

                apiController apiController = (apiController)actionExecutedContext.ActionContext.ControllerContext.Controller;

                Map    map     = apiController.Map;
                string appName = string.Empty;
                try
                {
                    if (System.Web.HttpContext.Current.Items.Contains(Database.AppName))
                    {
                        appName = System.Web.HttpContext.Current.Items[Database.AppName].ToString();
                    }
                }
                catch { }

                HandleConnectionFailure(map, exception);

                string actionName = string.Empty;
                if (apiController.ControllerContext.RouteData.Values.ContainsKey("action"))
                {
                    actionName = (apiController.ControllerContext.RouteData.Values["action"] ?? string.Empty).ToString();
                }

                map.Logger.Log(apiController.GetControllerNameForLog(apiController.ControllerContext), actionName, appName + ": " + exception.Source, exception, 1, actionExecutedContext.Request.RequestUri.ToString(), DateTime.Now);
            }
            catch (Exception e)
            {
                Durados.Diagnostics.EventViewer.WriteEvent(e);
            }
        }
Exemplo n.º 2
0
        protected virtual void Log(System.Web.Http.Controllers.HttpActionContext actionContext, Exception exception)
        {
            try
            {
                apiController apiController = (apiController)actionContext.ControllerContext.Controller;

                Map map = apiController.Map;

                string exceptionSource = exception == null ? null : exception.Source;

                int logType = exception == null ? 3 : 1;

                string verb = actionContext.Request.Method.Method;

                string appName = string.Empty;
                try
                {
                    if (System.Web.HttpContext.Current.Items.Contains(Database.AppName))
                    {
                        appName = System.Web.HttpContext.Current.Items[Database.AppName].ToString();
                    }
                }
                catch { }

                map.Logger.Log(apiController.GetControllerNameForLog(apiController.ControllerContext), verb, appName + ": " + exceptionSource, exception, logType, actionContext.Request.RequestUri.ToString());
            }
            catch (Exception e)
            {
                Durados.Diagnostics.EventViewer.WriteEvent(e);
            }
        }
Exemplo n.º 3
0
        protected virtual void Log(System.Web.Http.Controllers.HttpActionContext actionContext, Exception exception)
        {
            try
            {
                apiController apiController = (apiController)actionContext.ControllerContext.Controller;

                Map map = apiController.Map;

                string exceptionSource = exception == null ? null : exception.Source;

                int logType = exception == null ? 3 : 1;

                string verb = actionContext.Request.Method.Method;

                string appName = string.Empty;
                try
                {
                    if (System.Web.HttpContext.Current.Items.Contains(Database.AppName))
                    {
                        appName = System.Web.HttpContext.Current.Items[Database.AppName].ToString();
                    }
                }
                catch { }

                int?reqMilli = null;
                if (!apiController.started.HasValue)
                {
                    apiController.started = DateTime.Now;
                }
                else
                {
                    reqMilli = Convert.ToInt32(DateTime.Now.Subtract(apiController.started.Value).TotalMilliseconds);
                }

                UpdateRequestInfo(actionContext);
                map.Logger.Log(apiController.GetControllerNameForLog(apiController.ControllerContext), verb, appName + ": " + exceptionSource, exception, logType, actionContext.Request.RequestUri.ToString(), DateTime.Now, reqMilli);
            }
            catch (Exception e)
            {
                Durados.Diagnostics.EventViewer.WriteEvent(e);
            }
        }