Click here to Skip to main content
15,896,154 members
Articles / Web Development / IIS

Scheduled Tasks Web Service

Rate me:
Please Sign up or sign in to vote.
4.00/5 (9 votes)
23 Nov 2007CPOL6 min read 127.6K   2.5K   65  
A web service that acts as a scheduler for tasks.
Public Class ServiceLayer



    ''' <summary>
    ''' Get a reference to the Scheduler Service
    ''' </summary>
    Private Shared Function GetSchedulerService() As Scheduler.Scheduler
        Try
            'Create a reference to the service
            GetSchedulerService = New Scheduler.Scheduler
            'Check if we have setup another URL as a reference
            If System.Configuration.ConfigurationManager.AppSettings.Get("SchedulerURL") IsNot Nothing AndAlso _
            System.Configuration.ConfigurationManager.AppSettings.Get("SchedulerURL").Trim.Length > 0 Then
                GetSchedulerService.Url = System.Configuration.ConfigurationManager.AppSettings.Get("SchedulerURL")
            End If
        Catch ex As Exception
            Return Nothing
        End Try
    End Function


    ''' <summary>
    ''' Makes a call to the Scheduler Service to keep it alive
    ''' </summary>
    Public Shared Sub KeepServiceAlive()
        'Keep alive the service
        GetSchedulerService.KeepAlive()
    End Sub


    ''' <summary>
    ''' Gets the list of Task Scheduled on the servier
    ''' </summary>
    Public Shared Function GetTaskList() As SchedulerService.Entities.ScheduleTaskDataset
        'Get the task list
        Dim serviceData As Scheduler.ScheduleTaskDataset
        serviceData = GetSchedulerService.GetTaskList
        'Convert from web service object to local object
        GetTaskList = New SchedulerService.Entities.ScheduleTaskDataset
        GetTaskList.Merge(serviceData, False, MissingSchemaAction.Ignore)
    End Function


    ''' <summary>
    ''' Get a list of all Available tasjs
    ''' </summary>
    Public Shared Function GetAvailableTasks() As String()
        Return GetSchedulerService.GetAvailableTasks()
    End Function


    ''' <summary>
    ''' Updates the Schediule task list 
    ''' </summary>
    ''' <param name="TaskListData">The Scheduled Tasks</param>
    ''' <returns>True if success</returns>
    Public Shared Function UpdateScheduleTaskList(ByVal TaskListData As SchedulerService.Entities.ScheduleTaskDataset) As Boolean
        'Convert from Local to Service object
        Dim serviceData As New Scheduler.ScheduleTaskDataset
        serviceData.Merge(TaskListData, False, MissingSchemaAction.Ignore)
        'Update and return result
        Return GetSchedulerService.UpdateTaskList(serviceData)
    End Function

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Mexico Mexico
I am Pedro Ramirez from mexico, work for www.sciodev.com, the company is located in Mexico, we do outsourcing and nearshore development, we are focused on SaaS nearshore development, I started with VB.Net, but now I am ambidextrous using VB.Net or C#.

Comments and Discussions