如何检查计划项目正在列表计划SQL Server代理作业C#中运行

时间:2021-02-23 14:39:00

I am using SQL server Agent in C#. My job has 3 Schedule, i set one Schedule runs ahead. How to check name of Schedule running. Thanks you. This is code:

我在C#中使用SQL Server Agent。我的工作有3个时间表,我设置了一个时间表。如何检查计划运行的名称。谢谢。这是代码:

private void timer1_Tick(object sender, EventArgs e)
{
            JobSQL.Refresh();
            if (JobSQL.CurrentRunStatus == JobExecutionStatus.Executing)
            {
                List<JobSchedule> listSchedule = new List<JobSchedule>();
                foreach (JobSchedule JobSchedule in JobSQL.JobSchedules)
                {
                    if (JobSchedule.IsEnabled == true)
                    {
                        listSchedule.Add(JobSchedule);
                    }
                }

                foreach (JobSchedule item in listSchedule)
                {
                    MessageBox.Show("Schedule run is -----" + item.Name.ToString());
                }
            }
}

1 个解决方案

#1


0  

I solve my proplem. I just check Job.LastRunDate for my proplem

我解决了我的问题。我只是检查Job.LastRunDate我的问题

#1


0  

I solve my proplem. I just check Job.LastRunDate for my proplem

我解决了我的问题。我只是检查Job.LastRunDate我的问题