コード例 #1
0
        public static bool LogLine(string message, MessagePriority priority = MessagePriority.Infomation)
        {
            switch (priority)
            {
            case MessagePriority.Critical:
                break;

            case MessagePriority.Error:
                break;

            case MessagePriority.Warning:
                errorLogged?.Invoke(message);
                break;

            case MessagePriority.Infomation:
                break;

            default:
                break;
            }

            // ToDo fix this so that the log level check works.
            return(WriteLine(String.Format("{0} \t{1} \t{2}", DateTime.Now.ToString(), priority.ToString(""), message)));

            //    if (priority <= logLevel)
            //        return WriteLine(String.Format("{0} \t{1} \t{2}", DateTime.Now.ToString(), priority.ToString(""), message));
            //    else
            //        return false;
        }
コード例 #2
0
ファイル: MSMQHelper.cs プロジェクト: Amoenus/WisdomScenic
        /// <summary>
        /// 连接消息队列并发送消息到队列
        /// </summary>
        public static bool SendMessage <T>(string queuePath, T body, MessagePriority priority = MessagePriority.Normal)
        {
            bool result = true;

            try
            {
                //连接到本地的队列
                MessageQueue myQueue = new MessageQueue(queuePath);

                Message myMessage = new Message();
                myMessage.Body      = body;
                myMessage.Formatter = new XmlMessageFormatter(new Type[] { typeof(T) });
                myMessage.Priority  = priority;


                MessageQueueTransaction transcation = new MessageQueueTransaction();

                transcation.Begin();

                //发送消息到队列中
                myQueue.Send(myMessage, transcation);

                transcation.Commit();
            }
            catch (ArgumentException)
            {
                result = false;
            }
            return(result);
        }
コード例 #3
0
        int messagePriorityToPriority(MessagePriority p)
        {
            switch (p)
            {
            case MessagePriority.Highest:
                return(0);

            case MessagePriority.VeryHigh:
                return(2);

            case MessagePriority.High:
                return(3);

            case MessagePriority.AboveNormal:
                return(4);

            case MessagePriority.Normal:
                return(5);

            case MessagePriority.Low:
                return(6);

            case MessagePriority.VeryLow:
                return(7);

            case MessagePriority.Lowest:
                return(9);
            }
            return(5);
        }
コード例 #4
0
 public OutboundEnvelopeContextImpl(Guid id, ReadableCourierEndpoint endpoint, TMessage message, MessagePriority priority)
 {
     this.id       = id;
     this.endpoint = endpoint;
     this.message  = message;
     this.priority = priority;
 }
コード例 #5
0
        private Diagnostics()
        {
            //try
            //{
            //    logLevel = (MessagePriority)Properties.Settings.Default.LogLevel;
            //}
            //catch
            //{
            //    logLevel = MessagePriority.Warning ;
            //}

            logLevel = MessagePriority.Infomation;
            Logs     = new List <string>();

            try
            {
                string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FConn Diagnostics");

                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }

                FileName            = tempPath + @"\" + DateTime.Now.ToString().Replace(':', '-') + ".log";
                logStream           = File.AppendText(FileName);
                logStream.AutoFlush = true;
                logStream.WriteLine("Log file created at {0}", DateTime.Now.ToString());
            }
            catch (Exception)
            {
            }
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of <see cref="MsmqTraceListener"/>.
 /// </summary>
 /// <param name="name">The name of the new instance.</param>
 /// <param name="queuePath">The path to the queue to deliver to.</param>
 /// <param name="formatter">The formatter to use.</param>
 /// <param name="messagePriority">The priority for the messages to send.</param>
 /// <param name="recoverable">The recoverable flag for the messages to send.</param>
 /// <param name="timeToReachQueue">The timeToReachQueue for the messages to send.</param>
 /// <param name="timeToBeReceived">The timeToBeReceived for the messages to send.</param>
 /// <param name="useAuthentication">The useAuthentication flag for the messages to send.</param>
 /// <param name="useDeadLetterQueue">The useDeadLetterQueue flag for the messages to send.</param>
 /// <param name="useEncryption">The useEncryption flag for the messages to send.</param>
 /// <param name="transactionType">The <see cref="MessageQueueTransactionType"/> for the message to send.</param>
 /// <param name="msmqInterfaceFactory">The factory to create the msmq interfaces.</param>
 public MsmqTraceListener(string name,
                          string queuePath,
                          ILogFormatter formatter,
                          MessagePriority messagePriority,
                          bool recoverable,
                          TimeSpan timeToReachQueue,
                          TimeSpan timeToBeReceived,
                          bool useAuthentication,
                          bool useDeadLetterQueue,
                          bool useEncryption,
                          MessageQueueTransactionType transactionType,
                          IMsmqSendInterfaceFactory msmqInterfaceFactory)
     : base(formatter)
 {
     this.queuePath            = queuePath;
     this.messagePriority      = messagePriority;
     this.recoverable          = recoverable;
     this.timeToReachQueue     = timeToReachQueue;
     this.timeToBeReceived     = timeToBeReceived;
     this.useAuthentication    = useAuthentication;
     this.useDeadLetterQueue   = useDeadLetterQueue;
     this.useEncryption        = useEncryption;
     this.transactionType      = transactionType;
     this.msmqInterfaceFactory = msmqInterfaceFactory;
 }
コード例 #7
0
    public void SendMessageToIRC(string message, MessagePriority priority = MessagePriority.Classic)
    {
        if (_antiSpamFilter)
        {
            switch (priority)
            {
            case MessagePriority.Classic:
                _antiSpamFilter.SendMessageWithFilter(message);
                break;

            case MessagePriority.Important:
                _antiSpamFilter.SendMessageWithPriorityFilter(message);
                break;

            case MessagePriority.Direct:
                _antiSpamFilter.SendMessageWithNoProtection(message);
                break;

            default:
                break;
            }
        }
        else
        {
            _twitchIRC.SendMsg(message);
        }
    }
コード例 #8
0
ファイル: Message.cs プロジェクト: isabella232/banter
 protected Message(string text) : base()
 {
     ID       = Guid.NewGuid().ToString();
     Creation = DateTime.Now;
     Priority = MessagePriority.Normal;
     Text     = text;
 }
コード例 #9
0
ファイル: ControlByte1.cs プロジェクト: ChrisTTian667/KNX
 /// <summary>
 /// Initializes a new instance of the <see cref="ControlByte1"/> class.
 /// </summary>
 public ControlByte1()
 {
     IsRepetition          = false;
     IsStandardFrame       = true;
     IsPositivConfirmation = true;
     Priority = MessagePriority.Auto;
 }
コード例 #10
0
 public void Write(MessageLevel level, MessagePriority priority, Exception ex)
 {
     if (IsLevelEnabled(level) == false)
     {
         return;
     }
 }
コード例 #11
0
        //**************************************************
        // Sends a string message to a queue.
        //**************************************************

        public void SendMessage(MessagePriority priority, string messageBody)
        {
            // Connect to a queue on the local computer.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");

            // Create a new message.
            Message myMessage = new Message();

            if (priority > MessagePriority.Normal)
            {
                myMessage.Body = "High Priority: " + messageBody;
            }
            else
            {
                myMessage.Body = messageBody;
            }

            // Set the priority of the message.
            myMessage.Priority = priority;


            // Send the Order to the queue.
            myQueue.Send(myMessage);

            return;
        }
コード例 #12
0
 public UnconfirmedTextMessageRequest(ObjectIdentifier textMessageSourceDevice, MessagePriority messagePriority,
                                      CharacterString message)
 {
     this.textMessageSourceDevice = textMessageSourceDevice;
     this.messagePriority         = messagePriority;
     this.message = message;
 }
コード例 #13
0
ファイル: QueueManger.cs プロジェクト: sztony/MSMQCase
 /// <summary>
 /// 发送消息
 /// </summary>
 /// <typeparam name="T">用户数据类型</typeparam>
 /// <param name="target">用户数据</param>
 /// <param name="queuePath">队列路径</param>
 /// <param name="prio">优先级</param>
 /// <param name="tran"></param>
 /// <returns></returns>
 public static bool SendMessage <T>(T target, string queuePath, MessagePriority prio = MessagePriority.High, MessageQueueTransaction tran = null)
 {
     try
     {
         //连接到本地的队列
         MessageQueue myQueue   = new MessageQueue(queuePath);
         Message      myMessage = new Message();
         myMessage.Body      = target;
         myMessage.Priority  = prio;//消息优先级
         myMessage.Formatter = new XmlMessageFormatter(new Type[] { typeof(T) });
         //发送消息到队列中
         if (tran == null)
         {
             myQueue.Send(myMessage);
         }
         else
         {
             //tran.Begin();
             myQueue.Send(myMessage, tran);
             //tran.Commit();
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #14
0
        public bool SendMsgToQueue(string queueName, object queueMsg, MessagePriority msgPriority = MessagePriority.Normal, string queueHost = "private$")
        {
            try
            {
                string       path    = ".\\" + queueHost + "\\" + queueName;
                MessageQueue myQueue = null;

                if (MessageQueue.Exists(path))
                {
                    myQueue = new MessageQueue(path);
                }
                else
                {
                    myQueue = MessageQueue.Create(path, true);
                }
                System.Messaging.Message myMessage = new System.Messaging.Message();
                myMessage.Priority  = msgPriority;
                myMessage.Body      = queueMsg;
                myMessage.Formatter = new BinaryMessageFormatter();
                //发送消息到队列中
                myQueue.Send(myMessage, MessageQueueTransactionType.Single);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #15
0
        void Update()
        {
            //按钮响应
            if (Input.GetMouseButtonDown(0))
            {
                //随机选取优先级
                MessagePriority priority = MessagePriority.High;
                float           random   = UnityEngine.Random.value;
                if (random < 0.333f)
                {
                    priority = MessagePriority.Low;
                }
                else if (random < 0.666f)
                {
                    priority = MessagePriority.Medium;
                }

                //随机选取显示时间
                float showTime = UnityEngine.Random.Range(1f, 5f);

                //加入事件到队列
                EventQueueManager.Instance.AddEventToQueue(new MessageEvent(priorityLookup[priority] + " priority message shown at "
                                                                            + System.DateTime.Now + " for " + showTime + " seconds", Time.time + showTime, priority));
            }
        }
コード例 #16
0
        public void Priorities()
        {
            using var connection = ConnectCluster();

            var priorities = new MessagePriority[] {
                MessagePriority.Highest,
                MessagePriority.High,
                MessagePriority.Normal,
                MessagePriority.Low,
                MessagePriority.Lowest
            };
            var rng       = new Random();
            var responses = new List <int>();

            for (int i = 0; i < 100; ++i)
            {
                var options = new DeliveryOptions {
                    Priority = priorities[rng.Next(priorities.Length)]
                };
                connection.Send(options, new PriorityRequest {
                    Priority = 2 + (int)options.Priority
                }, (PriorityResponse ?response, RequestResult result) => {
                    responses.Add(response?.Priority ?? -1);
                });
            }

            WaitForPendingRequests(connection);

            Assert.Equal(100, responses.Count);
        }
コード例 #17
0
ファイル: Debug.cs プロジェクト: EchoArray/Hellion
        internal static void Out(object source, string message, MessagePriority messagePriority)
        {
            // If we're not outputting, stop.
            if (!_debugLogPrint && !_logOnPrint)
            {
                return;
            }

            // Determine our name from type.
            string name = source.GetType().ToString();

            // Print our message
            Color colorPriority = singleton._outputSettings.outTypeInfoColor;

            switch (messagePriority)
            {
            case MessagePriority.Information:
                colorPriority = singleton._outputSettings.outTypeInfoColor;
                break;

            case MessagePriority.Low:
                colorPriority = singleton._outputSettings.outTypeLowColor;
                break;

            case MessagePriority.Medium:
                colorPriority = singleton._outputSettings.outTypeMediumColor;
                break;

            case MessagePriority.High:
                colorPriority = singleton._outputSettings.outTypeHighColor;
                break;
            }
            Out(string.Format("<color='#{0}'>[{1}]: </color><color='#{2}'>{3}</color>", singleton._outputSettings.outHeaderColor.GetHashCode(), name, colorPriority.ToArgbString(), message));
        }
コード例 #18
0
        /// <summary>
        /// Converts the specified MSMQ message priority to an equivalent NMS
        /// message priority.
        /// </summary>
        /// <param name="messagePriority">MSMQ message priority to be converted.</param>
        /// <result>Converted NMS message priority.</result>
        private static MsgPriority ToNmsMsgPriority(MessagePriority messagePriority)
        {
            switch (messagePriority)
            {
            case MessagePriority.Lowest:
                return(MsgPriority.Lowest);

            case MessagePriority.VeryLow:
                return(MsgPriority.VeryLow);

            case MessagePriority.Low:
                return(MsgPriority.Low);

            default:
            case MessagePriority.Normal:
                return(MsgPriority.Normal);

            case MessagePriority.AboveNormal:
                return(MsgPriority.AboveNormal);

            case MessagePriority.High:
                return(MsgPriority.High);

            case MessagePriority.VeryHigh:
                return(MsgPriority.VeryHigh);

            case MessagePriority.Highest:
                return(MsgPriority.Highest);
            }
        }
コード例 #19
0
 public void Write(MessageLevel level, MessagePriority priority, string message, params object[] args)
 {
     if (IsLevelEnabled(level) == false)
     {
         return;
     }
 }
コード例 #20
0
ファイル: Services.cs プロジェクト: ibgib/LearnLanguages
    //private static NavigationController _Navigator;
    //public static NavigationController Navigator
    //{
    //  get
    //  {
    //    if (_Navigator == null)
    //      _Navigator = Container.Resolve<NavigationController>();
    //    return _Navigator;
    //  }
    //}

    public static void PublishMessageEvent(string msgText, 
                                           MessagePriority messagePriority, 
                                           MessageType messageType)
    {
      var msgEvent = new Common.Events.MessageEvent(msgText, messagePriority, messageType);
      EventAggregator.Publish(msgEvent);
    }
コード例 #21
0
 public MessageEvent(object message, float displayTime, MessagePriority priority)
 {
     this.message     = message;
     this.displayTime = displayTime;
     this.priority    = priority;
     timeRaised       = DateTime.Now;
 }
コード例 #22
0
        /// <summary>
        /// Registers an action that will get invoked whenever that message is received.
        /// </summary>
        /// <typeparam name="TMsg">The type of the message.</typeparam>
        /// <param name="action">The action to invoke.</param>
        /// <param name="priority">The priority of this registration.</param>
        public void RegisterMessage <TMsg>(Action <T, TMsg> action, MessagePriority priority) where TMsg : IMessage
        {
            // Check if the Message Type was never used
            var msgType = typeof(TMsg);

            if (!_registeredMessages.ContainsKey(msgType))
            {
                _registeredMessages.TryAdd(msgType, new ConcurrentDictionary <int, RegisteredMessage <T> >());
            }

            if (_registeredMessages.TryGetValue(msgType,
                                                out ConcurrentDictionary <int, RegisteredMessage <T> > registeredMsgs))
            {
                // Check if the same method/action is already registered
                int actionHashCode = action.GetHashCode();
                if (registeredMsgs.ContainsKey(actionHashCode))
                {
                    throw new Exception("The same method/action is already registered.");
                }

                // If not, add it
                registeredMsgs.TryAdd(actionHashCode, new RegisteredMessage <T>
                {
                    Handler  = (s, o) => action(s, (TMsg)o),
                    Priority = priority
                });
            }
        }
コード例 #23
0
ファイル: Services.cs プロジェクト: marcsommer/LearnLanguages
        //private static NavigationController _Navigator;
        //public static NavigationController Navigator
        //{
        //  get
        //  {
        //    if (_Navigator == null)
        //      _Navigator = Container.Resolve<NavigationController>();
        //    return _Navigator;
        //  }
        //}

        public static void PublishMessageEvent(string msgText,
                                               MessagePriority messagePriority,
                                               MessageType messageType)
        {
            var msgEvent = new Common.Events.MessageEvent(msgText, messagePriority, messageType);

            EventAggregator.Publish(msgEvent);
        }
コード例 #24
0
 public void Send(object obj, MessagePriority priority, MessageQueueTransaction mqTransaction)
 {
     using (Message msg = new Message(obj, _messageQueue.Formatter))
     {
         msg.Priority = priority;
         _messageQueue.Send(msg, mqTransaction);
     }
 }
コード例 #25
0
 public void Send(object obj, MessagePriority priority)
 {
     using (Message msg = new Message(obj, _messageQueue.Formatter))
     {
         msg.Priority = priority;
         _messageQueue.Send(msg);
     }
 }
コード例 #26
0
 public NotificationEvent(MessagePriority _prority, object _message, float _displayTime, DateTime _timeRaised, Action _onTapAction = null)
 {
     this.displayTime = _displayTime;
     this.priority    = _prority;
     this.message     = _message;
     this.timeRaised  = _timeRaised;
     this.onTapAction = _onTapAction;
 }
コード例 #27
0
        public void AddMessage(Guid messageId, Guid recipientId, object payload, MessagePriority messagePriority, MessageFlags messageFlags)
        {
            var messageContext = messageContextPool.TakeObject();

            messageContext.UpdateAndMarkUnacknowledged(messageId, recipientId, payload, messagePriority, messageFlags);
            unacknowledgedMessageContextsById.Add(messageId, messageContext);
            pendingQueue.Enqueue(messageContext);
        }
コード例 #28
0
        public Task SendMessage(MessagePriority priority, float time, string format, params object[] args)
        {
            string msg = format.SafeFormat(args);

            return(_gameServerConnection.SendRequest(
                       Eleon.Modding.CmdId.Request_InGameMessage_SinglePlayer,
                       new Eleon.Modding.IdMsgPrio(EntityId, msg, (byte)priority, time)));
        }
コード例 #29
0
 public UnconfirmedTextMessageRequest(ObjectIdentifier textMessageSourceDevice, UnsignedInteger messageClass,
                                      MessagePriority messagePriority, CharacterString message)
 {
     this.textMessageSourceDevice = textMessageSourceDevice;
     this.messageClass            = new Choice(0, messageClass);
     this.messagePriority         = messagePriority;
     this.message = message;
 }
        public void Send(MessagePriority priority, MessageReliability reliability, ArraySegment<byte> data)
        {
            NetOutgoingMessage packet = _connection.Peer.CreateMessage();
            packet.Write(data.Count);
            packet.Write(data.Array, data.Offset, data.Count);

            _connection.SendMessage(packet, Convert(reliability), (int) priority);
        }
コード例 #31
0
        public Task SendMessageToAll(MessagePriority priority, float time, string format, params object[] args)
        {
            string msg = format.SafeFormat(args);

            return(SendRequest(
                       Eleon.Modding.CmdId.Request_InGameMessage_AllPlayers,
                       new Eleon.Modding.IdMsgPrio(0, msg, (byte)priority, time)));
        }
コード例 #32
0
        public void ParseMessagePriorityTests(string input, MessagePriority expected)
        {
            // Act
            var result = MailTarget.ParseMessagePriority(input);

            // Assert
            Assert.Equal(expected, result);
        }
コード例 #33
0
 public PriorityAttribute(MessagePriority messagePriority)
 {
     if (Enum.IsDefined(typeof(MessagePriority), messagePriority)) {
         Value = messagePriority;
     }
     else {
         Value = MessagePriority.Normal;
     }
 }
コード例 #34
0
ファイル: Logger.cs プロジェクト: CoryBR/OverlayFS
 public void WriteLine(String value, MessagePriority messagePriority)
 {
     if (messagePriority <= priority && file != null)
     {
         String date = DateTime.Now.ToString();
         file.WriteLine(date + ": " + value);
         file.Flush();
     }
 }
コード例 #35
0
ファイル: MsmqTraceListener.cs プロジェクト: bnantz/NCS-V2-0
        /// <summary>
        /// Initializes a new instance of <see cref="MsmqTraceListener"/>.
        /// </summary>
        /// <param name="name">The name of the new instance.</param>
        /// <param name="queuePath">The path to the queue to deliver to.</param>
        /// <param name="formater">The formatter to use.</param>
        /// <param name="messagePriority">The priority for the messages to send.</param>
        /// <param name="recoverable">The recoverable flag for the messages to send.</param>
        /// <param name="timeToReachQueue">The timeToReachQueue for the messages to send.</param>
        /// <param name="timeToBeReceived">The timeToBeReceived for the messages to send.</param>
        /// <param name="useAuthentication">The useAuthentication flag for the messages to send.</param>
        /// <param name="useDeadLetterQueue">The useDeadLetterQueue flag for the messages to send.</param>
        /// <param name="useEncryption">The useEncryption flag for the messages to send.</param>
        /// <param name="transactionType">The <see cref="MessageQueueTransactionType"/> for the message to send.</param>
        public MsmqTraceListener(string name, string queuePath, ILogFormatter formater,
								 MessagePriority messagePriority, bool recoverable,
								 TimeSpan timeToReachQueue, TimeSpan timeToBeReceived,
								 bool useAuthentication, bool useDeadLetterQueue, bool useEncryption,
								 MessageQueueTransactionType transactionType)
            : this(name, queuePath, formater, messagePriority, recoverable,
				   timeToReachQueue, timeToBeReceived,
				   useAuthentication, useDeadLetterQueue, useEncryption,
				   transactionType, new MsmqSendInterfaceFactory())
        {
        }
コード例 #36
0
ファイル: MsmqSinkData.cs プロジェクト: bnantz/NCS-V1-1
 /// <summary>
 /// Initialize a new instance of the <see cref="MsmqSinkData"/> class with a name.
 /// </summary>
 /// <param name="name">
 /// The name of the sink.
 /// </param>
 /// <param name="queuePath">
 /// The path to the message queue.
 /// </param>
 public MsmqSinkData(string name, string queuePath)
     : base(name)
 {
     this.queuePath = queuePath;
     messagePriority = MessagePriority.Normal;
     recoverable = false;
     //            timeToReachQueue = new DateTime(new TimeSpan(1, 0, 0, 0, 0).Ticks);
     //            timeToBeReceived = new DateTime(new TimeSpan(1, 0, 0 , 0, 0).Ticks);
     useAuthentication = false;
     useDeadLetterQueue = false;
     useEncryption = false;
 }
コード例 #37
0
ファイル: Logger.cs プロジェクト: CoryBR/OverlayFS
        public Logger(String logPath, MessagePriority logLevel)
        {
            this.logPath = logPath;
            //file = new System.IO.StreamWriter(logPath, true);
            RollLog();
            priority = logLevel;

            timerStart = DateTime.Now.Ticks;
            System.Timers.Timer LogRoller = new System.Timers.Timer();
            LogRoller.Elapsed += new System.Timers.ElapsedEventHandler(LogRoller_Elapsed);
            LogRoller.Interval = 10 * 60 * 60 * 1000; //Roll every 10 hours
            LogRoller.Enabled = true;
        }
コード例 #38
0
        public SocketManager()
        {
            this._standardPriority = MessagePriority.Normal;/*/MessagePriority.RealTime;*/

            // listener
            this.listener_thread = new Listener(this);
            this.listener_thread.Start();

            // reader
            this.reader_thread = new Reader(this);
            this.reader_thread.Start();

            // writer
            this.writer_thread = new Writer(this);
            this.writer_thread.Start();
        }
コード例 #39
0
        public void SendMessage(string eventType, MessagePriority priority, string message, string file, 
			int lineNumber, string code)
        {
            packetBuilder.Reset();
            packetBuilder.Write(eventType);
            packetBuilder.Write(null);	// projectName
            packetBuilder.Write(null);	// targetName
            packetBuilder.Write(null);	// taskName
            packetBuilder.Write(((int)priority).ToString());
            packetBuilder.Write(file);
            packetBuilder.Write(lineNumber.ToString());
            packetBuilder.Write(code);
            packetBuilder.Write(TruncateIfNeeded(message));

            SendData(packetBuilder.ToArray());
        }
コード例 #40
0
		/// <summary>
		/// Initialize a new instance of the <see cref="MsmqTraceListenerNode"/> class with a <see cref="MsmqTraceListenerData"/> instance.
		/// </summary>
		/// <param name="msmqTraceListenerData">A <see cref="MsmqTraceListenerData"/> instance.</param>
        public MsmqTraceListenerNode(MsmqTraceListenerData msmqTraceListenerData)
        {
			if (null == msmqTraceListenerData) throw new ArgumentNullException("msmqTraceListenerData");

			Rename(msmqTraceListenerData.Name);
			TraceOutputOptions = msmqTraceListenerData.TraceOutputOptions;
			this.useEncryption = msmqTraceListenerData.UseEncryption;
			this.useDeadLetterQueue = msmqTraceListenerData.UseDeadLetterQueue;
			this.useAuthentication = msmqTraceListenerData.UseAuthentication;
			this.transactionType = msmqTraceListenerData.TransactionType;
			this.messagePriority = msmqTraceListenerData.MessagePriority;
			this.timeToReachQueue = msmqTraceListenerData.TimeToReachQueue;
			this.timeToBeReceived = msmqTraceListenerData.TimeToBeReceived;
			this.recoverable = msmqTraceListenerData.Recoverable;
			this.queuePath = msmqTraceListenerData.QueuePath;
			this.formatterName = msmqTraceListenerData.Formatter;
        }
コード例 #41
0
		/// <summary>
		/// Initializes a new instance of <see cref="MsmqTraceListener"/>.
		/// </summary>
		/// <param name="name">The name of the new instance.</param>
		/// <param name="queuePath">The path to the queue to deliver to.</param>
		/// <param name="formater">The formatter to use.</param>
		/// <param name="messagePriority">The priority for the messages to send.</param>
		/// <param name="recoverable">The recoverable flag for the messages to send.</param>
		/// <param name="timeToReachQueue">The timeToReachQueue for the messages to send.</param>
		/// <param name="timeToBeReceived">The timeToBeReceived for the messages to send.</param>
		/// <param name="useAuthentication">The useAuthentication flag for the messages to send.</param>
		/// <param name="useDeadLetterQueue">The useDeadLetterQueue flag for the messages to send.</param>
		/// <param name="useEncryption">The useEncryption flag for the messages to send.</param>
		/// <param name="transactionType">The <see cref="MessageQueueTransactionType"/> for the message to send.</param>
		/// <param name="msmqInterfaceFactory">The factory to create the msmq interfaces.</param>
		public MsmqTraceListener(string name, string queuePath, ILogFormatter formater,
								 MessagePriority messagePriority, bool recoverable,
								 TimeSpan timeToReachQueue, TimeSpan timeToBeReceived,
								 bool useAuthentication, bool useDeadLetterQueue, bool useEncryption,
								 MessageQueueTransactionType transactionType,
								 IMsmqSendInterfaceFactory msmqInterfaceFactory)
			: base(formater)
		{
			this.queuePath = queuePath;
			this.messagePriority = messagePriority;
			this.recoverable = recoverable;
			this.timeToReachQueue = timeToReachQueue;
			this.timeToBeReceived = timeToBeReceived;
			this.useAuthentication = useAuthentication;
			this.useDeadLetterQueue = useDeadLetterQueue;
			this.useEncryption = useEncryption;
			this.transactionType = transactionType;
			this.msmqInterfaceFactory = msmqInterfaceFactory;
		}
コード例 #42
0
ファイル: NAntListener.cs プロジェクト: majianxiong/vulcan
        public void ParseMessage(BuildEventArgs e, out MessagePriority priority, out string file, out int lineNumber, out string code, out string message)
        {
            switch(e.MessageLevel) {
                case Level.Warning: priority = MessagePriority.WARNING; break;
                case Level.Error: priority = MessagePriority.ERROR; break;
                default: priority = MessagePriority.INFO; break;
            }

            file = null;
            code = null;
            lineNumber = 0;
            message = e.Message;

            Match match = messageRegex.Match(message);
            if (match.Success)
            {
                if (match.Groups["category"].Value == "warning")
                {
                    priority = MessagePriority.WARNING;
                }
                else
                {
                    priority = MessagePriority.ERROR;
                }

                file = match.Groups["file"].Value;

                string lineString = match.Groups["line"].Value;
                if (lineString != "")
                {
                    lineNumber = int.Parse(lineString);
                }

                code = match.Groups["code"].Value;
                message = match.Groups["message"].Value;
            }
        }
 public ILoggingConfigurationSendToMsmqTraceListener Prioritize(MessagePriority priority)
 {
     msmqTraceListener.MessagePriority = priority;
     
     return this;
 }
コード例 #44
0
ファイル: Log4NetTracker.cs プロジェクト: fandrei/AppMetrics
 public override void Log(string name, string val, MessagePriority priority = MessagePriority.Low)
 {
     var tmp = new AppMetricsMessage(name, val);
     _log.Info(tmp);
 }
コード例 #45
0
        public void Send(IWorker worker, byte[] data, MessagePriority priority)
        {
            if (priority == MessagePriority.RealTime)
            {
                this.InternalSend(worker, data);
            }
            else
            {
                HandleData handledata = new HandleData(worker, data);
                ((Queue)this.writer_thread.SendBuffer[priority]).Enqueue(handledata);

                lock (this.writer_thread.SendBuffer)
                {
                    Monitor.Pulse(this.writer_thread.SendBuffer);
                    Monitor.Wait(this.writer_thread.SendBuffer);
                    Monitor.Pulse(this.writer_thread.SendBuffer);
                }
            }
        }
コード例 #46
0
 public virtual void Send(byte[] data, MessagePriority priority)
 {
     if (use_gzip)
     {
         // TODO: data = gzip ...
     }
     this._server.SocketManager.Send(this, data, priority);
 }
コード例 #47
0
 public virtual void SendLine(string text, MessagePriority priority)
 {
     // to/do: EOL
     //text += "\n";// this._config.EOL;
     text += ((SettingsHost)ServiceManager.Services[typeof(SettingsHost)]).Settings.EndOfLine;
     this.Send(text, priority);
 }
コード例 #48
0
ファイル: Snarl.cs プロジェクト: TlhanGhun/FileSystemSnarl
 public Int32 Notify(String classId, String title, String text, Int32? timeout, String iconPath, String iconBase64, MessagePriority? priority)
 {
     return Notify(classId, title, text, timeout, iconPath, iconBase64, priority, null, null, null);
 }
コード例 #49
0
 public virtual void Send(string text, MessagePriority priority)
 {
     //this._server.SocketManager.Send(this, text, priority);
     this.Send(((SettingsHost)ServiceManager.Services[typeof(SettingsHost)]).Settings.Encoding.GetBytes(text), priority);
 }
コード例 #50
0
 public EventMessage()
 {
     _id = Guid.NewGuid().ToString();
     _processorType = "";
     _body = "";
     _priority = MessagePriority.Low;
     _attributes = new NameValueCollection();
     _sender = "";
     _subscribers = "";
     _authorizedRoles = "";
     _exceptionMessage = "";
 }
コード例 #51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MsmqTraceListenerData"/> class.
 /// </summary>
 /// <param name="name">The name for the represented trace listener.</param>
 /// <param name="queuePath">The path name for the represented trace listener.</param>
 /// <param name="formatterName">The formatter name for the represented trace listener.</param>
 /// <param name="messagePriority">The priority for the represented trace listener.</param>
 /// <param name="recoverable">The recoverable flag for the represented trace listener.</param>
 /// <param name="timeToReachQueue">The timeToReachQueue for the represented trace listener.</param>
 /// <param name="timeToBeReceived">The timeToReachQueue for the represented trace listener.</param>
 /// <param name="useAuthentication">The use authentication flag for the represented trace listener.</param>
 /// <param name="useDeadLetterQueue">The use dead letter flag for the represented trace listener.</param>
 /// <param name="useEncryption">The use encryption flag for the represented trace listener.</param>
 /// <param name="transactionType">The transaction type for the represented trace listener.</param>
 public MsmqTraceListenerData(string name, string queuePath, string formatterName,
                              MessagePriority messagePriority, bool recoverable,
                              TimeSpan timeToReachQueue, TimeSpan timeToBeReceived,
                              bool useAuthentication, bool useDeadLetterQueue, bool useEncryption,
                              MessageQueueTransactionType transactionType)
     : this(name, queuePath, formatterName, messagePriority, recoverable, timeToReachQueue, timeToBeReceived,
                              useAuthentication, useDeadLetterQueue, useEncryption, transactionType, TraceOptions.None, SourceLevels.All)
 {
 }
コード例 #52
0
ファイル: MimeMessage.cs プロジェクト: yukine/MimeKit
		void ReloadHeader (HeaderId id)
		{
			if (id == HeaderId.Unknown)
				return;

			switch (id) {
			case HeaderId.ResentMessageId:
				resentMessageId = null;
				break;
			case HeaderId.ResentSender:
				resentSender = null;
				break;
			case HeaderId.ResentDate:
				resentDate = DateTimeOffset.MinValue;
				break;
			case HeaderId.References:
				references.Changed -= ReferencesChanged;
				references.Clear ();
				references.Changed += ReferencesChanged;
				break;
			case HeaderId.InReplyTo:
				inreplyto = null;
				break;
			case HeaderId.MessageId:
				messageId = null;
				break;
			case HeaderId.Sender:
				sender = null;
				break;
			case HeaderId.Importance:
				importance = MessageImportance.Normal;
				break;
			case HeaderId.Priority:
				priority = MessagePriority.Normal;
				break;
			case HeaderId.Date:
				date = DateTimeOffset.MinValue;
				break;
			}

			foreach (var header in Headers) {
				if (header.Id != id)
					continue;

				var rawValue = header.RawValue;
				InternetAddress address;
				int index = 0;

				switch (id) {
				case HeaderId.MimeVersion:
					if (MimeUtils.TryParse (rawValue, 0, rawValue.Length, out version))
						return;
					break;
				case HeaderId.References:
					references.Changed -= ReferencesChanged;
					foreach (var msgid in MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length))
						references.Add (msgid);
					references.Changed += ReferencesChanged;
					break;
				case HeaderId.InReplyTo:
					inreplyto = MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length).FirstOrDefault ();
					break;
				case HeaderId.ResentMessageId:
					resentMessageId = MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length).FirstOrDefault ();
					if (resentMessageId != null)
						return;
					break;
				case HeaderId.MessageId:
					messageId = MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length).FirstOrDefault ();
					if (messageId != null)
						return;
					break;
				case HeaderId.ResentSender:
					if (InternetAddress.TryParse (Headers.Options, rawValue, ref index, rawValue.Length, false, out address))
						resentSender = address as MailboxAddress;
					if (resentSender != null)
						return;
					break;
				case HeaderId.Sender:
					if (InternetAddress.TryParse (Headers.Options, rawValue, ref index, rawValue.Length, false, out address))
						sender = address as MailboxAddress;
					if (sender != null)
						return;
					break;
				case HeaderId.ResentDate:
					if (DateUtils.TryParse (rawValue, 0, rawValue.Length, out resentDate))
						return;
					break;
				case HeaderId.Importance:
					switch (header.Value.ToLowerInvariant ().Trim ()) {
					case "high": importance = MessageImportance.High; break;
					case "low": importance = MessageImportance.Low; break;
					default: importance = MessageImportance.Normal; break;
					}
					break;
				case HeaderId.Priority:
					switch (header.Value.ToLowerInvariant ().Trim ()) {
					case "non-urgent": priority = MessagePriority.NonUrgent; break;
					case "urgent": priority = MessagePriority.Urgent; break;
					default: priority = MessagePriority.Normal; break;
					}
					break;
				case HeaderId.Date:
					if (DateUtils.TryParse (rawValue, 0, rawValue.Length, out date))
						return;
					break;
				}
			}
		}
コード例 #53
0
ファイル: MimeMessage.cs プロジェクト: yukine/MimeKit
		void HeadersChanged (object o, HeaderListChangedEventArgs e)
		{
			InternetAddressList list;
			InternetAddress address;
			byte[] rawValue;
			int index = 0;

			switch (e.Action) {
			case HeaderListChangedAction.Added:
				if (addresses.TryGetValue (e.Header.Field, out list)) {
					AddAddresses (e.Header, list);
					break;
				}

				rawValue = e.Header.RawValue;

				switch (e.Header.Id) {
				case HeaderId.MimeVersion:
					MimeUtils.TryParse (rawValue, 0, rawValue.Length, out version);
					break;
				case HeaderId.References:
					references.Changed -= ReferencesChanged;
					foreach (var msgid in MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length))
						references.Add (msgid);
					references.Changed += ReferencesChanged;
					break;
				case HeaderId.InReplyTo:
					inreplyto = MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length).FirstOrDefault ();
					break;
				case HeaderId.ResentMessageId:
					resentMessageId = MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length).FirstOrDefault ();
					break;
				case HeaderId.MessageId:
					messageId = MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length).FirstOrDefault ();
					break;
				case HeaderId.ResentSender:
					if (InternetAddress.TryParse (Headers.Options, rawValue, ref index, rawValue.Length, false, out address))
						resentSender = address as MailboxAddress;
					break;
				case HeaderId.Sender:
					if (InternetAddress.TryParse (Headers.Options, rawValue, ref index, rawValue.Length, false, out address))
						sender = address as MailboxAddress;
					break;
				case HeaderId.ResentDate:
					DateUtils.TryParse (rawValue, 0, rawValue.Length, out resentDate);
					break;
				case HeaderId.Importance:
					switch (e.Header.Value.ToLowerInvariant ().Trim ()) {
					case "high": importance = MessageImportance.High; break;
					case "low": importance = MessageImportance.Low; break;
					default: importance = MessageImportance.Normal; break;
					}
					break;
				case HeaderId.Priority:
					switch (e.Header.Value.ToLowerInvariant ().Trim ()) {
					case "non-urgent": priority = MessagePriority.NonUrgent; break;
					case "urgent": priority = MessagePriority.Urgent; break;
					default: priority = MessagePriority.Normal; break;
					}
					break;
				case HeaderId.Date:
					DateUtils.TryParse (rawValue, 0, rawValue.Length, out date);
					break;
				}
				break;
			case HeaderListChangedAction.Changed:
			case HeaderListChangedAction.Removed:
				if (addresses.TryGetValue (e.Header.Field, out list)) {
					ReloadAddressList (e.Header.Id, list);
					break;
				}

				ReloadHeader (e.Header.Id);
				break;
			case HeaderListChangedAction.Cleared:
				foreach (var kvp in addresses) {
					kvp.Value.Changed -= InternetAddressListChanged;
					kvp.Value.Clear ();
					kvp.Value.Changed += InternetAddressListChanged;
				}

				references.Changed -= ReferencesChanged;
				references.Clear ();
				references.Changed += ReferencesChanged;

				importance = MessageImportance.Normal;
				priority = MessagePriority.Normal;
				resentMessageId = null;
				resentSender = null;
				inreplyto = null;
				messageId = null;
				version = null;
				sender = null;
				break;
			default:
				throw new ArgumentOutOfRangeException ();
			}
		}
コード例 #54
0
 public void Deserialize( string configXml )
 {
     XmlTextReader oXMLTextReader = new XmlTextReader( new StringReader( configXml ) );
     oXMLTextReader.MoveToContent();
     while( oXMLTextReader.Read() )
     {
         if( oXMLTextReader.NodeType == XmlNodeType.Element )
         {
             if( oXMLTextReader.Name.ToUpper() == "ID" )
             {
                 oXMLTextReader.Read();
                 _id = oXMLTextReader.Value;
             }
             else if( oXMLTextReader.Name.ToUpper() == "PRIORITY" )
             {
                 oXMLTextReader.Read();
                 _priority = (MessagePriority)( @Enum.Parse( typeof( MessagePriority ), oXMLTextReader.Value ) );
             }
             else if( oXMLTextReader.Name.ToUpper() == "PROCESSORTYPE" )
             {
                 oXMLTextReader.Read();
                 _processorType = oXMLTextReader.Value;
             }
             else if( oXMLTextReader.Name.ToUpper() == "BODY" )
             {
                 oXMLTextReader.Read();
                 _body = oXMLTextReader.Value;
             }
             else if( oXMLTextReader.Name.ToUpper() == "SENDER" )
             {
                 oXMLTextReader.Read();
                 _sender = oXMLTextReader.Value;
             }
             else if( oXMLTextReader.Name.ToUpper() == "SUBSCRIBERS" )
             {
                 oXMLTextReader.Read();
                 _subscribers = oXMLTextReader.Value;
             }
             else if( oXMLTextReader.Name.ToUpper() == "AUTHORIZEDROLES" )
             {
                 oXMLTextReader.Read();
                 _authorizedRoles = oXMLTextReader.Value;
             }
             else if( oXMLTextReader.Name.ToUpper() == "EXCEPTIONMESSAGE" )
             {
                 oXMLTextReader.Read();
                 _exceptionMessage = oXMLTextReader.Value;
             }
             else if( oXMLTextReader.Name.ToUpper() == "EXPIRATIONDATE" )
             {
                 oXMLTextReader.Read();
                 _expirationDate = DateTime.Parse( oXMLTextReader.Value, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal );
             }
             else if( oXMLTextReader.Name.ToUpper() == "SENTDATE" )
             {
                 oXMLTextReader.Read();
                 _sentDate = DateTime.Parse( oXMLTextReader.Value, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal );
             }
             else if( oXMLTextReader.Name.ToUpper() == "ATTRIBUTES" )
             {
                 //move to the first Attribute node of the EventMessage
                 ReadToFollowing( ref oXMLTextReader, "Attribute" );
                 _attributes = new NameValueCollection();
                 while( oXMLTextReader.Name.ToUpper() != "ATTRIBUTES" )
                 {
                     if( oXMLTextReader.NodeType == XmlNodeType.Element && oXMLTextReader.Name.ToUpper() == "ATTRIBUTE" )
                     {
                         //move to the Name node of the Message Attribute
                         ReadToFollowing( ref oXMLTextReader, "Name" );
                         string attName = oXMLTextReader.ReadString();
                         //move to the Value node of the Message Attribute
                         ReadToFollowing( ref oXMLTextReader, "Value" );
                         _attributes.Add( attName, oXMLTextReader.ReadString() );
                     }
                     //move to the Next Element
                     oXMLTextReader.Read();
                 }
             }
         }
     }
 }
コード例 #55
0
ファイル: Snarl.cs プロジェクト: TlhanGhun/FileSystemSnarl
 public Int32 Update(Int32 msgToken, String classId, String title, String text, Int32? timeout, String iconPath, String iconBase64, MessagePriority? priority)
 {
     return Update(msgToken, classId, title, text, timeout, iconPath, iconBase64, priority, null, null, null);
 }
コード例 #56
0
ファイル: Snarl.cs プロジェクト: TlhanGhun/FileSystemSnarl
        public Int32 Update(Int32 msgToken, String classId, String title, String text, Int32? timeout, String iconPath, String iconBase64, MessagePriority? priority, String ack, String callback, String value)
        {
            // Made from best guess - no documentation available yet
            SnarlParameterList spl = new SnarlParameterList(12);
            spl.Add("token", msgToken);
            spl.Add("password", password);

            spl.Add("id", classId);
            spl.Add("title", title);
            spl.Add("text", text);
            spl.Add("icon", iconPath);
            spl.Add("icon-base64", iconBase64);
            spl.Add("ack", ack);
            spl.Add("callback", callback);
            spl.Add("value", value);
            spl.Add("timeout", timeout);
            spl.Add("priority", (Int32?)priority);

            return DoRequest(Requests.Update, spl);
        }
 public static bool ValidateMessagePriority(MessagePriority value)
 {
     return ((value >= MessagePriority.Lowest) && (value <= MessagePriority.Highest));
 }
コード例 #58
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MsmqTraceListenerData"/> class.
 /// </summary>
 /// <param name="name">The name for the represented trace listener.</param>
 /// <param name="queuePath">The path name for the represented trace listener.</param>
 /// <param name="formatterName">The formatter name for the represented trace listener.</param>
 /// <param name="messagePriority">The priority for the represented trace listener.</param>
 /// <param name="recoverable">The recoverable flag for the represented trace listener.</param>
 /// <param name="timeToReachQueue">The timeToReachQueue for the represented trace listener.</param>
 /// <param name="timeToBeReceived">The timeToReachQueue for the represented trace listener.</param>
 /// <param name="useAuthentication">The use authentication flag for the represented trace listener.</param>
 /// <param name="useDeadLetterQueue">The use dead letter flag for the represented trace listener.</param>
 /// <param name="useEncryption">The use encryption flag for the represented trace listener.</param>
 /// <param name="transactionType">The transaction type for the represented trace listener.</param>
 /// <param name="traceOutputOptions">The trace output options for the represented trace listener.</param>
 /// <param name="filter">The filter for the represented trace listener.</param>
 public MsmqTraceListenerData(string name, string queuePath, string formatterName,
                              MessagePriority messagePriority, bool recoverable,
                              TimeSpan timeToReachQueue, TimeSpan timeToBeReceived,
                              bool useAuthentication, bool useDeadLetterQueue, bool useEncryption,
                              MessageQueueTransactionType transactionType, TraceOptions traceOutputOptions, SourceLevels filter)
     : base(name, typeof(MsmqTraceListener), traceOutputOptions, filter)
 {
     this.QueuePath = queuePath;
     this.Formatter = formatterName;
     this.MessagePriority = messagePriority;
     this.Recoverable = recoverable;
     this.TimeToReachQueue = timeToReachQueue;
     this.TimeToBeReceived = timeToBeReceived;
     this.UseAuthentication = useAuthentication;
     this.UseDeadLetterQueue = useDeadLetterQueue;
     this.UseEncryption = useEncryption;
     this.TransactionType = transactionType;
 }
コード例 #59
0
        public void Send(IWorker worker, string text, MessagePriority priority)
        {
            if (worker == null)
                throw new ArgumentNullException("worker");

            byte[] data = ((SettingsHost)ServiceManager.Services[typeof(SettingsHost)]).Settings.Encoding.GetBytes(text);
            this.Send(worker, data, priority);
        }
コード例 #60
0
ファイル: Snarl.cs プロジェクト: TlhanGhun/FileSystemSnarl
        /// <summary>
        /// Notify
        /// </summary>
        /// <param name="classId">Optional</param>
        /// <param name="title">Optional</param>
        /// <param name="text">Optional</param>
        /// <param name="timeout">Optional</param>
        /// <param name="iconPath">Optional</param>
        /// <param name="iconBase64">Optional</param>
        /// <param name="callback">Optional</param>
        /// <param name="priority">Optional</param>
        /// <param name="uid">Optional</param>
        /// <param name="value">Optional</param>
        /// <returns></returns>
        /// <remarks>All parameters are optional. Pass null to use class default values.</remarks>
        public Int32 Notify(String classId, String title, String text, Int32? timeout, String iconPath, String iconBase64, MessagePriority? priority, String uid, String callback, String value)
        {
            // notify?[app-sig=<signature>|token=<application token>][&password=<password>][&id=<class identifier>]
            //        [&title=<title>][&text=<text>][&timeout=<timeout>][&icon=<icon path>][&icon-base64=<MIME data>][&callback=<default callback>]
            //        [&priority=<priority>][&uid=<notification uid>][&value=<value>]

            SnarlParameterList spl = new SnarlParameterList(8);
            spl.Add("token", appToken);
            spl.Add("password", password);

            spl.Add("id", classId);
            spl.Add("title", title);
            spl.Add("text", text);
            spl.Add("timeout", timeout);
            spl.Add("icon", iconPath);
            spl.Add("icon-base64", iconBase64);
            spl.Add("callback", callback);
            spl.Add("priority", (Int32?)priority);
            spl.Add("uid", uid);
            spl.Add("value", value);

            lastMsgToken = DoRequest(Requests.Notify, spl);

            return lastMsgToken;
        }