最近在看Andrew Connell的一篇关于timer job的文章,http://www.andrewconnell.com/blog/articles/CreatingCustomSharePointTimerJobs.aspx 其中讲到了如何用feature来对一个新的timer job进行部署。这里使用到了如何添加feature event handler。这里就利用学习timer job 的机会,也写写如何自定义一个feature的event handler
    与feature自身相关的event有四种安装 删除 激活 取消。我们就是利用activate的时候,来控制对job的设置,利用deactivate的时候,将指定的job删除。
    1.在VS中创建一个class library的工程。在reference中加入Microsoft.sharepoint.dll,这个dll可以在C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI下找到。
    
    
我所知道的SharePoint feature(3)using System;
我所知道的SharePoint feature(3)
using System.Collections.Generic;
我所知道的SharePoint feature(3)
using System.Linq;
我所知道的SharePoint feature(3)
using System.Text;
我所知道的SharePoint feature(3)
using Microsoft.SharePoint;
我所知道的SharePoint feature(3)
using Microsoft.SharePoint.Administration;
我所知道的SharePoint feature(3)
我所知道的SharePoint feature(3)
namespace TimerJobDemo

        以上就是feature event handler的代码,我们可以看到,在featurereceiver中我们需要重载四个不同时期的函数,但是我们只是对其中的featureactivate进行了完整的实现。
        2.在同一个工程中新建一个文件夹,命名为TimerJobDemo,创建一个Feature.xml(具体的过程可以参看前面的两篇)
        这个feature的任务就是创建,并注册一个新的timer job,所以这个feature十分的简单。相比前面提到的feature,它多了两个十分主要的属性。
    
我所知道的SharePoint feature(3)<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="TimerJobDemo" Id="2D301FC8-DB43-4d5e-93DE-8F722054F4EE" ReceiverAssembly="TimerJobDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=80614946b1f438b6" ReceiverClass="TimerJobDemo.TimerJobDemoFeature" Scope="WebApplication"/>
    这个就是这个feature的全部内容,只有一个节点。Titile ID等属性我们前面都已经提到了,这里出现两个新的属性,就是ReceiverAssembly 和ReceiverClass。ReceiverAssembly 指定的是FeatureReceiver所在的程序集,而ReceiverClass指定的是FeatureReceiver所在的类。在激活feature前,我们需要将已经强签名的程序集Gac。然后安装和激活feature。激活后,我们到前面代码中提到的list中,看看是不是多了一个新的item。
    我所知道的SharePoint feature(3)
        

相关文章:

  • 2021-11-30
  • 2021-09-07
  • 2021-08-15
  • 2022-02-27
  • 2022-02-01
  • 2022-12-23
  • 2021-08-12
  • 2022-02-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2021-12-01
  • 2021-09-16
  • 2022-12-23
  • 2022-01-19
相关资源
相似解决方案