Hi Bill,
Please find my code below
public List<String> getPortfolioNames()
{
List<String> jobs = null;
Application app = new Application();
Scheduler sched = app.ConnectRemote("", "", "");
Job list = (Job)GetJobsForName(sched, "job1);
System.Diagnostics.Debug.WriteLine(list.GetStatus());
return jobs;
}
public static ADTObjects GetJobsForName(Scheduler connection, string jobName)
{
JobByNameFilter filter = new JobByNameFilter(jobName);
Int32 recordCount = default(Int32);
filter.singleGroupOnly = false;
return connection.GetObjectsWhere(filter, 0, true, out recordCount);
}
public class JobByNameFilter: IObjectRequestFilter
{
public string jobName = "";
public bool singleGroupOnly = true;
public JobByNameFilter(string jobName)
{
this.jobName = jobName;
}
public string GetTableName()
{
return "job";
}
public string GetSelectClause()
{
return "*";
}
public string GetWhereClause()
{
if (!singleGroupOnly)
{
//Search for all jobs matching this name, in all job groups
string query = "name='" + jobName + "'";
// System.Diagnostics.Debug.WriteLine(query);
return query;
}
//else we're looking for a single job, located in a specific group
System.Text.RegularExpressions.Match match = default(System.Text.RegularExpressions.Match);
//the name may be just the job name (in which case we look in the root group)
//or it may contain parent group information, delimited by "\"
match = System.Text.RegularExpressions.Regex.Match(jobName, "(?:(.+)\\\\){0,1}([^\\\\]+)");
if (!match.Success)
{
//it's an error, but let the server handle it.
return "name='" + jobName + "'";
}
if (match.Groups[1].Success)
{
//a group hierarchy was specified.
//match.groups(1) contains the group path, e.g., "group 1\group 1a"
//match.groups(2) contains the job name
//Search for the job with the specified name within the specified group.
//the jobGroup table has a "fullName" column that stores its full hierarchical name
return "name='" + match.Groups[2].Value + "' and jobGroup in (select OID from jobGroup where fullName='Root\\" + match.Groups[1].Value + "')";
}
else
{
//else there was no group information specified--the job is in the root.
//match.groups(2) contains the job name, and we search only in the root group,
//which always has the same OID.
return "name='" + match.Groups[2].Value + "' and jobGroup='{2C13CBB7-57D7-44A7-A74C-92B9F92A2A01}:{9A3EA996-9137-4EA7-8CAC-55E70695B473}'";
}
}
public string GetOrderClause()
{
return "";
}
}