public object B2COutboundDownFile()
{
var obj = new object();
try
{
var jobConnection = new SqlConnection(JobDBConString);
ServerConnection conn = new ServerConnection(jobConnection); //Create SQL server conn, Windows Authentication
Server server = new Server(conn); //Connect SQL Server
var job = server.JobServer.Jobs["Sustainable_B2C_OutBound"];//Get the specified job
var JobStatus = job.CurrentRunStatus.ToString();
//var dataTime = job.LastRunDate.ToString();
if (JobStatus == "Idle")
{
obj = new
{
code = 0,
msg = "Run Start"
};
job.Start();
}
else
{
//该job正在运行中
obj = new
{
code = 1,
msg = "The job is executing,Please try again later!"
};
}
jobConnection.Close();
}
catch (Exception ex)
{
obj = new
{
code = 500,
msg = "Run failed"
};
log.Error("调用Sql Job" + ex);
}
return obj;
}