Sharepoint 2007 如何在MOSS上安装自定义SharePoint计时器作业

Sharepoint 2007 如何在MOSS上安装自定义SharePoint计时器作业,sharepoint-2007,Sharepoint 2007,如何在MOSS上安装自定义SharePoint计时器作业 你好,我创造了, 自定义SharePoint计时器作业, 下面是我的代码 我编写并安装了很多 网页部件 但这是我第一次写作 MOSS上的SharePoint计时器作业 我尝试在wspBuilder中部署它, 尝试将其复制到gac, 但该作业未显示在上的作业列表中 中央管理局网站, 中央管理>操作>计时器作业定义, 我如何添加它并在屏幕上看到它 中央管理>操作>计时器作业定义 密码 using System; using System.Co

如何在MOSS上安装自定义SharePoint计时器作业

你好,我创造了, 自定义SharePoint计时器作业, 下面是我的代码

我编写并安装了很多 网页部件

但这是我第一次写作 MOSS上的SharePoint计时器作业

我尝试在wspBuilder中部署它, 尝试将其复制到gac, 但该作业未显示在上的作业列表中 中央管理局网站, 中央管理>操作>计时器作业定义,
我如何添加它并在屏幕上看到它

中央管理>操作>计时器作业定义 密码

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Administration;
using System.IO;
using Microsoft.SharePoint;
namespace WSPBuilderProject1.FeatureCode
{
    public class MyTimerJob : SPJobDefinition
    {
        public MyTimerJob()
            : base()
        {
            this.Title = "My Timer Job";
        }

        public MyTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType)
            : base(jobName, service, server, targetType)
        {
            this.Title = "My Timer Job";
        }

        public MyTimerJob(string jobName, SPWebApplication webApplication)
            : base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
        {
            this.Title = "My Timer Job";
        }


        public override void Execute(Guid contentDbId)
        {

            using (SPWeb oWeb = SPContext.Current.Site.OpenWeb("/"))
            {
                SPWeb mySite = SPContext.Current.Web;
                mySite.AllowUnsafeUpdates = true;
                SPListItemCollection listItems = mySite.Lists["AuditLogCalculatedData"].Items;
                int itemCount = listItems.Count;

                for (int k = 0; k < itemCount; k++)
                {
                    try
                    {
                        listItems.Delete(k);
                    }
                    catch { }
                }


                    SPListItem item = listItems.Add();

                    item["FileName"] = "roi";
                    item["NumOfEntries"] = 10102;


                    item.Update();

                mySite.AllowUnsafeUpdates = false;

            }

        }
    }
}
使用系统;
使用System.Collections.Generic;
使用系统文本;
使用Microsoft.SharePoint.Administration;
使用System.IO;
使用Microsoft.SharePoint;
命名空间WSPBuilderProject1.FeatureCode
{
公共类MyTimerJob:SPJobDefinition
{
公共MyTimerJob()
:base()
{
this.Title=“我的计时器作业”;
}
公共MyTimerJob(字符串jobName、SPSService服务、SPSServer服务器、SPJobLockType targetType)
:base(作业名、服务、服务器、目标类型)
{
this.Title=“我的计时器作业”;
}
公共MyTimerJob(字符串jobName,SPWebApplication webApplication)
:base(jobName、webApplication、null、SPJobLockType.ContentDatabase)
{
this.Title=“我的计时器作业”;
}
公共重写无效执行(Guid contentDbId)
{
使用(SPWeb oWeb=SPContext.Current.Site.OpenWeb(“/”)
{
SPWeb mySite=SPContext.Current.Web;
mySite.AllowUnsafeUpdates=true;
SPListItemCollection listItems=mySite.List[“AuditLogCalculatedData”].Items;
int itemCount=listItems.Count;
for(int k=0;k
解决方案 如果你仔细阅读这篇文章,有一个压缩的解决方案文件(),你可以自己使用和编译

VS2008将提示您将项目转换为2008,只需执行并编译即可

建设项目 无法生成的问题存在于文件BuildSharePointPackage.Targets中。MakeCabPath对您的环境无效。我的makecab.exe位于
C:\Windows\system32
路径中。我试图改变路径并重建,但没有成功,它试图使用旧的位置。因此,我刚刚将makecab.exe复制到
C:\Program Files\Microsoft Cabinet SDK\bin
,并成功构建了它

WSPBuilder 此外,您可能希望使用WSPBuilder来减轻创建SharePoint解决方案的痛苦。它安装visual studio扩展,您可以使用该扩展创建wsp文件并从visual studio部署,并使用

解决方案 如果你仔细阅读这篇文章,有一个压缩的解决方案文件(),你可以自己使用和编译

VS2008将提示您将项目转换为2008,只需执行并编译即可

建设项目 无法生成的问题存在于文件BuildSharePointPackage.Targets中。MakeCabPath对您的环境无效。我的makecab.exe位于
C:\Windows\system32
路径中。我试图改变路径并重建,但没有成功,它试图使用旧的位置。因此,我刚刚将makecab.exe复制到
C:\Program Files\Microsoft Cabinet SDK\bin
,并成功构建了它

WSPBuilder
此外,您可能希望使用WSPBuilder来减轻创建SharePoint解决方案的痛苦。它安装visual studio扩展,您可以使用该扩展创建wsp文件并从visual studio部署,并使用

这是可以在
FeatureActivated
事件上执行的示例代码

public override void FeatureActivated (SPFeatureReceiverProperties props) {
  SPWebApplication webApp = props.Feature.Parent as SPWebApplication;
  if (webApp == null)
    throw new SPException("Error obtaining reference to Web application.");

  // Ensure the job is not already registered.
  foreach (SPJobDefinition job in webApp.JobDefinitions)
    if (job.Name == JOB_NAME) job.Delete();

  // Install job.
  SharePointWarmupJob warmupJob = new SharePointWarmupJob(webApplication);

  // Schedule the job to run every minute all the time.
  SPMinuteSchedule schedule = new SPMinuteSchedule();
  schedule.BeginSecond = 0;
  schedule.EndSecond = 59;
  schedule.Interval = 1;
  warmupJob.Schedule = schedule;

  // Save changes.
  warmupJob.Update();
}

这是可在
FeatureActivated
事件上执行的示例代码

public override void FeatureActivated (SPFeatureReceiverProperties props) {
  SPWebApplication webApp = props.Feature.Parent as SPWebApplication;
  if (webApp == null)
    throw new SPException("Error obtaining reference to Web application.");

  // Ensure the job is not already registered.
  foreach (SPJobDefinition job in webApp.JobDefinitions)
    if (job.Name == JOB_NAME) job.Delete();

  // Install job.
  SharePointWarmupJob warmupJob = new SharePointWarmupJob(webApplication);

  // Schedule the job to run every minute all the time.
  SPMinuteSchedule schedule = new SPMinuteSchedule();
  schedule.BeginSecond = 0;
  schedule.EndSecond = 59;
  schedule.Interval = 1;
  warmupJob.Schedule = schedule;

  // Save changes.
  warmupJob.Update();
}

你能说出你所面临的问题吗?Webpart是一个UI元素。TimerJobs不显示任何接口。你到底想要实现什么?您希望计时器作业执行什么操作?请指定sharepoint版本。您能告诉我们您面临的问题吗?Webpart是一个UI元素。TimerJobs不显示任何接口。你到底想要实现什么?您希望计时器作业执行什么操作?请指定sharepoint版本。创建一个功能,并将其放入该功能的featureactivated事件SharePointWarmupJob的用途是什么它显示错误4找不到类型或命名空间名称“SharePointWarmupJob”(您是否缺少using指令或程序集引用?)SharePointWarmupJob是您的自定义计时器作业类。根据您的示例,它是“MyTimerJob”。此代码示例回答如何注册计时器作业。使用本文了解如何将功能激活事件挂接到计时器作业功能:创建一个功能并将其放入该功能的功能激活事件SharePointWarmupJob的用途是什么它表示错误4找不到类型或命名空间名称“SharePointWarmupJob”(是否缺少using指令或程序集引用?)SharePointWarmupJob是您的自定义计时器作业类。根据您的示例,它是“MyTimerJob”。此代码示例回答如何注册计时器作业。使用本文了解如何将该功能激活的事件挂接到计时器作业功能:当命令“C:\Program Files\Microsoft Cabinet SDK\BIN\MAKECAB.EXE”/F BuildSharePointPackage.ddf/D CabinetNameTemplate=AndrewConnell.TaskLoggerJob.wsp/D DiskDirectory1=BIN\Debug\spackage\”退出时,代码为3。任务记录工和我在国际米兰找不到