Exemple #1
0
 private void ReturnToBox()
 {
     parent.SetOpenText(true, true);
     if (this.inReplyToId != 0 && TweetStorage.Contains(this.inReplyToId) == TweetExistState.Exists)
     {
         parent.SetInReplyTo(TweetStorage.Get(this.inReplyToId));
     }
     parent.SetText(this.body);
     parent.OverrideTarget(new[] { this.accountInfo });
     Remove();
 }
Exemple #2
0
        public static IEnumerable <TwitterStatusBase> UnfoldTimeline(Func <int, IEnumerable <TwitterStatusBase> > reader, int lengthThreshold, int maxDepth)
        {
            List <IEnumerable <TwitterStatusBase> > cache = new List <IEnumerable <TwitterStatusBase> >();

            for (int i = 0; i < maxDepth; i++)
            {
                var status = ApiHelper.ExecApi(() => reader(i)).Guard().OrderByDescending(t => t.CreatedAt);
                cache.Add(status);
                if (status.Count() < lengthThreshold)
                {
                    break;
                }
                if (!status.Take(1).Any(s => TweetStorage.Contains(s.Id) == TweetExistState.Unreceived))
                {
                    break;
                }
            }
            return(cache.Where(i => i != null).SelectMany(i => i));
        }
Exemple #3
0
        public FilterStatusId(long pivot, bool getStatus)
        {
            this.Range = LongRange.FromPivotValue(pivot);

            if (getStatus)
            {
                if (TweetStorage.Contains(pivot) != TweetExistState.Exists)
                {
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            var status = ApiHelper.ExecApi(() => AccountStorage.GetRandom().GetStatus(pivot));
                            if (status != null)
                            {
                                TweetStorage.Register(status);
                                RaisePartialRequireReaccept(status);
                            }
                        }
                        catch { }
                    });
                }
            }
        }
Exemple #4
0
        private void RecursiveCheckId(long id)
        {
            if (id == 0)
            {
                RaiseRequireReaccept();
                return;
            }
            var cont = TweetStorage.Contains(id);

            if (cont == TweetExistState.Exists)
            {
                // データをチェックして、先があれば再帰
                var tweet = TweetStorage.Get(id);
                if (tweet == null)
                {
                    RaiseRequireReaccept();
                    return;
                }
                var ts = tweet.Status as TwitterStatus;
                if (ts != null && ts.InReplyToStatusId != 0)
                {
                    this.tracePoint = ts.InReplyToStatusId;
                    RaisePartialRequireReaccept(ts);
                    RecursiveCheckId(ts.InReplyToStatusId);
                    tweet.RefreshInReplyToInfo(); // 返信情報の更新を通知
                }
                else
                {
                    RaiseRequireReaccept();
                }
            }
            else if (cont == TweetExistState.ServerDeleted)
            {
                // 消されてるからダメ
                RaiseRequireReaccept();
                return;
            }
            else
            {
                // tweetを受信しようか
                Action receive = null;
                receive = () =>
                {
                    try
                    {
                        var status = ApiHelper.ExecApi(() => AccountStorage.GetRandom().GetStatus(id));
                        if (status != null)
                        {
                            var vm = TweetStorage.Register(status);
                            this.tracePoint = status.Id; // temporarily id
                            Task.Factory.StartNew(() => RecursiveCheckId(status.Id));
                            Task.Factory.StartNew(() =>
                                                  TweetStorage.GetAll(tvm => (tvm.Status is TwitterStatus) && ((TwitterStatus)tvm.Status).InReplyToStatusId == id)
                                                  .ForEach(tvm => tvm.RefreshInReplyToInfo()));
                        }
                        else
                        {
                            RaiseRequireReaccept();
                        }
                    }
                    catch (Exception e)
                    {
                        ExceptionStorage.Register(e, ExceptionCategory.TwitterError, "ツイート " + id + " の受信に失敗しました。", receive);
                        RaiseRequireReaccept();
                    }
                };
                Task.Factory.StartNew(() => receive());
            }
        }