public Job.Job CreateJob( string name, string config_xml) { Trace.TraceInformation("Creating job: {0} with Config xml: {2}{1}{2}", name, config_xml, Environment.NewLine); Login(); Job.Job jobinfo = null; // GetJobInfo(name); if (jobinfo == null) { Cookie session_id = AuthCookies.GetCookies(new Uri(ServerUrl)).Cast <Cookie>().First(x => x.Name == "_session_id"); string response = SendPostRequest( ServerUrl + String.Format(Queries.CREATE_JOB, HttpUtility.UrlEncode(name)), String.Format("data={0}&_session_id={1}", HttpUtility.UrlEncode(config_xml), HttpUtility.UrlEncode(session_id.Value)), "application/x-www-form-urlencoded"); //Console.WriteLine(response); if (response != null) { jobinfo = GetJobInfo(name); } } return(jobinfo); }
public Job.Job GetJobInfo(string name, bool rethrow = false) { Login(); string response = SendGetRequest(ServerUrl + String.Format(Queries.JOB_INFO, HttpUtility.UrlEncode(name)), rethrow: rethrow); //Console.WriteLine(response); Job.Job jobInfo = null; if (response != null) { try { jobInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <Job.Job>(response); } catch (Newtonsoft.Json.JsonException ex) { Trace.TraceError(ex.ToString()); if (rethrow) { throw; } } } return(jobInfo); }