Hi,
I have my code here below. I need to check if the job is currently running. I found when I get the job variable there is a bool "NotStartIfRunning" but this doesnt appear to be what I need. I need a result to tell me if job is Running, Failed, or Success but I can't seem to figure out how to return this.
// create Server object that holds all VisualCron objects like Jobs, Credentials, Connections etc.
Server s = new Server();
// create Client object that is used to connect to the Server
Client c = new Client();
// create a Connection object which tells how VisualCron should connect
Connection conn = new Connection();
// use remote connection method to connect to a Server instance on another computer (default local connection)
conn.ConnectionType = Connection.ConnectionT.Remote;
// specify the DNS name or IP of remote server
conn.Address = "xxx.xx.xx.xxx";
// specify username you want connect as (default "admin") - user must exist in the Manage user Permissions window at Server
conn.UserName = "admin";
// specify password you want to connect with (default empty)
conn.PassWord = "";
// set below to true if you want to connect with your AD credentials (must be setup on Server to support) - if set you ignore setting username and password
//conn.UseADLogon = true;
// connect to Server, set sync to true to get all Server objects
var connTest = c.Connect(conn, true);
s = connTest;
var lJob = s.Jobs.GetJobByName("Sleep Testing");
var lJobId = lJob.Id;
if (lJob.NotStartIfRunning)
{
lMessage = "currently running.";
return Json(new { msg = lMessage }, JsonRequestBehavior.AllowGet);
}
s.Jobs.Run(lJobId, false);
// finally disconnect
s.Disconnect();