Esempio n. 1
0
        public MR_posts_getLatest Posts_getLatest(string limit)
        {
            if (!IsNetworkAvailable)
            {
                return(null);
            }

            MR_posts_getLatest _ret = null;

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

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

            return(null);
        }
Esempio n. 2
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);
        }