/// <summary> /// Web Application의 요청 처리 후 사후 처리를 한다. /// UnitOfWork 를 Stop 시키고, /// </summary> protected override void OnEndRequest(object sender, EventArgs e) { if (IsDebugEnabled) { log.Debug("사용자 요청을 모두 처리하고, UnitOfWork에 대해 종료처리를 시작합니다..."); } // lock(_syncLock) { if (HttpContext.Current != null && UnitOfWork.IsStarted) { // no error in asp.net pages and long conversion mode in Unit Of Work. // if (HttpContext.Current.Server.GetLastError() == null && UnitOfWork.InLongConversation) { if (IsDebugEnabled) { log.Debug("Disconnect current NHibernate session. not close, just disconnect!!!."); } if (UnitOfWork.CurrentSession != null && UnitOfWork.CurrentSession.IsConnected) { UnitOfWork.CurrentSession.Disconnect(); } if (IsAspSessionAvailable == false) { throw new InvalidOperationException( @"HttpSession must be enabled when using Long Conversation in Unit Of Work pattern!!!" + @"If you are using web services, make sure use [WebMethod(EnabledSession=true)]"); } LongConversationManager.SaveConversation(); } else { if (IsDebugEnabled) { log.Debug("if not in long conversation mode. current unit of work instance is disposing."); } if (UnitOfWork.IsStarted) { UnitOfWork.Stop(); if (IsDebugEnabled) { log.Debug("UnitOfWork를 끝냈습니다!!!"); } } } } } if (IsDebugEnabled) { log.Debug("사용자 요청을 모두 처리하고, UnitOfWork에 대해 종료처리를 완료했습니다."); } // Finalize base.OnEndRequest(sender, e); }