aktueller Stand

This commit is contained in:
Meik
2026-02-03 15:54:56 +01:00
parent ee1f54675e
commit 7192319e1e
25 changed files with 689 additions and 260 deletions

View File

@@ -14,6 +14,7 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
{
private readonly Dictionary<enumFasdInformationClass, IList<cF4sdApiSearchResultRelation>> _caseRelations = new Dictionary<enumFasdInformationClass, IList<cF4sdApiSearchResultRelation>>();
private readonly Dictionary<string, Dictionary<cF4sdApiSearchResultRelation, cF4SDHealthCardRawData.cHealthCardTable>> _supportCaseDataCache = new Dictionary<string, Dictionary<cF4sdApiSearchResultRelation, cF4SDHealthCardRawData.cHealthCardTable>>();
private readonly Dictionary<cF4sdApiSearchResultRelation, cF4SDHealthCardRawData> _rawDataCache = new Dictionary<cF4sdApiSearchResultRelation, cF4SDHealthCardRawData>(); // todo remove, currently only used for SupportCaseDataProviderArtifact
internal readonly Guid Id;
private readonly IRelationService _relationService;
@@ -93,11 +94,13 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
// todo this is only a temporary fix. Currently the tablesToLoad contain also detail tables
// and tables won't be loaded e.g. the QuickActionHistory
bool isDataComplete = tablesToLoad.Any(t =>
_supportCaseDataCache.TryGetValue(t, out var cachedTables)
&& cachedTables.TryGetValue(relation, out var table)
&& !table.IsIncomplete && !table.Columns.Values.Any(c => c.IsIncomplete)
);
bool isDataComplete = IsRawDataCacheComplete() && IsSupportCaseDataCacheComplete();
if (isDataComplete)
{
await SupportCaseDataProviderArtifact.HealthCardDataHelper.LoadingHelper.SetHealthCardRawData(_rawDataCache[relation], relation.Identities);
return;
}
var rawDataRequest = new cF4sdHealthCardRawDataRequest()
{
@@ -111,11 +114,13 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
if (rawData is null)
{
rawData = await cFasdCockpitCommunicationBase.Instance.GetHealthCardData(rawDataRequest);
_rawDataCache[relation] = rawData;
await SupportCaseDataProviderArtifact.HealthCardDataHelper.LoadingHelper.SetHealthCardRawData(rawData, rawDataRequest.Identities);
}
else
{
rawData = await cFasdCockpitCommunicationBase.Instance.GetHealthCardData(rawData.Id);
_rawDataCache[relation] = _rawDataCache[relation].Combine(rawData);
await SupportCaseDataProviderArtifact.HealthCardDataHelper.LoadingHelper.UpdateHealthcardRawData(rawData);
}
@@ -130,6 +135,24 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
{
LogException(ex);
}
bool IsRawDataCacheComplete()
{
return tablesToLoad.All(t =>
_rawDataCache.TryGetValue(relation, out var cachedRawData)
&& cachedRawData.Tables.TryGetValue(t, out var cachedTable)
&& !cachedTable.IsIncomplete && !cachedTable.Columns.Values.Any(c => c.IsIncomplete)
);
}
bool IsSupportCaseDataCacheComplete()
{
return tablesToLoad.Any(t =>
_supportCaseDataCache.TryGetValue(t, out var cachedTables)
&& cachedTables.TryGetValue(relation, out var table)
&& !table.IsIncomplete && !table.Columns.Values.Any(c => c.IsIncomplete)
);
}
}
public void UpdateSupportCaseDataCache(cF4sdApiSearchResultRelation relation, IEnumerable<cF4SDHealthCardRawData.cHealthCardTable> tables)
@@ -151,7 +174,7 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
if (!_supportCaseDataCache[table.Name].ContainsKey(relation))
_supportCaseDataCache[table.Name][relation] = table;
else
else if (_supportCaseDataCache[table.Name][relation].IsIncomplete)
MergeTable(_supportCaseDataCache[table.Name][relation], table);
}
@@ -164,9 +187,18 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
void MergeTable(cF4SDHealthCardRawData.cHealthCardTable existingTable, cF4SDHealthCardRawData.cHealthCardTable newTable)
{
foreach (var newColumn in newTable.Columns)
try
{
existingTable.Columns[newColumn.Key] = newColumn.Value;
existingTable.IsIncomplete = newTable.IsIncomplete;
foreach (var newColumn in newTable.Columns)
{
existingTable.Columns[newColumn.Key] = newColumn.Value;
}
}
catch (Exception ex)
{
LogException(ex);
}
}
}
@@ -175,6 +207,8 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
{
try
{
_rawDataCache.Remove(relation);
foreach (var tableCache in _supportCaseDataCache.Values)
{
tableCache.Remove(relation);
@@ -209,6 +243,20 @@ namespace FasdDesktopUi.Basics.Services.SupportCase
invalidatedTables.Add(table);
}
if (!_rawDataCache.TryGetValue(relation, out var cachedRawData) || cachedRawData?.Tables is null)
return;
foreach (var table in cachedRawData.Tables.Values)
{
table.IsIncomplete = true;
foreach (var column in table.Columns.Values)
{
column.Values[0] = null;
column.IsIncomplete = true;
}
}
}
catch (Exception ex)
{