diff --git a/csharp/App/Backend/Controller.cs b/csharp/App/Backend/Controller.cs index 867a15a9e..435857e9e 100644 --- a/csharp/App/Backend/Controller.cs +++ b/csharp/App/Backend/Controller.cs @@ -984,7 +984,7 @@ public class Controller : ControllerBase // Cache miss or forceRegenerate: generate fresh Console.WriteLine($"[GetWeeklyReport] Generating fresh report for installation {installationId}, period {periodStartStr}–{periodEndStr}"); var report = await WeeklyReportService.GenerateReportAsync( - installationId, installation.InstallationName, lang, weekStartDate); + installationId, installation.Name, lang, weekStartDate); // Persist weekly summary and seed AiInsightCache for this language ReportAggregationService.SaveWeeklySummary(installationId, report, lang); @@ -1015,7 +1015,7 @@ public class Controller : ControllerBase try { var lang = user.Language ?? "en"; - var report = await WeeklyReportService.GenerateReportAsync(installationId, installation.InstallationName, lang); + var report = await WeeklyReportService.GenerateReportAsync(installationId, installation.Name, lang); await ReportEmailService.SendReportEmailAsync(report, emailAddress, lang, user.Name); return Ok(new { message = $"Report sent to {emailAddress}" }); } @@ -1404,7 +1404,7 @@ public class Controller : ControllerBase { var lang = user.Language ?? "en"; report.AiInsight = await ReportAggregationService.GetOrGenerateMonthlyInsightAsync(report, lang); - await ReportEmailService.SendMonthlyReportEmailAsync(report, installation.InstallationName, emailAddress, lang, user.Name); + await ReportEmailService.SendMonthlyReportEmailAsync(report, installation.Name, emailAddress, lang, user.Name); return Ok(new { message = $"Monthly report sent to {emailAddress}" }); } catch (Exception ex) @@ -1433,7 +1433,7 @@ public class Controller : ControllerBase { var lang = user.Language ?? "en"; report.AiInsight = await ReportAggregationService.GetOrGenerateYearlyInsightAsync(report, lang); - await ReportEmailService.SendYearlyReportEmailAsync(report, installation.InstallationName, emailAddress, lang, user.Name); + await ReportEmailService.SendYearlyReportEmailAsync(report, installation.Name, emailAddress, lang, user.Name); return Ok(new { message = $"Yearly report sent to {emailAddress}" }); } catch (Exception ex) diff --git a/csharp/App/Backend/Services/ReportEmailService.cs b/csharp/App/Backend/Services/ReportEmailService.cs index 1026b3aaf..e484a7501 100644 --- a/csharp/App/Backend/Services/ReportEmailService.cs +++ b/csharp/App/Backend/Services/ReportEmailService.cs @@ -16,8 +16,7 @@ public static class ReportEmailService public static async Task SendReportEmailAsync(WeeklyReportResponse report, string recipientEmail, string language = "en", string customerName = null) { var strings = GetStrings(language); - var nameSegment = !string.IsNullOrWhiteSpace(customerName) ? $" — {customerName}" : ""; - var subject = $"{strings.Title} — {report.InstallationName}{nameSegment} ({report.PeriodStart} to {report.PeriodEnd})"; + var subject = $"{strings.Title} — {report.InstallationName} ({report.PeriodStart} to {report.PeriodEnd})"; var html = BuildHtmlEmail(report, strings, customerName); var config = await ReadMailerConfig(); @@ -81,7 +80,8 @@ public static class ReportEmailService string GridIn, string GridOut, string BattInOut, - string Footer + string Footer, + string FooterLink ); private static EmailStrings GetStrings(string language) => language switch @@ -114,7 +114,8 @@ public static class ReportEmailService GridIn: "Netz Ein", GridOut: "Netz Aus", BattInOut: "Batt. Laden/Entl.", - Footer: "Erstellt von inesco Energy Monitor" + Footer: "Erstellt von inesco Energy Monitor", + FooterLink: "Detaillierte Berichte ansehen auf monitor.inesco.energy" ), "fr" => new EmailStrings( Title: "Rapport de performance hebdomadaire", @@ -144,7 +145,8 @@ public static class ReportEmailService GridIn: "Réseau Ent.", GridOut: "Réseau Sor.", BattInOut: "Batt. Ch./Déch.", - Footer: "Généré par inesco Energy Monitor" + Footer: "Généré par inesco Energy Monitor", + FooterLink: "Consultez vos rapports détaillés sur monitor.inesco.energy" ), "it" => new EmailStrings( Title: "Rapporto settimanale delle prestazioni", @@ -174,7 +176,8 @@ public static class ReportEmailService GridIn: "Rete Ent.", GridOut: "Rete Usc.", BattInOut: "Batt. Car./Sc.", - Footer: "Generato da inesco Energy Monitor" + Footer: "Generato da inesco Energy Monitor", + FooterLink: "Visualizza i tuoi report dettagliati su monitor.inesco.energy" ), _ => new EmailStrings( Title: "Weekly Performance Report", @@ -204,7 +207,8 @@ public static class ReportEmailService GridIn: "Grid In", GridOut: "Grid Out", BattInOut: "Batt. Ch./Dis.", - Footer: "Generated by inesco Energy Monitor" + Footer: "Generated by inesco Energy Monitor", + FooterLink: "View your detailed reports at monitor.inesco.energy" ) }; @@ -332,7 +336,6 @@ public static class ReportEmailService
{s.Title}
{r.InstallationName}
- {(!string.IsNullOrWhiteSpace(customerName) ? $@"
{customerName}
" : "")}
{r.PeriodStart} — {r.PeriodEnd}
@@ -398,7 +401,7 @@ public static class ReportEmailService {s.Footer} -
View your reports anytime at monitor.inesco.ch
+
{s.FooterLink}
@@ -464,8 +467,7 @@ public static class ReportEmailService var monthNames = language switch { "de" => MonthNamesDe, "fr" => MonthNamesFr, "it" => MonthNamesIt, _ => MonthNamesEn }; var monthName = report.Month >= 1 && report.Month <= 12 ? monthNames[report.Month] : report.Month.ToString(); var s = GetAggregatedStrings(language, "monthly"); - var nameSegment = !string.IsNullOrWhiteSpace(customerName) ? $" — {customerName}" : ""; - var subject = $"{s.Title} — {installationName}{nameSegment} ({monthName} {report.Year})"; + var subject = $"{s.Title} — {installationName} ({monthName} {report.Year})"; var html = BuildAggregatedHtmlEmail(report.PeriodStart, report.PeriodEnd, installationName, report.TotalPvProduction, report.TotalConsumption, report.TotalGridImport, report.TotalGridExport, report.TotalBatteryCharged, report.TotalBatteryDischarged, report.TotalEnergySaved, report.TotalSavingsCHF, @@ -483,8 +485,7 @@ public static class ReportEmailService string customerName = null) { var s = GetAggregatedStrings(language, "yearly"); - var nameSegment = !string.IsNullOrWhiteSpace(customerName) ? $" — {customerName}" : ""; - var subject = $"{s.Title} — {installationName}{nameSegment} ({report.Year})"; + var subject = $"{s.Title} — {installationName} ({report.Year})"; var html = BuildAggregatedHtmlEmail(report.PeriodStart, report.PeriodEnd, installationName, report.TotalPvProduction, report.TotalConsumption, report.TotalGridImport, report.TotalGridExport, report.TotalBatteryCharged, report.TotalBatteryDischarged, report.TotalEnergySaved, report.TotalSavingsCHF, @@ -525,7 +526,8 @@ public static class ReportEmailService string GridImport, string GridExport, string BatteryInOut, string SolarEnergyUsed, string StayedAtHome, string EstMoneySaved, string AtRate, string SolarCoverage, string FromSolar, - string BatteryEff, string OutVsIn, string CountLabel, string Footer + string BatteryEff, string OutVsIn, string CountLabel, string Footer, + string FooterLink ); private static AggregatedEmailStrings GetAggregatedStrings(string language, string type) => (language, type) switch @@ -535,49 +537,57 @@ public static class ReportEmailService "Kennzahl", "Gesamt", "PV-Produktion", "Verbrauch", "Netzbezug", "Netzeinspeisung", "Batterie Laden / Entladen", "Energie gespart", "Solar + Batterie, nicht vom Netz", "Geschätzte Ersparnis", "bei 0.39 CHF/kWh", "Energieunabhängigkeit", "aus eigenem Solar + Batterie System", "Batterie-Eff.", "Entladung vs. Ladung", - "Tage aggregiert", "Erstellt von inesco Energy Monitor"), + "Tage aggregiert", "Erstellt von inesco Energy Monitor", + "Detaillierte Berichte ansehen auf monitor.inesco.energy"), ("de", "yearly") => new AggregatedEmailStrings( "Jährlicher Leistungsbericht", "Jährliche Erkenntnisse", "Jährliche Zusammenfassung", "Ihre Ersparnisse dieses Jahr", "Kennzahl", "Gesamt", "PV-Produktion", "Verbrauch", "Netzbezug", "Netzeinspeisung", "Batterie Laden / Entladen", "Energie gespart", "Solar + Batterie, nicht vom Netz", "Geschätzte Ersparnis", "bei 0.39 CHF/kWh", "Energieunabhängigkeit", "aus eigenem Solar + Batterie System", "Batterie-Eff.", "Entladung vs. Ladung", - "Monate aggregiert", "Erstellt von inesco Energy Monitor"), + "Monate aggregiert", "Erstellt von inesco Energy Monitor", + "Detaillierte Berichte ansehen auf monitor.inesco.energy"), ("fr", "monthly") => new AggregatedEmailStrings( "Rapport de performance mensuel", "Aperçus du mois", "Résumé du mois", "Vos économies ce mois", "Indicateur", "Total", "Production PV", "Consommation", "Import réseau", "Export réseau", "Batterie Charge / Décharge", "Énergie économisée", "solaire + batterie, non achetée au réseau", "Économies estimées", "à 0.39 CHF/kWh", "Indépendance énergétique", "de votre système solaire + batterie", "Eff. batterie", "décharge vs charge", - "jours agrégés", "Généré par inesco Energy Monitor"), + "jours agrégés", "Généré par inesco Energy Monitor", + "Consultez vos rapports détaillés sur monitor.inesco.energy"), ("fr", "yearly") => new AggregatedEmailStrings( "Rapport de performance annuel", "Aperçus de l'année", "Résumé de l'année", "Vos économies cette année", "Indicateur", "Total", "Production PV", "Consommation", "Import réseau", "Export réseau", "Batterie Charge / Décharge", "Énergie économisée", "solaire + batterie, non achetée au réseau", "Économies estimées", "à 0.39 CHF/kWh", "Indépendance énergétique", "de votre système solaire + batterie", "Eff. batterie", "décharge vs charge", - "mois agrégés", "Généré par inesco Energy Monitor"), + "mois agrégés", "Généré par inesco Energy Monitor", + "Consultez vos rapports détaillés sur monitor.inesco.energy"), ("it", "monthly") => new AggregatedEmailStrings( "Rapporto mensile delle prestazioni", "Approfondimenti mensili", "Riepilogo mensile", "I tuoi risparmi questo mese", "Metrica", "Totale", "Produzione PV", "Consumo", "Import dalla rete", "Export nella rete", "Batteria Carica / Scarica", "Energia risparmiata", "solare + batteria, non acquistata dalla rete", "Risparmio stimato", "a 0.39 CHF/kWh", "Indipendenza energetica", "dal proprio impianto solare + batteria", "Eff. batteria", "scarica vs carica", - "giorni aggregati", "Generato da inesco Energy Monitor"), + "giorni aggregati", "Generato da inesco Energy Monitor", + "Visualizza i tuoi report dettagliati su monitor.inesco.energy"), ("it", "yearly") => new AggregatedEmailStrings( "Rapporto annuale delle prestazioni", "Approfondimenti annuali", "Riepilogo annuale", "I tuoi risparmi quest'anno", "Metrica", "Totale", "Produzione PV", "Consumo", "Import dalla rete", "Export nella rete", "Batteria Carica / Scarica", "Energia risparmiata", "solare + batteria, non acquistata dalla rete", "Risparmio stimato", "a 0.39 CHF/kWh", "Indipendenza energetica", "dal proprio impianto solare + batteria", "Eff. batteria", "scarica vs carica", - "mesi aggregati", "Generato da inesco Energy Monitor"), + "mesi aggregati", "Generato da inesco Energy Monitor", + "Visualizza i tuoi report dettagliati su monitor.inesco.energy"), (_, "monthly") => new AggregatedEmailStrings( "Monthly Performance Report", "Monthly Insights", "Monthly Summary", "Your Savings This Month", "Metric", "Total", "PV Production", "Consumption", "Grid Import", "Grid Export", "Battery Charge / Discharge", "Energy Saved", "solar + battery, not bought from grid", "Est. Money Saved", "at 0.39 CHF/kWh", "Energy Independence", "from your own solar + battery system", "Battery Eff.", "discharge vs charge", - "days aggregated", "Generated by inesco Energy Monitor"), + "days aggregated", "Generated by inesco Energy Monitor", + "View your detailed reports at monitor.inesco.energy"), _ => new AggregatedEmailStrings( "Annual Performance Report", "Annual Insights", "Annual Summary", "Your Savings This Year", "Metric", "Total", "PV Production", "Consumption", "Grid Import", "Grid Export", "Battery Charge / Discharge", "Energy Saved", "solar + battery, not bought from grid", "Est. Money Saved", "at 0.39 CHF/kWh", "Energy Independence", "from your own solar + battery system", "Battery Eff.", "discharge vs charge", - "months aggregated", "Generated by inesco Energy Monitor") + "months aggregated", "Generated by inesco Energy Monitor", + "View your detailed reports at monitor.inesco.energy") }; // ── Aggregated HTML email template ──────────────────────────────────── @@ -615,7 +625,6 @@ public static class ReportEmailService
{s.Title}
{installationName}
- {(!string.IsNullOrWhiteSpace(customerName) ? $@"
{customerName}
" : "")}
{periodStart} — {periodEnd}
{countLabel}
@@ -668,7 +677,7 @@ public static class ReportEmailService {s.Footer} -
View your reports anytime at monitor.inesco.ch
+
{s.FooterLink}