Ejemplo n.º 1
0
 public static void Reply(Message source)
 {
     ClientState.Current.ViewController.MoveTo(
         PluginsManager.Current.GetPlugin <ConversationsPlugin>().NewItemView,
         new NewMessageDataHelper
     {
         SourceMessageId   = source.MessageId,
         SelectedChannelId = source.SourceChannelId,
         Context           = "Re: " + source.Context,
         To   = source.From.ToList(),
         Body = MessageBodyGenerator.CreateBodyTextForReply(source, true)
     });
 }
Ejemplo n.º 2
0
        public static void ReplyAll(Message source, string text)
        {
            var recipients = new SourceAddressCollection();

            recipients.AddRange(source.To);
            recipients.AddRange(source.CC);

            long channelid;

            // Remove receivers own address from list
            if (source.SourceChannelId != 0)
            {
                var channel       = ChannelsManager.GetChannelObject(source.SourceChannelId);
                var sourceAddress = channel.InputChannel.GetSourceAddress();

                if (recipients.Contains(sourceAddress))
                {
                    recipients.Remove(sourceAddress);
                }

                channelid = source.SourceChannelId;
            }
            else
            {
                var channel       = ChannelsManager.GetChannelObject(source.TargetChannelId);
                var sourceAddress = channel.InputChannel.GetSourceAddress();

                if (recipients.Contains(sourceAddress))
                {
                    recipients.Remove(sourceAddress);
                }

                channelid = source.TargetChannelId;
            }

            ClientState.Current.ViewController.MoveTo(
                PluginsManager.Current.GetPlugin <ConversationsPlugin>().NewItemView,
                new NewMessageDataHelper
            {
                SourceMessageId   = source.MessageId,
                SelectedChannelId = channelid,
                Context           = "Re: " + source.Context,
                To   = source.From.ToList(),
                Cc   = recipients,
                Body = MessageBodyGenerator.CreateBodyTextForReply(source, text),
                SuppressSignature = !String.IsNullOrEmpty(text)
            });
        }
Ejemplo n.º 3
0
        void Send_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ClientStats.LogEvent("Quick reply all send");

            if (String.IsNullOrEmpty(QuickReplyAll.Text.Trim()))
            {
                return;
            }

            var newMessage = new Message();

            #region Create message

            var channel = message.SourceChannelId == 0 ?
                          ChannelsManager.GetDefaultChannel() :
                          ChannelsManager.GetChannelObject(Message.SourceChannelId);

            var recipients    = new SourceAddressCollection();
            var sourceAddress = channel.InputChannel.GetSourceAddress();

            recipients.Add(Message.From);
            recipients.AddRange(Message.To);

            // Remove our own address from recipient list
            if (recipients.Contains(sourceAddress))
            {
                recipients.Remove(sourceAddress);
            }

            newMessage.InReplyTo = Message.MessageIdentifier;
            newMessage.ConversationIdentifier = Message.ConversationIdentifier;
            newMessage.Context         = "Re: " + Message.Context;
            newMessage.From            = channel.InputChannel.GetSourceAddress();
            newMessage.TargetChannelId = channel.Configuration.ChannelId;
            newMessage.To.AddRange(recipients);
            newMessage.CC.AddRange(Message.CC);

            var access = new ClientMessageAccess(newMessage, null,
                                                 MessageBodyGenerator.CreateBodyTextForReply(Message, QuickReplyAll.Text.Nl2Br()));

            newMessage.BodyHtmlStreamName = access.WriteBodyHtml();
            newMessage.BodyPreview        = access.GetBodyPreview();
            newMessage.IsRead             = true;
            newMessage.DateSent           = DateTime.Now;
            newMessage.MessageFolder      = Folders.SentItems;
            newMessage.DateSent           = DateTime.Now;
            newMessage.DateCreated        = DateTime.Now;

            #endregion

            #region Send message

            ClientState.Current.DataService.Save(newMessage);

            // Add message to mailbox
            EventBroker.Publish(AppEvents.MessageStored, newMessage);

            // Save command
            CommandQueue.Enqueue(AppCommands.SendMessage, newMessage);

            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                ClientState.Current.ShowMessage(
                    new AppMessage(Strings.MessageWillBeSentLater)
                {
                    EntityId   = newMessage.MessageId.Value,
                    EntityType = EntityType.Message
                }, MessageType.Success);
            }

            QuickReplyAll.Text = String.Empty;

            message.TrackAction(ActionType.ReplyForward);

            #endregion
        }