How do I install custom SharePoint Timer job on MOSS
Hello I created, custom SharePoint Timer job, Below in this document is my code.
I wrote and installed a lot of webparts.
But this is the first time I write SharePoint Timer job on MOSS.
i try to deploy it wite wspBuilder,
try to copy it to gac,
But the JOB not appear on the list JOB on
Central Administration site ,
Central Administration > Operations > Timer Job Definitions ,
how can i add it and see it on the ,
Central Administration > Operations > Timer Job Definitions the code.
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;
}
}
}
}