|
| A UserQuery within a CSJob? |
 |
Fri, 13 Oct 2006 09:39:17 +000 |
I am trying to do a UserQuery to get a UserSet within a CSJob. But get an error
on the following line:
objUserSet = CommunityServer.Users.GetUsers(objQuery, False)
But are getting a "No CSContext exists in the Current Application.
AutoCreate fails since HttpContext.Current is not accessible" error. I know
from reading other forum posts that a CSJob doesn't have a context, and I
suspect that GetUsers needs som Context object "under the hood" to be
able to get users from the correct community?
It works every now and then though. :-)
|
| Post Reply
|
| Re: A UserQuery within a CSJob? |
 |
Fri, 13 Oct 2006 13:20:04 +000 |
Try something like this:
public void Execute(XmlNode node)
{
SiteSettingsManager.IterateSiteSettings(new
SiteSettingsListIterator(RunMyJob));
}
private void RunMyJob(int settingsid)
{
CSContext.Create(settingsid);
// get the users here.
}
|
| Post Reply
|
| Re: A UserQuery within a CSJob? |
 |
Fri, 13 Oct 2006 14:02:45 +000 |
Aahh, great! Thanks! Will try!
|
| Post Reply
|
| Re: A UserQuery within a CSJob? |
 |
Fri, 13 Oct 2006 17:52:40 +000 |
Seems to work great. Just wanted to post for those who use VB (like myself). The
code above would be:
Public Sub Execute(ByVal node As System.Xml.XmlNode)
Implements CommunityServer.Configuration.IJob.Execute
SiteSettingsManager.IterateSiteSettings(New
SiteSettingsListIterator(AddressOf RunMyJob))
End Sub
Private Sub RunMyJob(ByVal SettingsID As Integer)
CSContext.Create(SettingsID)
'get the users here
End Sub
|
| Post Reply
|
| Re: A UserQuery within a CSJob? |
 |
Fri, 13 Oct 2006 18:16:49 +000 |
Glad it worked.
Wish I could say it was my idea, but there are a few CS Core jobs that do this
I just happened to have written a couple jobs that needed to do this a month
ago.
|
| Post Reply
|
|
|
|
|
|
|
|
|
|