Exemplo n.º 1
0
        public MR_posts_get Posts_get(string limit, string datum, string filter)
        {
            if (!IsNetworkAvailable)
            {
                return(null);
            }

            MR_posts_get _ret = null;

            try
            {
                _ret = m_service.posts_get(SessionToken, m_rt.CurrentGroupID, limit, datum, filter);
            }
            catch (Station401Exception _e)
            {
                Main.Current.Station401ExceptionHandler(_e.Message);
            }

            if (_ret != null)
            {
                if (_ret.status == "200")
                {
                    return(_ret);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        /*
         * private void timerGetNewestPost_Tick(object sender, EventArgs e)
         * {
         *  timerGetNewestPost.Enabled = false;
         *
         *  if (m_canAutoFetchNewestPosts)
         *  {
         *      //RefreshNewestPosts();
         *  }
         *
         *  timerGetNewestPost.Enabled = true;
         * }
         */

        public bool RefreshNewestPosts()
        {
            if (RT.LoginOK)
            {
                if (RT.CurrentGroupPosts.Count > 0)
                {
                    string _newestPostTime = RT.CurrentGroupPosts[0].timestamp;
                    string _newestPostID   = RT.CurrentGroupPosts[0].post_id;

                    MR_posts_get _postsGet = RT.REST.Posts_get("+200", _newestPostTime, "");

                    if (_postsGet != null)
                    {
                        if (_postsGet.posts.Count > 0)
                        {
                            Post _toDel = null;

                            foreach (Post _p in _postsGet.posts)
                            {
                                if (_p.post_id == _newestPostID)
                                {
                                    _toDel = _p;
                                    break;
                                }
                            }

                            if (_toDel != null)
                            {
                                _postsGet.posts.Remove(_toDel);
                            }

                            if (_postsGet.posts.Count > 0)
                            {
                                //@ RT.CurrentGroupPosts.InsertRange(0, _postsGet.posts);
                                // MessageBox.Show(_postsGet.posts.Count + " New Post");
                            }

                            //showTaskbarNotifier(_posts[0]);

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        private void FilterFetchPostsAndShow(bool firstTime)
        {
            if ((RT.FilterPostsAllCount != 0) && (RT.FilterPostsAllCount == RT.FilterPosts.Count))
            {
                return;
            }

            int _offset = RT.FilterPosts.Count;

            string _filter = RT.CurrentFilterItem.Filter;

            if (RT.CurrentFilterItem.DynamicNow)
            {
                _filter = FilterHelper.GetAllPostFilterStringByPostType(_filter);
            }

            _filter = _filter.Replace("[offset]", _offset.ToString());

            Cursor = Cursors.WaitCursor;

            MR_posts_get _postsGet = RT.REST.Posts_FetchByFilter(_filter);

            if (_postsGet != null)
            {
                RT.FilterPosts.AddRange(_postsGet.posts);

                if (firstTime)
                {
                    RT.FilterPostsAllCount = _postsGet.remaining_count + _postsGet.get_count;

                    RT.IsFilterFirstTimeGetData = true;
                }
                else
                {
                    RT.IsFilterFirstTimeGetData = false;
                }
            }

            Cursor = Cursors.Default;

            ShowPostToUI(false);
        }
Exemplo n.º 4
0
        private void bgWorkerGetAllData_DoWork(object sender, DoWorkEventArgs e)
        {
            string _firstGetCount               = "100";  //200
            string _continueGetCount            = "-100"; //200
            Dictionary <string, Post> _allPosts = new Dictionary <string, Post>();
            string _datum = string.Empty;

            MR_posts_getLatest _getLatest = null;

            try
            {
                _getLatest = RT.REST.Posts_getLatest(_firstGetCount);
            }
            catch
            {
                //Hack: Cloud ¦R¥X¿ù»~¸ê®Æ

                ForceLogout();
                m_getAllDataError = true;
                return;
            }

            if (_getLatest != null)
            {
                foreach (Post _p in _getLatest.posts)
                {
                    _allPosts.Add(_p.post_id, _p);
                    _datum = _p.timestamp;
                }

                if (_getLatest.get_count < _getLatest.total_count)
                {
                    int _remainingCount = int.MaxValue;

                    while (_remainingCount > 0)
                    {
                        _datum =
                            DateTimeHelp.ToUniversalTime_ToISO8601(DateTimeHelp.ISO8601ToDateTime(_datum).AddSeconds(1));

                        MR_posts_get _postsGet = RT.REST.Posts_get(_continueGetCount, _datum, "");

                        if (_postsGet != null)
                        {
                            foreach (Post _p in _postsGet.posts)
                            {
                                if (!_allPosts.ContainsKey(_p.post_id))
                                {
                                    _allPosts.Add(_p.post_id, _p);
                                    _datum = _p.timestamp;
                                }
                            }

                            _remainingCount = _postsGet.remaining_count;
                        }
                    }
                }
            }

            List <Post> _tmpPosts = new List <Post>();

            foreach (Post _p in _allPosts.Values)
            {
                _tmpPosts.Add(_p);
            }

            if (m_manualRefresh)
            {
                RT.SetAllCurrentGroupPostHaveRead();
            }

            RT.CurrentGroupPosts = _tmpPosts;

            if (m_manualRefresh)
            {
                SetLastReadPos();
            }

            s_logger.Info("bgWorkerGetAllData_DoWork. Get Post Count:" + _tmpPosts.Count);
        }