Exemplo n.º 1
0
        void backgroundWorkerPersonalStream_DoWork(object sender, DoWorkEventArgs e)
        {
            Tuple <List <Post>, ApiCallResponse> items;
            ParametersMyStream parameter = new ParametersMyStream();

            parameter.count = Properties.Settings.Default.TwitterItemsFetchInPast;
            if (PersonalStream.Count > 0)
            {
                parameter.since_id = PersonalStream.Max(i => i.Id).ToString();
            }
            parameter.include_annotations = true;
            items = SimpleStreams.getUserStream(this.accessToken, parameter);

            if (items.Item2.success)
            {
                foreach (Post post in items.Item1)
                {
                    if (!post.machine_only && !string.IsNullOrEmpty(post.text) && !post.is_deleted)
                    {
                        ApnItem item = new ApnItem(post, this);
                        if (item != null)
                        {
                            item.receivingAccount = this;
                            backgroundWorkerPersonalStream.ReportProgress(50, item);
                        }
                    }
                }
                if (items.Item1 != null)
                {
                    backgroundWorkerPersonalStream.ReportProgress(99, items.Item2);
                }
            }
        }
Exemplo n.º 2
0
 public void streamCallback(List <Post> posts, bool is_deleted = false)
 {
     if (posts != null)
     {
         foreach (Post post in posts)
         {
             if (post == null)
             {
                 continue;
             }
             if (post.machine_only || string.IsNullOrEmpty(post.text))
             {
                 continue;
             }
             if (!post.is_deleted)
             {
                 ApnItem item = new ApnItem(post, this);
                 item.receivingAccount = this;
                 PersonalStream.Add(item);
                 AppController.Current.sendNotification("App.net " + username + " personal stream", item.AuthorName, item.Text, item.Avatar, item);
             }
             else
             {
                 IEnumerable <ApnItem> existing_items = PersonalStream.Where(item => item.Id.ToString() == post.id);
                 if (existing_items != null)
                 {
                     if (existing_items.Count() > 0)
                     {
                         List <ApnItem> cache = new List <ApnItem>();
                         foreach (ApnItem item in existing_items)
                         {
                             cache.Add(item);
                         }
                         foreach (ApnItem item in cache)
                         {
                             PersonalStream.Remove(item);
                         }
                         cache = null;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public void unifiedCallback(List <Post> posts, bool is_deleted = false)
 {
     if (posts != null)
     {
         foreach (Post post in posts)
         {
             if (post == null)
             {
                 continue;
             }
             if (post.machine_only || string.IsNullOrEmpty(post.text))
             {
                 continue;
             }
             if (!post.is_deleted)
             {
                 ApnItem item = new ApnItem(post, this);
                 item.receivingAccount = this;
                 PersonalStream.Add(item);
             }
             else
             {
                 IEnumerable <ApnItem> existing_items = PersonalStream.Where(item => item.Id.ToString() == post.id);
                 if (existing_items != null)
                 {
                     if (existing_items.Count() > 0)
                     {
                         List <ApnItem> cache = new List <ApnItem>();
                         foreach (ApnItem item in existing_items)
                         {
                             cache.Add(item);
                         }
                         foreach (ApnItem item in cache)
                         {
                             PersonalStream.Remove(item);
                         }
                         cache = null;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        void backgroundWorkerPersonalStream_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e != null)
            {
                switch (e.ProgressPercentage)
                {
                case 50:
                    ApnItem item = e.UserState as ApnItem;
                    if (item != null)
                    {
                        PersonalStream.Add(item);
                        if (showNotifications)
                        {
                            AppController.Current.sendNotification("App.net " + username + " personal stream", item.AuthorName, item.Text, item.Avatar, item);
                        }
                    }
                    break;

                case 99:
                    ApiCallResponse apiCallResponse = e.UserState as ApiCallResponse;
                    streamMarkerMyStreamUpdateComplete = true;
                    if (apiCallResponse != null)
                    {
                        if (apiCallResponse.meta != null)
                        {
                            if (apiCallResponse.meta.marker != null)
                            {
                                storeMarkerIdMyStream      = apiCallResponse.meta.marker.id;
                                storeMarkerVersionMyStream = apiCallResponse.meta.marker.version;
                            }
                        }
                    }

                    if (PersonalStream.Count > 0)
                    {
                        InitialUpdateForPersonalStream = true;
                    }
                    streamMarkerMyStreamUpdateComplete = true;

                    break;
                }
            }
        }