Daily schedule problems with version 4.0

Jun 15, 2012 at 2:12 PM
Edited Jun 15, 2012 at 2:30 PM

The problem with daily schedules was partly fixed in version 4.0, but not completely. The problem is, that the settings are not saved correctly when configuring daily schedule in admin console:
- the Interval is not set to zero in Apply method in ScheduledPropertyPage code behind.
- default value for Interval is 1 in DailySchedule class.
- in admin console the day checkboxes are initialized from config only if Interval is 0 (checked in ScheduledPropertyPage_OnLoad)
- DaySchedule.GetNextActivationTime also works incorrectly if Interval is other than 0 and day based schedule is desired

After I fixed that issue the config xml no longer serialized, because there were some validation checks in setters of DailySchedule class and the order of calling the setters in serialization caused validation errors. I moved the validation logic from setter methods to Validate method in AdapterConfiguration class. The method is called before saving the configuration xml to property bag. I think this fixed the problems, but would appreciate if someone else verified this.

I didn't find a way to attach the diff file so I pasted it here.

Cheers,
maakku

 

Index: C:/vsWorkspace/ScheduledTaskAdapter/ScheduledTaskAdapter/AdapterConfiguration.cs
===================================================================
--- C:/vsWorkspace/ScheduledTaskAdapter/ScheduledTaskAdapter/AdapterConfiguration.cs (revision 30656)
+++ C:/vsWorkspace/ScheduledTaskAdapter/ScheduledTaskAdapter/AdapterConfiguration.cs (revision 30660)
@@ -93,5 +93,40 @@
writer.Close();
}
}
+
+ public void Validate()
+ {
+ switch (this.schedule.Type)
+ {
+ case ScheduleType.TimeSpan:
+ var tsSchedule = this.schedule as TimeSpanSchedule;
+ if (tsSchedule.Interval <= 0)
+ throw (new ArgumentOutOfRangeException("Interval", "Must specify scheduled interval greater than zero"));
+ break;
+ case ScheduleType.Daily:
+ var dSchedule = this.schedule as DaySchedule;
+ if ((dSchedule.ScheduledDays == ScheduleDay.None) && (dSchedule.Interval < 1))
+ throw (new ArgumentOutOfRangeException("days", "Must specify scheduled days or interval"));
+ break;
+ case ScheduleType.Weekly:
+ var wSchedule = this.schedule as WeekSchedule;
+ if ((wSchedule.Interval < 1) || (wSchedule.Interval > 52))
+ throw (new ArgumentOutOfRangeException("interval", "Week interval must be between 1 and 52"));
+ if ((wSchedule.ScheduledDays == ScheduleDay.None))
+ throw (new ArgumentOutOfRangeException("days", "Must specify the scheduled days"));
+ break;
+ case ScheduleType.Monthly:
+ var mSchedule = this.schedule as MonthSchedule;
+ if (mSchedule.Day < 0 || mSchedule.Day > 31)
+ throw (new ArgumentOutOfRangeException("value", "Day range: 0 - 31"));
+ if (mSchedule.ScheduledMonths == ScheduleMonth.None)
+ {
+ throw (new ArgumentOutOfRangeException("months", "Must specify a month"));
+ }
+ break;
+ default:
+ break;
+ }
+ }
}
}
Index: C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/TimeSpanSchedule.cs
===================================================================
--- C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/TimeSpanSchedule.cs (revision 30656)
+++ C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/TimeSpanSchedule.cs (revision 30660)
@@ -22,10 +22,6 @@
}
set
{
- if (value <= 0)
- {
- throw (new ArgumentOutOfRangeException("Interval", "Must specify scheduled interval greater than zero"));
- }
if (value != Interlocked.Exchange(ref this.timeSpan, value))
{
this.FireChangedEvent();
Index: C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/MonthSchedule.cs
===================================================================
--- C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/MonthSchedule.cs (revision 30656)
+++ C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/MonthSchedule.cs (revision 30660)
@@ -26,10 +26,6 @@
}
set
{
- if (value < 0 || value > 31)
- {
- throw (new ArgumentOutOfRangeException("value", "Day range: 0 - 31"));
- }
if (value != Interlocked.Exchange(ref this.day, value))
{
this.FireChangedEvent();
@@ -72,10 +68,6 @@
}
set
{
- if (value == ScheduleMonth.None)
- {
- throw (new ArgumentOutOfRangeException("months", "Must specify a month"));
- }
if (value != (ScheduleMonth)Interlocked.Exchange(ref this.months, value))
{
this.FireChangedEvent();
Index: C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/WeekSchedule.cs
===================================================================
--- C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/WeekSchedule.cs (revision 30656)
+++ C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/WeekSchedule.cs (revision 30660)
@@ -21,10 +21,6 @@

set
{
- if ((value < 1) || (value > 52))
- {
- throw (new ArgumentOutOfRangeException("interval", "Week interval must be between 1 and 52"));
- }
if (value != Interlocked.Exchange(ref this.interval, value))
{
this.FireChangedEvent();
@@ -38,10 +34,6 @@

set
{
- if ((value == ScheduleDay.None))
- {
- throw (new ArgumentOutOfRangeException("days", "Must specify the scheduled days"));
- }
if (value != (ScheduleDay)Interlocked.Exchange(ref this.days, value))
{
this.FireChangedEvent();
Index: C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/DaySchedule.cs
===================================================================
--- C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/DaySchedule.cs (revision 30656)
+++ C:/vsWorkspace/ScheduledTaskAdapter/Calendar.Schedules/DaySchedule.cs (revision 30660)
@@ -24,10 +24,6 @@
}
set
{
- if ((this.ScheduledDays == ScheduleDay.None) && (value < 1))
- {
- throw (new ArgumentOutOfRangeException("days", "Must specify scheduled days or interval"));
- }
if (value != Interlocked.Exchange(ref this.interval, value))
{
this.FireChangedEvent();
@@ -42,10 +38,6 @@
}
set
{
- if ((value == ScheduleDay.None) && (this.Interval < 1))
- {
- throw (new ArgumentOutOfRangeException("days", "Must specify scheduled days or interval"));
- }
if (value != (ScheduleDay)Interlocked.Exchange(ref this.days, value))
{
this.FireChangedEvent();
Index: C:/vsWorkspace/ScheduledTaskAdapter/ScheduledTaskAdapter.Admin/ScheduledPropertyPageFrame.cs
===================================================================
--- C:/vsWorkspace/ScheduledTaskAdapter/ScheduledTaskAdapter.Admin/ScheduledPropertyPageFrame.cs (revision 30656)
+++ C:/vsWorkspace/ScheduledTaskAdapter/ScheduledTaskAdapter.Admin/ScheduledPropertyPageFrame.cs (revision 30660)
@@ -90,7 +90,8 @@
}

public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
- {
+ {
+ this.adapterConfiguration.Validate();
using (new DisposableObjectWrapper(new object[] { propertyBag }))
{
if (propertyBag == null)
@@ -133,6 +134,7 @@

public void Save(Microsoft.BizTalk.ExplorerOM.IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
{
+ this.adapterConfiguration.Validate();
using (new DisposableObjectWrapper(new object[] { propertyBag }))
{
if (propertyBag == null)
Index: C:/vsWorkspace/ScheduledTaskAdapter/ScheduledTaskAdapter.Admin/ScheduledPropertyPage.cs
===================================================================
--- C:/vsWorkspace/ScheduledTaskAdapter/ScheduledTaskAdapter.Admin/ScheduledPropertyPage.cs (revision 30656)
+++ C:/vsWorkspace/ScheduledTaskAdapter/ScheduledTaskAdapter.Admin/ScheduledPropertyPage.cs (revision 30660)
@@ -80,6 +80,7 @@
if (radioDayInterval.Checked)
{
((DaySchedule)schedule).Interval = Convert.ToInt32(this.updownDayInterval.Value);
+ ((DaySchedule)schedule).ScheduledDays = ScheduleDay.None;
}
else
{
@@ -92,6 +93,7 @@
if (checkDayFriday.Checked) days |= ScheduleDay.Friday;
if (checkDaySaturday.Checked) days |= ScheduleDay.Saturday;
((DaySchedule)schedule).ScheduledDays = days;
+ ((DaySchedule)schedule).Interval = 0;
}
break;
case ScheduleType.Weekly:
@@ -200,7 +202,7 @@
//set Daily schedule properties
DaySchedule daySchedule = adapterConfiguration.Schedule as DaySchedule;
this.updownDayInterval.Value = Convert.ToDecimal(daySchedule.Interval);
- if (this.updownDayInterval.Value == 0)
+ if (daySchedule.ScheduledDays != ScheduleDay.None)
{
ScheduleDay days = daySchedule.ScheduledDays;
if ((days & ScheduleDay.Sunday) > 0) checkDaySunday.Checked = true;
@@ -210,7 +212,7 @@
if ((days & ScheduleDay.Thursday) > 0) checkDayThursday.Checked = true;
if ((days & ScheduleDay.Friday) > 0) checkDayFriday.Checked = true;
if ((days & ScheduleDay.Saturday) > 0) checkDaySaturday.Checked = true;
- radioDayInterval.Checked = false;
+ radioSelectDays.Checked = true;
}
else
{
@@ -340,14 +342,6 @@
this.checkDayFriday.Enabled = true;
this.checkDaySaturday.Enabled = true;
this.checkDaySunday.Enabled = true;
-
- this.checkDayMonday.Checked = true;
- this.checkDayTuesday.Checked = true;
- this.checkDayWednesday.Checked = true;
- this.checkDayThursday.Checked = true;
- this.checkDayFriday.Checked = true;
- this.checkDaySaturday.Checked = true;
- this.checkDaySunday.Checked = true;
}
else
{
@@ -360,17 +354,7 @@
this.checkDayFriday.Enabled = false;
this.checkDaySaturday.Enabled = false;
this.checkDaySunday.Enabled = false;
-
- this.checkDayMonday.Checked = false;
- this.checkDayTuesday.Checked = false;
- this.checkDayWednesday.Checked = false;
- this.checkDayThursday.Checked = false;
- this.checkDayFriday.Checked = false;
- this.checkDaySaturday.Checked = false;
- this.checkDaySunday.Checked = false;
}
-
-
}
#endregion

Coordinator
Jun 26, 2012 at 4:53 PM

Thanks for your feedback and explanation.

I’m ’m working in a new version and I will take this feedback into consideration.

Sep 11, 2012 at 9:21 AM

I have made the changes from maakku and now the adapter works perfectly. Without these changes the adapter has some problems.

Coordinator
Nov 25, 2012 at 11:29 PM

I already published these changes and other minor changes.
Thank you both.