Esempio n. 1
0
        /// <summary>
        /// Handles the Click event of the Button_Send control. Send what was written in the third tab's box.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void Button_Send_Click(object sender, EventArgs e)
        {
            Message message = BuildMessage();

            textBox_Send.Clear();
            _sendMessage(message);

            User.LoadUserNames(message.UserToChannel.User);
            AddMessage(message);
        }
Esempio n. 2
0
        /// <summary>
        /// Receives the message.
        /// </summary>
        /// <param name="iMessage">The message.</param>
        void ReceiveMessage(IMessage iMessage)
        {
            Logger.LoggerInstance.LogNoisy("Received a message.");
            try
            {
                Logger.LoggerInstance.LogNoisy("Creating message.");
                Message message = BLL.Message.GetOrCreate(iMessage);

                Logger.LoggerInstance.LogNoisy("Loading message's related datas.");
                LoadMessageChilds(message);

                Logger.LoggerInstance.LogInformation(
                    $"Message was sent by {message.UserToChannel.User} in {(message.UserToChannel.Channel.Private ? "private" : message.UserToChannel.Channel.ToString())} on {message.ApplicationName}.{(string.IsNullOrEmpty(message.Text) ? "" : $" \"{message.Text}\"")}");
                DispatchMessage(message);
            }
Esempio n. 3
0
        /// <summary>
        /// Builds a message sent with the third tab.
        /// </summary>
        /// <returns></returns>
        private Message BuildMessage()
        {
            Message message = new Message(
                (Entites.Application)comboBox_Application.SelectedItem,
                null,
                DateTime.UtcNow,
                new UserToChannel(
                    (Entites.Application)comboBox_Application.SelectedItem,
                    BLL.User.GetOrCreate(((Entites.Application)comboBox_Application.SelectedItem).Terministrator),
                    (Channel)comboBox_ChannelUser.SelectedItem,
                    DateTime.MinValue,
                    null),
                MessageType.Get("Text"));

            message.Texts = new List <Text> {
                new Text(textBox_Send.Text, DateTime.UtcNow, message)
            };

            return(message);
        }
Esempio n. 4
0
        /// <summary>
        /// Adds the message in the third tab.
        /// </summary>
        /// <param name="message">The message.</param>
        internal void AddMessage(Message message)
        {
            int id = message.UserToChannel.ChannelId.Value;

            if (_channelDiscussions.ContainsKey(id))
            {
                _channelDiscussions[id].AppendLine(message.ToString());
            }
            else
            {
                _channelDiscussions.Add(id, new StringBuilder(message.ToString()));
            }

            Action maybeAddText = delegate
            {
                if (((Channel)comboBox_ChannelUser.SelectedItem)?.NamableId == message.UserToChannel.ChannelId)
                {
                    textBox_Interact.AppendText((textBox_Interact.Text.Length > 0 ? "\r\n" : "") + message);
                }
            };

            ControlAccess(textBox_Interact, maybeAddText);
        }
Esempio n. 5
0
 /// <summary>
 /// Sends the message before treating it if needed.
 /// </summary>
 /// <param name="message">The message.</param>
 private void SendMessage(Message message)
 {
     message.Application.SendMessage(message);
     Logger.LoggerInstance.LogInformation($"Sent a message to {message.UserToChannel.Channel}: {message.Text}");
     _mainConsole.MessagesSent++;
 }