public ServerService() : base() { try { sessionId = Guid.Parse(OperationContext.Current.IncomingMessageHeaders .GetHeader<string>("SessionId", string.Empty)); using (var session = SessionProvider.OpenSession()) using (var transaction = session.BeginTransaction()) { currentUser = session.CreateCriteria<User>() .Add(Restrictions.Eq("SessionId", sessionId)) .SetMaxResults(1) .UniqueResult<User>(); } } catch { } logger.Debug("Создан новый экземпляр службы [{0}]", sessionId); channel = OperationContext.Current.Channel; channel.Faulted += channel_Faulted; channel.Closing += channel_Closing; }
public StandardServerService() : base() { try { var operationContext = OperationContext.Current; if (operationContext != null) { sessionId = Guid.Parse(operationContext.IncomingMessageHeaders .GetHeader<string>("SessionId", string.Empty)); } } catch { } try { var webOperationContext = WebOperationContext.Current; if (webOperationContext != null && sessionId == Guid.Empty) { sessionId = Guid.Parse(webOperationContext.IncomingRequest .Headers[ExtendHttpHeaders.Session]); } } catch { } if (sessionId != Guid.Empty) { using (var session = SessionProvider.OpenSession()) using (var transaction = session.BeginTransaction()) { currentUser = session.CreateCriteria<User>() .Add(Restrictions.Eq("SessionId", sessionId)) .SetMaxResults(1) .UniqueResult<User>(); } } logger.Debug("Создан новый экземпляр службы [{0}]", sessionId); channel = OperationContext.Current.Channel; channel.Faulted += channel_Faulted; channel.Closing += channel_Closing; }