diff --git a/src/OutlookAddin.Core/Models/CaseEntity.cs b/src/OutlookAddin.Core/Models/CaseEntity.cs
index c73995b..4333233 100644
--- a/src/OutlookAddin.Core/Models/CaseEntity.cs
+++ b/src/OutlookAddin.Core/Models/CaseEntity.cs
@@ -23,6 +23,13 @@ namespace MarcusLaw.OutlookAddin.Core.Models
[JsonPropertyName("status")]
public string? Status { get; set; }
+ // Marcus-Law custom field on Case — court file/docket number.
+ // Field name guessed from EspoCRM "c-prefixed PascalCase" convention;
+ // adjust if the admin used a different name.
+ [JsonPropertyName("cCourtCaseNumber")]
+ [JsonConverter(typeof(FlexibleStringConverter))]
+ public string? CourtCaseNumber { get; set; }
+
[JsonPropertyName("accountId")]
public string? AccountId { get; set; }
diff --git a/src/OutlookAddin.UI/Dialogs/SaveAttachmentsDialog.xaml b/src/OutlookAddin.UI/Dialogs/SaveAttachmentsDialog.xaml
index e199c7e..7daf05c 100644
--- a/src/OutlookAddin.UI/Dialogs/SaveAttachmentsDialog.xaml
+++ b/src/OutlookAddin.UI/Dialogs/SaveAttachmentsDialog.xaml
@@ -80,32 +80,28 @@
-
-
+
+
+
+
@@ -130,23 +126,16 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/OutlookAddin.UI/ViewModels/SaveAttachmentsViewModel.cs b/src/OutlookAddin.UI/ViewModels/SaveAttachmentsViewModel.cs
index 023e9c2..61621de 100644
--- a/src/OutlookAddin.UI/ViewModels/SaveAttachmentsViewModel.cs
+++ b/src/OutlookAddin.UI/ViewModels/SaveAttachmentsViewModel.cs
@@ -237,6 +237,27 @@ namespace MarcusLaw.OutlookAddin.UI.ViewModels
return name.Trim(' ', '-');
}
+ private async Task LoadCaseRowAsync(EspoEntityRef hit, CancellationToken ct)
+ {
+ var row = new CaseEntity { Id = hit.Id, Name = hit.Name };
+ if (string.IsNullOrEmpty(hit.Id)) return row;
+ try
+ {
+ var detail = await _client.GetCaseAsync(
+ hit.Id, "id,name,number,status,cCourtCaseNumber", ct).ConfigureAwait(false);
+ row.Number = detail.Number;
+ row.Status = detail.Status;
+ row.CourtCaseNumber = detail.CourtCaseNumber;
+ if (!string.IsNullOrEmpty(detail.Name)) row.Name = detail.Name;
+ }
+ catch (OperationCanceledException) { throw; }
+ catch (Exception ex)
+ {
+ _logger.Warning(ex, "Hydrating case {CaseId} for picker failed", hit.Id);
+ }
+ return row;
+ }
+
private async Task SearchAsync(string query, CancellationToken ct)
{
try
@@ -255,20 +276,32 @@ namespace MarcusLaw.OutlookAddin.UI.ViewModels
ct.ThrowIfCancellationRequested();
Cases.Clear();
- int kept = 0;
+ var caseHits = new List();
foreach (var hit in search.List)
{
- if (!string.Equals(hit.EntityType, "Case", StringComparison.OrdinalIgnoreCase)) continue;
- Cases.Add(new CaseEntity
- {
- Id = hit.Id,
- Name = hit.Name
- });
- kept++;
+ if (string.Equals(hit.EntityType, "Case", StringComparison.OrdinalIgnoreCase))
+ caseHits.Add(hit);
}
- StatusMessage = kept == 0
- ? "אין תוצאות מסוג תיק (Case)"
- : $"נמצאו {kept} תיקים";
+
+ if (caseHits.Count == 0)
+ {
+ StatusMessage = "אין תוצאות מסוג תיק (Case)";
+ return;
+ }
+
+ var detailTasks = new List>(caseHits.Count);
+ foreach (var hit in caseHits)
+ {
+ detailTasks.Add(LoadCaseRowAsync(hit, ct));
+ }
+ var details = await Task.WhenAll(detailTasks).ConfigureAwait(true);
+ ct.ThrowIfCancellationRequested();
+
+ foreach (var row in details)
+ {
+ if (row != null) Cases.Add(row);
+ }
+ StatusMessage = $"נמצאו {Cases.Count} תיקים";
}
catch (OperationCanceledException) { /* superseded */ }
catch (EspoCrmAuthorizationException)