Exemple #1
0
 /// <summary>
 /// Zobrazí chybovou hlášku týkající se sběrnice
 /// </summary>
 /// <param name="type">typ hlášky</param>
 /// <param name="message">text chyby</param>
 public void showDisgnosticMessage(MessageTypeEnum type, string message)
 {
     switch (type)
     {
         case MessageTypeEnum.error:
             //MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             labelMessage.ForeColor = Color.Red;
             break;
         case MessageTypeEnum.success:
             labelMessage.ForeColor = Color.Green;
             break;
         case MessageTypeEnum.progress:
             labelMessage.ForeColor = Color.Blue;
             break;
     }
     if (labelMessage.InvokeRequired)
     {
         ShowDisagnosticMessageCallback cb = new ShowDisagnosticMessageCallback(showDisgnosticMessage);
         this.Invoke(cb, new object[] { type, message });
     }
     else
     {
         labelMessage.Text = message;
     }
     
 }
        public static void AddMessage(this FlowLayoutPanel source, MessageTypeEnum messageType, string message)
        {
            var panel = new FlowLayoutPanel();
            panel.AutoSize = true;
            panel.WrapContents = false;
            panel.FlowDirection = FlowDirection.TopDown;

            var lbl = new Label();
            lbl.AutoSize = true;
            lbl.Margin = new Padding(10, 10, 10, 0);
            lbl.Text = messageType.ToString();
            lbl.ForeColor = Color.FromName("White");
            lbl.BackColor = messageType.ToColor();
            lbl.BorderStyle = BorderStyle.FixedSingle;
            lbl.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Bold);
            panel.Controls.Add(lbl);

            var lbl2 = new Label();
            lbl2.AutoSize = true;
            lbl2.Margin = new Padding(10, 5, 10, 5);
            lbl2.Text = message;
            lbl2.Font = new Font("Microsoft Sans Serif", 10f);
            panel.Controls.Add(lbl2);

            source.Controls.Add(panel);
            Application.DoEvents();
            source.Focus();
        }
Exemple #3
0
 public Message(MessageTypeEnum _messageType, string _userName, string _time, string _text, byte[] _bitmap, string _room)
 {
     messageType = _messageType;
     userName = _userName;
     time = _time;
     text = _text;
     bitmap = _bitmap;
     room = _room;
 }
Exemple #4
0
 public MeasuringMessage(DateTime dateTime, MessageTypeEnum messageType,
     string measurableType, Guid plantsAreaId, double parameterValue)
 {
     Id = Guid.NewGuid();
     DateTime = dateTime;
     MessageType = messageType;
     MeasurableType = measurableType;
     PlantsAreaId = plantsAreaId;
     ParameterValue = parameterValue;
 }
Exemple #5
0
 public static void ShowMessage(this System.Web.Mvc.Controller controller, MessageTypeEnum messageType, string message, bool showAfterRedirect = false)
 {
     var messageTypeKey = messageType.ToString();
     if (showAfterRedirect)
     {
         controller.TempData[messageTypeKey] = message;
     }
     else
     {
         controller.ViewData[messageTypeKey] = message;
     }
 }
Exemple #6
0
 /// <summary>
 /// Set up simple message
 /// messageType = eviivo
 /// contentType = plain text
 /// Status = unread
 /// text = "Test text"
 /// business id = 1
 /// message id = 1
 /// </summary>
 /// <param name="businessId">business to create message for, default 1</param>
 /// <param name="messageId">id of message, default 1</param>
 /// <param name="messageTypeEnum">message type, default eviivo</param>
 /// <param name="contentTypeEnum">content type, default plain</param>
 /// <param name="messageStatusEnum">message status, default unread</param>
 /// <param name="content">content text, default "Test text"</param>
 /// <returns>a new Message</returns>
 public static Message BuildSimple(long businessId = 1, int messageId = 1,
                                   MessageTypeEnum messageTypeEnum = MessageTypeEnum.EviivoMessage,
                                   ContentTypeEnum contentTypeEnum = ContentTypeEnum.PlainText,
                                   MessageStatusEnum messageStatusEnum = MessageStatusEnum.Unread,
                                   string content = "Test text")
 {
     return new Message
         {
             BusinessId = businessId,
             Id = messageId,
             MessageStatusEnum = messageStatusEnum,
             MessageTypeEnum = messageTypeEnum,
             ContentTypeEnum = contentTypeEnum,
             Content = content,
             CreatedDateTime = DateTime.Now,
             Events = new System.Collections.Generic.List<MessageEvent>()
         };
 }
Exemple #7
0
 public void ConsoleWrite(string msg, MessageTypeEnum type)
 {
     LogWrite(FormatMessage(msg, type));
 }
Exemple #8
0
 internal override void Synchronize()
 {
     m_MessageType = (MessageTypeEnum)m_reader.ReadByte();
     m_EncodingFlags = m_reader.ReadByte();
     switch ((MessageLengthFieldTypeEnum)(m_EncodingFlags & EncodingFlagsMessageLengthMask))
     {
       case MessageLengthFieldTypeEnum.OneByte:
     m_MessageLength = m_reader.ReadByte();
     break;
       case MessageLengthFieldTypeEnum.TwoBytes:
     m_MessageLength = m_reader.ReadUInt16();
     break;
       case MessageLengthFieldTypeEnum.FourBytes:
     m_MessageLength = m_reader.ReadUInt32();
     break;
     }
     m_MessageSequenceNumber = m_reader.ReadUInt16();
     m_ConfigurationVersion.MajorVersion = m_reader.ReadByte();
     m_ConfigurationVersion.MinorVersion = m_reader.ReadByte();
     switch (m_MessageType)
     {
       case MessageTypeEnum.DataKeyFrame:
       case MessageTypeEnum.DataDeltaFrame:
       case MessageTypeEnum.Event:
     m_TimeStamp = m_reader.ReadDateTime();
     m_FieldCount = m_reader.ReadUInt16();
     break;
       case MessageTypeEnum.KeepAlive:
     break;
       case MessageTypeEnum.DataSetMetadata:
     break;
       default:
     break;
     }
     m_IsSynchronized = true;
 }
Exemple #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="messageNumber">The message number</param>
 /// <param name="messageType">The message type</param>
 public WixMessage(int messageNumber, MessageTypeEnum messageType)
     : base(messageNumber, messageType)
 {
 }
Exemple #10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="messageNumber">The message number</param>
 /// <param name="messageType">The message type</param>
 public Message(int messageNumber, MessageTypeEnum messageType)
 {
     this.messageNumber = messageNumber;
     this.messageText = String.Empty;
     this.messageType = messageType;
 }
Exemple #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="messageNumber">The message number</param>
 /// <param name="messageText">The message text</param>
 /// <param name="messageType">The message type</param>
 public Message(int messageNumber, string messageText, MessageTypeEnum messageType)
 {
     this.messageNumber = messageNumber;
     this.messageText = messageText;
     this.messageType = messageType;
 }
 public void FromByte(byte data)
 {
     MessageType = (MessageTypeEnum)((data >> 5) & 0x7);
     ExtendedMessage = (data & 0x10) != 0;
     HopsLeft = (byte)((data >> 2) & 0x3);
     MaxHops = (byte)((data >> 0) & 0x3);
 }
Exemple #13
0
        private static ContentInfo ContentParser(MessageTypeEnum type, string messageInfo, string messageId, string targetId)
        {
            var result = JsonConvert.DeserializeObject<ContentInfo>(messageInfo);
            result.MessageType = type;
            result.Id = messageId;
            if (type != MessageTypeEnum.TxtMsg)
            {
                if (type == MessageTypeEnum.ContactNtf)
                {
                    result.content += result.message;
                }
                else if (type == MessageTypeEnum.InfoNtf)
                {
                    result.content += result.message;
                }
                else if (type == MessageTypeEnum.ProfileNtf)
                {

                }
                else if (type == MessageTypeEnum.CmdNtf)
                {

                }
                else if (type == MessageTypeEnum.CmdMsg)
                {

                }
                else if (type == MessageTypeEnum.DizNtf)
                {
                    result.content = type.GetDescription();
                }
                else if (type == MessageTypeEnum.LBSMsg)
                {
                    result.content = "[地理位置]";
                }
            }

            if (type == MessageTypeEnum.VcMsg)
            {
                var localFile = String.Format(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Temp", targetId + "-" + messageId + ".wav"));

                if (!File.Exists(localFile))
                {
                    var tempAmrFile = String.Format(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Temp", targetId + "-" + messageId + ".amr"));
                    Byte[] wavBytes = Convert.FromBase64String(result.content);
                    File.WriteAllBytes(tempAmrFile, wavBytes);
                    Rcsdk.DecodeAmrToWav(tempAmrFile, localFile);
                }

                result.extra = localFile;
            }

            if (type == MessageTypeEnum.ImgMsg)
            {
                var image = System.Drawing.Image.FromStream(new MemoryStream(System.Convert.FromBase64String(result.content)));
                var localFile = String.Format(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Temp", targetId + "-" + messageId + ".jpg"));

                if (!File.Exists(localFile))
                {
                    image.Save(localFile, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
                result.thumImgPath = localFile;
            }

            if (type == MessageTypeEnum.TxtMsg)
            {
                result.content = EncryptHelper.Decrypt(result.content);
                // result.content = Regex.Replace(result.content, @"\p{Cs}", "[表情]");
            }

            if (type == MessageTypeEnum.file)
            {
                //ToDO:如果为文件,则保存
            }

            return result;
        }
Exemple #14
0
        private static ContentInfo ConversationContentParser(MessageTypeEnum type, string messageInfo)
        {
            var result = JsonConvert.DeserializeObject<ContentInfo>(messageInfo);
            result.MessageType = type;

            if (type != MessageTypeEnum.TxtMsg)
            {
                result.content = type.GetDescription();

                if (type == MessageTypeEnum.ContactNtf)
                {
                    result.content += result.message;
                }
                else if (type == MessageTypeEnum.InfoNtf)
                {
                    result.content += result.message;
                }
                else if (type == MessageTypeEnum.ProfileNtf)
                {

                }
                else if (type == MessageTypeEnum.CmdNtf)
                {

                }
                else if (type == MessageTypeEnum.CmdMsg)
                {

                }
            }
            else
            {
                result.content = EncryptHelper.Decrypt(result.content);
            }

            return result;
        }
Exemple #15
0
 public static Message genRoomNotifi(string toNoti, MessageTypeEnum type)
 {
     Message msg = new Message();
     msg.messageType = type;
     msg.text = toNoti;
     msg.time = System.DateTime.Now.ToString();
     return msg;
 }
Exemple #16
0
        /// <summary>
        /// Add a notification to a booking
        /// </summary>
        /// <param name="businessId">Business for booking</param>
        /// <param name="booking">Booking to create the notification for</param>
        /// <param name="cultureCode">Culture for translating</param>
        /// <param name="type">Booking Type</param>
        /// <param name="notificationDate">The datetime at which this notification should be presented to the user</param>
        /// <param name="parameters">string.format() parameters to be included in the message content</param>
        private void AddNotificationMessage(long businessId, Model.Booking.Booking booking, string cultureCode, MessageTypeEnum type, DateTime notificationDate, params object[] parameters)
        {
            var notificationMessage = new Message
            {
                ContentTypeEnum = Model.Common.ContentTypeEnum.PlainText,
                BusinessId = businessId,
                MessageTypeEnum = type,
                MessageStatusEnum = MessageStatusEnum.Unread
            };

            var notificationKey = string.Empty;
            switch (type)
            {
                case MessageTypeEnum.PreAuth:
                    notificationKey = PREAUTH_NOTIFICATION_KEY;
                    break;
                case MessageTypeEnum.CollectPayOnArrival:
                    notificationKey = COLLECTPOA_NOTIFICATION_KEY;
                    break;
                case MessageTypeEnum.BookingWithExtras:
                    notificationKey = EXTRAS_NOTIFICATION_KEY;
                    break;
            }

            // get message text
            var items = dictionaryManager.GetDictionaryItemByKeysAndCultures(new List<string> { notificationKey }, null);
            if (items != null &&
                items.Any())
            {
                ICollection<DictionaryInstance> instances = items.First().DictionaryInstances;
                notificationMessage.Content = dictionaryManager.DictionaryInstanceToContentByCulture(instances,
                                                                           cultureCode);

                // if content isn't empty
                if (!string.IsNullOrWhiteSpace(notificationMessage.Content))
                {
                    // format the text
                    notificationMessage.Content = string.Format(notificationMessage.Content, parameters);
                }
            }

            // booking id for now
            notificationMessage.Reference = booking.Id.HasValue ? booking.Id.Value.ToString() : string.Empty;

            notificationMessage.NotifyAfter = notificationDate;

            messageDao.AddMessage(notificationMessage);
        }
Exemple #17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="messageNumber">The message number</param>
 /// <param name="messageText">The message text</param>
 /// <param name="messageType">The message type</param>
 public WixMessage(int messageNumber, string messageText, MessageTypeEnum messageType)
     : base(messageNumber, messageText, messageType)
 {
 }
Exemple #18
0
        public String FormatMessage(String msg, MessageTypeEnum type)
        {
            String prefix = "[^bBattlelog Cache^n] ";

            if (type.Equals(MessageTypeEnum.Warning))
            {
                prefix += "^1^bWARNING^0^n: ";
            }
            else if (type.Equals(MessageTypeEnum.Error))
            {
                prefix += "^1^bERROR^0^n: ";
            }
            else if (type.Equals(MessageTypeEnum.Exception))
            {
                prefix += "^1^bEXCEPTION^0^n: ";
            }

            return prefix + msg;
        }
Exemple #19
0
 /// <summary>
 /// Gets the producer message header.
 /// </summary>
 /// <param name="writer">The writer <see cref="IBinaryHeaderEncoder" /> to populate the payload with the header information.</param>
 /// <param name="encoding">The encoding.</param>
 /// <param name="lengthFieldType">Type of the length field in the the message header.</param>
 /// <param name="messageType">Type of the message.</param>
 /// <param name="configurationVersion">The configuration version.</param>
 /// <returns>MessageHeader.</returns>
 internal static MessageHeader GetProducerMessageHeader(IBinaryHeaderEncoder writer, FieldEncodingEnum encoding, MessageLengthFieldTypeEnum lengthFieldType, MessageTypeEnum messageType, ConfigurationVersionDataType configurationVersion)
 {
     return new ProducerMessageHeader(writer, encoding, lengthFieldType, messageType, configurationVersion);
 }
Exemple #20
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="messageText">The message tesxt</param>
 /// <param name="messageType">The message type</param>
 public MSBuildMessage(string messageText, MessageTypeEnum messageType)
     : base(0, messageText, messageType)
 {
 }
Exemple #21
0
 public ProducerMessageHeader(IBinaryHeaderEncoder writer, FieldEncodingEnum encoding, MessageLengthFieldTypeEnum lengthFieldType, MessageTypeEnum messageType, ConfigurationVersionDataType configurationVersion)
 {
     m_MessageType = messageType;
     m_Encoding = encoding;
     m_lengthFieldType = lengthFieldType;
     m_HeaderWriter = new HeaderWriter(writer, PackageHeaderLength());
     MessageSequenceNumber = 0;
     ConfigurationVersion = configurationVersion;
 }
Exemple #22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="messageNumber">The message number</param>
 /// <param name="messageType">The message type</param>
 public MSBuildMessage(int messageNumber, MessageTypeEnum messageType)
     : base(messageNumber, messageType)
 {
 }
 private void AddMessage(MessageTypeEnum messageType, string message)
 {
     MessageCallBack.Invoke(messageType, message);
 }
 public static MessageType Create(MessageTypeEnum v)
 {
   return new MessageType {
     InnerValue = v
   };
 }
    /// <summary>
    /// Logs message to for asynchronous displaying.
    /// </summary>
    /// <param name="line">Message to be displayed</param>
    /// <param name="type">Type of a message</param>
    /// <param name="logToEventLog">Log to event log</param>
    public void LogMessage(string line, MessageTypeEnum type, bool logToEventLog)
    {
        if (!line.EndsWithCSafe("<br />", StringComparison.InvariantCultureIgnoreCase))
        {
            line = line + "<br />";
        }
        ProgressMessagesHelper progressMessages = new ProgressMessagesHelper();
        switch (type)
        {
            case MessageTypeEnum.Info:
                progressMessages.LogInfo(line, SourceText, EventCodeText, logToEventLog);
                break;

            case MessageTypeEnum.Warning:
                progressMessages.LogWarning(line, SourceText, EventCodeText, logToEventLog);
                break;

            case MessageTypeEnum.Error:
                progressMessages.LogError(line, SourceText, EventCodeText, logToEventLog);
                break;

            case MessageTypeEnum.Finished:
                progressMessages.LogQuit(line, SourceText, EventCodeText, logToEventLog);
                break;
        }
    }
Exemple #26
0
 private void VeraMessagesCallBack(MessageTypeEnum messageType, string message)
 {
     //var addText = string.Format("{0} - {1}\r\n", messageType, message);
     this.flowLayoutPanel1.AddMessage(messageType, message);
 }
Exemple #27
0
        public string FormatMessage(string msg, MessageTypeEnum type)
        {
            string prefix = "[^bAdKats^n] ";

            if (type.Equals(MessageTypeEnum.Warning))
            {
                prefix += "^1^bWARNING^0^n: ";
            }
            else if (type.Equals(MessageTypeEnum.Error))
            {
                prefix += "^1^bERROR^0^n: ";
            }
            else if (type.Equals(MessageTypeEnum.Success))
            {
                prefix += "^b^2SUCCESS^n^0: ";
            }
            else if (type.Equals(MessageTypeEnum.Exception))
            {
                prefix += "^1^bEXCEPTION^0^n: ";
            }

            return prefix + msg;
        }
Exemple #28
0
 public Message(MessageTypeEnum MessageType)
 {
     this.MessageType = MessageType;
 }