Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a19a39b7d2 | |||
| 6349424007 | |||
| 7ffaddc77f | |||
| 9007e2a9b5 |
+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.18"
|
#define MyAppVersion "0.0.0.19"
|
||||||
#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"
|
||||||
|
|||||||
@@ -394,29 +394,40 @@ namespace StarfaceOutlookSync.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string SafeGet(dynamic ci, string property)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
object val = ci.GetType().InvokeMember(property,
|
||||||
|
System.Reflection.BindingFlags.GetProperty, null, ci, null);
|
||||||
|
return val?.ToString() ?? "";
|
||||||
|
}
|
||||||
|
catch { return ""; }
|
||||||
|
}
|
||||||
|
|
||||||
private UnifiedContact MapFromOutlook(dynamic ci)
|
private UnifiedContact MapFromOutlook(dynamic ci)
|
||||||
{
|
{
|
||||||
return new UnifiedContact
|
return new UnifiedContact
|
||||||
{
|
{
|
||||||
OutlookEntryId = (string)(ci.EntryID ?? ""),
|
OutlookEntryId = SafeGet(ci, "EntryID"),
|
||||||
FirstName = (string)(ci.FirstName ?? ""),
|
FirstName = SafeGet(ci, "FirstName"),
|
||||||
LastName = (string)(ci.LastName ?? ""),
|
LastName = SafeGet(ci, "LastName"),
|
||||||
Company = (string)(ci.CompanyName ?? ""),
|
Company = SafeGet(ci, "CompanyName"),
|
||||||
JobTitle = (string)(ci.JobTitle ?? ""),
|
JobTitle = SafeGet(ci, "JobTitle"),
|
||||||
Email = (string)(ci.Email1Address ?? ""),
|
Email = SafeGet(ci, "Email1Address"),
|
||||||
EmailSecondary = (string)(ci.Email2Address ?? ""),
|
EmailSecondary = SafeGet(ci, "Email2Address"),
|
||||||
PhoneWork = (string)(ci.BusinessTelephoneNumber ?? ""),
|
PhoneWork = SafeGet(ci, "BusinessTelephoneNumber"),
|
||||||
PhoneMobile = (string)(ci.MobileTelephoneNumber ?? ""),
|
PhoneMobile = SafeGet(ci, "MobileTelephoneNumber"),
|
||||||
PhoneHome = (string)(ci.HomeTelephoneNumber ?? ""),
|
PhoneHome = SafeGet(ci, "HomeTelephoneNumber"),
|
||||||
Fax = (string)(ci.BusinessFaxNumber ?? ""),
|
Fax = SafeGet(ci, "BusinessFaxNumber"),
|
||||||
Street = (string)(ci.BusinessAddressStreet ?? ""),
|
Street = SafeGet(ci, "BusinessAddressStreet"),
|
||||||
City = (string)(ci.BusinessAddressCity ?? ""),
|
City = SafeGet(ci, "BusinessAddressCity"),
|
||||||
PostalCode = (string)(ci.BusinessAddressPostalCode ?? ""),
|
PostalCode = SafeGet(ci, "BusinessAddressPostalCode"),
|
||||||
State = (string)(ci.BusinessAddressState ?? ""),
|
State = SafeGet(ci, "BusinessAddressState"),
|
||||||
Country = (string)(ci.BusinessAddressCountry ?? ""),
|
Country = SafeGet(ci, "BusinessAddressCountry"),
|
||||||
Website = (string)(ci.WebPage ?? ""),
|
Website = SafeGet(ci, "WebPage"),
|
||||||
Notes = (string)(ci.Body ?? ""),
|
Notes = SafeGet(ci, "Body"),
|
||||||
Salutation = (string)(ci.Title ?? ""),
|
Salutation = SafeGet(ci, "Title"),
|
||||||
Birthday = GetBirthdayString(ci)
|
Birthday = GetBirthdayString(ci)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -425,8 +436,9 @@ namespace StarfaceOutlookSync.Services
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DateTime bday = ci.Birthday;
|
object val = ci.GetType().InvokeMember("Birthday",
|
||||||
if (bday.Year > 1900 && bday != DateTime.MinValue)
|
System.Reflection.BindingFlags.GetProperty, null, ci, null);
|
||||||
|
if (val is DateTime bday && bday.Year > 1900 && bday != DateTime.MinValue)
|
||||||
return bday.ToString("yyyy-MM-dd");
|
return bday.ToString("yyyy-MM-dd");
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|||||||
@@ -304,12 +304,27 @@ namespace StarfaceOutlookSync.Services
|
|||||||
{
|
{
|
||||||
var sfContact = MapToStarface(contact);
|
var sfContact = MapToStarface(contact);
|
||||||
sfContact["id"] = contactId;
|
sfContact["id"] = contactId;
|
||||||
|
|
||||||
|
// Tag beibehalten
|
||||||
|
if (!string.IsNullOrEmpty(book.TagId))
|
||||||
|
{
|
||||||
|
sfContact["tags"] = new JArray { new JObject { ["id"] = book.TagId } };
|
||||||
|
}
|
||||||
|
|
||||||
var query = "";
|
var query = "";
|
||||||
if (book.Type == "user" && !string.IsNullOrEmpty(book.UserId))
|
if (book.Type == "user" && !string.IsNullOrEmpty(book.UserId))
|
||||||
query = $"?userId={book.UserId}";
|
query = $"?userId={book.UserId}";
|
||||||
|
|
||||||
var content = new StringContent(sfContact.ToString(), Encoding.UTF8, "application/json");
|
var body = sfContact.ToString();
|
||||||
|
var content = new StringContent(body, Encoding.UTF8, "application/json");
|
||||||
var resp = await _http.PutAsync($"{_baseUrl}/contacts/{contactId}{query}", content);
|
var resp = await _http.PutAsync($"{_baseUrl}/contacts/{contactId}{query}", content);
|
||||||
|
|
||||||
|
if (!resp.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var respBody = await resp.Content.ReadAsStringAsync();
|
||||||
|
OnDebug?.Invoke($"PUT /contacts/{contactId} fehlgeschlagen: {(int)resp.StatusCode}\n{respBody}");
|
||||||
|
}
|
||||||
|
|
||||||
return resp.IsSuccessStatusCode;
|
return resp.IsSuccessStatusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,11 @@ namespace StarfaceOutlookSync.Services
|
|||||||
// Leere Firma vs. gefuellte Firma = verschiedene Kontakte
|
// Leere Firma vs. gefuellte Firma = verschiedene Kontakte
|
||||||
if (!FieldsCompatible(a.Company, b.Company)) return false;
|
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.PhoneWork, b.PhoneWork)) return false;
|
||||||
if (!PhoneFieldsCompatible(a.PhoneMobile, b.PhoneMobile)) 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
|
// Mindestens ein starkes Match muss vorhanden sein
|
||||||
bool emailMatch = !string.IsNullOrEmpty(a.Email) && !string.IsNullOrEmpty(b.Email)
|
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.FirstName.Equals(b.FirstName, StringComparison.OrdinalIgnoreCase)
|
||||||
&& a.LastName.Equals(b.LastName, StringComparison.OrdinalIgnoreCase)
|
&& a.LastName.Equals(b.LastName, StringComparison.OrdinalIgnoreCase)
|
||||||
&& (!string.IsNullOrEmpty(a.FirstName) || !string.IsNullOrEmpty(a.LastName));
|
&& (!string.IsNullOrEmpty(a.FirstName) || !string.IsNullOrEmpty(a.LastName));
|
||||||
bool phoneMatch = !string.IsNullOrEmpty(a.PhoneWork) && !string.IsNullOrEmpty(b.PhoneWork)
|
bool phoneMatch = (!string.IsNullOrEmpty(a.PhoneWork) && !string.IsNullOrEmpty(b.PhoneWork)
|
||||||
&& NormalizePhone(a.PhoneWork) == NormalizePhone(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -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.18</Version>
|
<Version>0.0.0.19</Version>
|
||||||
<AssemblyVersion>0.0.0.18</AssemblyVersion>
|
<AssemblyVersion>0.0.0.19</AssemblyVersion>
|
||||||
<FileVersion>0.0.0.18</FileVersion>
|
<FileVersion>0.0.0.19</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.18",
|
Text = "Version 0.0.0.19",
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user