diff --git a/src/StarfaceOutlookSync/Services/SyncEngine.cs b/src/StarfaceOutlookSync/Services/SyncEngine.cs index 94b81a0e..7f49df3d 100644 --- a/src/StarfaceOutlookSync/Services/SyncEngine.cs +++ b/src/StarfaceOutlookSync/Services/SyncEngine.cs @@ -56,9 +56,11 @@ namespace StarfaceOutlookSync.Services // Leere Firma vs. gefuellte Firma = verschiedene Kontakte if (!FieldsCompatible(a.Company, b.Company)) return false; - // Telefon: wenn auf einer Seite vorhanden, muss sie gleich sein + // Telefon/Fax: wenn auf einer Seite vorhanden, muss es gleich sein if (!PhoneFieldsCompatible(a.PhoneWork, b.PhoneWork)) return false; if (!PhoneFieldsCompatible(a.PhoneMobile, b.PhoneMobile)) return false; + if (!PhoneFieldsCompatible(a.PhoneHome, b.PhoneHome)) return false; + if (!PhoneFieldsCompatible(a.Fax, b.Fax)) return false; // Mindestens ein starkes Match muss vorhanden sein bool emailMatch = !string.IsNullOrEmpty(a.Email) && !string.IsNullOrEmpty(b.Email) @@ -67,10 +69,15 @@ namespace StarfaceOutlookSync.Services && a.FirstName.Equals(b.FirstName, StringComparison.OrdinalIgnoreCase) && a.LastName.Equals(b.LastName, StringComparison.OrdinalIgnoreCase) && (!string.IsNullOrEmpty(a.FirstName) || !string.IsNullOrEmpty(a.LastName)); - bool phoneMatch = !string.IsNullOrEmpty(a.PhoneWork) && !string.IsNullOrEmpty(b.PhoneWork) - && NormalizePhone(a.PhoneWork) == NormalizePhone(b.PhoneWork); + bool phoneMatch = (!string.IsNullOrEmpty(a.PhoneWork) && !string.IsNullOrEmpty(b.PhoneWork) + && NormalizePhone(a.PhoneWork) == NormalizePhone(b.PhoneWork)) + || (!string.IsNullOrEmpty(a.Fax) && !string.IsNullOrEmpty(b.Fax) + && NormalizePhone(a.Fax) == NormalizePhone(b.Fax)); + bool companyMatch = !string.IsNullOrEmpty(a.Company) && !string.IsNullOrEmpty(b.Company) + && a.Company.Equals(b.Company, StringComparison.OrdinalIgnoreCase); - return emailMatch || nameMatch || phoneMatch; + // Email oder Name reicht. Telefon/Fax nur mit Firma zusammen. + return emailMatch || nameMatch || (phoneMatch && companyMatch) || (companyMatch && phoneMatch); } ///