/// <summary> /// Parses the string of the message and obtains caducity and priority /// </summary> protected virtual void parseString() { XmlDocument doc = new XmlDocument(); doc.LoadXml(_msg); _priority = System.Messaging.MessagePriority.Normal; _caducity = System.Messaging.Message.InfiniteTimeout; // Get atributes of root (message) node XmlAttributeCollection attrs = doc.Attributes; if (attrs != null) { XmlAttribute attr = attrs["p"]; if (attr != null) { int ipriority = Convert.ToInt32(attr.Value); switch (ipriority) { case 0: _priority = System.Messaging.MessagePriority.Lowest; break; case 1: _priority = System.Messaging.MessagePriority.VeryLow; break; case 2: _priority = System.Messaging.MessagePriority.Low; break; case 3: _priority = System.Messaging.MessagePriority.Normal; break; case 4: _priority = System.Messaging.MessagePriority.AboveNormal; break; case 5: _priority = System.Messaging.MessagePriority.High; break; case 6: _priority = System.Messaging.MessagePriority.VeryHigh; break; case 7: _priority = System.Messaging.MessagePriority.Highest; break; } } attr = attrs["c"]; if (attr != null) { int seconds = Convert.ToInt32(attr.Value); _caducity = new TimeSpan(0, 0, seconds); } } // end if(attrs!=null) }
private System.Messaging.MessagePriority GetSelectedMessagePriority() { System.Messaging.MessagePriority result = System.Messaging.MessagePriority.Normal; foreach (ToolStripItem item in optionsPriorityMenuItem.DropDownItems) { ToolStripMenuItem menuItem = item as ToolStripMenuItem; if (menuItem != null && menuItem.Checked) { result = (System.Messaging.MessagePriority)item.Tag; break; } } return(result); }
public void ResolveLoggerWithMsmqWhenConfigured() { const string ListenerName = "Msmq Listener"; const string FormatterName = "Text Formatter"; const string Template = "My template"; System.Messaging.MessagePriority messagePriority = System.Messaging.MessagePriority.Lowest; TimeSpan timeToBeReceived = TimeSpan.MinValue; TimeSpan timeToReachQueue = TimeSpan.MaxValue; System.Messaging.MessageQueueTransactionType trxType = System.Messaging.MessageQueueTransactionType.Automatic; const string QueuePath = "QueuePath"; configurationStart.LogToCategoryNamed(CategoryName) .WithOptions .DoNotAutoFlushEntries() .SetAsDefaultCategory() .ToSourceLevels(SourceLevels.ActivityTracing) .SendTo .Msmq(ListenerName) .UseQueue(QueuePath) .AsRecoverable() .Prioritize(messagePriority) .UseAuthentication() .UseDeadLetterQueue() .UseEncryption() .WithTransactionType(trxType) .SetTimeToBeReceived(timeToBeReceived) .SetTimeToReachQueue(timeToReachQueue) .WithTraceOptions(TraceOptions.None) .Filter(SourceLevels.Verbose) .FormatWith(new FormatterBuilder() .TextFormatterNamed(FormatterName) .UsingTemplate(Template)); this.SetConfigurationSource(); LogWriterFactory factory = new LogWriterFactory((e) => this.ConfigurationSource.GetSection(e)); this.writer = factory.Create(); Assert.IsNotNull(this.writer); Assert.AreEqual(typeof(MsmqTraceListener), writer.TraceSources[CategoryName].Listeners.First().GetType()); }
private void SelectMessagePriorityMenuItem(System.Messaging.MessagePriority priority) { foreach (ToolStripItem item in optionsPriorityMenuItem.DropDownItems) { var menuItem = item as ToolStripMenuItem; if (menuItem != null) { if ((System.Messaging.MessagePriority)item.Tag == priority) { menuItem.Checked = true; } else { menuItem.Checked = false; } } } }
public void ConfigurationIsCorrectWhenConfiguringLoggingWithMsmq() { const string QueuePath = "QueuePath"; const string ListenerName = "Msmq Listener"; const string FormatterName = "Text Formatter"; const string Template = "My template"; System.Messaging.MessagePriority messagePriority = System.Messaging.MessagePriority.Lowest; TimeSpan timeToBeReceived = TimeSpan.MinValue; TimeSpan timeToReachQueue = TimeSpan.MaxValue; System.Messaging.MessageQueueTransactionType trxType = System.Messaging.MessageQueueTransactionType.Automatic; configurationStart.LogToCategoryNamed(CategoryName) .WithOptions .DoNotAutoFlushEntries() .SetAsDefaultCategory() .ToSourceLevels(SourceLevels.ActivityTracing) .SendTo .Msmq(ListenerName) .UseQueue(QueuePath) .AsRecoverable() .Prioritize(messagePriority) .UseAuthentication() .UseDeadLetterQueue() .UseEncryption() .WithTransactionType(trxType) .SetTimeToBeReceived(timeToBeReceived) .SetTimeToReachQueue(timeToReachQueue) .WithTraceOptions(TraceOptions.None) .Filter(SourceLevels.Verbose) .FormatWith(new FormatterBuilder() .TextFormatterNamed(FormatterName) .UsingTemplate(Template)); LoggingSettings settings = GetLoggingSettings(); Assert.IsNotNull(settings); Assert.AreEqual(LoggingFixtureBase.CategoryName, settings.DefaultCategory); Assert.AreEqual(1, settings.TraceSources.Count); var traceSource = settings.TraceSources.Get(0); Assert.IsFalse(traceSource.AutoFlush); Assert.AreEqual(SourceLevels.ActivityTracing, traceSource.DefaultLevel); Assert.AreEqual(ListenerName, traceSource.TraceListeners.Get(0).Name); Assert.AreEqual(1, settings.TraceListeners.Count); var msmqLogListener = settings.TraceListeners.Get(0) as MsmqTraceListenerData; Assert.IsNotNull(msmqLogListener); Assert.AreEqual(ListenerName, msmqLogListener.Name); Assert.AreEqual(messagePriority, msmqLogListener.MessagePriority); Assert.AreEqual(QueuePath, msmqLogListener.QueuePath); Assert.AreEqual(true, msmqLogListener.Recoverable); Assert.AreEqual(timeToBeReceived, msmqLogListener.TimeToBeReceived); Assert.AreEqual(timeToReachQueue, msmqLogListener.TimeToReachQueue); Assert.AreEqual(trxType, msmqLogListener.TransactionType); Assert.AreEqual(true, msmqLogListener.UseAuthentication); Assert.AreEqual(true, msmqLogListener.UseDeadLetterQueue); Assert.AreEqual(true, msmqLogListener.UseEncryption); Assert.AreEqual(SourceLevels.Verbose, msmqLogListener.Filter); Assert.AreEqual(TraceOptions.None, msmqLogListener.TraceOutputOptions); Assert.AreEqual(FormatterName, msmqLogListener.Formatter); Assert.AreEqual(1, settings.Formatters.Count); var formatter = settings.Formatters.Get(FormatterName) as TextFormatterData; Assert.IsNotNull(formatter); Assert.AreEqual(Template, formatter.Template); }