计时器作业功能的范围 [英] Scope of a timer job feature

查看:107
本文介绍了计时器作业功能的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次写定时器作业.我正在遵循可以通过谷歌搜索获得的示例作为参考.

I am writing a timer job for the first time. I am following the examples that can be obtained by googling as my reference.

在许多此类文章中,我遇到了计时器作业功能被激活到网站集"级别或网站"级别.

In many such articles, I am coming across the timer job features being activated to the Site Collection level or the Site level.

我觉得这很奇怪,因为特定Web应用程序只能有一个计时器作业实例.

I feel this is weird, since there can be only one instance of a timer job for a particular web application.

难道不是所有计时器作业功能都适用于Web应用程序吗?

Should't all the timer job features be scoped to a Web application?

我在这里错过了什么吗?

Am I missing anything here?

推荐答案

这完全取决于您的方案.到目前为止,我编写的计时器作业已由Web应用程序确定范围(这只是修改feature.xml的问题).但是,根据计时器工作的不同,从用户的角度来看,将其设置为网站或网站范围可能很有意义.您只需要让功能接收者知道在Activated等通知处理程序中传递的父级",即激活该功能的SPWeb,SPSite或SPWebApplication,就可以节省编写时间一个配置界面,只是让用户设置您的计时器作业应使用哪些网络,而哪些则不可以.从技术上讲,您是正确的:它们始终在Web应用程序级别上运行.但是,由于它们经常与网站或网站相关的内容一起使用,因此这种方式的作用域可能是限制计时器工作范围的有用方法.

It depends entirely on your scenario. The timer jobs I've written so far I have scoped by web application (it's just a matter of modifying your feature.xml). However, depending on what your timer job does, it might make sense from a user perspective to have it web or site scoped. You'd only need to make your feature receiver aware of the 'parent' that's passed in the Activated etc. notification handlers -- it will be the SPWeb, SPSite or SPWebApplication that the feature was activated on -- and you could save yourself writing a configuration interface just to have users set which webs your timer job should work with, and which not. Technically you're correct: they always run on the web application level. But since they often work with content that's web or site related, scoping this way might be a useful way to limit the, well, scope of the timer job.

这篇关于计时器作业功能的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆