C# application obtain results of program it executes
-
I have a question about how to obtain the results, condition codes and messages from a C# 2008 console application. Basically I have received the C# 2008 console application code that calls a remote webservice and consumes the results. The console application runs by giving it commands to know what method in the web service to call. Now I am going to write a C# 2010 service application that will call the C# 2008 console and run the commands in a specificed order. There are three types of calls that need to be called in a specified order. This new application will call the console application by executing the commands in a spcific order. However, I would like to know how this new application can obtain the results of the console application. How will the console application pass it's results back to my new application? Would it be better if I put the code I am describing in the application I am referring to? If so, can you tell me why and how to accomplsih that task?
-
I have a question about how to obtain the results, condition codes and messages from a C# 2008 console application. Basically I have received the C# 2008 console application code that calls a remote webservice and consumes the results. The console application runs by giving it commands to know what method in the web service to call. Now I am going to write a C# 2010 service application that will call the C# 2008 console and run the commands in a specificed order. There are three types of calls that need to be called in a specified order. This new application will call the console application by executing the commands in a spcific order. However, I would like to know how this new application can obtain the results of the console application. How will the console application pass it's results back to my new application? Would it be better if I put the code I am describing in the application I am referring to? If so, can you tell me why and how to accomplsih that task?
-
I have a question about how to obtain the results, condition codes and messages from a C# 2008 console application. Basically I have received the C# 2008 console application code that calls a remote webservice and consumes the results. The console application runs by giving it commands to know what method in the web service to call. Now I am going to write a C# 2010 service application that will call the C# 2008 console and run the commands in a specificed order. There are three types of calls that need to be called in a specified order. This new application will call the console application by executing the commands in a spcific order. However, I would like to know how this new application can obtain the results of the console application. How will the console application pass it's results back to my new application? Would it be better if I put the code I am describing in the application I am referring to? If so, can you tell me why and how to accomplsih that task?
I think it would be better to reorganize your code. The console project you wrote really should be a library/API, if you're going to consume it from another application (ie, the windows service). I'd suggest converting your console application into a class library project. Then, both the windows service and console can create their own implementations. So, let's say you execute the console app like this: myconsoleapp.exe "servicename" Then, create a library project with a public method "RunService":
public class MyAPI { public string ExecuteService(string serviceName) { // logic goes here } }
Now both the console app, and your new windows service can consume MyAPI as needed.
-
I think it would be better to reorganize your code. The console project you wrote really should be a library/API, if you're going to consume it from another application (ie, the windows service). I'd suggest converting your console application into a class library project. Then, both the windows service and console can create their own implementations. So, let's say you execute the console app like this: myconsoleapp.exe "servicename" Then, create a library project with a public method "RunService":
public class MyAPI { public string ExecuteService(string serviceName) { // logic goes here } }
Now both the console app, and your new windows service can consume MyAPI as needed.
dbaseman wrote:
Now both the console app, and your new windows service can consume MyAPI as needed
Of course it would require quite a bit more work than that. After all it probably takes input, and that would need to be dealt with. And it definitely creates output, which the OP mentioned, and that too would need to be dealt with.
-
I have a question about how to obtain the results, condition codes and messages from a C# 2008 console application. Basically I have received the C# 2008 console application code that calls a remote webservice and consumes the results. The console application runs by giving it commands to know what method in the web service to call. Now I am going to write a C# 2010 service application that will call the C# 2008 console and run the commands in a specificed order. There are three types of calls that need to be called in a specified order. This new application will call the console application by executing the commands in a spcific order. However, I would like to know how this new application can obtain the results of the console application. How will the console application pass it's results back to my new application? Would it be better if I put the code I am describing in the application I am referring to? If so, can you tell me why and how to accomplsih that task?
I never really liked console apps, here is what I would do. Create a windows forms app that will allow you to input information, a button and a display control. The input will be specific to our needs and set the defaults to the test information. The button will call the method you use in the console app The output (I usually use a listbox ot a textbox) will take the output you are currently using. I find this the easiest way to debug an console app that has been snaffled from the interweb. Make sure you keep all your processing (the console methods) in a seperate class as it is then easy to create a library class from that (as jschell suggested).
Never underestimate the power of human stupidity RAH
-
dbaseman wrote:
Now both the console app, and your new windows service can consume MyAPI as needed
Of course it would require quite a bit more work than that. After all it probably takes input, and that would need to be dealt with. And it definitely creates output, which the OP mentioned, and that too would need to be dealt with.
-
Right, of course, but my point is that it's far better to interact with an API, than trying to parse the output from a console application.
dbaseman wrote:
but my point is that it's far better
No not really. Sometime it can be much better not to do it that way. For example, if one has a server and one needs to interact with unmanaged C++ code in C# where the C++ code is known to be flaky (or even might be.) Because one doesn't want the server to exit every time the C++ code throws a system exception. Or because one doesn't have the original code. Or doesn't have a license to modify it. Or because one has a number of applications, all supporting the same idiom (console) and a single solution versus numerous others is more cost effective.
-
dbaseman wrote:
but my point is that it's far better
No not really. Sometime it can be much better not to do it that way. For example, if one has a server and one needs to interact with unmanaged C++ code in C# where the C++ code is known to be flaky (or even might be.) Because one doesn't want the server to exit every time the C++ code throws a system exception. Or because one doesn't have the original code. Or doesn't have a license to modify it. Or because one has a number of applications, all supporting the same idiom (console) and a single solution versus numerous others is more cost effective.