Skip to content

Commit 3a833df

Browse files
committed
save
1 parent 8093ac0 commit 3a833df

File tree

3 files changed

+68
-65
lines changed

3 files changed

+68
-65
lines changed

src/ScheduledTasks/Entity/Schedule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void UpdateSchedule(TaskEntityContext context, ScheduleUpdateOptions sche
6262
Verify.NotNull(scheduleUpdateOptions, nameof(scheduleUpdateOptions));
6363
Verify.NotNull(this.State.ScheduleConfiguration, nameof(this.State.ScheduleConfiguration));
6464

65-
HashSet<string> updatedScheduleConfigFields = this.State.UpdateConfig(scheduleUpdateOptions);
65+
HashSet<string> updatedScheduleConfigFields = this.State.ScheduleConfiguration.Update(scheduleUpdateOptions);
6666
if (updatedScheduleConfigFields.Count == 0)
6767
{
6868
// no need to interrupt and update current schedule run as there is no change in the schedule config

src/ScheduledTasks/Models/ScheduleConfiguration.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,71 @@ public static ScheduleConfiguration FromCreateOptions(ScheduleCreationOptions cr
120120
StartImmediatelyIfLate = createOptions.StartImmediatelyIfLate,
121121
};
122122
}
123+
124+
/// <summary>
125+
/// Updates this configuration with the provided update options.
126+
/// </summary>
127+
/// <param name="updateOptions">The options to update the configuration with.</param>
128+
/// <returns>A set of field names that were updated.</returns>
129+
public HashSet<string> Update(ScheduleUpdateOptions updateOptions)
130+
{
131+
Check.NotNull(updateOptions, nameof(updateOptions));
132+
HashSet<string> updatedFields = new HashSet<string>();
133+
134+
if (!string.IsNullOrEmpty(updateOptions.OrchestrationName))
135+
{
136+
this.OrchestrationName = updateOptions.OrchestrationName;
137+
updatedFields.Add(nameof(this.OrchestrationName));
138+
}
139+
140+
if (updateOptions.OrchestrationInput == null)
141+
{
142+
this.OrchestrationInput = updateOptions.OrchestrationInput;
143+
updatedFields.Add(nameof(this.OrchestrationInput));
144+
}
145+
146+
if (!string.IsNullOrEmpty(updateOptions.OrchestrationInstanceId))
147+
{
148+
this.OrchestrationInstanceId = updateOptions.OrchestrationInstanceId;
149+
updatedFields.Add(nameof(this.OrchestrationInstanceId));
150+
}
151+
152+
if (updateOptions.StartAt.HasValue)
153+
{
154+
this.StartAt = updateOptions.StartAt;
155+
updatedFields.Add(nameof(this.StartAt));
156+
}
157+
158+
if (updateOptions.EndAt.HasValue)
159+
{
160+
this.EndAt = updateOptions.EndAt;
161+
updatedFields.Add(nameof(this.EndAt));
162+
}
163+
164+
if (updateOptions.Interval.HasValue)
165+
{
166+
this.Interval = updateOptions.Interval;
167+
updatedFields.Add(nameof(this.Interval));
168+
}
169+
170+
if (!string.IsNullOrEmpty(updateOptions.CronExpression))
171+
{
172+
this.CronExpression = updateOptions.CronExpression;
173+
updatedFields.Add(nameof(this.CronExpression));
174+
}
175+
176+
if (updateOptions.MaxOccurrence != 0)
177+
{
178+
this.MaxOccurrence = updateOptions.MaxOccurrence;
179+
updatedFields.Add(nameof(this.MaxOccurrence));
180+
}
181+
182+
if (updateOptions.StartImmediatelyIfLate.HasValue)
183+
{
184+
this.StartImmediatelyIfLate = updateOptions.StartImmediatelyIfLate.Value;
185+
updatedFields.Add(nameof(this.StartImmediatelyIfLate));
186+
}
187+
188+
return updatedFields;
189+
}
123190
}

src/ScheduledTasks/Models/ScheduleState.cs

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -33,70 +33,6 @@ class ScheduleState
3333
/// </summary>
3434
internal ScheduleConfiguration? ScheduleConfiguration { get; set; }
3535

36-
/// <summary>
37-
/// Updates the schedule configuration with the provided options.
38-
/// </summary>
39-
/// <param name="scheduleUpdateOptions">The update options to apply.</param>
40-
/// <returns>A set of field names that were updated.</returns>
41-
public HashSet<string> UpdateConfig(ScheduleUpdateOptions scheduleUpdateOptions)
42-
{
43-
Check.NotNull(this.ScheduleConfiguration, nameof(this.ScheduleConfiguration));
44-
Check.NotNull(scheduleUpdateOptions, nameof(scheduleUpdateOptions));
45-
46-
HashSet<string> updatedFields = new HashSet<string>();
47-
48-
if (!string.IsNullOrEmpty(scheduleUpdateOptions.OrchestrationName))
49-
{
50-
this.ScheduleConfiguration.OrchestrationName = scheduleUpdateOptions.OrchestrationName;
51-
updatedFields.Add(nameof(this.ScheduleConfiguration.OrchestrationName));
52-
}
53-
54-
if (scheduleUpdateOptions.OrchestrationInput == null)
55-
{
56-
this.ScheduleConfiguration.OrchestrationInput = scheduleUpdateOptions.OrchestrationInput;
57-
updatedFields.Add(nameof(this.ScheduleConfiguration.OrchestrationInput));
58-
}
59-
60-
if (scheduleUpdateOptions.StartAt.HasValue)
61-
{
62-
this.ScheduleConfiguration.StartAt = scheduleUpdateOptions.StartAt;
63-
updatedFields.Add(nameof(this.ScheduleConfiguration.StartAt));
64-
}
65-
66-
if (scheduleUpdateOptions.EndAt.HasValue)
67-
{
68-
this.ScheduleConfiguration.EndAt = scheduleUpdateOptions.EndAt;
69-
updatedFields.Add(nameof(this.ScheduleConfiguration.EndAt));
70-
}
71-
72-
if (scheduleUpdateOptions.Interval.HasValue)
73-
{
74-
this.ScheduleConfiguration.Interval = scheduleUpdateOptions.Interval;
75-
updatedFields.Add(nameof(this.ScheduleConfiguration.Interval));
76-
}
77-
78-
if (!string.IsNullOrEmpty(scheduleUpdateOptions.CronExpression))
79-
{
80-
this.ScheduleConfiguration.CronExpression = scheduleUpdateOptions.CronExpression;
81-
updatedFields.Add(nameof(this.ScheduleConfiguration.CronExpression));
82-
}
83-
84-
if (scheduleUpdateOptions.MaxOccurrence != 0)
85-
{
86-
this.ScheduleConfiguration.MaxOccurrence = scheduleUpdateOptions.MaxOccurrence;
87-
updatedFields.Add(nameof(this.ScheduleConfiguration.MaxOccurrence));
88-
}
89-
90-
// Only update if the customer explicitly set a value
91-
if (scheduleUpdateOptions.StartImmediatelyIfLate.HasValue)
92-
{
93-
this.ScheduleConfiguration.StartImmediatelyIfLate = scheduleUpdateOptions.StartImmediatelyIfLate.Value;
94-
updatedFields.Add(nameof(this.ScheduleConfiguration.StartImmediatelyIfLate));
95-
}
96-
97-
return updatedFields;
98-
}
99-
10036
/// <summary>
10137
/// Refreshes the execution token to invalidate pending schedule operations.
10238
/// </summary>

0 commit comments

Comments
 (0)