Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 39ec176b16 | |||
| 39be854a4a | |||
| 724beba34a | |||
| 65d3e911d0 | |||
| ab9c16c69a |
+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.15"
|
#define MyAppVersion "0.0.0.17"
|
||||||
#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"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
@@ -115,43 +116,63 @@ namespace StarfaceOutlookSync.Services
|
|||||||
{
|
{
|
||||||
var books = new List<StarfaceAddressBook>();
|
var books = new List<StarfaceAddressBook>();
|
||||||
|
|
||||||
books.Add(new StarfaceAddressBook
|
// Alle Tags laden - die Starface nutzt Tags als Adressbuch-Zuordnung
|
||||||
{
|
var allTags = new JArray();
|
||||||
Type = "central",
|
|
||||||
Name = "Zentrales Adressbuch"
|
|
||||||
});
|
|
||||||
|
|
||||||
var userId = await GetCurrentUserIdAsync();
|
|
||||||
if (!string.IsNullOrEmpty(userId))
|
|
||||||
{
|
|
||||||
books.Add(new StarfaceAddressBook
|
|
||||||
{
|
|
||||||
Type = "user",
|
|
||||||
UserId = userId,
|
|
||||||
Name = "Persoenliches Adressbuch"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tags als virtuelle Adressbuecher
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var resp = await _http.GetAsync($"{_baseUrl}/contacts/tags");
|
var resp = await _http.GetAsync($"{_baseUrl}/contacts/tags");
|
||||||
if (resp.IsSuccessStatusCode)
|
if (resp.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var tags = JArray.Parse(await resp.Content.ReadAsStringAsync());
|
allTags = JArray.Parse(await resp.Content.ReadAsStringAsync());
|
||||||
foreach (var tag in tags)
|
OnDebug?.Invoke($"Gefundene Tags: {allTags.Count}");
|
||||||
{
|
foreach (var t in allTags)
|
||||||
books.Add(new StarfaceAddressBook
|
OnDebug?.Invoke($" Tag: {t["name"]} (id: {t["id"]}, alias: {t["alias"]}, owner: {t["owner"]})");
|
||||||
{
|
|
||||||
Type = "tag",
|
|
||||||
TagId = tag["id"]?.ToString() ?? "",
|
|
||||||
Name = $"Tag: {tag["name"]}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
|
// Zentrales Adressbuch (folder/all)
|
||||||
|
var allTag = allTags.FirstOrDefault(t => t["name"]?.ToString() == "folder/all"
|
||||||
|
|| t["alias"]?.ToString()?.Contains("folder.all") == true);
|
||||||
|
books.Add(new StarfaceAddressBook
|
||||||
|
{
|
||||||
|
Type = "central",
|
||||||
|
TagId = allTag?["id"]?.ToString() ?? "",
|
||||||
|
Name = "Zentrales Adressbuch"
|
||||||
|
});
|
||||||
|
|
||||||
|
// Persoenliches Adressbuch (folder/private mit owner = userId)
|
||||||
|
var userId = await GetCurrentUserIdAsync();
|
||||||
|
if (!string.IsNullOrEmpty(userId))
|
||||||
|
{
|
||||||
|
var privateTag = allTags.FirstOrDefault(t =>
|
||||||
|
(t["name"]?.ToString() == "folder/private" || t["alias"]?.ToString()?.Contains("folder.private") == true)
|
||||||
|
&& t["owner"]?.ToString() == userId);
|
||||||
|
|
||||||
|
books.Add(new StarfaceAddressBook
|
||||||
|
{
|
||||||
|
Type = "user",
|
||||||
|
UserId = userId,
|
||||||
|
TagId = privateTag?["id"]?.ToString() ?? "",
|
||||||
|
Name = "Persoenliches Adressbuch"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alle weiteren Tags als Adressbuecher anbieten
|
||||||
|
foreach (var tag in allTags)
|
||||||
|
{
|
||||||
|
var tagName = tag["name"]?.ToString() ?? "";
|
||||||
|
// folder/all und folder/private bereits oben erfasst
|
||||||
|
if (tagName == "folder/all" || tagName == "folder/private") continue;
|
||||||
|
|
||||||
|
books.Add(new StarfaceAddressBook
|
||||||
|
{
|
||||||
|
Type = "tag",
|
||||||
|
TagId = tag["id"]?.ToString() ?? "",
|
||||||
|
Name = tagName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return books;
|
return books;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,6 +269,16 @@ namespace StarfaceOutlookSync.Services
|
|||||||
public async Task<UnifiedContact> CreateContactAsync(UnifiedContact contact, StarfaceAddressBook book)
|
public async Task<UnifiedContact> CreateContactAsync(UnifiedContact contact, StarfaceAddressBook book)
|
||||||
{
|
{
|
||||||
var sfContact = MapToStarface(contact);
|
var sfContact = MapToStarface(contact);
|
||||||
|
|
||||||
|
// Tag zuweisen - die Starface verlangt dass jeder Kontakt einem Tag zugeordnet ist
|
||||||
|
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}";
|
||||||
|
|||||||
@@ -144,6 +144,45 @@ namespace StarfaceOutlookSync.Services
|
|||||||
if (oc == null && sc == null)
|
if (oc == null && sc == null)
|
||||||
{
|
{
|
||||||
// Beide Seiten geloescht -> Mapping entfernen
|
// Beide Seiten geloescht -> Mapping entfernen
|
||||||
|
Log($" Mapping verwaist (beide geloescht), entferne");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oc == null && sc != null)
|
||||||
|
{
|
||||||
|
// In Outlook geloescht -> in Starface auch loeschen
|
||||||
|
if (profile.SyncDirection == SyncDirection.Both || profile.SyncDirection == SyncDirection.OutlookToStarface)
|
||||||
|
{
|
||||||
|
if (await starface.DeleteContactAsync(mapping.StarfaceId))
|
||||||
|
{
|
||||||
|
result.Updated++;
|
||||||
|
Log($" Geloescht (OL->SF): {sc.DisplayName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Richtung erlaubt kein Loeschen -> Mapping behalten
|
||||||
|
newMappings.Add(mapping);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oc != null && sc == null)
|
||||||
|
{
|
||||||
|
// In Starface geloescht -> in Outlook auch loeschen
|
||||||
|
if (profile.SyncDirection == SyncDirection.Both || profile.SyncDirection == SyncDirection.StarfaceToOutlook)
|
||||||
|
{
|
||||||
|
if (_outlookService.DeleteContact(mapping.OutlookEntryId))
|
||||||
|
{
|
||||||
|
result.Updated++;
|
||||||
|
Log($" Geloescht (SF->OL): {oc.DisplayName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Richtung erlaubt kein Loeschen -> Mapping behalten
|
||||||
|
newMappings.Add(mapping);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.15</Version>
|
<Version>0.0.0.17</Version>
|
||||||
<AssemblyVersion>0.0.0.15</AssemblyVersion>
|
<AssemblyVersion>0.0.0.17</AssemblyVersion>
|
||||||
<FileVersion>0.0.0.15</FileVersion>
|
<FileVersion>0.0.0.17</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.15",
|
Text = "Version 0.0.0.17",
|
||||||
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
|
||||||
|
|||||||
@@ -333,9 +333,23 @@ namespace StarfaceOutlookSync.UI
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (_isNew)
|
if (_isNew)
|
||||||
|
{
|
||||||
_pm.AddProfile(profile);
|
_pm.AddProfile(profile);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// Wenn Adressbuch gewechselt wurde, Mappings zuruecksetzen
|
||||||
|
if (_existingProfile.StarfaceAddressBook?.TagId != profile.StarfaceAddressBook?.TagId
|
||||||
|
|| _existingProfile.StarfaceAddressBook?.Type != profile.StarfaceAddressBook?.Type)
|
||||||
|
{
|
||||||
|
_pm.SaveMappings(profile.Id, new List<SyncMapping>());
|
||||||
|
profile.LastSync = "";
|
||||||
|
MessageBox.Show(
|
||||||
|
"Adressbuch wurde geaendert.\nSync-Zuordnungen wurden automatisch zurueckgesetzt.",
|
||||||
|
"Adressbuch geaendert", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
_pm.UpdateProfile(profile);
|
_pm.UpdateProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
|
|||||||
Reference in New Issue
Block a user