57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.AI;
|
|
using BeWo.Service.Attributes;
|
|
using BeWo.Service.Core;
|
|
using BeWo.Service.ServiceContracts.Enhanced;
|
|
using BeWo.Service.Status;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
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"),
|
|
AssemblyVersion = Assembly.GetExecutingAssembly()
|
|
.GetName().Version?.ToString() ?? "unbekannt",
|
|
ServerVersion = BeWoAppInfo.BeWoAppVersion.ToString(),
|
|
Services = new List<ServiceStatusDC>()
|
|
};
|
|
|
|
// Datenbankverbindung prüfen
|
|
result.DatabaseOk = new DatenbankStatusService().DoHealthCheckup();
|
|
|
|
// Einzelne Subsysteme prüfen
|
|
result.Services.Add(new GeneralStatusService().DoHealthCheckup());
|
|
result.Services.Add(new AiStatusService().DoHealthCheckup());
|
|
|
|
var allHealthy = result.DatabaseOk.IsOk && result.Services.All(x => x.IsOk);
|
|
if (!allHealthy)
|
|
{
|
|
WebOperationContext.Current.OutgoingResponse.StatusCode =
|
|
HttpStatusCode.InternalServerError;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|