Merge branch 'master' into feature_rene_17_xrechnung

# Conflicts:
#	BeWo/ServiceProxy/Generated.cs
#	BeWo/Services/BeWoWindowService.cs
#	BeWo/View/Controls/GkvAbrechnungDetailControl.xaml.cs
#	BeWo/View/Windows/BeWoWindowBuilder.cs
#	Data/Data.csproj
#	Host/ServiceRecordPage.aspx.cs
#	Service/Core/ServiceHelper.cs
#	Service/Security/SecurityContextInitializer.cs
#	Service/ServiceBehavior/AdminMultitenancyContextInitializer.cs
This commit is contained in:
2025-06-17 13:07:41 +02:00
226 changed files with 9678 additions and 33887 deletions

View File

@@ -1,123 +0,0 @@
using System;
using System.Collections.Generic;
using System.IdentityModel.Claims;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Remoting.Channels;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using System.Text;
using System.Threading.Tasks;
using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Service.Core;
using BS.Shared.Core;
using BS.Shared.Exceptions;
using BS.Shared.Extensions;
using NHibernate.Hql.Ast.ANTLR.Tree;
namespace BeWo.Service.ServiceUtils
{
public static class ServiceHelper
{
public static FileLogger CoreLogger { get; } = new FileLogger(MergedConfig.GetSetting(WebConfigSetting.ServiceLogFilePath));
public static FileLogger WCFErrorLogger { get; } = new FileLogger(MergedConfig.GetSetting(WebConfigSetting.ServiceLogFilePath));
public static FileLogger JsonErrorLogger { get; } = new FileLogger(MergedConfig.GetSetting(WebConfigSetting.ServiceLogFilePath));
public static Tuple<string, string> GetInterfaceAndMethodASP(Message request , IClientChannel channel)
{
// Hole Interface
string lInterface = null;
var segments = channel.LocalAddress.Uri.Segments;
for (int i = 0; i < segments.Length; i++)
{
var seg = segments[i].Trim('/');
if (seg.EndsWith(".svc"))
{
lInterface = "I" + seg.Substring(0, seg.Length - 4);
}
}
if (string.IsNullOrWhiteSpace(lInterface))
{
throw new ArgumentException($"Zugriff verweigert. Interface unbekannt");
}
// Hole Methode
string lMethod = request.Properties[WebHttpDispatchOperationSelector.HttpOperationNamePropertyName] as string;
if (string.IsNullOrWhiteSpace(lMethod))
{
throw new ArgumentException($"Zugriff verweigert. Methode unbekannt");
}
return new Tuple<string, string>(lInterface, lMethod);
}
public static T GetCustomAttribute<T>(Uri baseAddress, Uri request) where T : Attribute
{
// Hole Interface
string lInterface = null;
var segments = baseAddress.Segments;
for (int i = 0; i < segments.Length; i++)
{
var seg = segments[i].Trim('/');
if (seg.EndsWith(".svc"))
{
lInterface = seg.Substring(0, seg.Length - 4);
}
}
// Falls kein Interface gefunden wird
if (string.IsNullOrWhiteSpace(lInterface) )
{
throw new ArgumentException($"Zugriff verweigert. Interface unbekannt");
}
// Wird für URLTemplate != Methodname verwendet
var name = $"BeWo.Service.ServiceContracts.I{lInterface}";
var t = Type.GetType(name);
var resolver = new UriTemplateResolver(baseAddress, t);
var method = resolver.ResolveMethod(request.AbsoluteUri);
var methodInfo = t.GetMethod(method);
// Rückgabe
return getCustomAttribute<T>(methodInfo);
}
public static T GetCustomAttribute<T>(string pServiceInterface, string pMethodName) where T : Attribute
{
MethodInfo methodInfo = null;
try
{
// Hole entsprechende Methode
var name = $"BeWo.Service.ServiceContracts.{pServiceInterface}";
var t = Type.GetType(name);
methodInfo = t?.GetMethod(pMethodName);
}
catch (Exception)
{
throw new ArgumentException($"Zugriff verweigert. Interface oder Methode unbekannt");
}
return getCustomAttribute<T>(methodInfo);
}
private static T getCustomAttribute<T>(MethodInfo methodInfo) where T : Attribute
{
if (methodInfo == null)
{
throw new ArgumentException($"Zugriff verweigert. Interface oder Methode unbekannt");
}
// Hole Custome Attribute
var attribute = methodInfo.GetCustomAttribute<T>();
return attribute;
}
}
}