获取SPWeb实例

方式一 if deployed on farm,we can get spweb by time job title

A define site url in feature template.xml as property,and access it in FeatureActivated event

string url = properties.Feature.Properties[activeSiteUrl].Value;

……

job.Title = displayName + "(" + url.ToLower().Trim() + ")";

B Access spweb by title which contains the site url

string webUrl = Title.Substring(Title.IndexOf("(") + 1).Replace(")", "");

using (SPSite site = new SPSite(webUrl))

 

方式二  if deployed on web,we can get spweb by feature parent

SPSite currentSite = properties.Feature.Parent as SPSite;

 

部署:

如果不是第一次部署,一定要重新启动TimerJob服务,新版本的TimerJob应用才会生效。

相关文章:

  • 2021-06-16
  • 2021-06-24
  • 2021-10-25
  • 2021-06-21
  • 2022-01-14
  • 2022-02-05
  • 2019-11-20
猜你喜欢
  • 2021-11-02
  • 2022-01-12
  • 2021-12-18
  • 2021-05-20
  • 2022-02-23
  • 2021-07-29
  • 2021-09-30
相关资源
相似解决方案