Commit 468b291cc2ff900f605072a30d6722c61513a446
1 parent
b83e80f6
v1.11.2.0
- MSMQ Manager-ben apró javítások
Showing
2 changed files
with
73 additions
and
47 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - MSMQManager.cs
@@ -15,7 +15,7 @@ using Vrh.XmlProcessing; | @@ -15,7 +15,7 @@ using Vrh.XmlProcessing; | ||
15 | using VRH.Common; | 15 | using VRH.Common; |
16 | using System.Xml.Linq; | 16 | using System.Xml.Linq; |
17 | using System.Text.RegularExpressions; | 17 | using System.Text.RegularExpressions; |
18 | - | 18 | +using System.ComponentModel; |
19 | 19 | ||
20 | namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | 20 | namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS |
21 | { | 21 | { |
@@ -72,7 +72,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -72,7 +72,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
72 | MSMQ st = p.Parameters as MSMQ; | 72 | MSMQ st = p.Parameters as MSMQ; |
73 | try | 73 | try |
74 | { | 74 | { |
75 | - var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 75 | + var fullpath = st.Xml_FullPath; |
76 | MSMQManagerCore.CreateQueue(fullpath, st.Xml_Label); | 76 | MSMQManagerCore.CreateQueue(fullpath, st.Xml_Label); |
77 | ColorConsole.WriteLine($"MSMQ:{st.Xml_Name} created.", ConsoleColor.Green); | 77 | ColorConsole.WriteLine($"MSMQ:{st.Xml_Name} created.", ConsoleColor.Green); |
78 | foreach (var accessright in st.Xml_AccessRights) | 78 | foreach (var accessright in st.Xml_AccessRights) |
@@ -106,7 +106,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -106,7 +106,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
106 | MSMQ st = p.Parameters as MSMQ; | 106 | MSMQ st = p.Parameters as MSMQ; |
107 | try | 107 | try |
108 | { | 108 | { |
109 | - var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 109 | + var fullpath = st.Xml_FullPath; |
110 | MSMQManagerCore.DeleteQueue(fullpath); | 110 | MSMQManagerCore.DeleteQueue(fullpath); |
111 | ColorConsole.WriteLine($"MSMQ:{st.Xml_Name} removed.", ConsoleColor.Green); | 111 | ColorConsole.WriteLine($"MSMQ:{st.Xml_Name} removed.", ConsoleColor.Green); |
112 | } | 112 | } |
@@ -138,7 +138,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -138,7 +138,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
138 | { | 138 | { |
139 | foreach (var accessright in st.Xml_AccessRights) | 139 | foreach (var accessright in st.Xml_AccessRights) |
140 | { | 140 | { |
141 | - var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 141 | + var fullpath = st.Xml_FullPath; |
142 | MSMQManagerCore.SetPermissions(fullpath, accessright.un, accessright.ar, accessright.ac); | 142 | MSMQManagerCore.SetPermissions(fullpath, accessright.un, accessright.ar, accessright.ac); |
143 | string ctrlstring = accessright.AccessControlEntryTypeText(); | 143 | string ctrlstring = accessright.AccessControlEntryTypeText(); |
144 | ColorConsole.WriteLine($"Access right {accessright.ar} {ctrlstring} for user:{accessright.un}.", ConsoleColor.Green); | 144 | ColorConsole.WriteLine($"Access right {accessright.ar} {ctrlstring} for user:{accessright.un}.", ConsoleColor.Green); |
@@ -171,12 +171,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -171,12 +171,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
171 | 171 | ||
172 | while (true) | 172 | while (true) |
173 | { | 173 | { |
174 | - string username = ColorConsole.ReadLine("Enter username:", ConsoleColor.Yellow,defaultvalue:defaultusername); | 174 | + string username = ColorConsole.ReadLine("Enter username:", ConsoleColor.Yellow, defaultvalue: defaultusername); |
175 | if (username.ToUpper() == "EX") { break; } | 175 | if (username.ToUpper() == "EX") { break; } |
176 | 176 | ||
177 | - string accessrightsstring = ColorConsole.ReadLine("Enter access right:", ConsoleColor.Yellow, validitylist: Enum.GetNames(typeof(MessageQueueAccessRights)).Select(e=>e.ToString()).ToList(), defaultvalue: defaultaccessrightsstring); | 177 | + string accessrightsstring = ColorConsole.ReadLine("Enter access right:", ConsoleColor.Yellow, validitylist: Enum.GetNames(typeof(MessageQueueAccessRights)).Select(e => e.ToString()).ToList(), defaultvalue: defaultaccessrightsstring); |
178 | if (accessrightsstring.ToUpper() == "EX") { break; } | 178 | if (accessrightsstring.ToUpper() == "EX") { break; } |
179 | - var accessrights = (MessageQueueAccessRights)Enum.Parse(typeof(MessageQueueAccessRights),accessrightsstring); | 179 | + var accessrights = (MessageQueueAccessRights)Enum.Parse(typeof(MessageQueueAccessRights), accessrightsstring); |
180 | 180 | ||
181 | string controltypestring = ColorConsole.ReadLine("Enter access right:", ConsoleColor.Yellow, validitylist: Enum.GetNames(typeof(AccessControlEntryType)).Select(e => e.ToString()).ToList(), defaultvalue: defaultcontroltypestring); | 181 | string controltypestring = ColorConsole.ReadLine("Enter access right:", ConsoleColor.Yellow, validitylist: Enum.GetNames(typeof(AccessControlEntryType)).Select(e => e.ToString()).ToList(), defaultvalue: defaultcontroltypestring); |
182 | if (controltypestring.ToUpper() == "EX") { break; } | 182 | if (controltypestring.ToUpper() == "EX") { break; } |
@@ -187,7 +187,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -187,7 +187,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
187 | MSMQ st = p.Parameters as MSMQ; | 187 | MSMQ st = p.Parameters as MSMQ; |
188 | try | 188 | try |
189 | { | 189 | { |
190 | - var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 190 | + var fullpath = st.Xml_FullPath; |
191 | MSMQManagerCore.SetPermissions(fullpath, username, accessrights, controltype); | 191 | MSMQManagerCore.SetPermissions(fullpath, username, accessrights, controltype); |
192 | ColorConsole.WriteLine($"Permissions set for MSMQ:{st.Xml_Name}. Username:{username}, access right: {accessrights}, control type: {controltype}", ConsoleColor.Green); | 192 | ColorConsole.WriteLine($"Permissions set for MSMQ:{st.Xml_Name}. Username:{username}, access right: {accessrights}, control type: {controltype}", ConsoleColor.Green); |
193 | } | 193 | } |
@@ -211,14 +211,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -211,14 +211,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
211 | string sn; | 211 | string sn; |
212 | while (true) | 212 | while (true) |
213 | { | 213 | { |
214 | - sn = ColorConsole.ReadLine("Enter server ip/name to get queue info from (enter . for localhost)",defaultvalue:sndefault); | 214 | + sn = ColorConsole.ReadLine("Enter server ip/name to get queue info from (enter . for localhost)", defaultvalue: sndefault); |
215 | if (sn.ToLower() == "ex") { return o; } | 215 | if (sn.ToLower() == "ex") { return o; } |
216 | sndefault = sn; | 216 | sndefault = sn; |
217 | 217 | ||
218 | List<System.Messaging.MessageQueue> queuearray = new List<System.Messaging.MessageQueue>(); | 218 | List<System.Messaging.MessageQueue> queuearray = new List<System.Messaging.MessageQueue>(); |
219 | queuearray = System.Messaging.MessageQueue.GetPrivateQueuesByMachine(sn).ToList(); | 219 | queuearray = System.Messaging.MessageQueue.GetPrivateQueuesByMachine(sn).ToList(); |
220 | 220 | ||
221 | - var menumsmqs = DisplayMSMQMenu(queuearray.Select((q, ixx) => new MSMQ(q, "Q"+((ixx + 1).ToString()))).ToList(), $"Select the MSMQ(s) on server '{sn}'!", silent: false,midf: DisplayMSMQShortInfo) | 221 | + var menumsmqs = DisplayMSMQMenu(queuearray.Select((q, ixx) => new MSMQ(q, "Q" + ((ixx + 1).ToString()))).ToList(), $"Select the MSMQ(s) on server '{sn}'!", silent: false, midf: DisplayMSMQShortInfo) |
222 | .SetSelectionMode(Menu.SelectionMode.Multi); | 222 | .SetSelectionMode(Menu.SelectionMode.Multi); |
223 | 223 | ||
224 | Menu.Selection sr = menumsmqs.Select(); | 224 | Menu.Selection sr = menumsmqs.Select(); |
@@ -235,12 +235,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -235,12 +235,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
235 | var sp = SendParameters.Get(msmq.Xml_Encoding, msmq.Xml_Formatter); | 235 | var sp = SendParameters.Get(msmq.Xml_Encoding, msmq.Xml_Formatter); |
236 | if (sp != null) | 236 | if (sp != null) |
237 | { | 237 | { |
238 | - var fullpath = MSMQManagerCore.CreateFullQueuePath(msmq.Xml_AddressPrefix, msmq.Xml_Server, msmq.Xml_Name); | 238 | + var fullpath = msmq.Xml_FullPath; |
239 | MSMQManagerCore.Send(fullpath, sp.messagebody, sp.messagelabel, sp.messageformatter, sp.encoding); | 239 | MSMQManagerCore.Send(fullpath, sp.messagebody, sp.messagelabel, sp.messageformatter, sp.encoding); |
240 | ColorConsole.WriteLine($"Sending to '{fullpath}' ....", ConsoleColor.Yellow); | 240 | ColorConsole.WriteLine($"Sending to '{fullpath}' ....", ConsoleColor.Yellow); |
241 | Message msg = MSMQManagerCore.PeekLast(fullpath, sp.messageformatter, sp.encoding, out string body, out string label); | 241 | Message msg = MSMQManagerCore.PeekLast(fullpath, sp.messageformatter, sp.encoding, out string body, out string label); |
242 | TestSendCheckMessage(fullpath, msg, sp, body, label, "message sending/peek back"); | 242 | TestSendCheckMessage(fullpath, msg, sp, body, label, "message sending/peek back"); |
243 | - 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 | + 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"); |
244 | if (ans.ToLower() == "yes") | 244 | if (ans.ToLower() == "yes") |
245 | { | 245 | { |
246 | msg = MSMQManagerCore.ReadById(fullpath, msg.LookupId, sp.messageformatter, sp.encoding, out body, out label); | 246 | msg = MSMQManagerCore.ReadById(fullpath, msg.LookupId, sp.messageformatter, sp.encoding, out body, out label); |
@@ -253,7 +253,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -253,7 +253,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
253 | return o; | 253 | return o; |
254 | } | 254 | } |
255 | 255 | ||
256 | - private static void TestSendCheckMessage(string fullpath,Message msg, SendParameters sp, string body, string label,string actiontext) | 256 | + private static void TestSendCheckMessage(string fullpath, Message msg, SendParameters sp, string body, string label, string actiontext) |
257 | { | 257 | { |
258 | if (sp.messagebody == body && sp.messagelabel == label) { ColorConsole.WriteLine($"Success! Action:{actiontext}. Queue:'{fullpath}'.", ConsoleColor.Green); } | 258 | if (sp.messagebody == body && sp.messagelabel == label) { ColorConsole.WriteLine($"Success! Action:{actiontext}. Queue:'{fullpath}'.", ConsoleColor.Green); } |
259 | else | 259 | else |
@@ -310,7 +310,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -310,7 +310,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
310 | { | 310 | { |
311 | var messageformatter = MSMQManagerCore.SetFormatter(st.Xml_Formatter); //new ActiveXMessageFormatter(); | 311 | var messageformatter = MSMQManagerCore.SetFormatter(st.Xml_Formatter); //new ActiveXMessageFormatter(); |
312 | var encoding = MSMQManagerCore.SetEncoding(st.Xml_Encoding); // Encoding.UTF8; | 312 | var encoding = MSMQManagerCore.SetEncoding(st.Xml_Encoding); // Encoding.UTF8; |
313 | - var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 313 | + var fullpath = st.Xml_FullPath; |
314 | MSMQManagerCore.Peek(fullpath, messageformatter, encoding, out string msgbody, out string msglabel); | 314 | MSMQManagerCore.Peek(fullpath, messageformatter, encoding, out string msgbody, out string msglabel); |
315 | ColorConsole.WriteLine($"Message peeked from MSMQ:{st.Xml_Name}", ConsoleColor.Green); | 315 | ColorConsole.WriteLine($"Message peeked from MSMQ:{st.Xml_Name}", ConsoleColor.Green); |
316 | ColorConsole.WriteLine($" Body: {msgbody}", ConsoleColor.Yellow); | 316 | ColorConsole.WriteLine($" Body: {msgbody}", ConsoleColor.Yellow); |
@@ -346,7 +346,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -346,7 +346,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
346 | { | 346 | { |
347 | var messageformatter = MSMQManagerCore.SetFormatter(st.Xml_Formatter); //new ActiveXMessageFormatter(); | 347 | var messageformatter = MSMQManagerCore.SetFormatter(st.Xml_Formatter); //new ActiveXMessageFormatter(); |
348 | var encoding = MSMQManagerCore.SetEncoding(st.Xml_Encoding); // Encoding.UTF8; | 348 | var encoding = MSMQManagerCore.SetEncoding(st.Xml_Encoding); // Encoding.UTF8; |
349 | - var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 349 | + var fullpath = st.Xml_FullPath; |
350 | MSMQManagerCore.Read(fullpath, messageformatter, encoding, out string msgbody, out string msglabel); | 350 | MSMQManagerCore.Read(fullpath, messageformatter, encoding, out string msgbody, out string msglabel); |
351 | ColorConsole.WriteLine($"Message read from MSMQ:{st.Xml_Name}", ConsoleColor.Green); | 351 | ColorConsole.WriteLine($"Message read from MSMQ:{st.Xml_Name}", ConsoleColor.Green); |
352 | ColorConsole.WriteLine($" Body: {msgbody}", ConsoleColor.Yellow); | 352 | ColorConsole.WriteLine($" Body: {msgbody}", ConsoleColor.Yellow); |
@@ -368,7 +368,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -368,7 +368,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
368 | 368 | ||
369 | var menufolders = DisplayMSMQMenuFromXml(config, $"Select the MSMQ(s) to manage with function '{nameof(Send)}'!", silent: true) | 369 | var menufolders = DisplayMSMQMenuFromXml(config, $"Select the MSMQ(s) to manage with function '{nameof(Send)}'!", silent: true) |
370 | .SetSelectionMode(Menu.SelectionMode.Single); | 370 | .SetSelectionMode(Menu.SelectionMode.Single); |
371 | - | 371 | + |
372 | Menu.Selection sr = menufolders.Select(selectedtaskindexes); | 372 | Menu.Selection sr = menufolders.Select(selectedtaskindexes); |
373 | if (sr.Result == Menu.SelectionResult.Exit) { return o; } | 373 | if (sr.Result == Menu.SelectionResult.Exit) { return o; } |
374 | else if (sr.Result == Menu.SelectionResult.None) { return o; } | 374 | else if (sr.Result == Menu.SelectionResult.None) { return o; } |
@@ -385,8 +385,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -385,8 +385,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
385 | var sp = SendParameters.Get(st.Xml_Encoding, st.Xml_Formatter); | 385 | var sp = SendParameters.Get(st.Xml_Encoding, st.Xml_Formatter); |
386 | if (sp == null) { break; } | 386 | if (sp == null) { break; } |
387 | 387 | ||
388 | - var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | ||
389 | - MSMQManagerCore.Send(fullpath,sp.messagebody, sp.messagelabel, sp.messageformatter, sp.encoding); | 388 | + var fullpath = st.Xml_FullPath; |
389 | + MSMQManagerCore.Send(fullpath, sp.messagebody, sp.messagelabel, sp.messageformatter, sp.encoding); | ||
390 | ColorConsole.WriteLine($"Message sent to MSMQ:{st.Xml_Name}.", ConsoleColor.Green); | 390 | ColorConsole.WriteLine($"Message sent to MSMQ:{st.Xml_Name}.", ConsoleColor.Green); |
391 | } | 391 | } |
392 | catch (ApplicationException ex) { ColorConsole.WriteLine(ex.Message, ConsoleColor.Red); } | 392 | catch (ApplicationException ex) { ColorConsole.WriteLine(ex.Message, ConsoleColor.Red); } |
@@ -424,9 +424,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -424,9 +424,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
424 | public IMessageFormatter messageformatter; | 424 | public IMessageFormatter messageformatter; |
425 | public Encoding encoding; | 425 | public Encoding encoding; |
426 | public SendParameters() { } | 426 | public SendParameters() { } |
427 | - public static SendParameters Get(string defaultencoding, string defaultformatter) | 427 | + public static SendParameters Get(string defaultencoding, string defaultformatter) |
428 | { | 428 | { |
429 | - ColorConsole.WriteLine("Enter test message data!",ConsoleColor.Yellow); | 429 | + ColorConsole.WriteLine("Enter test message data!", ConsoleColor.Yellow); |
430 | var sp = new SendParameters() { }; | 430 | var sp = new SendParameters() { }; |
431 | var now = DateTime.Now.ToString(); | 431 | var now = DateTime.Now.ToString(); |
432 | sp.messagebody = ColorConsole.ReadLine("Enter message body:", ConsoleColor.Yellow, defaultvalue: "TEST MESSAGE " + now); | 432 | sp.messagebody = ColorConsole.ReadLine("Enter message body:", ConsoleColor.Yellow, defaultvalue: "TEST MESSAGE " + now); |
@@ -468,7 +468,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -468,7 +468,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
468 | MSMQ st = p.Parameters as MSMQ; | 468 | MSMQ st = p.Parameters as MSMQ; |
469 | try | 469 | try |
470 | { | 470 | { |
471 | - var fullpath = MSMQManagerCore.CreateFullQueuePath(st.Xml_AddressPrefix, st.Xml_Server, st.Xml_Name); | 471 | + var fullpath = st.Xml_FullPath; |
472 | MSMQManagerCore.Purge(fullpath); | 472 | MSMQManagerCore.Purge(fullpath); |
473 | ColorConsole.WriteLine($"MSMQ messages purged. Name:{st.Xml_Name}", ConsoleColor.Green); | 473 | ColorConsole.WriteLine($"MSMQ messages purged. Name:{st.Xml_Name}", ConsoleColor.Green); |
474 | } | 474 | } |
@@ -485,9 +485,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -485,9 +485,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
485 | { | 485 | { |
486 | if (config == null) { config = new MSMQManagerXmlProcessor(XMLCONNECTIONSTRING, "", "hu-HU"); } | 486 | if (config == null) { config = new MSMQManagerXmlProcessor(XMLCONNECTIONSTRING, "", "hu-HU"); } |
487 | List<MSMQ> msmqdefList = config.GetDefinitionList(); | 487 | List<MSMQ> msmqdefList = config.GetDefinitionList(); |
488 | - return DisplayMSMQMenu(msmqdefList, prompt,silent,DisplayMSMQInfo); | 488 | + return DisplayMSMQMenu(msmqdefList, prompt, silent, DisplayMSMQInfo); |
489 | } | 489 | } |
490 | - private static Menu DisplayMSMQMenu(List<MSMQ> msmqlist = null, string prompt = null, bool silent = false,Menu.MenuItemDisplayerFunc midf=null) | 490 | + private static Menu DisplayMSMQMenu(List<MSMQ> msmqlist = null, string prompt = null, bool silent = false, Menu.MenuItemDisplayerFunc midf = null) |
491 | { | 491 | { |
492 | List<MSMQ> msmqdefList = msmqlist; | 492 | List<MSMQ> msmqdefList = msmqlist; |
493 | var menufct = new Menu("MSMQ list", prompt) | 493 | var menufct = new Menu("MSMQ list", prompt) |
@@ -559,18 +559,18 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -559,18 +559,18 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
559 | successpattern = p; | 559 | successpattern = p; |
560 | bool isip = IPAddress.TryParse(servername, out IPAddress ip); | 560 | bool isip = IPAddress.TryParse(servername, out IPAddress ip); |
561 | if (servername == "" || servername == "." || servername.ToLower() == "localhost") { servername = System.Environment.MachineName; } | 561 | if (servername == "" || servername == "." || servername.ToLower() == "localhost") { servername = System.Environment.MachineName; } |
562 | - if (formatname == "") | ||
563 | - { | 562 | + if (formatname == "") |
563 | + { | ||
564 | if (isip) { formatname = @"FormatName:DIRECT=TCP"; addresstype = @"TCP"; } | 564 | if (isip) { formatname = @"FormatName:DIRECT=TCP"; addresstype = @"TCP"; } |
565 | else { formatname = @"FormatName:DIRECT=OS"; addresstype = @"OS"; } | 565 | else { formatname = @"FormatName:DIRECT=OS"; addresstype = @"OS"; } |
566 | } | 566 | } |
567 | - if ((isip && addresstype=="OS") || (!isip && addresstype == "TCP")) { return false; } | 567 | + if ((isip && addresstype == "OS") || (!isip && addresstype == "TCP")) { return false; } |
568 | return true; | 568 | return true; |
569 | } | 569 | } |
570 | } | 570 | } |
571 | return false; | 571 | return false; |
572 | } | 572 | } |
573 | - public static bool CheckIfQueueExists(string servername,string queuefullname) | 573 | + public static bool CheckIfQueueExists(string servername, string queuefullname) |
574 | { | 574 | { |
575 | if (string.IsNullOrWhiteSpace(servername) || servername == "." || servername.ToLower() == "localhost") { servername = System.Environment.MachineName; } | 575 | if (string.IsNullOrWhiteSpace(servername) || servername == "." || servername.ToLower() == "localhost") { servername = System.Environment.MachineName; } |
576 | if (servername == "*") | 576 | if (servername == "*") |
@@ -586,15 +586,15 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -586,15 +586,15 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
586 | //var queuenamelist = queuearray.Select(q => q.Path == queuefullname || q.FormatName== queuefullname || q.QueueName== queuefullname).ToList(); | 586 | //var queuenamelist = queuearray.Select(q => q.Path == queuefullname || q.FormatName== queuefullname || q.QueueName== queuefullname).ToList(); |
587 | //return queuenamelist.Any(); | 587 | //return queuenamelist.Any(); |
588 | } | 588 | } |
589 | - public static void CreateQueue(string msmqFullname, string label=null) | 589 | + public static void CreateQueue(string msmqFullname, string label = null) |
590 | { | 590 | { |
591 | - if (!MessageQueue.Exists(msmqFullname)) { MessageQueue.Create(msmqFullname); } | 591 | + if (!MSMQ.IsExists(msmqFullname, out string returnmessage)) { MessageQueue.Create(msmqFullname); } |
592 | using (var msmq = new MessageQueue(msmqFullname)) | 592 | using (var msmq = new MessageQueue(msmqFullname)) |
593 | { | 593 | { |
594 | if (!string.IsNullOrWhiteSpace(label)) { msmq.Label = label; } | 594 | if (!string.IsNullOrWhiteSpace(label)) { msmq.Label = label; } |
595 | } | 595 | } |
596 | } | 596 | } |
597 | - public static void SetPermissions(string msmqFullname,string username, MessageQueueAccessRights accessrights, AccessControlEntryType controltype) | 597 | + public static void SetPermissions(string msmqFullname, string username, MessageQueueAccessRights accessrights, AccessControlEntryType controltype) |
598 | { | 598 | { |
599 | using (var msmq = new MessageQueue(msmqFullname)) | 599 | using (var msmq = new MessageQueue(msmqFullname)) |
600 | { | 600 | { |
@@ -621,7 +621,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -621,7 +621,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
621 | 621 | ||
622 | public static void DeleteQueue(string msmqFullname) | 622 | public static void DeleteQueue(string msmqFullname) |
623 | { | 623 | { |
624 | - if (MessageQueue.Exists(msmqFullname)) { MessageQueue.Delete(msmqFullname); } | 624 | + if (MSMQ.IsExists(msmqFullname,out string returnmessage)) { MessageQueue.Delete(msmqFullname); } |
625 | } | 625 | } |
626 | public static void Purge(string msmqFullname) | 626 | public static void Purge(string msmqFullname) |
627 | { | 627 | { |
@@ -747,8 +747,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -747,8 +747,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
747 | label = ""; | 747 | label = ""; |
748 | using (var msmq = new MessageQueue(msmqFullname)) | 748 | using (var msmq = new MessageQueue(msmqFullname)) |
749 | { | 749 | { |
750 | - if (Count(msmq) == 0) {return null; } | ||
751 | - | 750 | + if (Count(msmq) == 0) { return null; } |
751 | + | ||
752 | msmq.Formatter = messageformatter; | 752 | msmq.Formatter = messageformatter; |
753 | var m = msmq.ReceiveByLookupId(msgid); | 753 | var m = msmq.ReceiveByLookupId(msgid); |
754 | label = m.Label; | 754 | label = m.Label; |
@@ -886,7 +886,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -886,7 +886,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
886 | public List<AccessRights> Xml_AccessRights = new List<AccessRights>(); | 886 | public List<AccessRights> Xml_AccessRights = new List<AccessRights>(); |
887 | public MSMQDefaults(XElement rootxml) | 887 | public MSMQDefaults(XElement rootxml) |
888 | { | 888 | { |
889 | - var generalxml = GetXElement(rootxml,nameof(MSMQ.XmlStructure.MSMQManager.General)); | 889 | + var generalxml = GetXElement(rootxml, nameof(MSMQ.XmlStructure.MSMQManager.General)); |
890 | var messagefiles = GetXElement(generalxml, nameof(MSMQ.XmlStructure.MSMQManager.General.MessageFiles)); | 890 | var messagefiles = GetXElement(generalxml, nameof(MSMQ.XmlStructure.MSMQManager.General.MessageFiles)); |
891 | 891 | ||
892 | Xml_MessageFilesDirectory = GetValue(nameof(MSMQ.XmlStructure.MSMQManager.General.MessageFiles.Attributes.Directory), messagefiles, MSMQ.XmlStructure.MSMQManager.General.MessageFiles.Attributes.Directory.Values.DEFAULT); | 892 | Xml_MessageFilesDirectory = GetValue(nameof(MSMQ.XmlStructure.MSMQManager.General.MessageFiles.Attributes.Directory), messagefiles, MSMQ.XmlStructure.MSMQManager.General.MessageFiles.Attributes.Directory.Values.DEFAULT); |
@@ -945,6 +945,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -945,6 +945,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
945 | public EncryptionRequired EncryptionRequired; | 945 | public EncryptionRequired EncryptionRequired; |
946 | #endregion fields | 946 | #endregion fields |
947 | 947 | ||
948 | + public string Xml_FullPath {get{return MSMQManagerCore.CreateFullQueuePath(this.Xml_AddressPrefix, this.Xml_Server, this.Xml_Name);} } | ||
949 | + | ||
948 | #region basic constructor | 950 | #region basic constructor |
949 | public MSMQ() { } | 951 | public MSMQ() { } |
950 | #endregion basic constructor | 952 | #endregion basic constructor |
@@ -1007,22 +1009,38 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -1007,22 +1009,38 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
1007 | } | 1009 | } |
1008 | #endregion Xml cloner constructor | 1010 | #endregion Xml cloner constructor |
1009 | 1011 | ||
1010 | - #region CollectMSMQInfo | ||
1011 | - public MSMQ CollectMSMQInfo() | 1012 | + #region IsExists |
1013 | + public static bool IsExists(string queueName, out string returnmessage) | ||
1014 | + { | ||
1015 | + returnmessage = ""; | ||
1016 | + //return MessageQueue.Exists(queueName); // nem működik remote messagequeue esetében | ||
1017 | + var queue = new MessageQueue(queueName); | ||
1018 | + try | ||
1019 | + { | ||
1020 | + queue.Peek(new TimeSpan(0, 0, 5)); | ||
1021 | + return true; | ||
1022 | + } | ||
1023 | + catch (MessageQueueException ex) | ||
1024 | + { | ||
1025 | + returnmessage= ex.ErrorCode + ":" + ex.Message + (ex.InnerException != null ? ("\n" + ex.InnerException.Message) : ""); | ||
1026 | + return ex.Message.StartsWith("Timeout"); | ||
1027 | + } | ||
1028 | + } | ||
1029 | + #endregion IsExists | ||
1030 | + | ||
1031 | + #region CollectMSMQInfo | ||
1032 | + public MSMQ CollectMSMQInfo() | ||
1012 | { | 1033 | { |
1013 | MSMQ msmqdef = this; | 1034 | MSMQ msmqdef = this; |
1014 | - string msmqaddressprefix = msmqdef.Xml_AddressPrefix; | ||
1015 | - string msmqservername = msmqdef.Xml_Server; | ||
1016 | - string msmqFullname = MSMQManagerCore.CreateFullQueuePath(msmqaddressprefix, msmqservername, msmqdef.Xml_Name); | ||
1017 | msmqdef.QueueName = msmqdef.Xml_Name; | 1035 | msmqdef.QueueName = msmqdef.Xml_Name; |
1018 | - msmqdef.MachineName = msmqservername; | ||
1019 | - msmqdef.Path = msmqFullname; | 1036 | + msmqdef.MachineName = msmqdef.Xml_Server; |
1037 | + msmqdef.Path = msmqdef.Xml_FullPath; | ||
1020 | try | 1038 | try |
1021 | { | 1039 | { |
1022 | - msmqdef.Status = MessageQueue.Exists(msmqFullname) ? "Installed" : "Uninstalled"; | 1040 | + msmqdef.Status = MSMQ.IsExists(msmqdef.Path,out string returnmessage) ? "Installed" : "Uninstalled/Error"; |
1023 | if (msmqdef.Status == "Installed") | 1041 | if (msmqdef.Status == "Installed") |
1024 | { | 1042 | { |
1025 | - using (var msmq = new MessageQueue(msmqFullname)) | 1043 | + using (var msmq = new MessageQueue(msmqdef.Path)) |
1026 | { | 1044 | { |
1027 | msmqdef.QueueName = msmq.QueueName; | 1045 | msmqdef.QueueName = msmq.QueueName; |
1028 | msmqdef.MachineName = msmq.MachineName; | 1046 | msmqdef.MachineName = msmq.MachineName; |
@@ -1049,8 +1067,16 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -1049,8 +1067,16 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
1049 | msmqdef.Status = "Ready"; | 1067 | msmqdef.Status = "Ready"; |
1050 | } | 1068 | } |
1051 | } | 1069 | } |
1070 | + else { msmqdef.StatusDescription = returnmessage; } | ||
1071 | + } | ||
1072 | + catch (MessageQueueException ex) | ||
1073 | + { | ||
1074 | + msmqdef.Status = "Error"; msmqdef.StatusDescription = ex.ErrorCode +":"+ ex.Message + (ex.InnerException != null ? ("\n" + ex.InnerException.Message) : ""); | ||
1075 | + } | ||
1076 | + catch (Exception ex) | ||
1077 | + { | ||
1078 | + msmqdef.Status = "Error"; msmqdef.StatusDescription = ex.Message + (ex.InnerException != null ? ("\n" + ex.InnerException.Message) : ""); | ||
1052 | } | 1079 | } |
1053 | - catch (Exception ex) { msmqdef.Status = "Error"; msmqdef.StatusDescription = ex.Message + (ex.InnerException != null ? ("\n" + ex.InnerException.Message) : ""); } | ||
1054 | return msmqdef; | 1080 | return msmqdef; |
1055 | } | 1081 | } |
1056 | #endregion CollectMSMQInfo | 1082 | #endregion CollectMSMQInfo |
@@ -1075,7 +1101,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | @@ -1075,7 +1101,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MSMQManagerNS | ||
1075 | { | 1101 | { |
1076 | var privatepublictext = msmq.Private ? "private" : "public"; | 1102 | var privatepublictext = msmq.Private ? "private" : "public"; |
1077 | ColorConsole.Write($"{msmq.Xml_AddressPrefix}", ConsoleColor.Black, ConsoleColor.White, prefix: "Format:", suffix: $" Queue is { privatepublictext }."); | 1103 | ColorConsole.Write($"{msmq.Xml_AddressPrefix}", ConsoleColor.Black, ConsoleColor.White, prefix: "Format:", suffix: $" Queue is { privatepublictext }."); |
1078 | - ColorConsole.Write($"{msmq.Xml_Server}", ConsoleColor.Black, ConsoleColor.White, prefix: "Server:", suffix: $" Queue is { privatepublictext }."); | 1104 | + ColorConsole.Write($"{msmq.Xml_Server}", ConsoleColor.Black, ConsoleColor.White, prefix: "Server:"); |
1079 | ColorConsole.WriteLine(); | 1105 | ColorConsole.WriteLine(); |
1080 | return " "; | 1106 | return " "; |
1081 | } | 1107 | } |
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | ||
32 | // You can specify all the values or you can default the Build and Revision Numbers | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
33 | // by using the '*' as shown below: | 33 | // by using the '*' as shown below: |
34 | // [assembly: AssemblyVersion("1.0.*")] | 34 | // [assembly: AssemblyVersion("1.0.*")] |
35 | -[assembly: AssemblyVersion("1.11.1.0")] | ||
36 | -[assembly: AssemblyFileVersion("1.11.1.0")] | 35 | +[assembly: AssemblyVersion("1.11.2.0")] |
36 | +[assembly: AssemblyFileVersion("1.11.2.0")] |