Commit f13d7fa30950712036694972fb158231b8025bf7
1 parent
a6a553c9
apró szépészeti javítások
Showing
3 changed files
with
546 additions
and
492 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - MSMQManager - MSMQ.cs deleted
@@ -1,426 +0,0 @@ | @@ -1,426 +0,0 @@ | ||
1 | -using System; | ||
2 | -using System.Collections.Generic; | ||
3 | -using System.Linq; | ||
4 | -using System.Messaging; | ||
5 | -using System.Text; | ||
6 | -using System.Threading.Tasks; | ||
7 | - | ||
8 | -using Vrh.Log4Pro.MaintenanceConsole.MenuNS; | ||
9 | -using Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS; | ||
10 | -using Vrh.Log4Pro.MaintenanceConsole.ToolsNS; | ||
11 | -using Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS; | ||
12 | - | ||
13 | -using Vrh.XmlProcessing; | ||
14 | -using VRH.Common; | ||
15 | -using System.Xml.Linq; | ||
16 | -using System.Text.RegularExpressions; | ||
17 | - | ||
18 | - | ||
19 | -namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
20 | -{ | ||
21 | - public class MSMQ : XmlLinqBase | ||
22 | - { | ||
23 | - #region fields | ||
24 | - public bool Valid = true; | ||
25 | - public string Xml_Key; | ||
26 | - public string Xml_Name; | ||
27 | - public string Xml_AddressPrefix = XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.AddressPrefix.Values.DEFAULT; | ||
28 | - public string Xml_Server = XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Server.Values.DEFAULT; | ||
29 | - public bool Private; | ||
30 | - public string Xml_Mode = XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Mode.Values.DEFAULT; | ||
31 | - public string Xml_Label; | ||
32 | - public string Xml_Formatter = XmlStructure.MSMQManager.General.DefaultFormatter.Values.DEFAULT; | ||
33 | - public string Xml_Encoding = XmlStructure.MSMQManager.General.DefaultEncoding.Values.DEFAULT; | ||
34 | - public List<AccessRights> Xml_AccessRights = new List<AccessRights>(); | ||
35 | - | ||
36 | - public string Status; | ||
37 | - public string StatusDescription=null; | ||
38 | - public Guid Id; | ||
39 | - public string QueueName; | ||
40 | - public long NumOfMessages; | ||
41 | - public string Label; | ||
42 | - public string MachineName; | ||
43 | - public IMessageFormatter Formatter; | ||
44 | - public string FormatName; | ||
45 | - public string Path; | ||
46 | - public DateTime LastModifyTime; | ||
47 | - public QueueAccessMode AccessMode; | ||
48 | - public bool CanRead; | ||
49 | - public bool CanWrite; | ||
50 | - public long MaximumQueueSize; | ||
51 | - public bool UseJournalQueue; | ||
52 | - public long MaximumJournalSize; | ||
53 | - | ||
54 | - public bool Transactional; | ||
55 | - public bool Authenticate; | ||
56 | - public int BasePriority; | ||
57 | - public EncryptionRequired EncryptionRequired; | ||
58 | - #endregion fields | ||
59 | - | ||
60 | - #region basic constructor | ||
61 | - public MSMQ() { } | ||
62 | - #endregion basic constructor | ||
63 | - | ||
64 | - #region constructor from MessageQueue | ||
65 | - public MSMQ(MessageQueue msmq, string key) | ||
66 | - { | ||
67 | - Xml_Key = key; | ||
68 | - Xml_Name = msmq.QueueName; | ||
69 | - Xml_Label = msmq.QueueName; | ||
70 | - Xml_Server = msmq.MachineName; | ||
71 | - Private = msmq.QueueName.ToLower().StartsWith("private$"); | ||
72 | - Xml_Formatter = msmq.Formatter.GetType().Name; | ||
73 | - Xml_AddressPrefix = "FormatName:"+msmq.FormatName.Replace(msmq.MachineName+"\\"+msmq.QueueName,""); | ||
74 | - } | ||
75 | - #endregion constructor from MessageQueue | ||
76 | - | ||
77 | - #region xml constructor | ||
78 | - public MSMQ(XElement msmqxml,MSMQDefaults msmqdefaults) | ||
79 | - { | ||
80 | - Valid = true; | ||
81 | - string ATTRIBUTEMANDATORY = nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue) + " attribute is mandatory! Name: {0}"; | ||
82 | - Xml_Key = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Key), msmqxml, XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Key.Values.DEFAULT); | ||
83 | - Xml_Name = msmqxml.Attribute(XName.Get(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Name)))?.Value; | ||
84 | - if (string.IsNullOrWhiteSpace(Xml_Name)) { throw new ApplicationException(string.Format(ATTRIBUTEMANDATORY, nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Name))); } | ||
85 | - Xml_AddressPrefix = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.AddressPrefix), msmqxml, XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.AddressPrefix.Values.DEFAULT); | ||
86 | - Xml_Server = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Server), msmqxml, XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Server.Values.DEFAULT); | ||
87 | - if (Xml_Server == "." || Xml_Server.ToLower() == "localhost") { Xml_Server = System.Environment.MachineName; } | ||
88 | - | ||
89 | - Private = Xml_Name.StartsWith("private$"); ; | ||
90 | - Xml_Mode = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Mode), msmqxml, XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Mode.Values.DEFAULT); | ||
91 | - Xml_Label = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Label), msmqxml, Xml_Name); | ||
92 | - Xml_Formatter = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Formatter), msmqxml, msmqdefaults.Xml_DefaultFormatter); | ||
93 | - Xml_Encoding = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Encoding), msmqxml, msmqdefaults.Xml_DefaultEncoding); | ||
94 | - | ||
95 | - foreach (var ar in msmqdefaults.Xml_AccessRights) { Xml_AccessRights.Add(ar); } | ||
96 | - try | ||
97 | - { | ||
98 | - var arxmllist = GetAllXElements(msmqxml, nameof(MSMQ.XmlStructure.MSMQManager.MessageQueues.MessageQueue.AccessRight)); | ||
99 | - foreach (var arxml in arxmllist) { var newa = AccessRights.Factory(arxml); if (newa != null) { Xml_AccessRights.Add(newa); } } | ||
100 | - } | ||
101 | - catch{ } | ||
102 | - | ||
103 | - | ||
104 | - } | ||
105 | - #endregion xml constructor | ||
106 | - | ||
107 | - #region Xml cloner constructor | ||
108 | - public MSMQ(MSMQ msmq) | ||
109 | - { | ||
110 | - Valid = msmq.Valid; | ||
111 | - Xml_Key = msmq.Xml_Key; | ||
112 | - Xml_Name = msmq.Xml_Name; | ||
113 | - Xml_Server = msmq.Xml_Server; | ||
114 | - Private = msmq.Private; | ||
115 | - Xml_Mode = msmq.Xml_Mode; | ||
116 | - Xml_Label = msmq.Xml_Label; | ||
117 | - Xml_Formatter= msmq.Xml_Formatter; | ||
118 | - Xml_Encoding = msmq.Xml_Encoding; | ||
119 | - } | ||
120 | - #endregion Xml cloner constructor | ||
121 | - | ||
122 | - #region CollectMSMQInfo | ||
123 | - public MSMQ CollectMSMQInfo() | ||
124 | - { | ||
125 | - MSMQ msmqdef = this; | ||
126 | - string msmqaddressprefix = msmqdef.Xml_AddressPrefix; | ||
127 | - string msmqservername = msmqdef.Xml_Server; | ||
128 | - string msmqFullname = MSMQManagerCore.CreateFullQueuePath(msmqaddressprefix, msmqservername, msmqdef.Xml_Name); | ||
129 | - msmqdef.QueueName = msmqdef.Xml_Name; | ||
130 | - msmqdef.MachineName = msmqservername; | ||
131 | - msmqdef.Path = msmqFullname; | ||
132 | - try | ||
133 | - { | ||
134 | - msmqdef.Status = MessageQueue.Exists(msmqFullname) ? "Installed" : "Uninstalled"; | ||
135 | - if (msmqdef.Status == "Installed") | ||
136 | - { | ||
137 | - using (var msmq = new MessageQueue(msmqFullname)) | ||
138 | - { | ||
139 | - msmqdef.QueueName = msmq.QueueName; | ||
140 | - msmqdef.MachineName = msmq.MachineName; | ||
141 | - | ||
142 | - msmqdef.Id = msmq.Id; | ||
143 | - msmqdef.NumOfMessages = MSMQManagerCore.Count(msmq); | ||
144 | - msmqdef.Label = msmq.Label; | ||
145 | - msmqdef.Formatter = msmq.Formatter; | ||
146 | - msmqdef.FormatName = msmq.FormatName; | ||
147 | - msmqdef.Path = msmq.Path; | ||
148 | - msmqdef.LastModifyTime = msmq.LastModifyTime; | ||
149 | - msmqdef.AccessMode = msmq.AccessMode; | ||
150 | - msmqdef.CanRead = msmq.CanRead; | ||
151 | - msmqdef.CanWrite = msmq.CanWrite; | ||
152 | - msmqdef.MaximumQueueSize = msmq.MaximumQueueSize; | ||
153 | - msmqdef.UseJournalQueue = msmq.UseJournalQueue; | ||
154 | - msmqdef.MaximumJournalSize = msmq.MaximumJournalSize; | ||
155 | - | ||
156 | - msmqdef.Transactional = msmq.Transactional; | ||
157 | - msmqdef.Authenticate = msmq.Authenticate; | ||
158 | - msmqdef.BasePriority = msmq.BasePriority; | ||
159 | - msmqdef.EncryptionRequired = msmq.EncryptionRequired; | ||
160 | - | ||
161 | - msmqdef.Status = "Ready"; | ||
162 | - } | ||
163 | - } | ||
164 | - } | ||
165 | - catch (Exception ex) { msmqdef.Status = "Error"; msmqdef.StatusDescription = ex.Message + (ex.InnerException != null ? ("\n" + ex.InnerException.Message) : ""); } | ||
166 | - return msmqdef; | ||
167 | - } | ||
168 | - #endregion CollectMSMQInfo | ||
169 | - | ||
170 | - public string DisplayVeryShortInfo(int lineix) | ||
171 | - { | ||
172 | - MSMQ msmq = this; | ||
173 | - if (lineix == 0) | ||
174 | - { | ||
175 | - ColorConsole.Write($"{msmq.Xml_Name}", ConsoleColor.Black, ConsoleColor.White, prefix: "Queue '", suffix: $"' queue label: '{msmq.Xml_Label}'."); | ||
176 | - ConsoleColor statuscolor; | ||
177 | - if (msmq.Status == "Uninstalled") { statuscolor = ConsoleColor.Red; } | ||
178 | - else if (msmq.Status == "Error") { statuscolor = ConsoleColor.Red; } | ||
179 | - else if (msmq.Status == "Installed") { statuscolor = ConsoleColor.Yellow; } | ||
180 | - else if (msmq.Status == "Ready") { statuscolor = ConsoleColor.Green; } | ||
181 | - else { statuscolor = ConsoleColor.Red; } | ||
182 | - ColorConsole.Write(msmq.Status, statuscolor, bracket: "[]", prefix: " ", suffix: ". "); | ||
183 | - ColorConsole.WriteLine(); | ||
184 | - return " "; | ||
185 | - } | ||
186 | - else if (lineix == 1) | ||
187 | - { | ||
188 | - var privatepublictext = msmq.Private ? "private" : "public"; | ||
189 | - ColorConsole.Write($"{msmq.Xml_AddressPrefix}", ConsoleColor.Black, ConsoleColor.White, prefix: "Format:", suffix: $" Queue is { privatepublictext }."); | ||
190 | - ColorConsole.Write($"{msmq.Xml_Server}", ConsoleColor.Black, ConsoleColor.White, prefix: "Server:", suffix: $" Queue is { privatepublictext }."); | ||
191 | - ColorConsole.WriteLine(); | ||
192 | - return " "; | ||
193 | - } | ||
194 | - return null; | ||
195 | - } | ||
196 | - public string DisplayShortInfo(int lineix) | ||
197 | - { | ||
198 | - MSMQ msmq = this; | ||
199 | - if (lineix == 0) | ||
200 | - { | ||
201 | - ColorConsole.Write($"{msmq.Xml_Name}", ConsoleColor.Black, ConsoleColor.White, prefix: "Queue '", suffix: $"' queue label: '{msmq.Xml_Label}'."); | ||
202 | - ConsoleColor statuscolor; | ||
203 | - if (msmq.Status == "Uninstalled") { statuscolor = ConsoleColor.Red; } | ||
204 | - else if (msmq.Status == "Error") { statuscolor = ConsoleColor.Red; } | ||
205 | - else if (msmq.Status == "Installed") { statuscolor = ConsoleColor.Yellow; } | ||
206 | - else if (msmq.Status == "Ready") { statuscolor = ConsoleColor.Green; } | ||
207 | - else { statuscolor = ConsoleColor.Red; } | ||
208 | - ColorConsole.Write(msmq.Status, statuscolor, bracket: "[]", prefix: " ", suffix: ". "); | ||
209 | - ColorConsole.WriteLine(); | ||
210 | - return " "; | ||
211 | - } | ||
212 | - else if (lineix == 1) | ||
213 | - { | ||
214 | - var privatepublictext = msmq.Private ? "private" : "public"; | ||
215 | - ColorConsole.Write($"{msmq.Xml_AddressPrefix}", ConsoleColor.Black, ConsoleColor.White, prefix: "Format:", suffix: $" Queue is { privatepublictext }."); | ||
216 | - ColorConsole.Write($"{msmq.Xml_Server}", ConsoleColor.Black, ConsoleColor.White, prefix: "Server:", suffix: $" Queue is { privatepublictext }."); | ||
217 | - ColorConsole.WriteLine(); | ||
218 | - return " "; | ||
219 | - } | ||
220 | - else if (lineix == 2) | ||
221 | - { | ||
222 | - ColorConsole.Write($"{msmq.Path}", ConsoleColor.Yellow, prefix: "Path ", suffix: ", "); | ||
223 | - ColorConsole.WriteLine(); | ||
224 | - return " "; | ||
225 | - } | ||
226 | - else if (lineix == 3) | ||
227 | - { | ||
228 | - if (msmq.StatusDescription != null) | ||
229 | - { | ||
230 | - ConsoleColor color = ConsoleColor.Yellow; | ||
231 | - if (msmq.Status == "Ready") { color = ConsoleColor.Green; } | ||
232 | - else if (msmq.Status == "Error") { color = ConsoleColor.Red; } | ||
233 | - ColorConsole.Write($"{msmq.StatusDescription}", color, prefix: "Status description "); | ||
234 | - ColorConsole.WriteLine(); | ||
235 | - return " "; | ||
236 | - } | ||
237 | - return "";//empty=van még szöveg, de most nem történt kiírás | ||
238 | - } | ||
239 | - else if (lineix == 4) | ||
240 | - { | ||
241 | - if (msmq.Status == "Ready") | ||
242 | - { | ||
243 | - ColorConsole.Write($"{msmq.FormatName}", ConsoleColor.Yellow, prefix: "FormatName "); | ||
244 | - ColorConsole.WriteLine(); | ||
245 | - return " "; | ||
246 | - } | ||
247 | - return ""; | ||
248 | - } | ||
249 | - else if (lineix == 5) | ||
250 | - { | ||
251 | - if (msmq.Status == "Ready") | ||
252 | - { | ||
253 | - ColorConsole.Write($"{msmq.Id}", ConsoleColor.Yellow, prefix: "Id "); | ||
254 | - ColorConsole.WriteLine(); | ||
255 | - return " "; | ||
256 | - } | ||
257 | - return ""; | ||
258 | - } | ||
259 | - else if (lineix == 6) | ||
260 | - { | ||
261 | - if (msmq.Status == "Ready") | ||
262 | - { | ||
263 | - ColorConsole.Write(msmq.NumOfMessages.ToString(), ConsoleColor.Yellow, prefix: "Num.of msgs in queue ", suffix: ". "); | ||
264 | - ColorConsole.Write($"{msmq.LastModifyTime}", ConsoleColor.Yellow, prefix: "LastModified ", suffix: ", "); | ||
265 | - ColorConsole.WriteLine(); | ||
266 | - return " "; | ||
267 | - } | ||
268 | - return ""; | ||
269 | - } | ||
270 | - else if (lineix == 7) | ||
271 | - { | ||
272 | - if (msmq.Status == "Ready") | ||
273 | - { | ||
274 | - ColorConsole.Write($"{msmq.AccessMode}", ConsoleColor.Yellow, prefix: "AccessMode ", suffix: ", "); | ||
275 | - ColorConsole.Write($"{msmq.CanRead}", ConsoleColor.Yellow, prefix: "CanRead ", suffix: ", "); | ||
276 | - ColorConsole.Write($"{msmq.CanWrite}", ConsoleColor.Yellow, prefix: "CanWrite ", suffix: ", "); | ||
277 | - ColorConsole.WriteLine(); | ||
278 | - return " "; | ||
279 | - } | ||
280 | - return ""; | ||
281 | - } | ||
282 | - return null; | ||
283 | - } | ||
284 | - | ||
285 | - #region DisplayInfo | ||
286 | - public void DisplayInfo() | ||
287 | - { | ||
288 | - MSMQ msmq = this; | ||
289 | - ColorConsole.Write($">>> MSMQ detailed info collected for ", ConsoleColor.Yellow); | ||
290 | - ColorConsole.Write($"{msmq.Xml_Name}", ConsoleColor.Yellow, suffix: ", ", prefix: " QueueName : "); | ||
291 | - ColorConsole.Write($"{msmq.Xml_Server}", ConsoleColor.Yellow, prefix: "MachineName: "); | ||
292 | - ColorConsole.WriteLine(); | ||
293 | - var qqn = msmq.Xml_Name; | ||
294 | - var qexists = MSMQManagerCore.CheckIfQueueExists(msmq.Xml_Server, qqn); | ||
295 | - if (!qexists) | ||
296 | - { | ||
297 | - ColorConsole.WriteLine($" Queue does not exist!", ConsoleColor.Red); | ||
298 | - } | ||
299 | - else | ||
300 | - { | ||
301 | - try | ||
302 | - { | ||
303 | - msmq = msmq.CollectMSMQInfo(); | ||
304 | - ColorConsole.WriteLine($"{msmq.QueueName}", ConsoleColor.Green, prefix: $" Queue name: "); | ||
305 | - ColorConsole.WriteLine($"{msmq.MachineName}", ConsoleColor.Green, prefix: $" Server: "); | ||
306 | - if (msmq.Status == "Error") | ||
307 | - { | ||
308 | - ColorConsole.WriteLine($"{msmq.Status}", ConsoleColor.Red, prefix: $" Status: "); | ||
309 | - ColorConsole.WriteLine($"{msmq.StatusDescription}", ConsoleColor.Red, prefix: " StatusDescription: "); | ||
310 | - } | ||
311 | - else if (msmq.Status != "Ready") | ||
312 | - { | ||
313 | - ColorConsole.WriteLine($"{msmq.Status}", ConsoleColor.Yellow, prefix: $" Status: "); | ||
314 | - ColorConsole.WriteLine($"{msmq.StatusDescription}", ConsoleColor.Yellow, prefix: " StatusDescription: "); | ||
315 | - } | ||
316 | - else | ||
317 | - { | ||
318 | - ColorConsole.WriteLine($"{msmq.Status}", ConsoleColor.Green, prefix: $" Status: "); | ||
319 | - ColorConsole.WriteLine($"{msmq.StatusDescription}", ConsoleColor.Green, prefix: " StatusDescription: "); | ||
320 | - ColorConsole.WriteLine($"{msmq.Id}", ConsoleColor.Green, prefix: " Id: "); | ||
321 | - ColorConsole.WriteLine($"{msmq.Label}", ConsoleColor.Green, prefix: " Label: "); | ||
322 | - ColorConsole.WriteLine($"{msmq.Path}", ConsoleColor.Green, prefix: " Path: "); | ||
323 | - ColorConsole.WriteLine($"{msmq.FormatName}", ConsoleColor.Green, prefix: " FormatName: "); | ||
324 | - ColorConsole.Write($"{msmq.Transactional}", ConsoleColor.Green, prefix: " Transactional: ", suffix: ", "); | ||
325 | - ColorConsole.Write($"{msmq.UseJournalQueue}", ConsoleColor.Green, suffix: ", ", prefix: "UseJournalQueue: "); | ||
326 | - ColorConsole.Write($"{msmq.AccessMode}", ConsoleColor.Green, suffix: ", ", prefix: "AccessMode: "); | ||
327 | - ColorConsole.Write($"{msmq.CanRead}", ConsoleColor.Green, suffix: ", ", prefix: "CanRead: "); | ||
328 | - ColorConsole.Write($"{msmq.CanWrite}", ConsoleColor.Green, suffix: ", ", prefix: "CanWrite: "); | ||
329 | - ColorConsole.WriteLine(); | ||
330 | - ColorConsole.Write($"{msmq.Authenticate}", ConsoleColor.Green, suffix: ", ", prefix: " Authenticate: "); | ||
331 | - ColorConsole.Write($"{msmq.BasePriority}", ConsoleColor.Green, suffix: ", ", prefix: "BasePriority: "); | ||
332 | - ColorConsole.Write($"{msmq.EncryptionRequired}", ConsoleColor.Green, suffix: ", ", prefix: "EncryptionRequired: "); | ||
333 | - ColorConsole.WriteLine(); | ||
334 | - ColorConsole.Write($"{msmq.Formatter}", ConsoleColor.Green, suffix: ", ", prefix: " Formatter: "); | ||
335 | - ColorConsole.Write($"{msmq.LastModifyTime}", ConsoleColor.Green, suffix: ", ", prefix: "LastModifyTime: "); | ||
336 | - ColorConsole.WriteLine(); | ||
337 | - ColorConsole.Write($"{msmq.NumOfMessages}", ConsoleColor.Green, suffix: ", ", prefix: " NumOfMessages: "); | ||
338 | - ColorConsole.Write($"{msmq.MaximumJournalSize}", ConsoleColor.Green, suffix: ", ", prefix: "MaximumJournalSize: "); | ||
339 | - ColorConsole.Write($"{msmq.MaximumQueueSize}", ConsoleColor.Green, suffix: ", ", prefix: "MaximumQueueSize: "); | ||
340 | - ColorConsole.WriteLine(); | ||
341 | - } | ||
342 | - } | ||
343 | - catch (Exception ex) { ColorConsole.WriteLine(" " + ex.Message, ConsoleColor.Red); } | ||
344 | - } | ||
345 | - } | ||
346 | - #endregion DisplayInfo | ||
347 | - | ||
348 | - #region XmlStructure | ||
349 | - public static class XmlStructure | ||
350 | - { | ||
351 | - public static class MSMQManager | ||
352 | - { | ||
353 | - public static class General | ||
354 | - { | ||
355 | - public static class AccessRights | ||
356 | - { | ||
357 | - public static class AccessRight | ||
358 | - { | ||
359 | - public static class Attributes | ||
360 | - { | ||
361 | - public static class Username { public static class Values { public const string DEFAULT = "Everyone"; } } | ||
362 | - public static class Right {public static class Values { public const string DEFAULT = nameof(MessageQueueAccessRights.FullControl); } } | ||
363 | - public static class Control { public static class Values { public const string DEFAULT = nameof(AccessControlEntryType.Allow); } } | ||
364 | - } | ||
365 | - } | ||
366 | - } | ||
367 | - public static class MessageFiles | ||
368 | - { | ||
369 | - public static class Attributes | ||
370 | - { | ||
371 | - public static class Directory { public static class Values { public const string DEFAULT = ""; } } | ||
372 | - public static class SendToMask { public static class Values { public const string DEFAULT = "*.*"; } } | ||
373 | - public static class ReadToMask { public static class Values { public const string DEFAULT = "*.*"; } } | ||
374 | - } | ||
375 | - } | ||
376 | - public static class DefaultFormatter { public static class Values { public const string DEFAULT = nameof(ActiveXMessageFormatter); } } | ||
377 | - public static class DefaultEncoding { public static class Values { public const string DEFAULT = nameof(System.Text.Encoding.UTF8); } } | ||
378 | - } | ||
379 | - | ||
380 | - public static class MessageQueues | ||
381 | - { | ||
382 | - public static class MessageQueue | ||
383 | - { | ||
384 | - public static class Attributes | ||
385 | - { | ||
386 | - public static class Key { public static class Values { public const string DEFAULT = ""; } } | ||
387 | - public static class AddressPrefix{ public static class Values { public const string DEFAULT = ""; } } | ||
388 | - public static class Server { public static class Values { public const string DEFAULT = "."; } } | ||
389 | - public static class Name { } | ||
390 | - public static class Label { } | ||
391 | - public static class Mode | ||
392 | - { | ||
393 | - public static class Values | ||
394 | - { | ||
395 | - public const string DEFAULT = "In"; | ||
396 | - public static class In { } | ||
397 | - public static class Out { } | ||
398 | - } | ||
399 | - } | ||
400 | - public static class Formatter | ||
401 | - { | ||
402 | - public static class Values | ||
403 | - { | ||
404 | - public static class ActiveXMessageFormatter { } | ||
405 | - public static class BinaryMessageFormatter { } | ||
406 | - public static class XmlMessageFormatter { } | ||
407 | - } | ||
408 | - } | ||
409 | - public static class Encoding { } | ||
410 | - } | ||
411 | - public static class AccessRight | ||
412 | - { | ||
413 | - public static class Attributes | ||
414 | - { | ||
415 | - public static class Username { public static class Values { public const string DEFAULT = "Everyone"; } } | ||
416 | - public static class Right { public static class Values { public const string DEFAULT = nameof(MessageQueueAccessRights.FullControl); } } | ||
417 | - public static class Control { public static class Values { public const string DEFAULT = nameof(AccessControlEntryType.Allow); } } | ||
418 | - } | ||
419 | - } | ||
420 | - } | ||
421 | - } | ||
422 | - } | ||
423 | - } | ||
424 | - #endregion XmlStructure | ||
425 | - } | ||
426 | -} |
Vrh.Log4Pro.MaintenanceConsole/Manager - MSMQManager.cs
@@ -74,16 +74,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -74,16 +74,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
74 | var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 74 | var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); |
75 | MSMQManagerCore.CreateQueue(fullpath, st.Xml_Label); | 75 | MSMQManagerCore.CreateQueue(fullpath, st.Xml_Label); |
76 | ColorConsole.WriteLine($"MSMQ:{st.Xml_Name} created.", ConsoleColor.Green); | 76 | ColorConsole.WriteLine($"MSMQ:{st.Xml_Name} created.", ConsoleColor.Green); |
77 | - foreach (var a in st.Xml_AccessRights) | 77 | + foreach (var accessright in st.Xml_AccessRights) |
78 | { | 78 | { |
79 | - MSMQManagerCore.SetPermissions(fullpath, a.un, a.ar, a.ac); | ||
80 | - string ctrlstring = | ||
81 | - a.ac == AccessControlEntryType.Allow ? "allowed" | ||
82 | - : a.ac == AccessControlEntryType.Deny ? "denied" | ||
83 | - : a.ac == AccessControlEntryType.Revoke ? "revoked" | ||
84 | - : a.ac == AccessControlEntryType.Set ? "set" | ||
85 | - : "???"; | ||
86 | - ColorConsole.WriteLine($"Access right {a.ar} {ctrlstring} for user:{a.un}.", ConsoleColor.Green); | 79 | + MSMQManagerCore.SetPermissions(fullpath, accessright.un, accessright.ar, accessright.ac); |
80 | + string ctrlstring = accessright.AccessControlEntryTypeText(); | ||
81 | + ColorConsole.WriteLine($"Access right {accessright.ar} {ctrlstring} for user:{accessright.un}.", ConsoleColor.Green); | ||
87 | } | 82 | } |
88 | } | 83 | } |
89 | catch (Exception ex) { ColorConsole.WriteLine(ex.Message, ConsoleColor.Red); } | 84 | catch (Exception ex) { ColorConsole.WriteLine(ex.Message, ConsoleColor.Red); } |
@@ -140,17 +135,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -140,17 +135,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
140 | MSMQ st = p.Parameters as MSMQ; | 135 | MSMQ st = p.Parameters as MSMQ; |
141 | try | 136 | try |
142 | { | 137 | { |
143 | - foreach (var a in st.Xml_AccessRights) | 138 | + foreach (var accessright in st.Xml_AccessRights) |
144 | { | 139 | { |
145 | var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 140 | var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); |
146 | - MSMQManagerCore.SetPermissions(fullpath, a.un, a.ar, a.ac); | ||
147 | - string ctrlstring = | ||
148 | - a.ac == AccessControlEntryType.Allow ? "allowed" | ||
149 | - : a.ac == AccessControlEntryType.Deny ? "denied" | ||
150 | - : a.ac == AccessControlEntryType.Revoke ? "revoked" | ||
151 | - : a.ac == AccessControlEntryType.Set ? "set" | ||
152 | - : "???"; | ||
153 | - ColorConsole.WriteLine($"Access right {a.ar} {ctrlstring} for user:{a.un}.", ConsoleColor.Green); | 141 | + MSMQManagerCore.SetPermissions(fullpath, accessright.un, accessright.ar, accessright.ac); |
142 | + string ctrlstring = accessright.AccessControlEntryTypeText(); | ||
143 | + ColorConsole.WriteLine($"Access right {accessright.ar} {ctrlstring} for user:{accessright.un}.", ConsoleColor.Green); | ||
154 | } | 144 | } |
155 | } | 145 | } |
156 | catch (Exception ex) { ColorConsole.WriteLine(ex.Message, ConsoleColor.Red); } | 146 | catch (Exception ex) { ColorConsole.WriteLine(ex.Message, ConsoleColor.Red); } |
@@ -247,13 +237,13 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -247,13 +237,13 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
247 | var fullpath = MSMQManagerCore.CreateFullQueuePath(msmq.Xml_AddressPrefix, msmq.Xml_Server, msmq.Xml_Name); | 237 | var fullpath = MSMQManagerCore.CreateFullQueuePath(msmq.Xml_AddressPrefix, msmq.Xml_Server, msmq.Xml_Name); |
248 | MSMQManagerCore.Send(fullpath, sp.messagebody, sp.messagelabel, sp.messageformatter, sp.encoding); | 238 | MSMQManagerCore.Send(fullpath, sp.messagebody, sp.messagelabel, sp.messageformatter, sp.encoding); |
249 | ColorConsole.WriteLine($"Sending to '{fullpath}' ....", ConsoleColor.Yellow); | 239 | ColorConsole.WriteLine($"Sending to '{fullpath}' ....", ConsoleColor.Yellow); |
250 | - MSMQManagerCore.ReadLast(fullpath, sp.messageformatter, sp.encoding, out string body, out string label); | ||
251 | - if (sp.messagebody == body && sp.messagelabel == label) { ColorConsole.WriteLine($"Message successfully sent to '{fullpath}' and read back!", ConsoleColor.Green); } | ||
252 | - else | 240 | + Message msg = MSMQManagerCore.PeekLast(fullpath, sp.messageformatter, sp.encoding, out string body, out string label); |
241 | + TestSendCheckMessage(fullpath, msg, sp, body, label, "message sending/peek back"); | ||
242 | + var ans = ColorConsole.ReadLine($"Do You want to remove this test message (lookup id='{msg.LookupId}') from quue?", ConsoleColor.Yellow,validitylist:new List<string> { "yes","no"},defaultvalue:"yes"); | ||
243 | + if (ans.ToLower() == "yes") | ||
253 | { | 244 | { |
254 | - ColorConsole.WriteLine(body, prefix: "Read back body: ", f: ConsoleColor.Red); | ||
255 | - ColorConsole.WriteLine(label, prefix: "Read back label: ", f: ConsoleColor.Red); | ||
256 | - ColorConsole.WriteLine($"Message sending or read back is failed to '{fullpath}' !", ConsoleColor.Red); | 245 | + msg = MSMQManagerCore.ReadById(fullpath, msg.LookupId, sp.messageformatter, sp.encoding, out body, out label); |
246 | + TestSendCheckMessage(fullpath, msg, sp, body, label, "Read back."); | ||
257 | } | 247 | } |
258 | } | 248 | } |
259 | } | 249 | } |
@@ -262,6 +252,16 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -262,6 +252,16 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
262 | return o; | 252 | return o; |
263 | } | 253 | } |
264 | 254 | ||
255 | + private static void TestSendCheckMessage(string fullpath,Message msg, SendParameters sp, string body, string label,string actiontext) | ||
256 | + { | ||
257 | + if (sp.messagebody == body && sp.messagelabel == label) { ColorConsole.WriteLine($"Success! Action:{actiontext}. Queue:'{fullpath}'.", ConsoleColor.Green); } | ||
258 | + else | ||
259 | + { | ||
260 | + ColorConsole.WriteLine(body, prefix: $"{actiontext} body: ", f: ConsoleColor.Red); | ||
261 | + ColorConsole.WriteLine(label, prefix: $"{actiontext} label: ", f: ConsoleColor.Red); | ||
262 | + ColorConsole.WriteLine($"Failure! Action:{actiontext}. Queue:'{fullpath}'.", ConsoleColor.Red); | ||
263 | + } | ||
264 | + } | ||
265 | private static object GetLocalInfo(object parameter, object o) | 265 | private static object GetLocalInfo(object parameter, object o) |
266 | { | 266 | { |
267 | var config = (parameter as Menu.ExecutorParameter).GetConfig<MSMQManagerXmlProcessor>(); | 267 | var config = (parameter as Menu.ExecutorParameter).GetConfig<MSMQManagerXmlProcessor>(); |
@@ -307,8 +307,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -307,8 +307,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
307 | MSMQ st = p.Parameters as MSMQ; | 307 | MSMQ st = p.Parameters as MSMQ; |
308 | try | 308 | try |
309 | { | 309 | { |
310 | + var messageformatter = MSMQManagerCore.SetFormatter(st.Xml_Formatter); //new ActiveXMessageFormatter(); | ||
311 | + var encoding = MSMQManagerCore.SetEncoding(st.Xml_Encoding); // Encoding.UTF8; | ||
310 | var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 312 | var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); |
311 | - MSMQManagerCore.Peek(fullpath, out string msgbody, out string msglabel); | 313 | + MSMQManagerCore.Peek(fullpath, messageformatter, encoding, out string msgbody, out string msglabel); |
312 | ColorConsole.WriteLine($"Message peeked from MSMQ:{st.Xml_Name}", ConsoleColor.Green); | 314 | ColorConsole.WriteLine($"Message peeked from MSMQ:{st.Xml_Name}", ConsoleColor.Green); |
313 | ColorConsole.WriteLine($" Body: {msgbody}", ConsoleColor.Yellow); | 315 | ColorConsole.WriteLine($" Body: {msgbody}", ConsoleColor.Yellow); |
314 | ColorConsole.WriteLine($" Label: {msglabel}", ConsoleColor.Yellow); | 316 | ColorConsole.WriteLine($" Label: {msglabel}", ConsoleColor.Yellow); |
@@ -341,8 +343,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -341,8 +343,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
341 | MSMQ st = p.Parameters as MSMQ; | 343 | MSMQ st = p.Parameters as MSMQ; |
342 | try | 344 | try |
343 | { | 345 | { |
344 | - var messageformatter = new ActiveXMessageFormatter(); | ||
345 | - var encoding = Encoding.UTF8; | 346 | + var messageformatter = MSMQManagerCore.SetFormatter(st.Xml_Formatter); //new ActiveXMessageFormatter(); |
347 | + var encoding = MSMQManagerCore.SetEncoding(st.Xml_Encoding); // Encoding.UTF8; | ||
346 | var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 348 | var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); |
347 | MSMQManagerCore.Read(fullpath, messageformatter, encoding, out string msgbody, out string msglabel); | 349 | MSMQManagerCore.Read(fullpath, messageformatter, encoding, out string msgbody, out string msglabel); |
348 | ColorConsole.WriteLine($"Message read from MSMQ:{st.Xml_Name}", ConsoleColor.Green); | 350 | ColorConsole.WriteLine($"Message read from MSMQ:{st.Xml_Name}", ConsoleColor.Green); |
@@ -550,7 +552,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -550,7 +552,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
550 | if (!string.IsNullOrWhiteSpace(label)) { msmq.Label = label; } | 552 | if (!string.IsNullOrWhiteSpace(label)) { msmq.Label = label; } |
551 | } | 553 | } |
552 | } | 554 | } |
553 | - public static void SetPermissions(string msmqFullname,string username, MessageQueueAccessRights accessrights, AccessControlEntryType controltype) | 555 | + public static void SetPermissions(string msmqFullname,string username, MessageQueueAccessRights accessrights, AccessControlEntryType controltype) |
554 | { | 556 | { |
555 | using (var msmq = new MessageQueue(msmqFullname)) | 557 | using (var msmq = new MessageQueue(msmqFullname)) |
556 | { | 558 | { |
@@ -571,7 +573,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -571,7 +573,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
571 | // | MessageQueueAccessRights.ReceiveMessage | 573 | // | MessageQueueAccessRights.ReceiveMessage |
572 | // | MessageQueueAccessRights.SetQueueProperties | 574 | // | MessageQueueAccessRights.SetQueueProperties |
573 | // | MessageQueueAccessRights.DeleteQueue; | 575 | // | MessageQueueAccessRights.DeleteQueue; |
574 | - msmq.SetPermissions("EveryOne", accessrights, controltype); | 576 | + msmq.SetPermissions(username, accessrights, controltype); |
575 | } | 577 | } |
576 | } | 578 | } |
577 | 579 | ||
@@ -586,29 +588,74 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -586,29 +588,74 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
586 | msmq.Purge(); | 588 | msmq.Purge(); |
587 | } | 589 | } |
588 | } | 590 | } |
589 | - public static void Peek(string msmqFullname, out string body, out string label) | 591 | + public static Message Peek(string msmqFullname, IMessageFormatter messageformatter, Encoding encoding, out string body, out string label) |
590 | { | 592 | { |
593 | + body = ""; | ||
594 | + label = ""; | ||
591 | using (var msmq = new MessageQueue(msmqFullname)) | 595 | using (var msmq = new MessageQueue(msmqFullname)) |
592 | { | 596 | { |
597 | + if (Count(msmq) == 0) { return null; } | ||
598 | + | ||
599 | + msmq.Formatter = messageformatter; | ||
593 | Message m = msmq.Peek(new TimeSpan(0)); | 600 | Message m = msmq.Peek(new TimeSpan(0)); |
594 | - m.BodyStream.Position = 0; | ||
595 | - var sr = new System.IO.StreamReader(m.BodyStream); | ||
596 | label = m.Label; | 601 | label = m.Label; |
597 | - body = sr.ReadToEnd().Replace(((char)0).ToString(), ""); | 602 | + //m.BodyStream.Position = 0; |
603 | + //var sr = new System.IO.StreamReader(m.BodyStream); | ||
604 | + //body = sr.ReadToEnd().Replace(((char)0).ToString(), ""); | ||
605 | + body = encoding.GetString((byte[])m.Body); | ||
606 | + return m; | ||
598 | } | 607 | } |
599 | } | 608 | } |
600 | - public static void Read(string msmqFullname, IMessageFormatter messageformatter, Encoding encoding, out string body, out string label) | 609 | + public static Message PeekLast(string msmqFullname, IMessageFormatter messageformatter, Encoding encoding, out string body, out string label) |
601 | { | 610 | { |
611 | + body = ""; | ||
612 | + label = ""; | ||
602 | using (var msmq = new MessageQueue(msmqFullname)) | 613 | using (var msmq = new MessageQueue(msmqFullname)) |
603 | { | 614 | { |
615 | + if (Count(msmq) == 0) { return null; } | ||
616 | + | ||
604 | //frmA = new System.Messaging.ActiveXMessageFormatter(); | 617 | //frmA = new System.Messaging.ActiveXMessageFormatter(); |
605 | //frmA = new System.Messaging.BinaryMessageFormatter(); | 618 | //frmA = new System.Messaging.BinaryMessageFormatter(); |
606 | //frmA = new System.Messaging.XmlMessageFormatter(); | 619 | //frmA = new System.Messaging.XmlMessageFormatter(); |
607 | msmq.Formatter = messageformatter; | 620 | msmq.Formatter = messageformatter; |
621 | + //Message m = msmq.Receive(new TimeSpan(0)); | ||
622 | + var m = msmq.PeekByLookupId(MessageLookupAction.Last, 0); | ||
623 | + label = m.Label; | ||
624 | + body = encoding.GetString((byte[])m.Body); | ||
625 | + return m; | ||
608 | 626 | ||
609 | - Message m = msmq.Receive(new TimeSpan(0)); | ||
610 | - m.BodyStream.Position = 0; | ||
611 | 627 | ||
628 | + //m.BodyStream.Position = 0; | ||
629 | + | ||
630 | + //// encoding = System.Text.Encoding.UTF8; | ||
631 | + //// encoding = System.Text.Encoding.UTF7; | ||
632 | + //// encoding = System.Text.Encoding.UTF32; | ||
633 | + //// encoding = System.Text.Encoding.Unicode; | ||
634 | + //// encoding = System.Text.Encoding.BigEndianUnicode; | ||
635 | + //// encoding = System.Text.Encoding.ASCII; | ||
636 | + //// encoding = System.Text.Encoding.Default; | ||
637 | + //var sr = new System.IO.StreamReader(m.BodyStream, encoding); | ||
638 | + //body = sr.ReadToEnd().Replace(((char)0).ToString(), ""); | ||
639 | + } | ||
640 | + } | ||
641 | + public static Message Read(string msmqFullname, IMessageFormatter messageformatter, Encoding encoding, out string body, out string label) | ||
642 | + { | ||
643 | + body = ""; | ||
644 | + label = ""; | ||
645 | + using (var msmq = new MessageQueue(msmqFullname)) | ||
646 | + { | ||
647 | + if (Count(msmq) == 0) { return null; } | ||
648 | + | ||
649 | + //frmA = new System.Messaging.ActiveXMessageFormatter(); | ||
650 | + //frmA = new System.Messaging.BinaryMessageFormatter(); | ||
651 | + //frmA = new System.Messaging.XmlMessageFormatter(); | ||
652 | + msmq.Formatter = messageformatter; | ||
653 | + | ||
654 | + Message m = msmq.Receive(new TimeSpan(0)); | ||
655 | + label = m.Label; | ||
656 | + //m.BodyStream.Position = 0; | ||
657 | + //var sr = new System.IO.StreamReader(m.BodyStream, encoding); | ||
658 | + //body = sr.ReadToEnd().Replace(((char)0).ToString(), ""); | ||
612 | // encoding = System.Text.Encoding.UTF8; | 659 | // encoding = System.Text.Encoding.UTF8; |
613 | // encoding = System.Text.Encoding.UTF7; | 660 | // encoding = System.Text.Encoding.UTF7; |
614 | // encoding = System.Text.Encoding.UTF32; | 661 | // encoding = System.Text.Encoding.UTF32; |
@@ -616,41 +663,55 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -616,41 +663,55 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
616 | // encoding = System.Text.Encoding.BigEndianUnicode; | 663 | // encoding = System.Text.Encoding.BigEndianUnicode; |
617 | // encoding = System.Text.Encoding.ASCII; | 664 | // encoding = System.Text.Encoding.ASCII; |
618 | // encoding = System.Text.Encoding.Default; | 665 | // encoding = System.Text.Encoding.Default; |
619 | - var sr = new System.IO.StreamReader(m.BodyStream, encoding); | 666 | + body = encoding.GetString((byte[])m.Body); |
667 | + return m; | ||
668 | + } | ||
669 | + } | ||
670 | + public static Message ReadLast(string msmqFullname, IMessageFormatter messageformatter, Encoding encoding, out string body, out string label) | ||
671 | + { | ||
672 | + body = ""; | ||
673 | + label = ""; | ||
674 | + using (var msmq = new MessageQueue(msmqFullname)) | ||
675 | + { | ||
676 | + if (Count(msmq) == 0) { return null; } | ||
677 | + | ||
678 | + //frmA = new System.Messaging.ActiveXMessageFormatter(); | ||
679 | + //frmA = new System.Messaging.BinaryMessageFormatter(); | ||
680 | + //frmA = new System.Messaging.XmlMessageFormatter(); | ||
681 | + msmq.Formatter = messageformatter; | ||
682 | + //Message m = msmq.Receive(new TimeSpan(0)); | ||
683 | + var m = msmq.ReceiveByLookupId(MessageLookupAction.Last, 0, null); | ||
620 | label = m.Label; | 684 | label = m.Label; |
621 | - body = sr.ReadToEnd().Replace(((char)0).ToString(), ""); | 685 | + body = encoding.GetString((byte[])m.Body); |
686 | + | ||
687 | + | ||
688 | + //m.BodyStream.Position = 0; | ||
689 | + | ||
690 | + //// encoding = System.Text.Encoding.UTF8; | ||
691 | + //// encoding = System.Text.Encoding.UTF7; | ||
692 | + //// encoding = System.Text.Encoding.UTF32; | ||
693 | + //// encoding = System.Text.Encoding.Unicode; | ||
694 | + //// encoding = System.Text.Encoding.BigEndianUnicode; | ||
695 | + //// encoding = System.Text.Encoding.ASCII; | ||
696 | + //// encoding = System.Text.Encoding.Default; | ||
697 | + //var sr = new System.IO.StreamReader(m.BodyStream, encoding); | ||
698 | + //body = sr.ReadToEnd().Replace(((char)0).ToString(), ""); | ||
699 | + return m; | ||
622 | } | 700 | } |
623 | } | 701 | } |
624 | - public static void ReadLast(string msmqFullname, IMessageFormatter messageformatter, Encoding encoding, out string body, out string label) | 702 | + public static Message ReadById(string msmqFullname, long msgid, IMessageFormatter messageformatter, Encoding encoding, out string body, out string label) |
625 | { | 703 | { |
626 | body = ""; | 704 | body = ""; |
627 | label = ""; | 705 | label = ""; |
628 | using (var msmq = new MessageQueue(msmqFullname)) | 706 | using (var msmq = new MessageQueue(msmqFullname)) |
629 | { | 707 | { |
630 | - if (Count(msmq)>0) | ||
631 | - { | ||
632 | - //frmA = new System.Messaging.ActiveXMessageFormatter(); | ||
633 | - //frmA = new System.Messaging.BinaryMessageFormatter(); | ||
634 | - //frmA = new System.Messaging.XmlMessageFormatter(); | ||
635 | - msmq.Formatter = messageformatter; | ||
636 | - //Message m = msmq.Receive(new TimeSpan(0)); | ||
637 | - var m = msmq.ReceiveByLookupId(MessageLookupAction.Last, 0, null); | ||
638 | - label = m.Label; | ||
639 | - body = encoding.GetString((byte[])m.Body); | ||
640 | - | ||
641 | - | ||
642 | - //m.BodyStream.Position = 0; | ||
643 | - | ||
644 | - //// encoding = System.Text.Encoding.UTF8; | ||
645 | - //// encoding = System.Text.Encoding.UTF7; | ||
646 | - //// encoding = System.Text.Encoding.UTF32; | ||
647 | - //// encoding = System.Text.Encoding.Unicode; | ||
648 | - //// encoding = System.Text.Encoding.BigEndianUnicode; | ||
649 | - //// encoding = System.Text.Encoding.ASCII; | ||
650 | - //// encoding = System.Text.Encoding.Default; | ||
651 | - //var sr = new System.IO.StreamReader(m.BodyStream, encoding); | ||
652 | - //body = sr.ReadToEnd().Replace(((char)0).ToString(), ""); | ||
653 | - } | 708 | + if (Count(msmq) == 0) {return null; } |
709 | + | ||
710 | + msmq.Formatter = messageformatter; | ||
711 | + var m = msmq.ReceiveByLookupId(msgid); | ||
712 | + label = m.Label; | ||
713 | + body = encoding.GetString((byte[])m.Body); | ||
714 | + return m; | ||
654 | } | 715 | } |
655 | } | 716 | } |
656 | public static void Send(string msmqFullname, string messagetosend, string messagelabel, IMessageFormatter messageformatter, Encoding encoding) | 717 | public static void Send(string msmqFullname, string messagetosend, string messagelabel, IMessageFormatter messageformatter, Encoding encoding) |
@@ -693,9 +754,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -693,9 +754,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
693 | r.Add(nameof(MSMQ.XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Formatter.Values.XmlMessageFormatter)); | 754 | r.Add(nameof(MSMQ.XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Formatter.Values.XmlMessageFormatter)); |
694 | return r; | 755 | return r; |
695 | } | 756 | } |
696 | - public static Encoding SetEncoding(string formattername) | 757 | + public static Encoding SetEncoding(string encodingname) |
697 | { | 758 | { |
698 | - switch (formattername) | 759 | + switch (encodingname) |
699 | { | 760 | { |
700 | case nameof(Encoding.UTF8): return Encoding.UTF8; | 761 | case nameof(Encoding.UTF8): return Encoding.UTF8; |
701 | case nameof(Encoding.UTF7): return Encoding.UTF7; | 762 | case nameof(Encoding.UTF7): return Encoding.UTF7; |
@@ -758,6 +819,17 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -758,6 +819,17 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
758 | } | 819 | } |
759 | catch { return null; } | 820 | catch { return null; } |
760 | } | 821 | } |
822 | + | ||
823 | + public string AccessControlEntryTypeText() | ||
824 | + { | ||
825 | + AccessRights accessright = this; | ||
826 | + return accessright.ac == AccessControlEntryType.Allow ? "allowed" | ||
827 | + : accessright.ac == AccessControlEntryType.Deny ? "denied" | ||
828 | + : accessright.ac == AccessControlEntryType.Revoke ? "revoked" | ||
829 | + : accessright.ac == AccessControlEntryType.Set ? "set" | ||
830 | + : "???"; | ||
831 | + } | ||
832 | + | ||
761 | public string un; | 833 | public string un; |
762 | public MessageQueueAccessRights ar; | 834 | public MessageQueueAccessRights ar; |
763 | public AccessControlEntryType ac; | 835 | public AccessControlEntryType ac; |
@@ -790,4 +862,413 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -790,4 +862,413 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
790 | } | 862 | } |
791 | } | 863 | } |
792 | #endregion Defaults class | 864 | #endregion Defaults class |
865 | + | ||
866 | + #region MSMQ | ||
867 | + public class MSMQ : XmlLinqBase | ||
868 | + { | ||
869 | + #region fields | ||
870 | + public bool Valid = true; | ||
871 | + public string Xml_Key; | ||
872 | + public string Xml_Name; | ||
873 | + public string Xml_AddressPrefix = XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.AddressPrefix.Values.DEFAULT; | ||
874 | + public string Xml_Server = XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Server.Values.DEFAULT; | ||
875 | + public bool Private; | ||
876 | + public string Xml_Mode = XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Mode.Values.DEFAULT; | ||
877 | + public string Xml_Label; | ||
878 | + public string Xml_Formatter = XmlStructure.MSMQManager.General.DefaultFormatter.Values.DEFAULT; | ||
879 | + public string Xml_Encoding = XmlStructure.MSMQManager.General.DefaultEncoding.Values.DEFAULT; | ||
880 | + public List<AccessRights> Xml_AccessRights = new List<AccessRights>(); | ||
881 | + | ||
882 | + public string Status; | ||
883 | + public string StatusDescription = null; | ||
884 | + public Guid Id; | ||
885 | + public string QueueName; | ||
886 | + public long NumOfMessages; | ||
887 | + public string Label; | ||
888 | + public string MachineName; | ||
889 | + public IMessageFormatter Formatter; | ||
890 | + public string FormatName; | ||
891 | + public string Path; | ||
892 | + public DateTime LastModifyTime; | ||
893 | + public QueueAccessMode AccessMode; | ||
894 | + public bool CanRead; | ||
895 | + public bool CanWrite; | ||
896 | + public long MaximumQueueSize; | ||
897 | + public bool UseJournalQueue; | ||
898 | + public long MaximumJournalSize; | ||
899 | + | ||
900 | + public bool Transactional; | ||
901 | + public bool Authenticate; | ||
902 | + public int BasePriority; | ||
903 | + public EncryptionRequired EncryptionRequired; | ||
904 | + #endregion fields | ||
905 | + | ||
906 | + #region basic constructor | ||
907 | + public MSMQ() { } | ||
908 | + #endregion basic constructor | ||
909 | + | ||
910 | + #region constructor from MessageQueue | ||
911 | + public MSMQ(MessageQueue msmq, string key) | ||
912 | + { | ||
913 | + Xml_Key = key; | ||
914 | + Xml_Name = msmq.QueueName; | ||
915 | + Xml_Label = msmq.QueueName; | ||
916 | + Xml_Server = msmq.MachineName; | ||
917 | + Private = msmq.QueueName.ToLower().StartsWith("private$"); | ||
918 | + Xml_Formatter = msmq.Formatter.GetType().Name; | ||
919 | + Xml_AddressPrefix = "FormatName:" + msmq.FormatName.Replace(msmq.MachineName + "\\" + msmq.QueueName, ""); | ||
920 | + } | ||
921 | + #endregion constructor from MessageQueue | ||
922 | + | ||
923 | + #region xml constructor | ||
924 | + public MSMQ(XElement msmqxml, MSMQDefaults msmqdefaults) | ||
925 | + { | ||
926 | + Valid = true; | ||
927 | + string ATTRIBUTEMANDATORY = nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue) + " attribute is mandatory! Name: {0}"; | ||
928 | + Xml_Key = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Key), msmqxml, XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Key.Values.DEFAULT); | ||
929 | + Xml_Name = msmqxml.Attribute(XName.Get(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Name)))?.Value; | ||
930 | + if (string.IsNullOrWhiteSpace(Xml_Name)) { throw new ApplicationException(string.Format(ATTRIBUTEMANDATORY, nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Name))); } | ||
931 | + Xml_AddressPrefix = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.AddressPrefix), msmqxml, XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.AddressPrefix.Values.DEFAULT); | ||
932 | + Xml_Server = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Server), msmqxml, XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Server.Values.DEFAULT); | ||
933 | + if (Xml_Server == "." || Xml_Server.ToLower() == "localhost") { Xml_Server = System.Environment.MachineName; } | ||
934 | + | ||
935 | + Private = Xml_Name.StartsWith("private$"); ; | ||
936 | + Xml_Mode = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Mode), msmqxml, XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Mode.Values.DEFAULT); | ||
937 | + Xml_Label = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Label), msmqxml, Xml_Name); | ||
938 | + Xml_Formatter = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Formatter), msmqxml, msmqdefaults.Xml_DefaultFormatter); | ||
939 | + Xml_Encoding = GetValue(nameof(XmlStructure.MSMQManager.MessageQueues.MessageQueue.Attributes.Encoding), msmqxml, msmqdefaults.Xml_DefaultEncoding); | ||
940 | + | ||
941 | + foreach (var ar in msmqdefaults.Xml_AccessRights) { Xml_AccessRights.Add(ar); } | ||
942 | + try | ||
943 | + { | ||
944 | + var arxmllist = GetAllXElements(msmqxml, nameof(MSMQ.XmlStructure.MSMQManager.MessageQueues.MessageQueue.AccessRight)); | ||
945 | + foreach (var arxml in arxmllist) { var newa = AccessRights.Factory(arxml); if (newa != null) { Xml_AccessRights.Add(newa); } } | ||
946 | + } | ||
947 | + catch { } | ||
948 | + | ||
949 | + | ||
950 | + } | ||
951 | + #endregion xml constructor | ||
952 | + | ||
953 | + #region Xml cloner constructor | ||
954 | + public MSMQ(MSMQ msmq) | ||
955 | + { | ||
956 | + Valid = msmq.Valid; | ||
957 | + Xml_Key = msmq.Xml_Key; | ||
958 | + Xml_Name = msmq.Xml_Name; | ||
959 | + Xml_Server = msmq.Xml_Server; | ||
960 | + Private = msmq.Private; | ||
961 | + Xml_Mode = msmq.Xml_Mode; | ||
962 | + Xml_Label = msmq.Xml_Label; | ||
963 | + Xml_Formatter = msmq.Xml_Formatter; | ||
964 | + Xml_Encoding = msmq.Xml_Encoding; | ||
965 | + } | ||
966 | + #endregion Xml cloner constructor | ||
967 | + | ||
968 | + #region CollectMSMQInfo | ||
969 | + public MSMQ CollectMSMQInfo() | ||
970 | + { | ||
971 | + MSMQ msmqdef = this; | ||
972 | + string msmqaddressprefix = msmqdef.Xml_AddressPrefix; | ||
973 | + string msmqservername = msmqdef.Xml_Server; | ||
974 | + string msmqFullname = MSMQManagerCore.CreateFullQueuePath(msmqaddressprefix, msmqservername, msmqdef.Xml_Name); | ||
975 | + msmqdef.QueueName = msmqdef.Xml_Name; | ||
976 | + msmqdef.MachineName = msmqservername; | ||
977 | + msmqdef.Path = msmqFullname; | ||
978 | + try | ||
979 | + { | ||
980 | + msmqdef.Status = MessageQueue.Exists(msmqFullname) ? "Installed" : "Uninstalled"; | ||
981 | + if (msmqdef.Status == "Installed") | ||
982 | + { | ||
983 | + using (var msmq = new MessageQueue(msmqFullname)) | ||
984 | + { | ||
985 | + msmqdef.QueueName = msmq.QueueName; | ||
986 | + msmqdef.MachineName = msmq.MachineName; | ||
987 | + | ||
988 | + msmqdef.Id = msmq.Id; | ||
989 | + msmqdef.NumOfMessages = MSMQManagerCore.Count(msmq); | ||
990 | + msmqdef.Label = msmq.Label; | ||
991 | + msmqdef.Formatter = msmq.Formatter; | ||
992 | + msmqdef.FormatName = msmq.FormatName; | ||
993 | + msmqdef.Path = msmq.Path; | ||
994 | + msmqdef.LastModifyTime = msmq.LastModifyTime; | ||
995 | + msmqdef.AccessMode = msmq.AccessMode; | ||
996 | + msmqdef.CanRead = msmq.CanRead; | ||
997 | + msmqdef.CanWrite = msmq.CanWrite; | ||
998 | + msmqdef.MaximumQueueSize = msmq.MaximumQueueSize; | ||
999 | + msmqdef.UseJournalQueue = msmq.UseJournalQueue; | ||
1000 | + msmqdef.MaximumJournalSize = msmq.MaximumJournalSize; | ||
1001 | + | ||
1002 | + msmqdef.Transactional = msmq.Transactional; | ||
1003 | + msmqdef.Authenticate = msmq.Authenticate; | ||
1004 | + msmqdef.BasePriority = msmq.BasePriority; | ||
1005 | + msmqdef.EncryptionRequired = msmq.EncryptionRequired; | ||
1006 | + | ||
1007 | + msmqdef.Status = "Ready"; | ||
1008 | + } | ||
1009 | + } | ||
1010 | + } | ||
1011 | + catch (Exception ex) { msmqdef.Status = "Error"; msmqdef.StatusDescription = ex.Message + (ex.InnerException != null ? ("\n" + ex.InnerException.Message) : ""); } | ||
1012 | + return msmqdef; | ||
1013 | + } | ||
1014 | + #endregion CollectMSMQInfo | ||
1015 | + | ||
1016 | + public string DisplayVeryShortInfo(int lineix) | ||
1017 | + { | ||
1018 | + MSMQ msmq = this; | ||
1019 | + if (lineix == 0) | ||
1020 | + { | ||
1021 | + ColorConsole.Write($"{msmq.Xml_Name}", ConsoleColor.Black, ConsoleColor.White, prefix: "Queue '", suffix: $"' queue label: '{msmq.Xml_Label}'."); | ||
1022 | + ConsoleColor statuscolor; | ||
1023 | + if (msmq.Status == "Uninstalled") { statuscolor = ConsoleColor.Red; } | ||
1024 | + else if (msmq.Status == "Error") { statuscolor = ConsoleColor.Red; } | ||
1025 | + else if (msmq.Status == "Installed") { statuscolor = ConsoleColor.Yellow; } | ||
1026 | + else if (msmq.Status == "Ready") { statuscolor = ConsoleColor.Green; } | ||
1027 | + else { statuscolor = ConsoleColor.Red; } | ||
1028 | + ColorConsole.Write(msmq.Status, statuscolor, bracket: "[]", prefix: " ", suffix: ". "); | ||
1029 | + ColorConsole.WriteLine(); | ||
1030 | + return " "; | ||
1031 | + } | ||
1032 | + else if (lineix == 1) | ||
1033 | + { | ||
1034 | + var privatepublictext = msmq.Private ? "private" : "public"; | ||
1035 | + ColorConsole.Write($"{msmq.Xml_AddressPrefix}", ConsoleColor.Black, ConsoleColor.White, prefix: "Format:", suffix: $" Queue is { privatepublictext }."); | ||
1036 | + ColorConsole.Write($"{msmq.Xml_Server}", ConsoleColor.Black, ConsoleColor.White, prefix: "Server:", suffix: $" Queue is { privatepublictext }."); | ||
1037 | + ColorConsole.WriteLine(); | ||
1038 | + return " "; | ||
1039 | + } | ||
1040 | + return null; | ||
1041 | + } | ||
1042 | + public string DisplayShortInfo(int lineix) | ||
1043 | + { | ||
1044 | + MSMQ msmq = this; | ||
1045 | + if (lineix == 0) | ||
1046 | + { | ||
1047 | + ColorConsole.Write($"{msmq.Xml_Name}", ConsoleColor.Black, ConsoleColor.White, prefix: "Queue '", suffix: $"' queue label: '{msmq.Xml_Label}'."); | ||
1048 | + ConsoleColor statuscolor; | ||
1049 | + if (msmq.Status == "Uninstalled") { statuscolor = ConsoleColor.Red; } | ||
1050 | + else if (msmq.Status == "Error") { statuscolor = ConsoleColor.Red; } | ||
1051 | + else if (msmq.Status == "Installed") { statuscolor = ConsoleColor.Yellow; } | ||
1052 | + else if (msmq.Status == "Ready") { statuscolor = ConsoleColor.Green; } | ||
1053 | + else { statuscolor = ConsoleColor.Red; } | ||
1054 | + ColorConsole.Write(msmq.Status, statuscolor, bracket: "[]", prefix: " ", suffix: ". "); | ||
1055 | + ColorConsole.WriteLine(); | ||
1056 | + return " "; | ||
1057 | + } | ||
1058 | + else if (lineix == 1) | ||
1059 | + { | ||
1060 | + var privatepublictext = msmq.Private ? "private" : "public"; | ||
1061 | + ColorConsole.Write($"{msmq.Xml_AddressPrefix}", ConsoleColor.Black, ConsoleColor.White, prefix: "Format:", suffix: $" Queue is { privatepublictext }."); | ||
1062 | + ColorConsole.Write($"{msmq.Xml_Server}", ConsoleColor.Black, ConsoleColor.White, prefix: "Server:", suffix: $" Queue is { privatepublictext }."); | ||
1063 | + ColorConsole.WriteLine(); | ||
1064 | + return " "; | ||
1065 | + } | ||
1066 | + else if (lineix == 2) | ||
1067 | + { | ||
1068 | + ColorConsole.Write($"{msmq.Path}", ConsoleColor.Yellow, prefix: "Path ", suffix: ", "); | ||
1069 | + ColorConsole.WriteLine(); | ||
1070 | + return " "; | ||
1071 | + } | ||
1072 | + else if (lineix == 3) | ||
1073 | + { | ||
1074 | + if (msmq.StatusDescription != null) | ||
1075 | + { | ||
1076 | + ConsoleColor color = ConsoleColor.Yellow; | ||
1077 | + if (msmq.Status == "Ready") { color = ConsoleColor.Green; } | ||
1078 | + else if (msmq.Status == "Error") { color = ConsoleColor.Red; } | ||
1079 | + ColorConsole.Write($"{msmq.StatusDescription}", color, prefix: "Status description "); | ||
1080 | + ColorConsole.WriteLine(); | ||
1081 | + return " "; | ||
1082 | + } | ||
1083 | + return "";//empty=van még szöveg, de most nem történt kiírás | ||
1084 | + } | ||
1085 | + else if (lineix == 4) | ||
1086 | + { | ||
1087 | + if (msmq.Status == "Ready") | ||
1088 | + { | ||
1089 | + ColorConsole.Write($"{msmq.FormatName}", ConsoleColor.Yellow, prefix: "FormatName "); | ||
1090 | + ColorConsole.WriteLine(); | ||
1091 | + return " "; | ||
1092 | + } | ||
1093 | + return ""; | ||
1094 | + } | ||
1095 | + else if (lineix == 5) | ||
1096 | + { | ||
1097 | + if (msmq.Status == "Ready") | ||
1098 | + { | ||
1099 | + ColorConsole.Write($"{msmq.Id}", ConsoleColor.Yellow, prefix: "Id "); | ||
1100 | + ColorConsole.WriteLine(); | ||
1101 | + return " "; | ||
1102 | + } | ||
1103 | + return ""; | ||
1104 | + } | ||
1105 | + else if (lineix == 6) | ||
1106 | + { | ||
1107 | + if (msmq.Status == "Ready") | ||
1108 | + { | ||
1109 | + ColorConsole.Write(msmq.NumOfMessages.ToString(), ConsoleColor.Yellow, prefix: "Num.of msgs in queue ", suffix: ". "); | ||
1110 | + ColorConsole.Write($"{msmq.LastModifyTime}", ConsoleColor.Yellow, prefix: "LastModified ", suffix: ", "); | ||
1111 | + ColorConsole.WriteLine(); | ||
1112 | + return " "; | ||
1113 | + } | ||
1114 | + return ""; | ||
1115 | + } | ||
1116 | + else if (lineix == 7) | ||
1117 | + { | ||
1118 | + if (msmq.Status == "Ready") | ||
1119 | + { | ||
1120 | + ColorConsole.Write($"{msmq.AccessMode}", ConsoleColor.Yellow, prefix: "AccessMode ", suffix: ", "); | ||
1121 | + ColorConsole.Write($"{msmq.CanRead}", ConsoleColor.Yellow, prefix: "CanRead ", suffix: ", "); | ||
1122 | + ColorConsole.Write($"{msmq.CanWrite}", ConsoleColor.Yellow, prefix: "CanWrite ", suffix: ", "); | ||
1123 | + ColorConsole.WriteLine(); | ||
1124 | + return " "; | ||
1125 | + } | ||
1126 | + return ""; | ||
1127 | + } | ||
1128 | + return null; | ||
1129 | + } | ||
1130 | + | ||
1131 | + #region DisplayInfo | ||
1132 | + public void DisplayInfo() | ||
1133 | + { | ||
1134 | + MSMQ msmq = this; | ||
1135 | + ColorConsole.Write($">>> MSMQ detailed info collected for ", ConsoleColor.Yellow); | ||
1136 | + ColorConsole.Write($"{msmq.Xml_Name}", ConsoleColor.Yellow, suffix: ", ", prefix: " QueueName : "); | ||
1137 | + ColorConsole.Write($"{msmq.Xml_Server}", ConsoleColor.Yellow, prefix: "MachineName: "); | ||
1138 | + ColorConsole.WriteLine(); | ||
1139 | + var qqn = msmq.Xml_Name; | ||
1140 | + var qexists = MSMQManagerCore.CheckIfQueueExists(msmq.Xml_Server, qqn); | ||
1141 | + if (!qexists) | ||
1142 | + { | ||
1143 | + ColorConsole.WriteLine($" Queue does not exist!", ConsoleColor.Red); | ||
1144 | + } | ||
1145 | + else | ||
1146 | + { | ||
1147 | + try | ||
1148 | + { | ||
1149 | + msmq = msmq.CollectMSMQInfo(); | ||
1150 | + ColorConsole.WriteLine($"{msmq.QueueName}", ConsoleColor.Green, prefix: $" Queue name: "); | ||
1151 | + ColorConsole.WriteLine($"{msmq.MachineName}", ConsoleColor.Green, prefix: $" Server: "); | ||
1152 | + if (msmq.Status == "Error") | ||
1153 | + { | ||
1154 | + ColorConsole.WriteLine($"{msmq.Status}", ConsoleColor.Red, prefix: $" Status: "); | ||
1155 | + ColorConsole.WriteLine($"{msmq.StatusDescription}", ConsoleColor.Red, prefix: " StatusDescription: "); | ||
1156 | + } | ||
1157 | + else if (msmq.Status != "Ready") | ||
1158 | + { | ||
1159 | + ColorConsole.WriteLine($"{msmq.Status}", ConsoleColor.Yellow, prefix: $" Status: "); | ||
1160 | + ColorConsole.WriteLine($"{msmq.StatusDescription}", ConsoleColor.Yellow, prefix: " StatusDescription: "); | ||
1161 | + } | ||
1162 | + else | ||
1163 | + { | ||
1164 | + ColorConsole.WriteLine($"{msmq.Status}", ConsoleColor.Green, prefix: $" Status: "); | ||
1165 | + ColorConsole.WriteLine($"{msmq.StatusDescription}", ConsoleColor.Green, prefix: " StatusDescription: "); | ||
1166 | + ColorConsole.WriteLine($"{msmq.Id}", ConsoleColor.Green, prefix: " Id: "); | ||
1167 | + ColorConsole.WriteLine($"{msmq.Label}", ConsoleColor.Green, prefix: " Label: "); | ||
1168 | + ColorConsole.WriteLine($"{msmq.Path}", ConsoleColor.Green, prefix: " Path: "); | ||
1169 | + ColorConsole.WriteLine($"{msmq.FormatName}", ConsoleColor.Green, prefix: " FormatName: "); | ||
1170 | + ColorConsole.Write($"{msmq.Transactional}", ConsoleColor.Green, prefix: " Transactional: ", suffix: ", "); | ||
1171 | + ColorConsole.Write($"{msmq.UseJournalQueue}", ConsoleColor.Green, suffix: ", ", prefix: "UseJournalQueue: "); | ||
1172 | + ColorConsole.Write($"{msmq.AccessMode}", ConsoleColor.Green, suffix: ", ", prefix: "AccessMode: "); | ||
1173 | + ColorConsole.Write($"{msmq.CanRead}", ConsoleColor.Green, suffix: ", ", prefix: "CanRead: "); | ||
1174 | + ColorConsole.Write($"{msmq.CanWrite}", ConsoleColor.Green, suffix: ", ", prefix: "CanWrite: "); | ||
1175 | + ColorConsole.WriteLine(); | ||
1176 | + ColorConsole.Write($"{msmq.Authenticate}", ConsoleColor.Green, suffix: ", ", prefix: " Authenticate: "); | ||
1177 | + ColorConsole.Write($"{msmq.BasePriority}", ConsoleColor.Green, suffix: ", ", prefix: "BasePriority: "); | ||
1178 | + ColorConsole.Write($"{msmq.EncryptionRequired}", ConsoleColor.Green, suffix: ", ", prefix: "EncryptionRequired: "); | ||
1179 | + ColorConsole.WriteLine(); | ||
1180 | + ColorConsole.Write($"{msmq.Formatter}", ConsoleColor.Green, suffix: ", ", prefix: " Formatter: "); | ||
1181 | + ColorConsole.Write($"{msmq.LastModifyTime}", ConsoleColor.Green, suffix: ", ", prefix: "LastModifyTime: "); | ||
1182 | + ColorConsole.WriteLine(); | ||
1183 | + ColorConsole.Write($"{msmq.NumOfMessages}", ConsoleColor.Green, suffix: ", ", prefix: " NumOfMessages: "); | ||
1184 | + ColorConsole.Write($"{msmq.MaximumJournalSize}", ConsoleColor.Green, suffix: ", ", prefix: "MaximumJournalSize: "); | ||
1185 | + ColorConsole.Write($"{msmq.MaximumQueueSize}", ConsoleColor.Green, suffix: ", ", prefix: "MaximumQueueSize: "); | ||
1186 | + ColorConsole.WriteLine(); | ||
1187 | + } | ||
1188 | + } | ||
1189 | + catch (Exception ex) { ColorConsole.WriteLine(" " + ex.Message, ConsoleColor.Red); } | ||
1190 | + } | ||
1191 | + } | ||
1192 | + #endregion DisplayInfo | ||
1193 | + | ||
1194 | + #region XmlStructure | ||
1195 | + public static class XmlStructure | ||
1196 | + { | ||
1197 | + public static class MSMQManager | ||
1198 | + { | ||
1199 | + public static class General | ||
1200 | + { | ||
1201 | + public static class AccessRights | ||
1202 | + { | ||
1203 | + public static class AccessRight | ||
1204 | + { | ||
1205 | + public static class Attributes | ||
1206 | + { | ||
1207 | + public static class Username { public static class Values { public const string DEFAULT = "Everyone"; } } | ||
1208 | + public static class Right { public static class Values { public const string DEFAULT = nameof(MessageQueueAccessRights.FullControl); } } | ||
1209 | + public static class Control { public static class Values { public const string DEFAULT = nameof(AccessControlEntryType.Allow); } } | ||
1210 | + } | ||
1211 | + } | ||
1212 | + } | ||
1213 | + public static class MessageFiles | ||
1214 | + { | ||
1215 | + public static class Attributes | ||
1216 | + { | ||
1217 | + public static class Directory { public static class Values { public const string DEFAULT = ""; } } | ||
1218 | + public static class SendToMask { public static class Values { public const string DEFAULT = "*.*"; } } | ||
1219 | + public static class ReadToMask { public static class Values { public const string DEFAULT = "*.*"; } } | ||
1220 | + } | ||
1221 | + } | ||
1222 | + public static class DefaultFormatter { public static class Values { public const string DEFAULT = nameof(ActiveXMessageFormatter); } } | ||
1223 | + public static class DefaultEncoding { public static class Values { public const string DEFAULT = nameof(System.Text.Encoding.UTF8); } } | ||
1224 | + } | ||
1225 | + | ||
1226 | + public static class MessageQueues | ||
1227 | + { | ||
1228 | + public static class MessageQueue | ||
1229 | + { | ||
1230 | + public static class Attributes | ||
1231 | + { | ||
1232 | + public static class Key { public static class Values { public const string DEFAULT = ""; } } | ||
1233 | + public static class AddressPrefix { public static class Values { public const string DEFAULT = ""; } } | ||
1234 | + public static class Server { public static class Values { public const string DEFAULT = "."; } } | ||
1235 | + public static class Name { } | ||
1236 | + public static class Label { } | ||
1237 | + public static class Mode | ||
1238 | + { | ||
1239 | + public static class Values | ||
1240 | + { | ||
1241 | + public const string DEFAULT = "In"; | ||
1242 | + public static class In { } | ||
1243 | + public static class Out { } | ||
1244 | + } | ||
1245 | + } | ||
1246 | + public static class Formatter | ||
1247 | + { | ||
1248 | + public static class Values | ||
1249 | + { | ||
1250 | + public static class ActiveXMessageFormatter { } | ||
1251 | + public static class BinaryMessageFormatter { } | ||
1252 | + public static class XmlMessageFormatter { } | ||
1253 | + } | ||
1254 | + } | ||
1255 | + public static class Encoding { } | ||
1256 | + } | ||
1257 | + public static class AccessRight | ||
1258 | + { | ||
1259 | + public static class Attributes | ||
1260 | + { | ||
1261 | + public static class Username { public static class Values { public const string DEFAULT = "Everyone"; } } | ||
1262 | + public static class Right { public static class Values { public const string DEFAULT = nameof(MessageQueueAccessRights.FullControl); } } | ||
1263 | + public static class Control { public static class Values { public const string DEFAULT = nameof(AccessControlEntryType.Allow); } } | ||
1264 | + } | ||
1265 | + } | ||
1266 | + } | ||
1267 | + } | ||
1268 | + } | ||
1269 | + } | ||
1270 | + #endregion XmlStructure | ||
1271 | + } | ||
1272 | + #endregion MSMQ | ||
1273 | + | ||
793 | } | 1274 | } |
Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj
@@ -359,7 +359,6 @@ | @@ -359,7 +359,6 @@ | ||
359 | <Compile Include="ConsoleFunction - Tools.cs" /> | 359 | <Compile Include="ConsoleFunction - Tools.cs" /> |
360 | <Compile Include="Manager - BackupPackageManager.cs" /> | 360 | <Compile Include="Manager - BackupPackageManager.cs" /> |
361 | <Compile Include="Manager - InstallManager.cs" /> | 361 | <Compile Include="Manager - InstallManager.cs" /> |
362 | - <Compile Include="Manager - MSMQManager - MSMQ.cs" /> | ||
363 | <Compile Include="Manager - MSMQManager.cs" /> | 362 | <Compile Include="Manager - MSMQManager.cs" /> |
364 | <Compile Include="Manager - UserManager.cs" /> | 363 | <Compile Include="Manager - UserManager.cs" /> |
365 | <Compile Include="Manager - SQLDataBaseManager.cs" /> | 364 | <Compile Include="Manager - SQLDataBaseManager.cs" /> |