Error-Handling verbessert. Alle C#-Exceptions werden geloggt mit Message und Stacktrace.

Altes Logo gelöscht mit beyondSoft.
This commit is contained in:
2025-07-24 10:21:01 +02:00
parent 048421bb5b
commit 478be4587e
11 changed files with 87 additions and 26 deletions

View File

@@ -7,6 +7,21 @@ namespace BeWoPlanerMobil
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new BeWoExceptionFilter());
}
}
public class BeWoExceptionFilter : IExceptionFilter
{
protected static readonly log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void OnException(ExceptionContext filterContext)
{
var exception = filterContext.Exception;
Log.Error($"{exception.Message}: {exception.StackTrace}");
filterContext.Result = new ViewResult { ViewName = "Error" };
}
}
}

View File

@@ -409,7 +409,6 @@
<Content Include="Content\images\bars-black.svg" />
<Content Include="Content\images\BeWoPlaner.ico" />
<Content Include="Content\images\bewoplaner_by_ownsoft_logo_mok.png" />
<Content Include="Content\images\bewoplaner_logo_big.png" />
<Content Include="Content\images\calendar-bs-orange.svg" />
<Content Include="Content\images\interval-finder-icon-v2.svg" />
<Content Include="Content\images\interval-finder-icon.svg" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -8,7 +8,6 @@ using BeWo.Service.DCEntityMapper;
using BeWo.Service.ServiceContracts;
using BeWoPlanerMobil.Models;
using BeWoPlanerMobil.Service;
using BeWoPlanerMobil.Util;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
@@ -154,5 +153,14 @@ namespace BeWoPlanerMobil.Controllers
}
public abstract string SaveCollapsibleStatus(bool isOpen, string identifier);
public ActionResult Error()
{
#if DEBUG
ViewBag.ErrorMessage = "[HIER KOMMT DIE FEHLERMELDUNG HIN]";
#endif
return View("Error");
}
}
}

View File

@@ -37,7 +37,7 @@ namespace BeWoPlanerMobil.Controllers
[Authorize]
public ActionResult DevExpressScheduler()
{
if(!MobileSessionFacade.IsUserLoggedIn() || Model == null)
if(!MobileSessionFacade.IsUserLoggedIn() || Model is null)
{
return RedirectToActionPermanent("Index", "Login");
}

View File

@@ -2935,7 +2935,7 @@ namespace BeWoPlanerMobil.Controllers
newResult.KannTrotzdemGespeichertWerden = false;
break;
case Error:
case ServiceRecordValidationResult.Error:
newResult.Message += "Beim Speichern ist ein Fehler aufgetreten.<br /><br />";
exitLoop = true;
newResult.KannTrotzdemGespeichertWerden = false;

View File

@@ -658,7 +658,7 @@ namespace BeWoPlanerMobil.Controllers
Model.SelectedValues.Remove(parameterOid.Value);
}
break;
break;
case QueryParameterType.DateRange:
if(textValue != null && textValue.Length == 21 &&textValue.Contains("_"))
{
@@ -673,7 +673,7 @@ namespace BeWoPlanerMobil.Controllers
{
Model.SelectedValues.Remove(parameterOid.Value);
}
break;
break;
case QueryParameterType.Month:
if(!textValue.Contains("_"))
{
@@ -689,7 +689,7 @@ namespace BeWoPlanerMobil.Controllers
Model.SelectedValues.AddOrUpdate(parameterOid.Value, new SelectedValue(queryParameterType, new DateTime(year, month, 1)));
}
break;
break;
case QueryParameterType.ServiceCategory:
if(objectOid is null || objectOid.Value.Equals(0))
{
@@ -703,7 +703,7 @@ namespace BeWoPlanerMobil.Controllers
{
Model.SelectedValues.AddOrUpdate(parameterOid.Value, new SelectedValue(queryParameterType, selectedServiceCategory));
}
break;
break;
case QueryParameterType.SupportConcept:
var costBearer2SupportConceptRelListObj = Model.CostBearer2SupportConceptRelListObjects.FirstOrDefault(costBearer2SupportConceptRelListObject => costBearer2SupportConceptRelListObject.CostBearer2SupportConceptOid.Equals(objectOid.ToString()));
@@ -719,7 +719,7 @@ namespace BeWoPlanerMobil.Controllers
{
Model.SelectedValues.AddOrUpdate(parameterOid.Value, new SelectedValue(queryParameterType, costBearer2SupportConceptRelListObj));
}
break;
break;
case QueryParameterType.Team:
if(objectOid is null || objectOid.Value.Equals(0))
{
@@ -733,7 +733,7 @@ namespace BeWoPlanerMobil.Controllers
{
Model.SelectedValues.AddOrUpdate(parameterOid.Value, new SelectedValue(queryParameterType, selectedTeam));
}
break;
break;
case QueryParameterType.ValueListEntryType:
if(objectOid is null || objectOid.Value.Equals(0))
{
@@ -747,7 +747,7 @@ namespace BeWoPlanerMobil.Controllers
{
Model.SelectedValues.AddOrUpdate(parameterOid.Value, new SelectedValue(queryParameterType, selectedValueListEntry));
}
break;
break;
case QueryParameterType.Year:
break;
}

View File

@@ -1,4 +1,5 @@
@using BeWoPlanerMobil.Views.DevExpressScheduler
@using BS.Shared.DataContracts
@using DevExpress.XtraScheduler
@model BeWoPlanerMobil.Models.DevExpressSchedulerModel
@@ -50,8 +51,19 @@
settings.Storage.Resources.Assign(SchedulerHelper.DefaultResourceStorage);
settings.Storage.Appointments.Assign(SchedulerHelper.DefaultAppointmentStorage);
/*
*
*/
settings.Storage.Appointments.Assign(SchedulerHelper.DefaultAppointmentStorage);
settings.Storage.Resources.Assign(SchedulerHelper.DefaultResourceStorage);
settings.Storage.Appointments.Mappings.Start = nameof(SchedulerAppointmentDC.StartDate);
settings.Storage.Appointments.Mappings.End = nameof(SchedulerAppointmentDC.EndDate);
settings.Storage.Appointments.Mappings.Subject = nameof(SchedulerAppointmentDC.Subject);
settings.Storage.Appointments.Mappings.AllDay = nameof(SchedulerAppointmentDC.AllDay);
settings.Storage.Appointments.Mappings.Description = nameof(SchedulerAppointmentDC.Description);
settings.Storage.Appointments.Mappings.Status = nameof(SchedulerAppointmentDC.Status);
settings.Storage.Appointments.Mappings.Label = nameof(SchedulerAppointmentDC.LabelKey);
settings.Views.DayView.Styles.ScrollAreaHeight = new Unit(500);

View File

@@ -627,7 +627,7 @@
<span class="input-group-text rounded-0 border-left-0 border-right-0">
Bis
</span>
<input class="form-control" type="date" name="bis" onfocusout="loadServiceRecords()" value="@defaultEndDate"/>
<input class="form-control" type="date" name="bis" id="time-frame-end-date" onfocusout="loadServiceRecords()" value="@defaultEndDate"/>
</div>
</div>
</div>

View File

@@ -1,19 +1,46 @@
@{
Layout = null;
}
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Fehler</title>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/jquery/jquery-3.7.1.min.js")"></script>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/devexpress-dependencies/jquery/jquery.validate.min.js")"></script>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/devexpress-dependencies/jquery/jquery.unobtrusive-ajax.min.js")"></script>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/knockout-3.5.1.js")"></script>
<script type="text/javascript" src="@Scripts.Url("~/Scripts/bootstrap/bootstrap.bundle.min.js")"></script>
<link rel="stylesheet" href="@Url.Content("~/Content/style.css")" />
<script type="text/javascript">
function copyTextToClipboard() {
const element = document.querySelector("#error-textarea");
element.select();
element.setSelectionRange(0, 99999);
document.execCommand("copy");
}
</script>
</head>
<body>
<hgroup>
<h1>Fehler.</h1>
<h2>Es ist ein Fehler aufgetreten. Bitte wenden Sie sich an Ihren Administrator.</h2>
<h4>@ViewData["BeWoError"]</h4>
</hgroup>
<div class="navbar navbar-expand-lg sticky-top justify-content-end">
<div class="container-fluid">
<a href="#" class="navbar-brand m-0 p-0">
<img height="30px" src="@Url.Content("~/Content/images/bewoplaner_by_ownsoft_logo_mok.png")" alt="bewoplaner by ownSoft" />
</a>
</div>
</div>
<div class="container lg-max-width mt-5">
<div class="card">
<div class="card-body">
<h1 class="card-title">Fehler</h1>
<p>Es ist ein Fehler aufgetreten. Bitte wenden Sie sich an Ihren Administrator.</p>
<button type="button" class="btn btn-primary" onclick="copyTextToClipboard()">Fehlerdetails Kopieren<span class="ml-3 fas fa-copy"></span></button>
<textarea id="error-textarea" class="form-control mt-2">@ViewBag.ErrorMessage</textarea>
</div>
</div>
</div>
</body>
</html>

View File

@@ -21,10 +21,10 @@
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
<customErrors defaultRedirect="Error" mode="On" xdt:Transform="Replace">
<!--<error statusCode="500" redirect="InternalError.htm"/>-->
</customErrors>
</system.web>
</configuration>