http://sharepoint2010shyju.blogspot.com/2010/12/creating-custom-timer-job.html?showComment=1296184785817#c3173481420652015259
please refer this link. I must say thanks to the author Mohan for his great post.
the logic is
1. use the properties like below in ur timer job class
[Persisted()]
public string MyCustomProperty;
2. assign the url of the web (site/subsite..whatever) to the property in feature activated event
SPWeb webN = properties.Feature.Parent as SPWeb;
taskLoggerJob.MyCustomProperty = webN.ServerRelativeUrl;
Note:- my scope is web
3. Use the property in Execute method
SPSite _siteCol = new SPSite(this.WebApplication.Sites[0].Url);
SPWeb _site = _siteCol.AllWebs[MyCustomProperty]; //
Note:- I have one site collection, (u can refer ur site collection using contentdbId)
:-), thats it...Happy coding
No comments:
Post a Comment