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

Annotation of /dao/DaoMqPump2/DaoMqPump2/MainProgram.cs

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20