Files
BeWoPlaner/Service/ServiceBehavior/AdminHibernateContextInitializer.cs

50 lines
1.2 KiB
C#
Raw Permalink Normal View History

2025-02-20 18:39:11 +01:00
using BeWo.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using System.Text;
using System.Threading.Tasks;
namespace BeWo.Service.ServiceBehavior
{
public class AdminHibernateContextInitializer : ICallContextInitializer
{
public void AfterInvoke(object pCorrelationState)
{
2025-02-21 16:09:11 +01:00
if (pCorrelationState != null)
{
WCFHibernateSessionManager.CloseSession();
OperationContext.Current.Extensions.Remove((SessionOperationContextExt)pCorrelationState);
}
2025-02-20 18:39:11 +01:00
}
public object BeforeInvoke(InstanceContext pInstanceContext, IClientChannel pChannel, Message pMessage)
{
2025-02-25 12:56:09 +01:00
if (MultitenancyOperationContextExt.Current?.Tenant is null)
2025-02-21 16:09:11 +01:00
return null;
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;
}
catch (Exception e)
{
throw new FaultException(e.ToString());
return null;
}
2025-02-20 18:39:11 +01:00
}
}
}