2016-06-27 01:45:38 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.ServiceModel;
|
|
|
|
|
|
using System.ServiceModel.Channels;
|
|
|
|
|
|
using System.ServiceModel.Dispatcher;
|
|
|
|
|
|
|
|
|
|
|
|
using BeWo.Data;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BeWo.Service.UnitOfWork
|
|
|
|
|
|
{
|
|
|
|
|
|
public class HibernateSessionContextInitializer : ICallContextInitializer
|
|
|
|
|
|
{
|
|
|
|
|
|
public void AfterInvoke(object pCorrelationState)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pCorrelationState != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
WCFHibernateSessionManager.CloseSession();
|
|
|
|
|
|
OperationContext.Current.Extensions.Remove((SessionOperationContextExt)pCorrelationState);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object BeforeInvoke(InstanceContext pInstanceContext, IClientChannel pChannel, Message pMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
//System.Threading.Monitor.Enter
|
|
|
|
|
|
SessionOperationContextExt lExt = new SessionOperationContextExt();
|
|
|
|
|
|
//int c = OperationContext.Current.Extensions.Count;
|
|
|
|
|
|
//if (c > 0)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int te st = 0;
|
|
|
|
|
|
//}
|
|
|
|
|
|
OperationContext.Current.Extensions.Add(lExt);
|
|
|
|
|
|
WCFHibernateSessionManager.OpenSession();
|
|
|
|
|
|
return lExt;
|
|
|
|
|
|
}
|
2024-10-31 15:38:24 +01:00
|
|
|
|
catch (Exception e)
|
2016-06-27 01:45:38 +02:00
|
|
|
|
{
|
2024-10-31 15:38:24 +01:00
|
|
|
|
throw new FaultException(e.ToString());
|
2016-06-27 01:45:38 +02:00
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|