Exemple #1
0
        public override void Run()
        {
            var appContext = AppContext.Default;

            Utils.VerifyLogin(appContext);

            var group = appContext.YamsterCache.GetGroupById(this.GroupId, nullIfMissing: true);

            if (group == null)
            {
                throw new InvalidOperationException("The group #" + this.GroupId
                                                    + " was not found in Yamster's database; you may need to sync it first");
            }
            var newMessage = YamsterNewMessage.CreateNewThread(group);

            newMessage.Body = this.Body;

            Utils.Log("Posting message...");

            Task <YamsterMessage> task = appContext.YamsterCache.PostMessageAsync(newMessage);

            ForegroundSynchronizationContext.RunSynchronously(task);
            var postedMessage = task.Result;

            Utils.Log("Successfully posted with MessageId={0}", postedMessage.MessageId);
        }
Exemple #2
0
        protected void btnSend_Clicked(object sender, EventArgs e)
        {
            if (!this.appContext.MessagePuller.Enabled)
            {
                Utilities.ShowMessageBox("Yamster is currently running in offline mode.  In order to"
                                         + " post a message, you must enable syncing.",
                                         "Post Message", ButtonsType.Ok, MessageType.Info);
                return;
            }

            List <YamsterUser> ccUsers = this.ctlCCUserEntry.ParseUserList();

            if (!showedPostWarning)
            {
                if (Utilities.ShowMessageBox(
                        @"Posting is new in Yamster.  There are currently some limitations:
● No realtime updates; always click ""Refresh"" before posting to check for new replies
● No spell check",
                        "Under Construction", ButtonsType.OkCancel, MessageType.Warning) != ResponseType.Ok)
                {
                    return;
                }

                // Don't suppress the warning if they clicked cancel
                showedPostWarning = true;
            }

            YamsterNewMessage newMessage;

            switch (this.ComposerMode)
            {
            case MessageComposerMode.NewThread:
                newMessage = YamsterNewMessage.CreateNewThread(this.GroupContext);
                break;

            case MessageComposerMode.ReplyToMessage:
                newMessage = YamsterNewMessage.CreateReply(this.MessageBeingRepliedTo);
                break;

            case MessageComposerMode.ReplyToThread:
                newMessage = YamsterNewMessage.CreateReply(this.ThreadContext);
                break;

            default:
                throw new InvalidOperationException("Invalid message composer state");
            }

            newMessage.Body = txtBody.Buffer.Text;
            newMessage.CarbonCopyUsers.AddRange(ccUsers);
            var task = this.PostMessageAsync(newMessage);
        }
Exemple #3
0
        async Task PostMessageAsync(YamsterNewMessage newMessage)
        {
            try
            {
                waitingForPost = true;
                UpdateUI();
                await this.appContext.YamsterCache.PostMessageAsync(newMessage);

                this.appContext.RequireForegroundThread();
                txtBody.Buffer.Text = "";
                ctlCCUserEntry.Text = "";
            }
            catch (Exception ex)
            {
                this.appContext.RequireForegroundThread();
                Utilities.ShowApplicationException(ex);
            }
            finally
            {
                waitingForPost = false;
                UpdateUI();
            }
        }