Exemple #1
0
        private void MessageList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((MessageWithText)MessageList.SelectedItem == null)
            {
                return;
            }
            MessageWithText selMess = (MessageWithText)MessageList.SelectedItem;

            CurMessage = selMess.Message;
            Message message = selMess.Message;

            MessageInfo.Items.Clear();
            switch (GetMessageType(message))
            {
            case MessageType.Message:
                message.Formatter = new System.Messaging.BinaryMessageFormatter();
                avantMobile.avantCore.Message mes = (avantMobile.avantCore.Message)message.Body;
                DrawMessage(mes);
                break;

            case MessageType.MessageState:
                message.Formatter = new System.Messaging.BinaryMessageFormatter();
                Avant.Core.Management.WMI.MessageState mes1 = (Avant.Core.Management.WMI.MessageState)message.Body;
                DrawMessage(mes1);
                break;

            case MessageType.MSMQLogEntry:
                message.Formatter = new System.Messaging.BinaryMessageFormatter();
                Avant.Core.MsmqLog.MSMQLogEntry mes2 = (Avant.Core.MsmqLog.MSMQLogEntry)message.Body;
                DrawMessage(mes2);
                break;

            case MessageType.OutputMessage:
                message.Formatter = new System.Messaging.BinaryMessageFormatter();
                avantMobile.avantCore.OutputMessage mes3 = (avantMobile.avantCore.OutputMessage)message.Body;
                DrawMessage(mes3);
                break;

            case MessageType.SubscriptionMessage:
                message.Formatter = new System.Messaging.BinaryMessageFormatter();
                SubscriptionMessage mes4 = (SubscriptionMessage)message.Body;
                DrawMessage(mes4);
                break;

            case MessageType.XML:
                DrawSimpleMessage(selMess.Text);
                break;

            case MessageType.Unknown:
                DrawSimpleMessage(selMess.Text);
                break;
            }
        }
Exemple #2
0
        /// <summary>
        /// разбор сообщений
        /// </summary>
        /// <param name="messages"></param>
        /// <returns></returns>
        private List <MessageWithText> ParseMessages(Message[] messages)
        {
            MessageType MType = MessageType.Unknown;

            if (messages.Count() > 0)
            {
                MType = GetMessageType(messages[0]);
            }
            List <MessageWithText> MessagesWithId = new List <MessageWithText>();

            foreach (var message in messages)
            {
                string ms = "";
                switch (MType)
                {
                case MessageType.Message:
                    message.Formatter = new System.Messaging.BinaryMessageFormatter();
                    avantMobile.avantCore.Message mes = (avantMobile.avantCore.Message)message.Body;
                    ms = "MSISDN=" + mes.MSISDN + "; Текст=" + mes.Text;
                    break;

                case MessageType.MessageState:
                    message.Formatter = new System.Messaging.BinaryMessageFormatter();
                    Avant.Core.Management.WMI.MessageState mes1 = (Avant.Core.Management.WMI.MessageState)message.Body;
                    ms = "Статус=" + mes1.Status + "; Дата=" + mes1.StatusTime + "; Описание" + mes1.StatusDescription;
                    break;

                case MessageType.MSMQLogEntry:
                    message.Formatter = new System.Messaging.BinaryMessageFormatter();
                    Avant.Core.MsmqLog.MSMQLogEntry mes2 = (Avant.Core.MsmqLog.MSMQLogEntry)message.Body;
                    ms = "Комманда=" + mes2.CommandText + "; БД=" + mes2.DatabaseName;
                    break;

                case MessageType.OutputMessage:
                    message.Formatter = new System.Messaging.BinaryMessageFormatter();
                    avantMobile.avantCore.OutputMessage mes3 = (avantMobile.avantCore.OutputMessage)message.Body;
                    ms = "ID=" + mes3.InboxMsgID.ToString() + "; Текст=" + mes3.Content;
                    break;

                case MessageType.SubscriptionMessage:
                    message.Formatter = new System.Messaging.BinaryMessageFormatter();
                    SubscriptionMessage mes4 = (SubscriptionMessage)message.Body;
                    ms = "MSISDN=" + mes4.MSISDN + "; Действие=" + mes4.actionType.ToString();
                    break;

                case MessageType.XML:
                    message.Formatter = new System.Messaging.BinaryMessageFormatter();
                    StreamReader sr = new StreamReader(message.BodyStream);
                    while (sr.Peek() >= 0)
                    {
                        ms += sr.ReadLine();
                    }
                    ms = Regex.Replace(ms, @"[^a-zA-Zа-яА-Я0-9=\.,\-:]", " ");
                    ms = Regex.Replace(ms, @"[ ]+", " ");
                    break;

                case MessageType.Unknown:
                    message.Formatter = new System.Messaging.BinaryMessageFormatter();
                    StreamReader sr1 = new StreamReader(message.BodyStream);
                    message.BodyStream.Seek(0, SeekOrigin.Begin);
                    while (sr1.Peek() >= 0)
                    {
                        ms += sr1.ReadLine();
                    }
                    ms = Regex.Replace(ms, @"[^a-zA-Zа-яА-Я0-9=\.,\-:]", " ");
                    ms = Regex.Replace(ms, @"[ ]+", " ");
                    break;
                }
                MessagesWithId.Add(new MessageWithText()
                {
                    Message = message, Text = ms
                });
            }
            return(MessagesWithId);
        }