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