Files
BeWoPlaner/Service/ServiceImplementations/ApiServiceImp.cs
Rene Evertz 2832bb9c5e Merge branch 'master' into feature_rene_18_ai - kein kommentar...
# Conflicts:
#	BeWo/BeWo.csproj
#	BeWo/BeWoApp.xaml.cs
#	BeWo/ServiceProxy/GeneratedAiEnhancedService.cs
#	BeWo/Services/BeWoControlFactory.cs
#	BeWo/Services/BeWoWindowFactory.cs
#	BeWo/Services/BeWoWindowService.cs
#	BeWo/Services/IControlFactory.cs
#	BeWo/Services/IWindowFactory.cs
#	BeWo/Services/IWindowService.cs
#	BeWo/View/BeWoFileView.xaml
#	BeWo/View/Detail/Report/AbwesenheitsView.xaml
#	BeWo/View/Windows/AnimatedBeWoWindow.xaml.cs
#	BeWo/app.config
#	BeWoAllReports.sln
#	BeWoPlanerMobil.sln
#	BeWoPlanerMobil/.vs/BeWoPlanerMobil.csproj.dtbcache.json
#	BeWoTests.sln
#	Dakota/DakotaUtils.cs
#	Dakota/Logic/DakotaInfoCreator.cs
#	Dakota/Models/DakotaFile.cs
#	Data/Access/GenericDAO.cs
#	Data/Access/SearchDAO.cs
#	Data/Data.csproj
#	Host/Web.config
#	Server/Components/ServerUtils/ApiFacade/WebClientFacade.cs
#	Service/BeWoServiceEnums.cs
#	Service/Core/ServiceHelper.cs
#	Service/Core/ServiceValidator.cs
#	Service/Extensions/ServiceEnumExtension.cs
#	Service/Service.csproj
#	Service/ServiceContracts/Enhanced/IAiEnhancedService.cs
#	Service/ServiceContracts/Enhanced/IOperationsEnhancedService.cs
#	Service/ServiceImplementations/EmployeeServiceImp.cs
#	Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs
#	Service/ServiceImplementations/Enhanced/OperationsEnhancedServiceImp.cs
#	Service/ServiceProxy/OpenWebUIFacade.cs
#	Service/ServiceProxy/ServiceFacade.cs
#	Service/ServiceUtils/DistanceCalculator/GoogleDistanceMatrixAPI.cs
#	Shared/BeWoEntityEnums.cs
#	Shared/Core/AppError.cs
#	Shared/Core/Facade/WebClientFacade.cs
#	Shared/Core/WebClientFacade.cs
#	Shared/Shared.csproj
2025-11-28 12:07:35 +01:00

115 lines
3.3 KiB
C#

using BeWo.Data.Access;
using BeWo.Service.Core;
using BeWo.Service.ServiceContracts;
using BeWo.Service.ServiceImplementations.Enhanced;
using BeWo.Service.ServiceUtils;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.AdminService;
using DevExpress.Pdf.Native.BouncyCastle.Ocsp;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Web;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace BeWo.Service.ServiceImplementations
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
public class ApiServiceImp : IApiService
{
public ApiResponse<string> Test()
{
try
{
var winIdentity = WindowsIdentity.GetCurrent();
var securityContext = ServiceSecurityContext.Current;
var principal = Thread.CurrentPrincipal;
var proc = Process.GetCurrentProcess();
var ipInfo = OperationContext.Current?.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
var httpInfo = OperationContext.Current?.IncomingMessageProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
var basedir = AppDomain.CurrentDomain.BaseDirectory;
var log = new
{
WindowsIdentity = new
{
winIdentity?.Name,
winIdentity?.IsAuthenticated,
winIdentity?.AuthenticationType
},
ServiceSecurityContext = new
{
PrimaryIdentity = securityContext?.PrimaryIdentity?.Name,
WindowsIdentity = securityContext?.WindowsIdentity?.Name,
},
Process = new
{
proc.ProcessName,
proc.StartTime
},
AppDomain = new
{
AppDomain.CurrentDomain.BaseDirectory,
AppDomain.CurrentDomain.FriendlyName
},
Environment = new
{
Environment.UserName,
Environment.MachineName,
Environment.OSVersion,
Environment.CurrentDirectory,
Environment.Is64BitProcess
},
ThreadPrincipal = principal?.Identity?.Name,
IP = ipInfo?.Address,
Port = ipInfo?.Port,
UserAgent = httpInfo?.Headers["User-Agent"],
};
var str = JsonConvert.SerializeObject(log, Formatting.Indented);
File.WriteAllText(MergedConfig.GetSetting(WebConfigSetting.ApiServiceTestFilePath), str, Encoding.UTF8);
return ApiResponse<string>.SuccessResponse("Hello World!");
}
catch (Exception ex)
{
return ApiResponse<string>.FailureResponse(ex.ToString());
}
}
public ApiResponse<decimal> GetGkvAbrechnungSumme(AdminServiceSumReqDC request)
{
if (request == null)
{
throw new ArgumentException("request darf nicht null sein");
}
if (!BS.Shared.Core.Utils.TryParseISO8601(request.Start, out var start))
{
throw new ArgumentException("start entspricht nicht ISO8601 Norm.");
}
if (!BS.Shared.Core.Utils.TryParseISO8601(request.End, out var end))
{
throw new ArgumentException("end entspricht nicht ISO8601 Norm.");
}
var sum = DAOFactory.ScriptDAO.GetGkvSumByDateRange(start, end);
return ApiResponse<decimal>.SuccessResponse(sum ?? 0);
}
}
}