Example #1
0
        protected async override Task <RenrenAyncRespArgs <LoginUserInfo> > DoRequest(params object[] args)
        {
            string userName = (string)args[2];
            string password = (string)args[3];

            int uid  = (int)args[0];
            int page = (int)args[1];

            var resp = await Renren3GApiWrapper.LogIn(userName, password);

            RenrenAyncRespArgs <LoginUserInfo> repAdaptor = null;

            if (resp.Result != null)
            {
                LoginUserInfo info = new LoginUserInfo()
                {
                    UserName = userName, PassWord = password, LoginInfo = resp.Result
                };
                repAdaptor = new RenrenAyncRespArgs <LoginUserInfo>(info)
                {
                    HandOverParams = resp.HandOverParams, Status = resp.Status
                };
            }
            else if (resp.LocalError != null)
            {
                repAdaptor = new RenrenAyncRespArgs <LoginUserInfo>(resp.LocalError);
            }
            else if (resp.RemoteError != null)
            {
                repAdaptor = new RenrenAyncRespArgs <LoginUserInfo>(resp.RemoteError);
            }

            return(repAdaptor);
        }
        protected override async Task <RenrenAyncRespArgs <FeedListEntity> > DoOfflineDataRequest(params object[] args)
        {
            int uid      = (int)args[0];
            int page     = (int)args[1];
            int pageSize = (int)args[2];

            // TODO:
            // 创建相应的缓存片段
            // 查看缓存是否有效
            // 进行缓存逻辑
            var      hashKey = generateHashKey(uid, page, pageSize);
            DateTime expTime = DateTime.Now.AddDays(ExpirationTimeDay);
            ICacheChip <FeedListEntity> chip = _cacheImpl.CreateCacheChip(hashKey, expTime);
            var valid = _cacheImpl.IsValid(chip);

            if (valid && !this.ForceDataRequest)
            {
                FeedListEntity content = await _cacheImpl.Pick(chip);

                return(new RenrenAyncRespArgs <FeedListEntity>(content));
            }
            else
            {
                var resp = await Renren3GApiWrapper.GetFeedList(this.LoginInfo.LoginInfo.Session_key, this.LoginInfo.LoginInfo.Secret_key, page, pageSize, uid);

                if (resp.Result != null)
                {
                    await _cacheImpl.Add(chip, resp.Result);
                }
                return(resp);
            }
        }
Example #3
0
        protected async override Task <RenrenAyncRespArgs <NewsCountEntity> > DoRequest(params object[] args)
        {
            string seesionKey = LoginService.Instance.Model.Session_key;
            string secrectKey = LoginService.Instance.Model.Secret_key;
            RenrenAyncRespArgs <NewsCountEntity> resp = await Renren3GApiWrapper.GetNewsCount(seesionKey, secrectKey);

            return(resp);
        }
Example #4
0
        protected async override Task <RenrenAyncRespArgs <PageInfoEntity> > DoRequestById(int id, params object[] args)
        {
            string seesionKey = LoginService.Instance.Model.Session_key;
            string secrectKey = LoginService.Instance.Model.Secret_key;
            RenrenAyncRespArgs <PageInfoEntity> resp = await Renren3GApiWrapper.GetPageInfo(seesionKey, secrectKey, id);

            return(resp);
        }
Example #5
0
        /// <summary>
        /// Request and update the self news count
        /// The wrapped convient method provided for outside call
        /// </summary>
        /// <returns></returns>
        public async Task <RenrenAyncRespArgs <NewsCountEntity> > RequestMyNewsCount()
        {
            string seesionKey = LoginService.Instance.Model.Session_key;
            string secrectKey = LoginService.Instance.Model.Secret_key;
            RenrenAyncRespArgs <NewsCountEntity> resp = await Renren3GApiWrapper.GetNewsCount(seesionKey, secrectKey);

            Model = resp.Result;
            return(resp);
        }
Example #6
0
        protected async override Task <RenrenAyncRespArgs <VideoGetEntity> > DoRequestById(string url, params object[] args)
        {
            string videoUrl   = url;
            string seesionKey = LoginService.Instance.Model.Session_key;
            string secrectKey = LoginService.Instance.Model.Secret_key;
            RenrenAyncRespArgs <VideoGetEntity> resp = await Renren3GApiWrapper.VideoGet(seesionKey, secrectKey, videoUrl);

            return(resp);
        }
        protected async override Task <RenrenAyncRespArgs <GossipListEntity> > DoRequestById(int userId, params object[] args)
        {
            string seesionKey = LoginService.Instance.Model.Session_key;
            string secrectKey = LoginService.Instance.Model.Secret_key;
            int    page       = args.Length > 0 ? (int)args[0] : 1;  // by default, page is 1
            int    pageSize   = args.Length > 1 ? (int)args[1] : 10; // by default, page size is 10
            RenrenAyncRespArgs <GossipListEntity> resp = await Renren3GApiWrapper.GetGossips(seesionKey, secrectKey, userId, page, pageSize);

            return(resp);
        }
        protected async override Task <RenrenAyncRespArgs <VisitorsEntity> > DoRequestById(int id, params object[] args)
        {
            string seesionKey = LoginService.Instance.Model.Session_key;
            string secrectKey = LoginService.Instance.Model.Secret_key;
            int    page       = args.Length > 0 ? (int)args[0] : -1;
            int    pageSize   = args.Length > 1 ? (int)args[1] : -1;
            RenrenAyncRespArgs <VisitorsEntity> resp = await Renren3GApiWrapper.GetVisitorList(seesionKey, secrectKey, id, page, pageSize);

            return(resp);
        }
        protected override Task <RenrenAyncRespArgs <FeedListEntity> > DoRequest(params object[] args)
        {
            int uid      = (int)args[0];
            int page     = (int)args[1];
            int pageSize = (int)args[2];

            // TODO: download the data and return through 3g api
            var resp = Renren3GApiWrapper.GetFeedList(this.LoginInfo.LoginInfo.Session_key, this.LoginInfo.LoginInfo.Secret_key, page, pageSize, uid);

            return(resp);
        }
Example #10
0
        /// <summary>
        /// Request and update the status comments content
        /// </summary>
        /// <returns>the async result</returns>
        protected async override Task <RenrenAyncRespArgs <StatusCommentsEntity> > DoRequestById(long id, params object[] args)
        {
            if (args.Length < 1)
            {
                throw new ArgumentException();
            }
            int    uid        = (int)args[0];
            string seesionKey = LoginService.Instance.Model.Session_key;
            string secrectKey = LoginService.Instance.Model.Secret_key;

            RenrenAyncRespArgs <StatusCommentsEntity> resp = await Renren3GApiWrapper.GetStatusComments(seesionKey, secrectKey, id, uid);

            return(resp);
        }
        /// <summary>
        /// Request and update the blog content
        /// </summary>
        /// <returns>the async result</returns>
        protected async override Task <RenrenAyncRespArgs <BlogEntity> > DoRequestById(long id, params object[] args)
        {
            if (args.Length < 1)
            {
                throw new ArgumentException();
            }
            int    uid        = (int)args[0];
            string password   = args.Length > 1 ? (string)args[1] : string.Empty;;
            string seesionKey = LoginService.Instance.Model.Session_key;
            string secrectKey = LoginService.Instance.Model.Secret_key;

            RenrenAyncRespArgs <BlogEntity> resp = await Renren3GApiWrapper.GetBlog(seesionKey, secrectKey, uid, id, password);

            return(resp);
        }