Pre-populating a Schedule can result in incorrect entries
Use the following configuration class structure:
[DataContract]
public class Configuration
: ConfigurationBase
{
[DataMember]
[RecurringOperationConfiguration(VaultApplication.QueueId, "TaskTypeB")]
public Schedule Schedule { get; set; } = new Schedule()
{
Enabled = true,
Triggers = new List<Trigger>
{
new DayOfMonthTrigger()
{
TriggerDays = new List<int> { 1 },
TriggerTimes = new List<TimeSpan>{ new TimeSpan(1, 0, 0) }
}
}
};
}
}
When the application starts, the processor is scheduled for 1am on the first of the next month. This can be seen on the dashboard. Good.
Go into the configuration editor and set up a trigger for 2am on the second of the next month. When saved, note that both the original trigger and the new one are shown as valid in the dashboard. There is no way to remove the one that was created initially.
This seems to be related to this issue whereby Newtonsoft appends the list items rather than replacing them.
As we cannot control the deserialization directly (it is done outside of this library), we probably need a custom JsonConverter to handle this.
Note: this issue only happens if the Schedule class is used directly. Using a Frequency instead is fine, as that already has a JsonConverter in place to control the deserialization.
There should be a number of unit tests added around this to check that any changes do not adversely affect the overall deserialization process.