Log what changed; add notification on/off settings

Protokoll:
- SyncResult.Changes erfasst jede tatsaechliche Aenderung (erstellt/aktualisiert/
  geloescht/verknuepft/zusammengefuehrt je Kontakt) per Action()-Helfer.
- Beide Sync-Pfade (Auto/Tray via RunSync UND manueller Sync via
  SyncProgressForm) schreiben Start, Ergebnis, Aenderungen, Konflikte und Fehler
  ins persistente Protokoll.

Benachrichtigungen:
- UserSettings: NotificationsEnabled (allgemein) + NotifyWarningsErrors
  (Konflikte/Fehler), beide in der Einstellungen-Maske als Haken.
- MainForm.Balloon() zeigt Tray-Meldungen nur, wenn der passende Haken aktiv
  ist; Zusammenfassung gilt als Warnung, wenn Fehler/Konflikte auftraten.
- Protokoll wird unabhaengig von den Benachrichtigungs-Einstellungen geschrieben.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-08 13:35:55 +02:00
co-authored by Claude Opus 4.8
parent 96c34e542f
commit 75c0c1126e
7 changed files with 113 additions and 35 deletions
+24 -17
View File
@@ -15,6 +15,13 @@ namespace StarfaceOutlookSync.Services
private void Log(string message) => OnProgress?.Invoke(message);
/// <summary>Protokolliert eine tatsaechliche Aenderung (fuer Live-Log UND SyncResult.Changes).</summary>
private void Action(SyncResult result, string message)
{
Log(" " + message);
result?.Changes.Add(message);
}
/// <summary>
/// Setzt die Baseline eines Mappings auf den uebergebenen Stand beider
/// Seiten (Snapshot + Hash). Der Snapshot wird fuer das Feld-Merge bei
@@ -184,7 +191,7 @@ namespace StarfaceOutlookSync.Services
if (await starface.DeleteContactAsync(mapping.StarfaceId))
{
result.Updated++;
Log($" Geloescht (OL->SF): {sc.DisplayName}");
Action(result, $"Geloescht (OL->SF): {sc.DisplayName}");
}
continue;
}
@@ -202,7 +209,7 @@ namespace StarfaceOutlookSync.Services
if (await starface.DeleteContactAsync(mapping.StarfaceId))
{
result.Updated++;
Log($" Geloescht (OL->SF): {sc.DisplayName}");
Action(result, $"Geloescht (OL->SF): {sc.DisplayName}");
}
continue;
}
@@ -245,7 +252,7 @@ namespace StarfaceOutlookSync.Services
if (_outlookService.DeleteContact(oc.OutlookEntryId))
{
result.Updated++;
Log($" Geloescht (SF->OL): {oc.DisplayName}");
Action(result, $"Geloescht (SF->OL): {oc.DisplayName}");
}
continue;
}
@@ -263,7 +270,7 @@ namespace StarfaceOutlookSync.Services
if (_outlookService.DeleteContact(oc.OutlookEntryId))
{
result.Updated++;
Log($" Geloescht (SF->OL): {oc.DisplayName}");
Action(result, $"Geloescht (SF->OL): {oc.DisplayName}");
}
continue;
}
@@ -322,7 +329,7 @@ namespace StarfaceOutlookSync.Services
{
SetBaseline(mapping, oc, updated);
result.Updated++;
Log($" Aktualisiert (OL->SF): {oc.DisplayName}");
Action(result, $"Aktualisiert (OL->SF): {oc.DisplayName}");
}
}
else if (sfChanged && !olChanged && (profile.SyncDirection == SyncDirection.Both || profile.SyncDirection == SyncDirection.StarfaceToOutlook))
@@ -333,7 +340,7 @@ namespace StarfaceOutlookSync.Services
{
SetBaseline(mapping, updated, sc);
result.Updated++;
Log($" Aktualisiert (SF->OL): {sc.DisplayName}");
Action(result, $"Aktualisiert (SF->OL): {sc.DisplayName}");
}
}
else if (olChanged && sfChanged)
@@ -366,9 +373,9 @@ namespace StarfaceOutlookSync.Services
mapping.LastSyncHash = "";
result.Updated++;
foreach (var cf in conflicts) result.Conflicts.Add(cf);
Log(conflicts.Count > 0
? $" Beidseitig geaendert, zusammengefuehrt ({conflicts.Count} Feld-Konflikt(e), Outlook gewinnt): {oc.DisplayName}"
: $" Beidseitig geaendert, zusammengefuehrt: {oc.DisplayName}");
Action(result, conflicts.Count > 0
? $"Beidseitig geaendert, zusammengefuehrt ({conflicts.Count} Feld-Konflikt(e), Outlook gewinnt): {oc.DisplayName}"
: $"Beidseitig geaendert, zusammengefuehrt: {oc.DisplayName}");
}
}
else if (profile.SyncDirection != SyncDirection.StarfaceToOutlook)
@@ -380,7 +387,7 @@ namespace StarfaceOutlookSync.Services
{
SetBaseline(mapping, oc, updated);
result.Updated++;
Log($" Konflikt (OL gewinnt): {oc.DisplayName}");
Action(result, $"Konflikt (OL gewinnt): {oc.DisplayName}");
}
}
else
@@ -390,7 +397,7 @@ namespace StarfaceOutlookSync.Services
{
SetBaseline(mapping, updated, sc);
result.Updated++;
Log($" Konflikt (SF gewinnt): {sc.DisplayName}");
Action(result, $"Konflikt (SF gewinnt): {sc.DisplayName}");
}
}
}
@@ -441,7 +448,7 @@ namespace StarfaceOutlookSync.Services
processedStarfaceIds.Add(match.StarfaceId);
unmappedStarface.Remove(match);
result.Updated++;
Log($" Verknuepft (OL->SF): {oc.DisplayName}");
Action(result, $"Verknuepft (OL->SF): {oc.DisplayName}");
}
}
else
@@ -462,7 +469,7 @@ namespace StarfaceOutlookSync.Services
LastStarfaceHash = created.GetHash()
});
result.Created++;
Log($" Erstellt (OL->SF): {oc.DisplayName}");
Action(result, $"Erstellt (OL->SF): {oc.DisplayName}");
}
else
{
@@ -521,7 +528,7 @@ namespace StarfaceOutlookSync.Services
processedOutlookIds.Add(match.OutlookEntryId);
unmappedOutlook.Remove(match);
result.Updated++;
Log($" Verknuepft (SF->OL): {sc.DisplayName}");
Action(result, $"Verknuepft (SF->OL): {sc.DisplayName}");
}
}
else
@@ -541,7 +548,7 @@ namespace StarfaceOutlookSync.Services
LastOutlookHash = created.GetHash()
});
result.Created++;
Log($" Erstellt (SF->OL): {sc.DisplayName}");
Action(result, $"Erstellt (SF->OL): {sc.DisplayName}");
}
}
}
@@ -581,7 +588,7 @@ namespace StarfaceOutlookSync.Services
if (await starface.DeleteContactAsync(sc.StarfaceId))
{
result.Updated++;
Log($" Geloescht (nur in Starface): {sc.DisplayName}");
Action(result, $"Geloescht (nur in Starface): {sc.DisplayName}");
}
}
catch (Exception ex)
@@ -612,7 +619,7 @@ namespace StarfaceOutlookSync.Services
if (_outlookService.DeleteContact(oc.OutlookEntryId))
{
result.Updated++;
Log($" Geloescht (nur in Outlook): {oc.DisplayName}");
Action(result, $"Geloescht (nur in Outlook): {oc.DisplayName}");
}
}
catch (Exception ex)