In my web application level feature, its activated, but unable to see teh timer job in the timerjob definitions, in monitoring so i went with activating feature with powershell, receiving this error:
Getting error while activating timer job feature:
PS C:\Windows\system32> E:\PoCSolutions\enable-feature-TestingTimerJob-Feature.ps1 enable-spfeature : The Feature is not a Farm Level Feature and is not found in a Site level defined by the Url http://srvr1:28516/.
- enable-spfeature -Identity "TestingTimerJobFeature" -Url "http://srvr01: ...
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidData: (Microsoft.Share...etEnableFeature:SPCmdletEnableFeature) [Enable-SPFeature], SPCmdletException
- FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletEnableFeature
private bool CreateJob(SPWebApplication site)
{
bool jobCreated = false;
try
{
TestingSPTimerJob.TestingSPTimer timerjobrilt1 = new
TestingSPTimerJob.TestingSPTimer(JobName, site);
SPDailySchedule jobDailySchedule = new SPDailySchedule();
jobDailySchedule.BeginHour = 24;
jobDailySchedule.BeginMinute = 02;
jobDailySchedule.BeginSecond = 1;
timerjobrilt1.Schedule = jobDailySchedule;
timerjobrilt1.Update();
}
catch (Exception)
{
return jobCreated;
}
return jobCreated;
}
######################################################################### public class TestingSPTimer :SPJobDefinition {
public TestingSPTimer()
: base()
{ }
public TestingSPTimer(string jobName, SPService service)
: base(jobName, service, null, SPJobLockType.Job)
{
this.Title = "Testing SPTimerJob";
}
public TestingSPTimer(string jobName, SPWebApplication webapp)
: base(jobName, webapp, null, SPJobLockType.Job)
{
this.Title = "Testing SPTimerJob";
}
public override void Execute(Guid targetInstanceId)
{
SPWebApplication webApp = this.Parent as SPWebApplication;
string strwebappname = webApp.Name.ToString();
foreach (SPSite singleSite in webApp.Sites)
{
if (singleSite.ContentDatabase.Id.Equals(targetInstanceId))
{
SPList objListProjRequest =
singleSite.RootWeb.Lists.TryGetList("TestingTimerJob");
SPWeb objspweb = singleSite.RootWeb;
SPListItem singleitemm= objListProjRequest.Items.Add();
singleitemm["Title"] = "Testingtimer_" +
DateTime.Now.ToString();
singleitemm.Update();