Rodney -
This is what I've tried...
Public Overrides Sub DoWork()
Try
SetHttpContextWithSimulatedRequest()
'Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)
' Code to do something goes here
Me.ScheduleHistoryItem.Succeeded = True
Me.ScheduleHistoryItem.AddLogNote("Completed schedule: " & HttpContext.Current.Items.Count)
Catch ex As Exception
Me.ScheduleHistoryItem.Succeeded = False
Me.ScheduleHistoryItem.AddLogNote("EXCEPTION: " & ex.Message)
Me.Errored(ex)
LogException(ex)
End Try
End Sub
' Joe Brinkman
Public Shared Sub SetHttpContextWithSimulatedRequest()
Dim page As String = (HttpRuntime.AppDomainAppVirtualPath + "/default.aspx").TrimStart("/")
Dim query As String = ""
Dim output As StringWriter = New StringWriter
Thread.GetDomain.SetData(".hostingInstallDir", HttpRuntime.AspInstallDirectory)
Thread.GetDomain.SetData(".hostingVirtualPath", HttpRuntime.AppDomainAppVirtualPath)
Dim workerRequest As SimpleWorkerRequest = New SimpleWorkerRequest(page, query, output)
HttpContext.Current = New HttpContext(workerRequest)
End Sub
When I write out the HttpContext.Current.Items.Count to the log, the value is always 0.
I'm trying to get the _portalSettings to send out portal-specific details by email.
Many thanks.