Overview
A couple months ago, in "The quest for the DotNetNuke Holy Grail", I blogged about using ScheduleItemSettings for passing data to a SchedulerClient. To make this work required a minor modification to the DotNetNuke core which was integrated into the 3.3/4.3 releases. There are still some people who are running older versions of DotNetNuke where this modification might still be useful. While we encourage everyone to upgrade to the latest DotNetNuke version, we also realize that sometimes business realities prevent this from happening.
For the people who cannot upgrade, I have included the modifications necessary to allow your scheduled task to take advantage of the ScheduleItemSettings. When I built this solution for a client, I created a simple module administration screen that allowed the user to save the appropriate settings to the ScheduleItemSettings table. By including the following code with an editor, you can use the module installation procedures to add the appropriate stored procedure and DAL methods. This will require you to add this code to every Scheduler module, but it provides a simple way to add it to your site without modifying the core.
SqlDataProvider Script
IF EXISTS (
SELECT *
FROM sysobjects
WHERE id = object_id(N'{databaseOwner}{objectQualifier}AddScheduleItemSetting')
AND OBJECTPROPERTY(id, N'IsProcedure') = 1
)
DROP PROCEDURE {databaseOwner}{objectQualifier}AddScheduleItemSetting
GO
CREATE PROCEDURE {databaseOwner}{objectQualifier}AddScheduleItemSetting
@ScheduleID int,
@Name nvarchar(50),
@Value nvarchar(256)
as
IF EXISTS (
SELECT *
FROM {databaseOwner}{objectQualifier}ScheduleItemSettings
WHERE ScheduleID = @ScheduleID
AND SettingName = @Name
)
BEGIN
UPDATE {databaseOwner}{objectQualifier}ScheduleItemSettings
SET SettingValue = @Value
WHERE ScheduleID = @ScheduleID
AND SettingName = @Name
END
ELSE
BEGIN
INSERT INTO {databaseOwner}{objectQualifier}ScheduleItemSettings (
ScheduleID,
SettingName,
Settingvalue
)
VALUES (
@ScheduleID,
@Name,
@Value
)
END
GO
SqlDataProvider Concrete Method
Public Overrides Sub AddScheduleItemSetting(ByVal ScheduleID As Integer, ByVal Name As String, ByVal Value As String)
SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "AddScheduleItemSetting", ScheduleID, Name, Value)
End Sub
DataProvider Abstract Method
Public MustOverride Sub AddScheduleItemSetting(ByVal ScheduleID As Integer, ByVal Name As String, ByVal Value As String)