Exemple #1
0
 /// <summary>
 /// Run the specified job
 /// </summary>
 public void Run(object sender, EventArgs e, object[] parameters)
 {
     if (parameters?.Length != this.Parameters?.Count && this.Parameters.Count > 0)
     {
         throw new ArgumentException("Invalid number of arguments to job");
     }
     else
     {
         try
         {
             using (var client = RemoteJobManager.GetRestClient())
             {
                 var parms = new ParameterCollection()
                 {
                     Parameters = parameters?.Select(o => new Parameter("_", o)).ToList()
                 };
                 client.Post <ParameterCollection, ParameterCollection>($"JobInfo/{this.Key}/$start", parms);
             }
         }
         catch (Exception ex)
         {
             throw new Exception($"Error running job {this.Key}", ex);
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// Cancel the job
 /// </summary>
 public void Cancel()
 {
     if (this.CanCancel)
     {
         try
         {
             using (var client = RemoteJobManager.GetRestClient())
                 client.Post <ParameterCollection, ParameterCollection>($"JobInfo/{this.Key}/$cancel", new ParameterCollection());
         }
         catch (Exception e)
         {
             throw new Exception($"Error canceling job {this.Key}", e);
         }
     }
 }