I am trying to implement a custom timer job in my SP 2013 on-premises
appln.
I have created the same. But the timer job is not appearing in the timer job definitions page.
I have activated and deactivated the feature multiple times, and after doing multiple IISRESET
and sptimer services
restarts, and sp admin service
restarts , the timer job failed to visible.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Administration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
namespace RILTILPTimerJob.RILTTimerJob
{
public class FreezeDocTimerJob :SPJobDefinition
{
HashSet<string> seenUids = new HashSet<string>();
public const string JobName = "FreezeDocument Timer Job";
public FreezeDocTimerJob() : base() { }
public FreezeDocTimerJob(string jobName, SPService service, SPServer
server,SPJobLockType targetType) :
base(jobName, service, server, targetType)
{ }
public FreezeDocTimerJob(string jobName, SPWebApplication webapp,
string strUrl) :
base(jobName, webapp, null, SPJobLockType.ContentDatabase)
{
this.Title = "FreezeDocument Timer Job";
}
/// <summary>
/// execute method of rilt timer job
/// </summary>
/// <param name="ContentDatabaseID"></param>
public override void Execute(Guid ContentDatabaseID)
{
try
{
SPWebApplication webApp = this.Parent as SPWebApplication;
SPList objlistRILTList = webApp.Sites
[0].RootWeb.Lists.TryGetList("RILTLIST");
SPListItem objRILTTaskItem = objlistRILTList.Items.Add();
objRILTTaskItem["Title"] = "New_Task_RILTWFTIMER_" +
DateTime.Now.ToString();
objRILTTaskItem.Update();
}
catch (Exception expinXecute_RILTTimerJob)
{
}
}
}
}