1 |
using System;
|
2 |
using System.Collections.Generic;
|
3 |
using System.Text;
|
4 |
|
5 |
using System.ServiceProcess;
|
6 |
using System.Diagnostics;
|
7 |
|
8 |
using System.Configuration.Install;
|
9 |
using System.Collections.Specialized;
|
10 |
using System.Runtime.InteropServices;
|
11 |
|
12 |
|
13 |
namespace MQFilter
|
14 |
{
|
15 |
class FilterMainProgram
|
16 |
{
|
17 |
static void Main(string[] args)
|
18 |
{
|
19 |
|
20 |
if (args.Length == 1)
|
21 |
{
|
22 |
if (args[0] == "--debug")
|
23 |
{
|
24 |
try
|
25 |
{
|
26 |
|
27 |
|
28 |
TransportController controller = TransportController.getInstance();
|
29 |
|
30 |
ElapsedTimer timer = new ElapsedTimer();
|
31 |
controller.transportAllMessages();
|
32 |
|
33 |
timer.stopAndPrint("debug run");
|
34 |
|
35 |
}
|
36 |
catch (Exception e)
|
37 |
{
|
38 |
Console.WriteLine("Error: " + e.Message);
|
39 |
}
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
Console.WriteLine("Press any key to continue");
|
46 |
Console.ReadKey(); //wait for user input
|
47 |
}
|
48 |
else if (args[0] == "/i" || args[0] == "/u")
|
49 |
{
|
50 |
|
51 |
bool undo;
|
52 |
if (args[0] == "/i")
|
53 |
{
|
54 |
undo = false;
|
55 |
}
|
56 |
else
|
57 |
{
|
58 |
undo = true;
|
59 |
}
|
60 |
MyServiceInstaller.DoInstall(undo, new string[] { });
|
61 |
}
|
62 |
else
|
63 |
{
|
64 |
Console.WriteLine("MQFilter by THN");
|
65 |
Console.WriteLine("Options:");
|
66 |
Console.WriteLine(" --debug start a single run debug session");
|
67 |
Console.WriteLine(" /i install as a service");
|
68 |
Console.WriteLine(" /u un-install service");
|
69 |
}
|
70 |
|
71 |
}
|
72 |
else
|
73 |
{
|
74 |
PumpService service = new PumpService();
|
75 |
|
76 |
|
77 |
// now run all the service that we have created.
|
78 |
// This doesn't actually cause the services
|
79 |
// to run but it registers the services with the
|
80 |
// Service Control Manager so that it can
|
81 |
// when you start the service the SCM will call
|
82 |
// the OnStart method of the service.
|
83 |
|
84 |
ServiceBase.Run(service);
|
85 |
}
|
86 |
|
87 |
}
|
88 |
|
89 |
}
|
90 |
}
|