118 lines
3.2 KiB
C#
118 lines
3.2 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Service.Core;
|
|
using BeWo.Service.ServiceContracts;
|
|
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
|
|
{
|
|
//generateApiServiceTestFile();
|
|
|
|
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);
|
|
}
|
|
|
|
private void generateApiServiceTestFile()
|
|
{
|
|
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(BeWoServerPathHelper.GetApiServiceTestFile(), str, Encoding.UTF8);
|
|
}
|
|
}
|
|
}
|