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
if (!RefreshGlobalConfigurationParameters())
return false;
InfrastructureConfig.RemoveLegacyActivityFilterConfiguration();
mainDbConnection = InfrastructureConfig.HistoryDB.Connection;

View File

@@ -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;
}
}