The Bluespring Command Service automatically generates a Web Service available at: http://<Server Name>:<Port Number>/Bluespring/CmdService/Service.ashx, where <Server Name> is the server on which you installed the Command Service and <Port Number> is the value you entered in the HTTP Server Settings screen during installation.
This Web Service has several associated Methods:
-
Execute
-
BeginExecute
-
GetJobInfo
-
KillJob
The first Method, Execute, initiates a command and waits for a specified period of time to receive a response from the command. The response then updates the values of the output parameters. For example, you may wish to use a command prompt to create a new directory named FileRepository on the root of your C: drive on your Server. To manually complete this action, you would open the Command Prompt on the Server and type: md c:\FileRepository. Using the Command Service, you perform these same actions by providing values for parameters within the Web Service call. So, you "open the Command Prompt" by specifying the fileName: cmd.exe. Then, you "type: md C:\FileRepository" by specifying the value of the argument parameter as, "md C:\FileRepository."
For more complicated commands, you may wish to initiate a command and then periodically check to see if it has completed. To do so, use the BeginExecute Method to initiate your command and the GetJobInfo Method to determine if a command has completed. For example, let's assume you have created a Batch File, C:\FileRepository\LoadFilesToDatabase.bat, which pushes information from comma-delimited files into a database table. Because these files may be large, causing the Batch File to take hours to complete, you decide to initiate the command without waiting for a response and then enter a loop that checks for completion of the command every 5 minutes.
Using the Command Service, you perform these same actions by calling the BeginExecute Method to initiate the command, and then every 5 minutes calling the GetJobInfo Method to determine if the Job has completed. When you call BeginExecute, specify the fileName: cmd.exe and the argument: "C:\FileRepository\LoadFilesToDatabase.bat" and ensure you store the value of the output parameter: Id. Then, you can determine if LoadFilesToDatabase.bat has completed by calling GetJobInfo and specifying the jobId parameter as the value of the recorded Id parameter from your previous call to BeginExecute.
The KillJob Method, then, allows you to stop a command by specifying the parameter: JobId. For example, let's assume you found an error in the LoadFilesToDatabase.bat which prevented the command from completing, even though all comma-delimited files have been loaded into your database.
Using the Command Service, you stop the command by calling the KillJobMethod, specifying the jobId parameter as the value of the recorded Id parameter from your previous call to BeginExecute