public void Build_update_on_error_debug() { var errorLog = new RequestLog(user, new HttpRequestMessage(HttpMethod.Get, "http://localhost/Main/"), controller.GetType().Name); errorLog.Faulted(new ExporterException("Пожалуйста, обратитесь в бухгалтерию АналитФармация.", ErrorType.AccessDenied)); session.Save(errorLog); var message = controller.Get(true); Assert.AreEqual(message.StatusCode, HttpStatusCode.Accepted); Assert.AreNotEqual(errorLog.Id, GetRequestId(message).ToString()); }
public override void OnException(HttpActionExecutedContext actionContext) { var context = actionContext.ActionContext.ControllerContext; var access = actionContext.Exception as AccessException; if (access == null) { return; } var factory = (ISessionFactory)context.Configuration.Properties[typeof(ISessionFactory)]; try { using (var logSession = factory.OpenSession()) using (var trx = logSession.BeginTransaction()) { var requestLog = new RequestLog(access.User, actionContext.Request, context.Controller.GetType().Name); requestLog.Faulted(new ExporterException(access.InternalMessage, ErrorType.AccessDenied)); logSession.Save(requestLog); trx.Commit(); } } catch (Exception e) { log.Error("Ошибка протоколирования", e); } }