Status Endpunkt
This commit is contained in:
@@ -199,9 +199,11 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="StatusService.svc" />
|
||||
<Content Include="ApiStreamService.svc" />
|
||||
<Content Include="ApiService.svc" />
|
||||
<Content Include="AdminService.svc" />
|
||||
<Content Include="status.htm" />
|
||||
<Content Include="Config\ai\systemPrompts\customFunctionPreSystemPrompt.txt" />
|
||||
<Content Include="Config\ai\systemPrompts\customPreSystemPrompt.txt" />
|
||||
<Content Include="Config\allowed_ips_admin_api.txt" />
|
||||
|
||||
1
Host/StatusService.svc
Normal file
1
Host/StatusService.svc
Normal file
@@ -0,0 +1 @@
|
||||
<%@ ServiceHost Language="C#" Debug="true" Service="BeWo.Service.ServiceImplementations.Enhanced.StatusServiceImp" %>
|
||||
@@ -307,6 +307,9 @@
|
||||
<service behaviorConfiguration="returnFaults" name="BeWo.Service.ServiceImplementations.Enhanced.AiEnhancedServiceImp">
|
||||
<endpoint behaviorConfiguration="SecurityAndSessionAndWCFErrorBehavior" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" name="AiEnhancedServiceEndpoint" contract="BeWo.Service.ServiceContracts.Enhanced.IAiEnhancedService" />
|
||||
</service>
|
||||
<service behaviorConfiguration="returnFaults" name="BeWo.Service.ServiceImplementations.Enhanced.StatusServiceImp">
|
||||
<endpoint behaviorConfiguration="webHttpBehaviorConfig" binding="webHttpBinding" bindingConfiguration="webHttpStreamBindingConfig" name="StatusServiceEndpoint" contract="BeWo.Service.ServiceContracts.Enhanced.IStatusService" />
|
||||
</service>
|
||||
</services>
|
||||
<bindings>
|
||||
<basicHttpBinding>
|
||||
|
||||
9
Host/status.htm
Normal file
9
Host/status.htm
Normal file
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" >
|
||||
<head>
|
||||
<title></title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -11,6 +11,7 @@ using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace BeWo.Service.Core
|
||||
{
|
||||
@@ -67,8 +68,15 @@ namespace BeWo.Service.Core
|
||||
var prop = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];
|
||||
lTenant = prop?.Headers["tenant"];
|
||||
|
||||
// Wenn kein Tenant gefunden wird,
|
||||
if (string.IsNullOrWhiteSpace(lTenant))
|
||||
if (string.IsNullOrWhiteSpace(lTenant) && prop is object)
|
||||
{
|
||||
var dict = HttpUtility.ParseQueryString(prop.QueryString);
|
||||
|
||||
lTenant = dict["Tenant"];
|
||||
}
|
||||
|
||||
// Wenn kein Tenant gefunden wird,
|
||||
if (string.IsNullOrWhiteSpace(lTenant))
|
||||
{
|
||||
throw new ArgumentException($"Zugriff verweigert. Tenant (\'{lTenant}\') darf nicht leer sein.", nameof(lTenant));
|
||||
}
|
||||
|
||||
@@ -545,6 +545,7 @@
|
||||
<Compile Include="ServiceBehavior\WCFError\WCFErrorBehaviorExtension.cs" />
|
||||
<Compile Include="ServiceBehavior\WCFError\WCFErrorHandler.cs" />
|
||||
<Compile Include="ServiceContracts\Enhanced\IAccountingEnhancedService.cs" />
|
||||
<Compile Include="ServiceContracts\Enhanced\IStatusService.cs" />
|
||||
<Compile Include="ServiceContracts\IAccountingService.cs" />
|
||||
<Compile Include="ServiceContracts\IAdminService.cs" />
|
||||
<Compile Include="ServiceContracts\IAnalysisService.cs" />
|
||||
@@ -569,6 +570,7 @@
|
||||
<Compile Include="ServiceImplementations\AdminServiceImp.cs" />
|
||||
<Compile Include="ServiceImplementations\AnalysisServiceImp.cs" />
|
||||
<Compile Include="ServiceImplementations\Enhanced\AccountingEnhancedServiceImp.cs" />
|
||||
<Compile Include="ServiceImplementations\Enhanced\StatusServiceImp.cs" />
|
||||
<Compile Include="ServiceImplementations\GkvAccountingServiceImp.cs" />
|
||||
<Compile Include="ServiceImplementations\MailServiceImp.cs" />
|
||||
<Compile Include="ServiceImplementations\Enhanced\AiEnhancedServiceImp.cs" />
|
||||
|
||||
20
Service/ServiceContracts/Enhanced/IStatusService.cs
Normal file
20
Service/ServiceContracts/Enhanced/IStatusService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using BeWo.Service.Attributes;
|
||||
using BS.Shared.DataContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.ServiceModel.Web;
|
||||
using System.ServiceModel;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.Service.ServiceContracts.Enhanced
|
||||
{
|
||||
[ServiceContract]
|
||||
public interface IStatusService
|
||||
{
|
||||
[OperationContract]
|
||||
[WebGet(UriTemplate = "/Status", ResponseFormat = WebMessageFormat.Json)]
|
||||
ServerStatusDC GetStatus();
|
||||
}
|
||||
}
|
||||
99
Service/ServiceImplementations/Enhanced/StatusServiceImp.cs
Normal file
99
Service/ServiceImplementations/Enhanced/StatusServiceImp.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.Attributes;
|
||||
using BeWo.Service.Core;
|
||||
using BeWo.Service.ServiceContracts.Enhanced;
|
||||
using BS.Shared.DataContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Web;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.Service.ServiceImplementations.Enhanced
|
||||
{
|
||||
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall,
|
||||
ConcurrencyMode = ConcurrencyMode.Single)]
|
||||
public class StatusServiceImp : IStatusService
|
||||
{
|
||||
public ServerStatusDC GetStatus()
|
||||
{
|
||||
var result = new ServerStatusDC
|
||||
{
|
||||
ServerTime = DateTime.Now.ToString("o"),
|
||||
Version = Assembly.GetExecutingAssembly()
|
||||
.GetName().Version?.ToString() ?? "unbekannt",
|
||||
Services = new List<ServiceStatusDC>()
|
||||
};
|
||||
|
||||
// Datenbankverbindung prüfen
|
||||
result.DatabaseOk = CheckDatabase();
|
||||
|
||||
// Einzelne Subsysteme prüfen
|
||||
result.Services.Add(CheckService("Database", result.DatabaseOk));
|
||||
//result.Services.Add(CheckService("Mail", CheckMail()));
|
||||
result.Services.Add(CheckService("AIModule", CheckAiModule()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private bool CheckDatabase()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Leichter DB-Ping – z.B. eine einfache Abfrage über DAOFactory
|
||||
DAOFactory.GenericDAO.GetAll<ApplicationUser>();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckMail()
|
||||
{
|
||||
try
|
||||
{
|
||||
// z.B. SMTP-Verbindung kurz aufbauen und sofort schließen
|
||||
// Kann auch weggelassen / später ergänzt werden
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckAiModule()
|
||||
{
|
||||
try
|
||||
{
|
||||
// #1
|
||||
var configPath = ConfigReader.GetConfigPath(SpecialConfig.CustomPreSystemPrompt);
|
||||
if (!File.Exists(configPath))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private ServiceStatusDC CheckService(string name, bool ok)
|
||||
{
|
||||
return new ServiceStatusDC
|
||||
{
|
||||
Name = name,
|
||||
IsOk = ok,
|
||||
Message = ok ? "OK" : "Fehler"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Shared/DataContracts/ServerStatusDC.cs
Normal file
25
Shared/DataContracts/ServerStatusDC.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.DataContracts
|
||||
{
|
||||
[DataContract]
|
||||
public class ServerStatusDC
|
||||
{
|
||||
[DataMember]
|
||||
public string ServerTime { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string Version { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public bool DatabaseOk { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public List<ServiceStatusDC> Services { get; set; }
|
||||
}
|
||||
}
|
||||
22
Shared/DataContracts/ServiceStatusDC.cs
Normal file
22
Shared/DataContracts/ServiceStatusDC.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.DataContracts
|
||||
{
|
||||
[DataContract]
|
||||
public class ServiceStatusDC
|
||||
{
|
||||
[DataMember]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public bool IsOk { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -347,6 +347,8 @@
|
||||
<Compile Include="DataContracts\CustomerTokenRelationDC.cs" />
|
||||
<Compile Include="DataContracts\EmployeeTokenRelationDC.cs" />
|
||||
<Compile Include="DataContracts\ChatBewoMessageSyncDC.cs" />
|
||||
<Compile Include="DataContracts\ServerStatusDC.cs" />
|
||||
<Compile Include="DataContracts\ServiceStatusDC.cs" />
|
||||
<Compile Include="DataContracts\ValidationResultDC.cs" />
|
||||
<Compile Include="DataContracts\StoredFileDC.cs" />
|
||||
<Compile Include="DataContracts\VertreterSucheFilterDC.cs" />
|
||||
|
||||
Reference in New Issue
Block a user