AccountingNext/Schaad.Accounting.UI/Program.cs
Claudio Schaad 0c6e78b0d8 Add JSON editor for the data files
New page Stammdaten -> JSON-Editor edits the data files of the selected year
and mandator (default Transactions.json) as plain JSON in Monaco (BlazorMonaco
3.5.0, loaded on demand): highlighting, folding, live syntax errors, search
and replace with regex, format.

RawDataRepository saves only validated text: strict JSON (unknown properties
rejected with line/column), unique non-empty Ids, transactions referencing
existing accounts, accounts still used by transactions not removed. It refuses
if the file changed since loading, backs up the previous version to
backup/{mandator}/{year}/json-{timestamp}/, and saves through BaseRepository
so caches are refreshed.

- Hub MaximumReceiveMessageSize raised to 8 MB (files are several hundred KB)
- unsaved-guard.js asks before leaving with unsaved changes; NavigationLock
  doesn't apply because routing between per-page interactive pages is static

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 19:52:20 +02:00

61 lines
2.2 KiB
C#

using System.Globalization;
using Microsoft.AspNetCore.Localization;
using Microsoft.Extensions.Options;
using Microsoft.FluentUI.AspNetCore.Components;
using Schaad.Accounting.Datasets;
using Schaad.Accounting.UI.Components;
namespace Schaad.Accounting.UI
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
// The JSON editor sends whole data files (Transactions.json is several hundred KB)
// from the browser; the default limit is 32 KB per message.
.AddHubOptions(options => options.MaximumReceiveMessageSize = 8 * 1024 * 1024);
builder.Services.AddFluentUIComponents();
builder.Services.Configure<SettingsDataset>(
builder.Configuration.GetSection("Settings"));
builder.Services.AddSingleton(sp =>
sp.GetRequiredService<IOptions<SettingsDataset>>().Value);
builder.Services.AddAccounting();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
var supportedCultures = new[] { new CultureInfo("de-CH") };
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture(supportedCultures[0]),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
app.UseAntiforgery();
app.MapStaticAssets();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();
}
}
}