Hi,
On the webpart front end,we have provided 'Run' button.So that when administrator can click on this button to run timer job.
Once timer job operation we are displaying time stamp on the page.But the problem is time stamp in the central admin is not getting updated after clicking 'Run' on the webpart.But when we run timer job on central admin through 'Run Now'then time stamp on central admin is getting updated.
Below is the method that has been written for timerjob
Please let me know if i am missing anything to update timerjob time stamp in central admin
privateList<JobInfo> PopulateJobInfo()
{
SPWebApplication webApp =default(SPWebApplication);
List<JobInfo> jobs = default(List<JobInfo>);
try
{
using (SPSite site = newSPSite(SPContext.Current.Web.Url))
{
webApp = site.WebApplication;
//SPSite currentSite = webApp.Sites[0] as SPSite;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
jobs = webApp.JobDefinitions.Where(e => e.Name =="TasktoStore" || e.Name =="BubbleTasks").
Select(e =>newJobInfo()
{
JobID = e.Id,
JobName = e.Title,
JobDescription = e.Description,
LastRunTime = e.LastRunTime.ToString(),
JobStatus = e.Status == SPObjectStatus.Online ?true :false,
JobStatusText = e.Status.ToString(),
Job = e,
ContentDatabaseID = site.ContentDatabase.Id
}).ToList();
});
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Thanks & Regards, Sudheer