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