1 |
using System; |
using System; |
2 |
using System.Collections.Generic; |
using System.Collections.Generic; |
3 |
using System.Text; |
using System.IO; |
4 |
|
using System.Text.RegularExpressions; |
5 |
|
|
6 |
|
using Microsoft.Win32; |
7 |
|
|
8 |
namespace MQFilter |
namespace MQFilter |
9 |
{ |
{ |
10 |
class FilterController |
class FilterController |
11 |
{ |
{ |
12 |
|
|
13 |
|
public string mqHost { get; private set; } |
14 |
|
public string mqChannel { get; private set; } |
15 |
|
public string mqQueueManager { get; private set; } |
16 |
|
|
17 |
|
public string logDirectory { get; private set; } |
18 |
|
|
19 |
|
public string[] filterTranscations { get; private set; } |
20 |
|
|
21 |
|
|
22 |
|
protected FilterController() |
23 |
|
{ |
24 |
|
initialize(); |
25 |
|
} |
26 |
|
|
27 |
|
private void initialize() |
28 |
|
{ |
29 |
|
Console.WriteLine("FilterController: Loading config"); |
30 |
|
RegistryKey key = Registry.LocalMachine.CreateSubKey("Software\\DAO\\MQFilter"); |
31 |
|
|
32 |
|
|
33 |
|
//Læser globale MQ Parametre |
34 |
|
mqHost = (string)key.GetValue("MQHost"); |
35 |
|
if (mqHost == null || mqHost.Length == 0) |
36 |
|
throw new System.ArgumentException("MQHost cannot be null or empty"); |
37 |
|
|
38 |
|
mqChannel = (string)key.GetValue("MQChannel"); |
39 |
|
if (mqChannel == null || mqChannel.Length == 0) |
40 |
|
throw new System.ArgumentException("MQChannel cannot be null or empty"); |
41 |
|
|
42 |
|
mqQueueManager = (string)key.GetValue("MQQueueManager"); |
43 |
|
if (mqQueueManager == null || mqQueueManager.Length == 0) |
44 |
|
throw new System.ArgumentException("MQQueueManager cannot be null or empty"); |
45 |
|
|
46 |
|
//Læser øvrige parametre |
47 |
|
|
48 |
|
logDirectory = (string)key.GetValue("LogDirectory"); |
49 |
|
if (logDirectory == null || logDirectory.Length == 0) |
50 |
|
throw new System.ArgumentException("LogDirectory cannot be null or empty"); |
51 |
|
|
52 |
|
String tmpFilterTransactions = (string)key.GetValue("FilterTransactions"); |
53 |
|
if (tmpFilterTransactions == null || tmpFilterTransactions.Length == 0) |
54 |
|
throw new System.ArgumentException("LogDirectory cannot be null or empty"); |
55 |
|
filterTranscations = Regex.Split( tmpFilterTransactions, "," ); |
56 |
|
|
57 |
|
for (int i = 0; i < filterTranscations.Length; i++) |
58 |
|
{ |
59 |
|
filterTranscations[i] = filterTranscations[i].Trim(); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
if (Directory.Exists(logDirectory) == false) |
64 |
|
{ |
65 |
|
Directory.CreateDirectory(logDirectory); |
66 |
|
} |
67 |
|
|
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
public void transportAllMessages() |
public void transportAllMessages() |
73 |
{ |
{ |
74 |
} |
} |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
/* Singleton */ |
/* Singleton */ |
79 |
private static FilterController instance = null; |
private static FilterController instance = null; |
80 |
public static FilterController getInstance() |
public static FilterController getInstance() |