diff --git a/F4SD-Cockpit-ServerCore/DataHistoryCollector.cs b/F4SD-Cockpit-ServerCore/DataHistoryCollector.cs index 1b5c25f..e044a39 100644 --- a/F4SD-Cockpit-ServerCore/DataHistoryCollector.cs +++ b/F4SD-Cockpit-ServerCore/DataHistoryCollector.cs @@ -505,11 +505,12 @@ namespace C4IT.DataHistoryProvider DoProcessUiMessage(1, "the data cluster configuration loaded successful."); DoProcessUiMessage(0, ""); - // load the global parameters - if (!RefreshGlobalConfigurationParameters()) - return false; - - mainDbConnection = InfrastructureConfig.HistoryDB.Connection; + // load the global parameters + if (!RefreshGlobalConfigurationParameters()) + return false; + InfrastructureConfig.RemoveLegacyActivityFilterConfiguration(); + + mainDbConnection = InfrastructureConfig.HistoryDB.Connection; if (InfrastructureConfig.M42Wpm != null) { diff --git a/F4SD-Cockpit-ServerCore/DataHistoryConfigInfrastructure.cs b/F4SD-Cockpit-ServerCore/DataHistoryConfigInfrastructure.cs index 32a039e..434be48 100644 --- a/F4SD-Cockpit-ServerCore/DataHistoryConfigInfrastructure.cs +++ b/F4SD-Cockpit-ServerCore/DataHistoryConfigInfrastructure.cs @@ -121,29 +121,45 @@ namespace C4IT.DataHistoryProvider return false; } - public override bool DoXmlUpdates(XmlElement xmlRoot, bool withM42Config = false, bool withIntuneConfig = false, bool withMobileDeviceConfig = false, bool withCitrixConfig = false) + internal bool RemoveLegacyActivityFilterConfiguration() { // Queue filtering moved to the provider-neutral global ActivityFilters policy. - // InstantiateProperties runs first, so the values remain available for the - // one-time migration while the obsolete XML is removed. - if (!(xmlRoot.SelectSingleNode("Matrix42-WPM") is XmlElement matrix42)) + // This intentionally runs only after the global configuration was loaded: + // DoXmlUpdates runs before InstantiateProperties and would otherwise erase + // the values before the one-time migration can read them. + if (string.IsNullOrWhiteSpace(FilePath)) return false; - var changed = false; - if (matrix42.HasAttribute("ActivityQueueFilter")) + try { - matrix42.RemoveAttribute("ActivityQueueFilter"); - changed = true; - } + var document = new XmlDocument(); + document.Load(FilePath); + if (!(document.DocumentElement?.SelectSingleNode("Matrix42-WPM") is XmlElement matrix42)) + return false; - var queues = matrix42.SelectSingleNode("Queues"); - if (queues != null) + var changed = false; + if (matrix42.HasAttribute("ActivityQueueFilter")) + { + matrix42.RemoveAttribute("ActivityQueueFilter"); + changed = true; + } + + var queues = matrix42.SelectSingleNode("Queues"); + if (queues != null) + { + matrix42.RemoveChild(queues); + changed = true; + } + + if (changed) + document.Save(FilePath); + return changed; + } + catch (Exception exception) { - matrix42.RemoveChild(queues); - changed = true; + LogException(exception); + return false; } - - return changed; } }