Skip to content

Instantly share code, notes, and snippets.

@splessons
Created December 13, 2013 10:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save splessons/7942491 to your computer and use it in GitHub Desktop.
Save splessons/7942491 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace customtimerjob.SPJobs
{
class SPTImerJobClass : SPJobDefinition
{
public SPTImerJobClass() : base() { }
public SPTImerJobClass(string jobName, SPService service): base(jobName, service, null, SPJobLockType.None)
{
this.Title = "Task Complete Timer";
}
public SPTImerJobClass(string jobName, SPWebApplication webapp): base(jobName, webapp, null, SPJobLockType.ContentDatabase)
{
this.Title = "Task Complete Timer";
}
public override void Execute(Guid targetInstanceId)
{
SPWebApplication webapp = this.Parent as SPWebApplication;
SPList tasklist = webapp.Sites[0].RootWeb.Lists["Tasks"];
SPListItem newTask = tasklist.Items.Add();
newTask["Title"] = "New Task" + DateTime.Now.ToString();
newTask.Update();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment