/[projects]/dao/DaoMqPump2/DaoMqPump2/MainProgram.cs
ViewVC logotype

Contents of /dao/DaoMqPump2/DaoMqPump2/MainProgram.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2161 - (show annotations) (download)
Fri May 16 16:05:47 2014 UTC (10 years ago) by torben
File size: 4202 byte(s)
Codesync

1 using System;
2 using System.Collections;
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
14 //Create a Console App - remember to add the System.ServiceProcess assembly to references
15
16 namespace DaoMqPump2
17 {
18
19
20 class MainProgram
21 {
22 public enum LoadLibraryFlags : uint
23 {
24 DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
25 LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
26 LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
27 LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
28 LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
29 LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
30 }
31
32 [DllImport("Kernel32.dll", CallingConvention = CallingConvention.StdCall)]
33 public static extern bool AddDllDirectory(String lpPathName);
34
35 [DllImport("kernel32.dll")]
36 static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryFlags dwFlags);
37
38
39 static void Main(string[] args)
40 {
41 //AddDllDirectory("c:\\Program Files\\IBM\\Websphere MQ\\bin");
42
43 /*string libPath = "c:\\Program Files\\IBM\\Websphere MQ\\bin\\mqic32.dll";
44
45 IntPtr res = LoadLibraryEx(libPath, IntPtr.Zero, LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH);
46
47 if (res == IntPtr.Zero)
48 {
49 EventLog.WriteEntry("DaoMqPump2", "error loading " + libPath, EventLogEntryType.Warning);
50 Console.WriteLine("Error loading library");
51 Console.ReadKey(); //wait for user input
52 return;
53 }*/
54
55 if (args.Length == 1)
56 {
57 if (args[0] == "--debug")
58 {
59 try
60 {
61
62
63 TransportController controller = TransportController.getInstance();
64
65 ElapsedTimer timer = new ElapsedTimer();
66 controller.transportAllMessages();
67
68 timer.stopAndPrint("debug run");
69
70 PumpService s = new PumpService();
71
72 s.startRemoteControl();
73 }
74 catch (Exception e)
75 {
76 Console.WriteLine("Error: " + e.Message);
77 }
78
79
80
81
82
83 Console.WriteLine("Press any key to continue");
84 Console.ReadKey(); //wait for user input
85 }
86 else if (args[0] == "/i" || args[0] == "/u")
87 {
88
89 bool undo;
90 if (args[0] == "/i")
91 {
92 undo = false;
93 }
94 else
95 {
96 undo = true;
97 }
98 MyServiceInstaller.DoInstall(undo, new string[] { });
99 }
100 else
101 {
102 Console.WriteLine("DaoMqPumpv2 by THN");
103 Console.WriteLine("Options:");
104 Console.WriteLine(" --debug start a single run debug session");
105 Console.WriteLine(" /i install as a service");
106 Console.WriteLine(" /u un-install service");
107 }
108
109 }
110 else
111 {
112 PumpService service = new PumpService();
113
114
115 // now run all the service that we have created.
116 // This doesn't actually cause the services
117 // to run but it registers the services with the
118 // Service Control Manager so that it can
119 // when you start the service the SCM will call
120 // the OnStart method of the service.
121
122 ServiceBase.Run(service);
123 }
124
125 }
126 }
127 }

  ViewVC Help
Powered by ViewVC 1.1.20