Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 96c34e542f | |||
| 23223fe0be | |||
| b8a7fda7bf | |||
| 257b6fb33d | |||
| cf2970a41a | |||
| 5a0203e49e |
@@ -38,6 +38,20 @@ Versionsschema ist `x.x.x.x` (siehe `release.sh`).
|
|||||||
|
|
||||||
### Hinzugefuegt
|
### Hinzugefuegt
|
||||||
|
|
||||||
|
- **Protokoll (Logdatei) + "Protokoll"-Button.** Syncs, Ergebnisse, Konflikte
|
||||||
|
(lokal und von anderen Arbeitsplaetzen) und Fehler werden dauerhaft in
|
||||||
|
`%AppData%\StarfaceOutlookSync\sync.log` festgehalten - so ist auch nach dem
|
||||||
|
Verschwinden einer Tray-Meldung nachvollziehbar, wer/was/wann. Im Hauptfenster
|
||||||
|
oeffnet der Button "Protokoll" einen Betrachter (Aktualisieren/Leeren/Ordner
|
||||||
|
oeffnen). Die Datei rotiert bei 2 MB.
|
||||||
|
- **Clientuebergreifende Konflikt-Hinweise (Mehrplatz).** Wird ein echter
|
||||||
|
Feld-Konflikt aufgeloest, legt der Client eine Notiz im gemeinsamen Verzeichnis
|
||||||
|
(`conflicts/`) ab - zugeordnet nach Kontakt (StarfaceId). Ein anderer
|
||||||
|
Arbeitsplatz zeigt die Meldung beim naechsten Sync nur an, wenn er den Kontakt
|
||||||
|
selbst hat UND sein eigener Feldwert vom uebernommenen Wert abweicht - so wird
|
||||||
|
der ueberschriebene Arbeitsplatz gewarnt, waehrend bereits aktuelle Clients
|
||||||
|
nicht benachrichtigt werden. Bereits gezeigte Notizen merkt sich jeder Client
|
||||||
|
lokal; alte Notizen werden nach 7 Tagen aufgeraeumt.
|
||||||
- **Clientuebergreifende Sync-Sperre (Mehrplatz).** In den Einstellungen laesst
|
- **Clientuebergreifende Sync-Sperre (Mehrplatz).** In den Einstellungen laesst
|
||||||
sich ein gemeinsames Verzeichnis (Netzlaufwerk/UNC) hinterlegen. Synct ein
|
sich ein gemeinsames Verzeichnis (Netzlaufwerk/UNC) hinterlegen. Synct ein
|
||||||
Arbeitsplatz, legt er dort eine Lock-Datei an (atomar via `CreateNew`); andere
|
Arbeitsplatz, legt er dort eine Lock-Datei an (atomar via `CreateNew`); andere
|
||||||
|
|||||||
@@ -260,11 +260,60 @@ StarfaceOutlookSync.exe
|
|||||||
Alle Daten werden lokal pro Benutzer gespeichert:
|
Alle Daten werden lokal pro Benutzer gespeichert:
|
||||||
- `%AppData%\StarfaceOutlookSync\profiles.json` - Sync-Profile mit Zugangsdaten
|
- `%AppData%\StarfaceOutlookSync\profiles.json` - Sync-Profile mit Zugangsdaten
|
||||||
- `%AppData%\StarfaceOutlookSync\mappings\` - Kontakt-Zuordnungen pro Profil
|
- `%AppData%\StarfaceOutlookSync\mappings\` - Kontakt-Zuordnungen pro Profil
|
||||||
|
- `%AppData%\StarfaceOutlookSync\sync.log` - Protokoll (Syncs, Konflikte, Fehler);
|
||||||
|
im Hauptfenster ueber den Button **Protokoll** einsehbar
|
||||||
|
|
||||||
### SSL-Zertifikate
|
### SSL-Zertifikate
|
||||||
|
|
||||||
Self-signed Zertifikate der Starface werden automatisch akzeptiert. Es ist kein manueller Zertifikat-Import erforderlich.
|
Self-signed Zertifikate der Starface werden automatisch akzeptiert. Es ist kein manueller Zertifikat-Import erforderlich.
|
||||||
|
|
||||||
|
### Mehrplatz-Betrieb / Sync-Sperre
|
||||||
|
|
||||||
|
Mehrere Arbeitsplaetze koennen dasselbe Starface-Adressbuch pflegen. Damit sich
|
||||||
|
gleichzeitig laufende Syncs nicht ins Gehege kommen (Dubletten, ueberschriebene
|
||||||
|
Aenderungen), gibt es zwei Schutzebenen:
|
||||||
|
|
||||||
|
**1. Lokal (immer aktiv):** Auf einem PC kann nie mehr als ein Sync gleichzeitig
|
||||||
|
laufen. Startet der Auto-Sync-Timer, waehrend ein manueller Sync laeuft (oder
|
||||||
|
umgekehrt), wird der zweite Lauf uebersprungen. Atomar per `Interlocked`.
|
||||||
|
|
||||||
|
**2. Clientuebergreifend (optional):** In den Einstellungen kann ein
|
||||||
|
**gemeinsames Verzeichnis** (Netzlaufwerk oder UNC-Pfad wie
|
||||||
|
`\\server\freigabe\sync`) hinterlegt werden. Funktionsweise:
|
||||||
|
|
||||||
|
- Beim Start eines Syncs legt der Client dort die Datei **`starface-sync.lock`**
|
||||||
|
an - **atomar** ueber `FileMode.CreateNew`: das Anlegen schlaegt fehl, wenn
|
||||||
|
die Datei bereits existiert. Damit kann immer nur ein Client gleichzeitig die
|
||||||
|
Sperre halten.
|
||||||
|
- Die Datei wird waehrend des gesamten Syncs **offen gehalten** und am Ende
|
||||||
|
wieder **geloescht**. Sie existiert also nur, solange tatsaechlich gerade
|
||||||
|
synchronisiert wird (bei kleinen Adressbuechern nur sehr kurz).
|
||||||
|
- Inhalt der Datei: `Rechnername | Benutzer | UTC-Zeitstempel | Prozess-ID` -
|
||||||
|
damit man sieht, wer gerade synct.
|
||||||
|
- Findet ein anderer Client die Sperre vor, **wartet** er (Abfrage alle 3
|
||||||
|
Sekunden, bis zu 2 Minuten) und synct erst danach. Wird die Sperre nicht frei,
|
||||||
|
wird der Lauf uebersprungen und beim naechsten Intervall erneut versucht.
|
||||||
|
- **Absturzsicher:** Stuerzt ein Client mitten im Sync ab, gibt Windows das
|
||||||
|
Datei-Handle frei. Die verwaiste Lock-Datei gilt nach 15 Minuten als veraltet
|
||||||
|
und wird vom naechsten Client uebernommen. Lebt der Halter noch, scheitert das
|
||||||
|
Loeschen am offenen Handle - die Sperre bleibt also korrekt bestehen.
|
||||||
|
- Ist **kein** Verzeichnis konfiguriert oder es ist nicht erreichbar, laeuft der
|
||||||
|
Sync ohne diese Sperre weiter (die lokale Sperre bleibt aktiv).
|
||||||
|
|
||||||
|
**Konflikt-Hinweise:** Wird im bidirektionalen Modus ein echter Feld-Konflikt
|
||||||
|
aufgeloest (dasselbe Feld auf beiden Seiten unterschiedlich geaendert, Outlook
|
||||||
|
gewinnt), legt der Client eine Notiz im Unterordner `conflicts/` des gemeinsamen
|
||||||
|
Verzeichnisses ab - zugeordnet ueber die StarfaceId des Kontakts. Beim naechsten
|
||||||
|
Sync zeigt ein anderer Arbeitsplatz die Meldung als Tray-Hinweis - aber **nur,
|
||||||
|
wenn er den Kontakt selbst hat UND sein eigener Feldwert vom uebernommenen Wert
|
||||||
|
abweicht** (so erfaehrt der ueberschriebene Arbeitsplatz davon, waehrend Clients,
|
||||||
|
die den Wert ohnehin schon haben, nicht benachrichtigt werden). Gezeigte Notizen
|
||||||
|
merkt sich jeder Client lokal, veraltete Notizen werden nach 7 Tagen entfernt.
|
||||||
|
|
||||||
|
> Hinweis: Im Mehrplatz-Betrieb sollte die **bidirektionale** Sync-Richtung
|
||||||
|
> verwendet werden. Die Ein-Richtungs-Modi ("Ersetzen") wuerden die von anderen
|
||||||
|
> Arbeitsplaetzen gepflegten Kontakte loeschen.
|
||||||
|
|
||||||
## Lizenz
|
## Lizenz
|
||||||
|
|
||||||
Proprietaer - Alle Rechte vorbehalten.
|
Proprietaer - Alle Rechte vorbehalten.
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
; Erfordert Inno Setup 6.x (https://jrsoftware.org/isinfo.php)
|
; Erfordert Inno Setup 6.x (https://jrsoftware.org/isinfo.php)
|
||||||
|
|
||||||
#define MyAppName "Starface Outlook Sync"
|
#define MyAppName "Starface Outlook Sync"
|
||||||
#define MyAppVersion "0.0.0.27"
|
#define MyAppVersion "0.0.0.29"
|
||||||
#define MyAppPublisher "HackerSoft - Hacker-Net Telekommunikation"
|
#define MyAppPublisher "HackerSoft - Hacker-Net Telekommunikation"
|
||||||
#define MyAppURL "https://www.hacker-net.de"
|
#define MyAppURL "https://www.hacker-net.de"
|
||||||
#define MyAppExeName "StarfaceOutlookSync.exe"
|
#define MyAppExeName "StarfaceOutlookSync.exe"
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
namespace StarfaceOutlookSync.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Hinweis ueber einen aufgeloesten Feld-Konflikt, der im gemeinsamen
|
||||||
|
/// Verzeichnis abgelegt wird, damit auch andere Arbeitsplaetze (die denselben
|
||||||
|
/// Kontakt pflegen) erfahren, dass ein Wert ueberschrieben wurde.
|
||||||
|
/// </summary>
|
||||||
|
public class ConflictNotice
|
||||||
|
{
|
||||||
|
public string Id { get; set; } = "";
|
||||||
|
public string ByHost { get; set; } = "";
|
||||||
|
public string ByUser { get; set; } = "";
|
||||||
|
public string TimestampUtc { get; set; } = "";
|
||||||
|
public string StarfaceId { get; set; } = "";
|
||||||
|
public string ContactName { get; set; } = "";
|
||||||
|
public string Field { get; set; } = "";
|
||||||
|
public string FieldKey { get; set; } = "";
|
||||||
|
public string OutlookValue { get; set; } = "";
|
||||||
|
public string StarfaceValue { get; set; } = "";
|
||||||
|
public string Winner { get; set; } = "";
|
||||||
|
|
||||||
|
public override string ToString() =>
|
||||||
|
$"{ContactName}: Feld '{Field}' geaendert an Arbeitsplatz {ByHost} " +
|
||||||
|
$"(Outlook: '{OutlookValue}' / Starface: '{StarfaceValue}') -> {Winner} uebernommen";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,7 +82,8 @@ namespace StarfaceOutlookSync.Models
|
|||||||
{
|
{
|
||||||
public string StarfaceId { get; set; } = "";
|
public string StarfaceId { get; set; } = "";
|
||||||
public string ContactName { get; set; } = "";
|
public string ContactName { get; set; } = "";
|
||||||
public string Field { get; set; } = "";
|
public string Field { get; set; } = ""; // Anzeige-Label, z.B. "E-Mail"
|
||||||
|
public string FieldKey { get; set; } = ""; // stabiler Schluessel, z.B. "Email"
|
||||||
public string OutlookValue { get; set; } = "";
|
public string OutlookValue { get; set; } = "";
|
||||||
public string StarfaceValue { get; set; } = "";
|
public string StarfaceValue { get; set; } = "";
|
||||||
public string Winner { get; set; } = ""; // "Outlook" oder "Starface"
|
public string Winner { get; set; } = ""; // "Outlook" oder "Starface"
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using StarfaceOutlookSync.Models;
|
||||||
|
|
||||||
|
namespace StarfaceOutlookSync.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Verteilt Konflikt-Hinweise ueber das gemeinsame Verzeichnis an alle
|
||||||
|
/// Arbeitsplaetze. Wer einen echten Feld-Konflikt aufloest, legt eine Notiz
|
||||||
|
/// ab; andere Clients zeigen beim naechsten Sync die Notizen zu Kontakten,
|
||||||
|
/// die sie selbst gemappt haben (per StarfaceId). Bereits gezeigte Notizen
|
||||||
|
/// merkt sich jeder Client lokal, damit sie nicht doppelt erscheinen.
|
||||||
|
/// </summary>
|
||||||
|
public class ConflictNotifier
|
||||||
|
{
|
||||||
|
private static readonly TimeSpan Ttl = TimeSpan.FromDays(7);
|
||||||
|
|
||||||
|
private readonly string _seenFile;
|
||||||
|
|
||||||
|
public ConflictNotifier()
|
||||||
|
{
|
||||||
|
var dir = Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
|
"StarfaceOutlookSync");
|
||||||
|
try { Directory.CreateDirectory(dir); } catch { }
|
||||||
|
_seenFile = Path.Combine(dir, "seen-conflicts.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ConflictsDir(string sharedDir) => Path.Combine(sharedDir, "conflicts");
|
||||||
|
|
||||||
|
/// <summary>Legt fuer jeden Konflikt eine Notiz im gemeinsamen Verzeichnis ab.</summary>
|
||||||
|
public void Write(string sharedDir, IEnumerable<FieldConflict> conflicts)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(sharedDir)) return;
|
||||||
|
var list = conflicts?.ToList();
|
||||||
|
if (list == null || list.Count == 0) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dir = ConflictsDir(sharedDir);
|
||||||
|
Directory.CreateDirectory(dir);
|
||||||
|
var host = Environment.MachineName;
|
||||||
|
var user = Environment.UserName;
|
||||||
|
var ts = DateTime.UtcNow.ToString("o");
|
||||||
|
|
||||||
|
foreach (var c in list)
|
||||||
|
{
|
||||||
|
var notice = new ConflictNotice
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid().ToString("N"),
|
||||||
|
ByHost = host,
|
||||||
|
ByUser = user,
|
||||||
|
TimestampUtc = ts,
|
||||||
|
StarfaceId = c.StarfaceId,
|
||||||
|
ContactName = c.ContactName,
|
||||||
|
Field = c.Field,
|
||||||
|
FieldKey = c.FieldKey,
|
||||||
|
OutlookValue = c.OutlookValue,
|
||||||
|
StarfaceValue = c.StarfaceValue,
|
||||||
|
Winner = c.Winner
|
||||||
|
};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.WriteAllText(Path.Combine(dir, notice.Id + ".json"),
|
||||||
|
JsonConvert.SerializeObject(notice, Formatting.Indented));
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Liefert ungesehene Konflikt-Notizen, die Kontakte dieses Clients
|
||||||
|
/// betreffen und nicht von ihm selbst stammen. Es werden nur die Notizen
|
||||||
|
/// zurueckgegeben, bei denen der EIGENE aktuelle Feldwert vom uebernommenen
|
||||||
|
/// (Gewinner-)Wert abweicht - wer den Wert ohnehin schon hat, wird nicht
|
||||||
|
/// benachrichtigt. myContacts bildet StarfaceId -> eigener Kontaktstand ab.
|
||||||
|
/// Markiert verarbeitete Notizen als gesehen und raeumt veraltete auf.
|
||||||
|
/// </summary>
|
||||||
|
public List<ConflictNotice> GetPending(string sharedDir, IDictionary<string, UnifiedContact> myContacts)
|
||||||
|
{
|
||||||
|
var result = new List<ConflictNotice>();
|
||||||
|
if (string.IsNullOrWhiteSpace(sharedDir)) return result;
|
||||||
|
|
||||||
|
var dir = ConflictsDir(sharedDir);
|
||||||
|
string[] files;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(dir)) return result;
|
||||||
|
files = Directory.GetFiles(dir, "*.json");
|
||||||
|
}
|
||||||
|
catch { return result; }
|
||||||
|
|
||||||
|
var seen = LoadSeen();
|
||||||
|
var host = Environment.MachineName;
|
||||||
|
var existingIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
foreach (var f in files)
|
||||||
|
{
|
||||||
|
ConflictNotice n = null;
|
||||||
|
try { n = JsonConvert.DeserializeObject<ConflictNotice>(File.ReadAllText(f)); }
|
||||||
|
catch { }
|
||||||
|
if (n == null || string.IsNullOrEmpty(n.Id)) continue;
|
||||||
|
|
||||||
|
// Veraltete Notizen entfernen.
|
||||||
|
if (DateTime.TryParse(n.TimestampUtc, out var ts)
|
||||||
|
&& DateTime.UtcNow - ts.ToUniversalTime() > Ttl)
|
||||||
|
{
|
||||||
|
try { File.Delete(f); } catch { }
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
existingIds.Add(n.Id);
|
||||||
|
|
||||||
|
if (seen.Contains(n.Id)) continue; // schon gezeigt
|
||||||
|
if (string.Equals(n.ByHost, host, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
seen.Add(n.Id); // selbst erzeugt -> nicht erneut anzeigen
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Habe ich diesen Kontakt ueberhaupt?
|
||||||
|
UnifiedContact mine = null;
|
||||||
|
bool haveContact = !string.IsNullOrEmpty(n.StarfaceId)
|
||||||
|
&& myContacts != null
|
||||||
|
&& myContacts.TryGetValue(n.StarfaceId, out mine);
|
||||||
|
if (!haveContact)
|
||||||
|
continue; // betrifft mich nicht (kein seen -> evtl. spaeter relevant)
|
||||||
|
|
||||||
|
// Bin ich wirklich betroffen? Nur wenn mein aktueller Feldwert vom
|
||||||
|
// uebernommenen Wert abweicht. Wer den Gewinner-Wert schon hat, wird
|
||||||
|
// nicht benachrichtigt.
|
||||||
|
if (mine != null && !string.IsNullOrEmpty(n.FieldKey))
|
||||||
|
{
|
||||||
|
var winnerValue = string.Equals(n.Winner, "Outlook", StringComparison.OrdinalIgnoreCase)
|
||||||
|
? n.OutlookValue : n.StarfaceValue;
|
||||||
|
var myValue = ContactMerger.GetValue(mine, n.FieldKey);
|
||||||
|
if (ContactMerger.ValuesEqual(n.FieldKey, myValue, winnerValue))
|
||||||
|
{
|
||||||
|
seen.Add(n.Id); // nicht betroffen -> als erledigt merken
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Add(n);
|
||||||
|
seen.Add(n.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gesehen-Liste auf noch vorhandene Notizen eindampfen.
|
||||||
|
seen.IntersectWith(existingIds);
|
||||||
|
SaveSeen(seen);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashSet<string> LoadSeen()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(_seenFile))
|
||||||
|
return new HashSet<string>(
|
||||||
|
JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(_seenFile)) ?? new List<string>(),
|
||||||
|
StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
return new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveSeen(HashSet<string> seen)
|
||||||
|
{
|
||||||
|
try { File.WriteAllText(_seenFile, JsonConvert.SerializeObject(seen.ToList())); }
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ namespace StarfaceOutlookSync.Services
|
|||||||
{
|
{
|
||||||
private class FieldDef
|
private class FieldDef
|
||||||
{
|
{
|
||||||
|
public string Key;
|
||||||
public string Label;
|
public string Label;
|
||||||
public Func<UnifiedContact, string> Get;
|
public Func<UnifiedContact, string> Get;
|
||||||
public Action<UnifiedContact, string> Set;
|
public Action<UnifiedContact, string> Set;
|
||||||
@@ -23,28 +24,43 @@ namespace StarfaceOutlookSync.Services
|
|||||||
|
|
||||||
private static readonly FieldDef[] Fields = new[]
|
private static readonly FieldDef[] Fields = new[]
|
||||||
{
|
{
|
||||||
new FieldDef { Label = "Vorname", Get = c => c.FirstName, Set = (c, v) => c.FirstName = v },
|
new FieldDef { Key = "FirstName", Label = "Vorname", Get = c => c.FirstName, Set = (c, v) => c.FirstName = v },
|
||||||
new FieldDef { Label = "Nachname", Get = c => c.LastName, Set = (c, v) => c.LastName = v },
|
new FieldDef { Key = "LastName", Label = "Nachname", Get = c => c.LastName, Set = (c, v) => c.LastName = v },
|
||||||
new FieldDef { Label = "Firma", Get = c => c.Company, Set = (c, v) => c.Company = v },
|
new FieldDef { Key = "Company", Label = "Firma", Get = c => c.Company, Set = (c, v) => c.Company = v },
|
||||||
new FieldDef { Label = "Position", Get = c => c.JobTitle, Set = (c, v) => c.JobTitle = v },
|
new FieldDef { Key = "JobTitle", Label = "Position", Get = c => c.JobTitle, Set = (c, v) => c.JobTitle = v },
|
||||||
new FieldDef { Label = "E-Mail", Get = c => c.Email, Set = (c, v) => c.Email = v },
|
new FieldDef { Key = "Email", Label = "E-Mail", Get = c => c.Email, Set = (c, v) => c.Email = v },
|
||||||
new FieldDef { Label = "E-Mail 2", Get = c => c.EmailSecondary, Set = (c, v) => c.EmailSecondary = v },
|
new FieldDef { Key = "EmailSecondary", Label = "E-Mail 2", Get = c => c.EmailSecondary, Set = (c, v) => c.EmailSecondary = v },
|
||||||
new FieldDef { Label = "Telefon", Get = c => c.PhoneWork, Set = (c, v) => c.PhoneWork = v, IsPhone = true },
|
new FieldDef { Key = "PhoneWork", Label = "Telefon", Get = c => c.PhoneWork, Set = (c, v) => c.PhoneWork = v, IsPhone = true },
|
||||||
new FieldDef { Label = "Mobil", Get = c => c.PhoneMobile, Set = (c, v) => c.PhoneMobile = v, IsPhone = true },
|
new FieldDef { Key = "PhoneMobile", Label = "Mobil", Get = c => c.PhoneMobile, Set = (c, v) => c.PhoneMobile = v, IsPhone = true },
|
||||||
new FieldDef { Label = "Telefon privat", Get = c => c.PhoneHome, Set = (c, v) => c.PhoneHome = v, IsPhone = true },
|
new FieldDef { Key = "PhoneHome", Label = "Telefon privat", Get = c => c.PhoneHome, Set = (c, v) => c.PhoneHome = v, IsPhone = true },
|
||||||
new FieldDef { Label = "Fax", Get = c => c.Fax, Set = (c, v) => c.Fax = v, IsPhone = true },
|
new FieldDef { Key = "Fax", Label = "Fax", Get = c => c.Fax, Set = (c, v) => c.Fax = v, IsPhone = true },
|
||||||
new FieldDef { Label = "Strasse", Get = c => c.Street, Set = (c, v) => c.Street = v },
|
new FieldDef { Key = "Street", Label = "Strasse", Get = c => c.Street, Set = (c, v) => c.Street = v },
|
||||||
new FieldDef { Label = "Ort", Get = c => c.City, Set = (c, v) => c.City = v },
|
new FieldDef { Key = "City", Label = "Ort", Get = c => c.City, Set = (c, v) => c.City = v },
|
||||||
new FieldDef { Label = "PLZ", Get = c => c.PostalCode, Set = (c, v) => c.PostalCode = v },
|
new FieldDef { Key = "PostalCode", Label = "PLZ", Get = c => c.PostalCode, Set = (c, v) => c.PostalCode = v },
|
||||||
new FieldDef { Label = "Bundesland", Get = c => c.State, Set = (c, v) => c.State = v },
|
new FieldDef { Key = "State", Label = "Bundesland", Get = c => c.State, Set = (c, v) => c.State = v },
|
||||||
new FieldDef { Label = "Land", Get = c => c.Country, Set = (c, v) => c.Country = v },
|
new FieldDef { Key = "Country", Label = "Land", Get = c => c.Country, Set = (c, v) => c.Country = v },
|
||||||
new FieldDef { Label = "Webseite", Get = c => c.Website, Set = (c, v) => c.Website = v },
|
new FieldDef { Key = "Website", Label = "Webseite", Get = c => c.Website, Set = (c, v) => c.Website = v },
|
||||||
new FieldDef { Label = "Notizen", Get = c => c.Notes, Set = (c, v) => c.Notes = v },
|
new FieldDef { Key = "Notes", Label = "Notizen", Get = c => c.Notes, Set = (c, v) => c.Notes = v },
|
||||||
new FieldDef { Label = "Anrede", Get = c => c.Salutation, Set = (c, v) => c.Salutation = v },
|
new FieldDef { Key = "Salutation", Label = "Anrede", Get = c => c.Salutation, Set = (c, v) => c.Salutation = v },
|
||||||
new FieldDef { Label = "Titel", Get = c => c.Title, Set = (c, v) => c.Title = v },
|
new FieldDef { Key = "Title", Label = "Titel", Get = c => c.Title, Set = (c, v) => c.Title = v },
|
||||||
new FieldDef { Label = "Geburtstag", Get = c => c.Birthday, Set = (c, v) => c.Birthday = v },
|
new FieldDef { Key = "Birthday", Label = "Geburtstag", Get = c => c.Birthday, Set = (c, v) => c.Birthday = v },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>Liest den Wert eines Feldes per stabilem Schluessel.</summary>
|
||||||
|
public static string GetValue(UnifiedContact c, string key)
|
||||||
|
{
|
||||||
|
if (c == null || string.IsNullOrEmpty(key)) return "";
|
||||||
|
var f = Fields.FirstOrDefault(x => x.Key == key);
|
||||||
|
return f == null ? "" : (f.Get(c) ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Vergleicht zwei Feldwerte (telefon-normalisiert je nach Feld).</summary>
|
||||||
|
public static bool ValuesEqual(string key, string a, string b)
|
||||||
|
{
|
||||||
|
var f = Fields.FirstOrDefault(x => x.Key == key);
|
||||||
|
return Equal(a ?? "", b ?? "", f?.IsPhone ?? false);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fuehrt den Outlook- und Starface-Stand gegen ihre jeweilige Baseline
|
/// Fuehrt den Outlook- und Starface-Stand gegen ihre jeweilige Baseline
|
||||||
/// zusammen. outlookWins entscheidet bei echten Feld-Konflikten.
|
/// zusammen. outlookWins entscheidet bei echten Feld-Konflikten.
|
||||||
@@ -95,6 +111,7 @@ namespace StarfaceOutlookSync.Services
|
|||||||
StarfaceId = starface.StarfaceId,
|
StarfaceId = starface.StarfaceId,
|
||||||
ContactName = outlook.DisplayName,
|
ContactName = outlook.DisplayName,
|
||||||
Field = f.Label,
|
Field = f.Label,
|
||||||
|
FieldKey = f.Key,
|
||||||
OutlookValue = olv,
|
OutlookValue = olv,
|
||||||
StarfaceValue = sfv,
|
StarfaceValue = sfv,
|
||||||
Winner = outlookWins ? "Outlook" : "Starface"
|
Winner = outlookWins ? "Outlook" : "Starface"
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace StarfaceOutlookSync.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Einfaches, threadsicheres Datei-Protokoll. Haelt fest, was bei Syncs
|
||||||
|
/// passiert (Ergebnisse, Konflikte, Fehler) - dauerhaft nachlesbar, auch
|
||||||
|
/// nachdem eine Tray-Meldung verschwunden ist.
|
||||||
|
/// </summary>
|
||||||
|
public static class Logger
|
||||||
|
{
|
||||||
|
private static readonly object _lock = new object();
|
||||||
|
private const long MaxBytes = 2 * 1024 * 1024; // 2 MB, dann Rotation
|
||||||
|
|
||||||
|
public static string LogFilePath { get; } = Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
|
"StarfaceOutlookSync", "sync.log");
|
||||||
|
|
||||||
|
public static void Log(string message)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(LogFilePath));
|
||||||
|
Rotate();
|
||||||
|
var line = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}{Environment.NewLine}";
|
||||||
|
File.AppendAllText(LogFilePath, line, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Rotate()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(LogFilePath);
|
||||||
|
if (fi.Exists && fi.Length > MaxBytes)
|
||||||
|
{
|
||||||
|
var bak = LogFilePath + ".1";
|
||||||
|
if (File.Exists(bak)) File.Delete(bak);
|
||||||
|
File.Move(LogFilePath, bak);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ReadAll()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
if (!File.Exists(LogFilePath)) return "";
|
||||||
|
using (var fs = new FileStream(LogFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
|
using (var sr = new StreamReader(fs, Encoding.UTF8))
|
||||||
|
return sr.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { return ""; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Clear()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
if (File.Exists(LogFilePath)) File.Delete(LogFilePath);
|
||||||
|
var bak = LogFilePath + ".1";
|
||||||
|
if (File.Exists(bak)) File.Delete(bak);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
<AssemblyTitle>Starface Outlook Sync</AssemblyTitle>
|
<AssemblyTitle>Starface Outlook Sync</AssemblyTitle>
|
||||||
<Company>HackerSoft - Hacker-Net Telekommunikation</Company>
|
<Company>HackerSoft - Hacker-Net Telekommunikation</Company>
|
||||||
<Product>Starface Outlook Sync</Product>
|
<Product>Starface Outlook Sync</Product>
|
||||||
<Version>0.0.0.27</Version>
|
<Version>0.0.0.29</Version>
|
||||||
<AssemblyVersion>0.0.0.27</AssemblyVersion>
|
<AssemblyVersion>0.0.0.29</AssemblyVersion>
|
||||||
<FileVersion>0.0.0.27</FileVersion>
|
<FileVersion>0.0.0.29</FileVersion>
|
||||||
<Description>Synchronisiert Outlook-Kontakte mit Starface Telefonanlage</Description>
|
<Description>Synchronisiert Outlook-Kontakte mit Starface Telefonanlage</Description>
|
||||||
<Copyright>Stefan Hacker - HackerSoft</Copyright>
|
<Copyright>Stefan Hacker - HackerSoft</Copyright>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace StarfaceOutlookSync.UI
|
|||||||
|
|
||||||
var lblVersion = new Label
|
var lblVersion = new Label
|
||||||
{
|
{
|
||||||
Text = "Version 0.0.0.27",
|
Text = "Version 0.0.0.29",
|
||||||
Left = 0, Top = 56, Width = 340, Height = 20,
|
Left = 0, Top = 56, Width = 340, Height = 20,
|
||||||
TextAlign = ContentAlignment.MiddleCenter,
|
TextAlign = ContentAlignment.MiddleCenter,
|
||||||
ForeColor = Color.Gray
|
ForeColor = Color.Gray
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using StarfaceOutlookSync.Services;
|
||||||
|
|
||||||
|
namespace StarfaceOutlookSync.UI
|
||||||
|
{
|
||||||
|
/// <summary>Zeigt das Sync-Protokoll an (read-only) mit Aktualisieren/Leeren.</summary>
|
||||||
|
public class LogViewerForm : Form
|
||||||
|
{
|
||||||
|
private TextBox _txt;
|
||||||
|
private Button _btnClose;
|
||||||
|
private Panel _panel;
|
||||||
|
|
||||||
|
public LogViewerForm()
|
||||||
|
{
|
||||||
|
Text = "Protokoll";
|
||||||
|
Size = new Size(720, 500);
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Font = new Font("Segoe UI", 9);
|
||||||
|
|
||||||
|
_txt = new TextBox
|
||||||
|
{
|
||||||
|
Multiline = true,
|
||||||
|
ReadOnly = true,
|
||||||
|
ScrollBars = ScrollBars.Both,
|
||||||
|
WordWrap = false,
|
||||||
|
Dock = DockStyle.Fill,
|
||||||
|
BackColor = Color.White,
|
||||||
|
Font = new Font("Consolas", 9)
|
||||||
|
};
|
||||||
|
|
||||||
|
_panel = new Panel { Dock = DockStyle.Bottom, Height = 44 };
|
||||||
|
|
||||||
|
var btnRefresh = new Button { Text = "Aktualisieren", Left = 10, Top = 8, Width = 100, Height = 28 };
|
||||||
|
btnRefresh.Click += (s, e) => LoadLog();
|
||||||
|
|
||||||
|
var btnClear = new Button { Text = "Leeren", Left = 118, Top = 8, Width = 80, Height = 28 };
|
||||||
|
btnClear.Click += (s, e) =>
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Protokoll wirklich leeren?", "Protokoll",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
Logger.Clear();
|
||||||
|
LoadLog();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var btnFolder = new Button { Text = "Ordner oeffnen", Left = 206, Top = 8, Width = 120, Height = 28 };
|
||||||
|
btnFolder.Click += (s, e) => OpenFolder();
|
||||||
|
|
||||||
|
_btnClose = new Button
|
||||||
|
{
|
||||||
|
Text = "Schliessen", Top = 8, Width = 100, Height = 28,
|
||||||
|
Anchor = AnchorStyles.Top | AnchorStyles.Right
|
||||||
|
};
|
||||||
|
_btnClose.Click += (s, e) => Close();
|
||||||
|
|
||||||
|
_panel.Controls.AddRange(new Control[] { btnRefresh, btnClear, btnFolder, _btnClose });
|
||||||
|
|
||||||
|
Controls.Add(_txt);
|
||||||
|
Controls.Add(_panel);
|
||||||
|
|
||||||
|
Load += (s, e) =>
|
||||||
|
{
|
||||||
|
_btnClose.Left = _panel.ClientSize.Width - _btnClose.Width - 10;
|
||||||
|
LoadLog();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadLog()
|
||||||
|
{
|
||||||
|
_txt.Text = Logger.ReadAll();
|
||||||
|
_txt.SelectionStart = _txt.TextLength;
|
||||||
|
_txt.ScrollToCaret();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenFolder()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dir = Path.GetDirectoryName(Logger.LogFilePath);
|
||||||
|
Process.Start(new ProcessStartInfo { FileName = dir, UseShellExecute = true });
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,10 +16,11 @@ namespace StarfaceOutlookSync.UI
|
|||||||
{
|
{
|
||||||
private readonly ProfileManager _profileManager = new ProfileManager();
|
private readonly ProfileManager _profileManager = new ProfileManager();
|
||||||
private readonly SyncEngine _syncEngine = new SyncEngine();
|
private readonly SyncEngine _syncEngine = new SyncEngine();
|
||||||
|
private readonly ConflictNotifier _conflictNotifier = new ConflictNotifier();
|
||||||
private NotifyIcon _trayIcon;
|
private NotifyIcon _trayIcon;
|
||||||
private ContextMenuStrip _trayMenu;
|
private ContextMenuStrip _trayMenu;
|
||||||
private ListView _profileList;
|
private ListView _profileList;
|
||||||
private Button _btnNew, _btnEdit, _btnDelete, _btnSync, _btnReset, _btnSettings, _btnInfo;
|
private Button _btnNew, _btnEdit, _btnDelete, _btnSync, _btnReset, _btnSettings, _btnLog, _btnInfo;
|
||||||
private StatusStrip _statusBar;
|
private StatusStrip _statusBar;
|
||||||
private ToolStripStatusLabel _statusLabel;
|
private ToolStripStatusLabel _statusLabel;
|
||||||
private Timer _autoSyncTimer;
|
private Timer _autoSyncTimer;
|
||||||
@@ -128,10 +129,13 @@ namespace StarfaceOutlookSync.UI
|
|||||||
_btnSettings = new Button { Text = "Einstellungen", Width = 95, Height = 30 };
|
_btnSettings = new Button { Text = "Einstellungen", Width = 95, Height = 30 };
|
||||||
_btnSettings.Click += (s, e) => ShowSettings();
|
_btnSettings.Click += (s, e) => ShowSettings();
|
||||||
|
|
||||||
|
_btnLog = new Button { Text = "Protokoll", Width = 80, Height = 30 };
|
||||||
|
_btnLog.Click += (s, e) => ShowLog();
|
||||||
|
|
||||||
_btnInfo = new Button { Text = "Info", Width = 50, Height = 30 };
|
_btnInfo = new Button { Text = "Info", Width = 50, Height = 30 };
|
||||||
_btnInfo.Click += (s, e) => ShowAbout();
|
_btnInfo.Click += (s, e) => ShowAbout();
|
||||||
|
|
||||||
buttonPanel.Controls.AddRange(new Control[] { _btnNew, _btnEdit, _btnDelete, _btnSync, _btnReset, _btnSettings, _btnInfo });
|
buttonPanel.Controls.AddRange(new Control[] { _btnNew, _btnEdit, _btnDelete, _btnSync, _btnReset, _btnSettings, _btnLog, _btnInfo });
|
||||||
|
|
||||||
// Statusbar
|
// Statusbar
|
||||||
_statusBar = new StatusStrip();
|
_statusBar = new StatusStrip();
|
||||||
@@ -349,16 +353,25 @@ namespace StarfaceOutlookSync.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
SyncLock crossLock = null;
|
SyncLock crossLock = null;
|
||||||
|
var sharedDir = UserSettings.Load().SharedDirectory;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Clientuebergreifende Sperre (falls gemeinsames Verzeichnis konfiguriert).
|
// Clientuebergreifende Sperre (falls gemeinsames Verzeichnis konfiguriert).
|
||||||
crossLock = await AcquireCrossClientLock();
|
crossLock = await AcquireCrossClientLock(sharedDir);
|
||||||
if (crossLock == null)
|
if (crossLock == null)
|
||||||
{
|
{
|
||||||
SetStatus("Anderer Arbeitsplatz synchronisiert gerade - uebersprungen.");
|
SetStatus("Anderer Arbeitsplatz synchronisiert gerade - uebersprungen.");
|
||||||
|
Logger.Log($"Sync '{profile.Name}' uebersprungen: anderer Arbeitsplatz synct gerade.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Log($"Sync gestartet: '{profile.Name}' (Richtung: {profile.SyncDirection})");
|
||||||
|
|
||||||
|
// Konflikt-Hinweise von ANDEREN Arbeitsplaetzen anzeigen, BEVOR der
|
||||||
|
// Sync den eigenen Stand auf den Gewinner-Wert aktualisiert (sonst
|
||||||
|
// koennte man nicht mehr erkennen, ob man betroffen war).
|
||||||
|
ShowRemoteConflictNotices(sharedDir);
|
||||||
|
|
||||||
SetStatus($"Synchronisiere '{profile.Name}'...");
|
SetStatus($"Synchronisiere '{profile.Name}'...");
|
||||||
_trayIcon.ShowBalloonTip(2000, "Starface Sync",
|
_trayIcon.ShowBalloonTip(2000, "Starface Sync",
|
||||||
$"Synchronisiere '{profile.Name}'...", ToolTipIcon.Info);
|
$"Synchronisiere '{profile.Name}'...", ToolTipIcon.Info);
|
||||||
@@ -372,6 +385,10 @@ namespace StarfaceOutlookSync.UI
|
|||||||
_trayIcon.ShowBalloonTip(3000, "Starface Sync", msg,
|
_trayIcon.ShowBalloonTip(3000, "Starface Sync", msg,
|
||||||
result.Errors > 0 ? ToolTipIcon.Warning : ToolTipIcon.Info);
|
result.Errors > 0 ? ToolTipIcon.Warning : ToolTipIcon.Info);
|
||||||
|
|
||||||
|
Logger.Log($"Sync fertig: {msg}");
|
||||||
|
foreach (var em in result.ErrorMessages)
|
||||||
|
Logger.Log($" Fehler: {em}");
|
||||||
|
|
||||||
// Echte Feld-Konflikte gesondert melden, damit der Benutzer weiss,
|
// Echte Feld-Konflikte gesondert melden, damit der Benutzer weiss,
|
||||||
// dass ein Wert ueberschrieben wurde.
|
// dass ein Wert ueberschrieben wurde.
|
||||||
if (result.Conflicts.Count > 0)
|
if (result.Conflicts.Count > 0)
|
||||||
@@ -381,6 +398,12 @@ namespace StarfaceOutlookSync.UI
|
|||||||
detail += $"\n... und {result.Conflicts.Count - 5} weitere";
|
detail += $"\n... und {result.Conflicts.Count - 5} weitere";
|
||||||
_trayIcon.ShowBalloonTip(10000,
|
_trayIcon.ShowBalloonTip(10000,
|
||||||
$"Konflikt bei {result.Conflicts.Count} Kontakt(en)", detail, ToolTipIcon.Warning);
|
$"Konflikt bei {result.Conflicts.Count} Kontakt(en)", detail, ToolTipIcon.Warning);
|
||||||
|
|
||||||
|
foreach (var c in result.Conflicts)
|
||||||
|
Logger.Log($" KONFLIKT: {c}");
|
||||||
|
|
||||||
|
// Andere Arbeitsplaetze ueber das gemeinsame Verzeichnis informieren.
|
||||||
|
_conflictNotifier.Write(sharedDir, result.Conflicts);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStatus(msg);
|
SetStatus(msg);
|
||||||
@@ -390,6 +413,7 @@ namespace StarfaceOutlookSync.UI
|
|||||||
_trayIcon.ShowBalloonTip(3000, "Starface Sync Fehler",
|
_trayIcon.ShowBalloonTip(3000, "Starface Sync Fehler",
|
||||||
ex.Message, ToolTipIcon.Error);
|
ex.Message, ToolTipIcon.Error);
|
||||||
SetStatus($"Fehler: {ex.Message}");
|
SetStatus($"Fehler: {ex.Message}");
|
||||||
|
Logger.Log($"Sync FEHLER '{profile.Name}': {ex.Message}");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -406,9 +430,8 @@ namespace StarfaceOutlookSync.UI
|
|||||||
/// Ist kein Verzeichnis konfiguriert oder es ist nicht erreichbar, wird
|
/// Ist kein Verzeichnis konfiguriert oder es ist nicht erreichbar, wird
|
||||||
/// ohne clientuebergreifende Sperre fortgefahren (lokaler Schutz bleibt).
|
/// ohne clientuebergreifende Sperre fortgefahren (lokaler Schutz bleibt).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task<SyncLock> AcquireCrossClientLock()
|
private async Task<SyncLock> AcquireCrossClientLock(string dir)
|
||||||
{
|
{
|
||||||
var dir = UserSettings.Load().SharedDirectory;
|
|
||||||
if (string.IsNullOrWhiteSpace(dir))
|
if (string.IsNullOrWhiteSpace(dir))
|
||||||
return SyncLock.NoOp();
|
return SyncLock.NoOp();
|
||||||
|
|
||||||
@@ -439,6 +462,50 @@ namespace StarfaceOutlookSync.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Zeigt Konflikt-Hinweise an, die andere Arbeitsplaetze ueber das
|
||||||
|
/// gemeinsame Verzeichnis hinterlassen haben und Kontakte betreffen, die
|
||||||
|
/// auch dieser Client gemappt hat.
|
||||||
|
/// </summary>
|
||||||
|
private void ShowRemoteConflictNotices(string sharedDir)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(sharedDir)) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pending = _conflictNotifier.GetPending(sharedDir, MyContactsByStarfaceId());
|
||||||
|
if (pending.Count == 0) return;
|
||||||
|
|
||||||
|
foreach (var p in pending)
|
||||||
|
Logger.Log($" KONFLIKT (anderer Arbeitsplatz): {p}");
|
||||||
|
|
||||||
|
var detail = string.Join("\n", pending.Take(5).Select(p => p.ToString()));
|
||||||
|
if (pending.Count > 5)
|
||||||
|
detail += $"\n... und {pending.Count - 5} weitere";
|
||||||
|
_trayIcon.ShowBalloonTip(10000,
|
||||||
|
$"Konflikt an anderem Arbeitsplatz ({pending.Count})", detail, ToolTipIcon.Warning);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Eigener Kontaktstand je StarfaceId (ueber alle Profile), aus den
|
||||||
|
/// Mapping-Snapshots. Dient dazu, bei Konflikt-Notizen zu pruefen, ob der
|
||||||
|
/// eigene Feldwert ueberhaupt vom uebernommenen Wert abweicht.
|
||||||
|
/// </summary>
|
||||||
|
private Dictionary<string, UnifiedContact> MyContactsByStarfaceId()
|
||||||
|
{
|
||||||
|
var map = new Dictionary<string, UnifiedContact>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var p in _profileManager.GetProfiles())
|
||||||
|
foreach (var m in _profileManager.GetMappings(p.Id))
|
||||||
|
if (!string.IsNullOrEmpty(m.StarfaceId) && !map.ContainsKey(m.StarfaceId))
|
||||||
|
map[m.StarfaceId] = m.LastOutlook;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
private void SetStatus(string text)
|
private void SetStatus(string text)
|
||||||
{
|
{
|
||||||
if (InvokeRequired)
|
if (InvokeRequired)
|
||||||
@@ -463,6 +530,14 @@ namespace StarfaceOutlookSync.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShowLog()
|
||||||
|
{
|
||||||
|
using (var log = new LogViewerForm())
|
||||||
|
{
|
||||||
|
log.ShowDialog(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ExitApplication()
|
private void ExitApplication()
|
||||||
{
|
{
|
||||||
_autoSyncTimer?.Stop();
|
_autoSyncTimer?.Stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user