--- dao/DaoMqPump2/MQFilter/FilterMainProgram.cs 2014/05/16 15:44:17 2160 +++ dao/DaoMqPump2/MQFilter/FilterMainProgram.cs 2014/05/16 16:05:47 2161 @@ -1,14 +1,90 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; +using System.ServiceProcess; +using System.Diagnostics; + +using System.Configuration.Install; +using System.Collections.Specialized; +using System.Runtime.InteropServices; + + namespace MQFilter { class FilterMainProgram { static void Main(string[] args) { + + if (args.Length == 1) + { + if (args[0] == "--debug") + { + try + { + + + TransportController controller = TransportController.getInstance(); + + ElapsedTimer timer = new ElapsedTimer(); + controller.transportAllMessages(); + + timer.stopAndPrint("debug run"); + + } + catch (Exception e) + { + Console.WriteLine("Error: " + e.Message); + } + + + + + + Console.WriteLine("Press any key to continue"); + Console.ReadKey(); //wait for user input + } + else if (args[0] == "/i" || args[0] == "/u") + { + + bool undo; + if (args[0] == "/i") + { + undo = false; + } + else + { + undo = true; + } + MyServiceInstaller.DoInstall(undo, new string[] { }); + } + else + { + Console.WriteLine("MQFilter by THN"); + Console.WriteLine("Options:"); + Console.WriteLine(" --debug start a single run debug session"); + Console.WriteLine(" /i install as a service"); + Console.WriteLine(" /u un-install service"); + } + + } + else + { + PumpService service = new PumpService(); + + + // now run all the service that we have created. + // This doesn't actually cause the services + // to run but it registers the services with the + // Service Control Manager so that it can + // when you start the service the SCM will call + // the OnStart method of the service. + + ServiceBase.Run(service); + } + } + } }