AddOutboxMessage() public static méthode

public static AddOutboxMessage ( [ provider, [ message ) : void
provider [
message [
Résultat void
Exemple #1
0
        public void Add(MessageInfo msgInfo)
        {
            OutboxHelper.AddOutboxMessage(_provider, msgInfo);
            Refresh();

            var maxId = int.MinValue;

            foreach (var newMessage in this)
            {
                if (newMessage.ID > maxId)
                {
                    maxId = newMessage.ID;
                }
            }
        }
Exemple #2
0
        private void SaveMessage(bool closeOnSave)
        {
            // subject validation
            if (_subjectTextBox.Text.Trim().Length == 0)
            {
                MessageBox.Show(
                    SR.MessageEditor.SubjectRequired,
                    ApplicationInfo.ApplicationName,
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // fill object from controls
            if (_forumsComboBox.ForumId != -1)
            {
                _messageInfo.ForumId = _forumsComboBox.ForumId;
            }

            _messageInfo.Subject = _subjectTextBox.Text.Trim();
            _messageInfo.Message = _messageEditor.Text.Trim();

            if (!_messageInfo.Hold)
            {
                // overquote validation
                if (_quoteAnalyzer != null &&
                    _quoteAnalyzer.IsOverquoted(_messageEditor.Text))
                {
                    // Предлагаем вернуться к редактированию сообщения.
                    if (MessageBox.Show(
                            this,
                            SR.MessageEditor.QuoteWarning,
                            ApplicationInfo.ApplicationName,
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }

            if (_formMode == MessageFormMode.Add || _formMode == MessageFormMode.Reply)
            {
                OutboxHelper.AddOutboxMessage(_serviceManager, _messageInfo);

                if (!closeOnSave)
                {
                    using (var db = _serviceManager.CreateDBContext())
                        _messageInfo.ID = db.OutboxMessages().Max(m => m.ID);
                    _formMode = MessageFormMode.Edit;
                }

                _serviceManager.LogInfo(string.Format(
                                            SR.MessageEditor.LogNewMsg, _forumsComboBox.Text));
            }
            else
            {
                UpdateOutboxMessage(_messageInfo);
                _serviceManager.LogInfo(string.Format(
                                            SR.MessageEditor.LogChangeMsg, _forumsComboBox.Text));
            }

            _messageEditor.SetSavePoint();
            _subjectTextBox.Modified = false;
            OnIsModifiedChanged();

            if (MessageSent != null)
            {
                MessageSent(this, _messageInfo.ID);
            }

            if (closeOnSave)
            {
                NativeMethods.PostMessage(Handle, NativeMethods.WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
            }

            _serviceManager.GetRequiredService <IOutboxManager>().NewMessages.Refresh();
        }