Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Custom Timer Job Last Run Time not getting exactly

$
0
0

Hi,

I am getting to get the timer job last run time and displaying on the user control.

For this i am using the method as below

But i am not getting the exact lastruntime of timer job.

I tried to use DateTime.Now but problem is it is getting machine time who is running the job.

I am expecting the last run time of timer job of application server where it is running.

Please let me know if i can change anything in the below line

LastRunTime = e.LastRunTime.ToString(),                                  

private List<JobInfo> PopulateJobInfo()

        {

            SPWebApplication webApp = default(SPWebApplication);

            List<JobInfo> jobs = default(List<JobInfo>);

            try

            {

                using (SPSite site = new SPSite(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 => new JobInfo()

                                {

                                    JobID = e.Id,

                                    JobName = e.Title,

                                    JobDescription = e.Description,                                   

                                    LastRunTime = e.LastRunTime.ToString(),                                   

                                    JobStatus = e.Status == SPObjectStatus.Online ? truefalse,

                                    JobStatusText = e.Status.ToString(),

                                    Job = e,                                   

                                    ContentDatabaseID = site.ContentDatabase.Id                                   

                                }).ToList();

                    });

                }

            }

            catch (Exception ex)

            {

                Response.Write(ex.Message);

            }


Thanks & Regards, Sudheer


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>