using System; using System.Collections.Generic; using System.Text; using System.ServiceProcess; using System.Diagnostics; using System.Configuration.Install; using System.Collections.Specialized; using System.Runtime.InteropServices; using DaoCommon; using IBM.WMQ; namespace MQFilter { class FilterMainProgram { static void Main(string[] args) { if (args.Length == 1) { if (args[0] == "--debug") { try { FilterController controller = FilterController.getInstance(); ElapsedTimer timer = new ElapsedTimer(); controller.transportAllMessages(); timer.stopAndPrint("debug run"); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.WriteLine(e.StackTrace); } 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); } } } }