Preserve queue filters during migration

This commit is contained in:
Drechsler, Meik
2026-07-23 11:22:58 +02:00
parent 8f66923952
commit 275d884bfe
2 changed files with 37 additions and 20 deletions

View File

@@ -508,6 +508,7 @@ namespace C4IT.DataHistoryProvider
// load the global parameters // load the global parameters
if (!RefreshGlobalConfigurationParameters()) if (!RefreshGlobalConfigurationParameters())
return false; return false;
InfrastructureConfig.RemoveLegacyActivityFilterConfiguration();
mainDbConnection = InfrastructureConfig.HistoryDB.Connection; mainDbConnection = InfrastructureConfig.HistoryDB.Connection;

View File

@@ -121,29 +121,45 @@ namespace C4IT.DataHistoryProvider
return false; 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. // Queue filtering moved to the provider-neutral global ActivityFilters policy.
// InstantiateProperties runs first, so the values remain available for the // This intentionally runs only after the global configuration was loaded:
// one-time migration while the obsolete XML is removed. // DoXmlUpdates runs before InstantiateProperties and would otherwise erase
if (!(xmlRoot.SelectSingleNode("Matrix42-WPM") is XmlElement matrix42)) // the values before the one-time migration can read them.
if (string.IsNullOrWhiteSpace(FilePath))
return false; return false;
var changed = false; try
if (matrix42.HasAttribute("ActivityQueueFilter"))
{ {
matrix42.RemoveAttribute("ActivityQueueFilter"); var document = new XmlDocument();
changed = true; document.Load(FilePath);
} if (!(document.DocumentElement?.SelectSingleNode("Matrix42-WPM") is XmlElement matrix42))
return false;
var queues = matrix42.SelectSingleNode("Queues"); var changed = false;
if (queues != null) 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); LogException(exception);
changed = true; return false;
} }
return changed;
} }
} }