Exemplo n.º 1
0
        void ScheduleWithServer(DateTime scheduleTime)
        {
            requestsLeft = 0;
            error        = false;
            foreach (var user in SelectedAccounts.OfType <UserToken>())
            {
                IsLoading = true;
                requestsLeft++;

                var scheduler = new Scheduler(user.Key, user.Secret);

                scheduler.ScheduleTweet(TweetText, scheduleTime, (sender, response) =>
                {
                    requestsLeft--;
                    if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.NoContent)
                    {
                        error = true;
                        MessageService.ShowError(string.Format(Resources.ScheduleError, user.ScreenName));
                    }

                    if (requestsLeft <= 0)
                    {
                        IsLoading = false;
                        if (!error)
                        {
                            MessageService.ShowMessage(Resources.MessageScheduled);
                            GoBack();
                        }
                    }
                });
            }
        }
Exemplo n.º 2
0
        public TwitterDraft CreateDraft()
        {
            var draft = new TwitterDraft();

            draft.Text = TweetText;

            if (IsScheduled == true)
            {
                draft.Scheduled = new DateTime(
                    ScheduledDate.Year,
                    ScheduledDate.Month,
                    ScheduledDate.Day,
                    ScheduledTime.Hour,
                    ScheduledTime.Minute,
                    0);
            }
            else
            {
                draft.Scheduled = null;
            }

            draft.CreatedAt = DateTime.Now;
            draft.Accounts  = new List <UserToken>();

            foreach (var acc in SelectedAccounts.OfType <UserToken>())
            {
                draft.Accounts.Add(acc as UserToken);
            }

            draft.ReplyId = DataTransfer.ReplyId;

            return(draft);
        }
Exemplo n.º 3
0
        private void ScheduleWithBackgroundAgent(DateTime scheduleTime)
        {
            TwitterStatusTask task = new TwitterStatusTask
            {
                InReplyTo = DataTransfer.ReplyId
            };

            task.Text = TweetText;

            if (ScheduledDate == null || ScheduledTime == null)
            {
                MessageService.ShowError(Resources.SelectDateTimeToSchedule);
                return;
            }

            task.Scheduled = scheduleTime;

            task.Accounts = new List <UserToken>();

            foreach (var user in SelectedAccounts.OfType <UserToken>())
            {
                task.Accounts.Add(user);
            }

            Config.TweetTasks.Add(task);
            Config.SaveTweetTasks();

            MessageService.ShowMessage(Resources.MessageScheduled, "");
            GoBack();
        }
Exemplo n.º 4
0
        bool CheckProtectedAccounts()
        {
            foreach (var user in SelectedAccounts.OfType <UserToken>())
            {
                if (user != null && ProtectedAccounts.IsProtected(user))
                {
                    var result = MessageService.AskYesNoQuestion(String.Format(Resources.AskTweetProtectedAccount, user.ScreenName), "");
                    if (!result)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }