Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 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);
        }
        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 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);
        }
Exemplo n.º 8
0
        public async Task <RenrenAyncRespArgs <LoginUserInfo> > Login(string userName, string password)
        {
            this.NeedOfflineData  = false;
            this.ForceDataRequest = true;

            RenrenAyncRespArgs <LoginUserInfo> resp = (RenrenAyncRespArgs <LoginUserInfo>)(await this.Invoke(ServiceRole.SelfInvoke, -1, -1, userName, password));

            if (resp.Result != null)
            {
                _hasLogined = true;
            }
            return(resp);
        }
        public async Task <RenrenAyncRespArgs <FeedListEntity> > RequestFeedListByUid(int uid = -1, int page = -1, int pageSize = -1, bool needOffline = false, bool forceRequest = false)
        {
            this.NeedOfflineData  = needOffline;
            this.ForceDataRequest = forceRequest;

            //int uidAdaptor = uid;
            //if (uid == -1)
            //    uidAdaptor = this.LoginInfo.LoginInfo.Uid;

            RenrenAyncRespArgs <FeedListEntity> resp = (RenrenAyncRespArgs <FeedListEntity>)(await this.Invoke(ServiceRole.SelfInvoke, uid, page, pageSize));

            return(resp);
        }
Exemplo n.º 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);
        }
Exemplo n.º 11
0
        /// <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);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Request and update the self friend list
        /// The wrapped convient method provided for outside call
        /// </summary>
        /// <returns></returns>
        public async Task <RenrenAyncRespArgs <FriendListEntity> > RequestMyFriendList()
        {
            RenrenAyncRespArgs <FriendListEntity> resp = await Request();

            return(resp);
        }
        public async Task <RenrenAyncRespArgs <PhotoCommentEntity> > RequestPhotoCommentsByPid(int userId, long albumId, long picId)
        {
            RenrenAyncRespArgs <PhotoCommentEntity> resp = await RequestById(picId, userId, albumId);

            return(resp);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Request and update the blog content by blog id
        /// The wrapped convient method provided for outside call
        /// \note: if the uid is null means requesting self friends list
        /// </summary>
        /// <param name="uid">user id</param>
        /// <param name="page">page count</param>
        /// <returns></returns>
        public async Task <RenrenAyncRespArgs <BlogEntity> > RequestBlogByUid(int uid, long blogId, string password)
        {
            RenrenAyncRespArgs <BlogEntity> resp = await RequestById(blogId, uid, password);

            return(resp);
        }
Exemplo n.º 15
0
        public async Task <RenrenAyncRespArgs <GossipListEntity> > RequestGossipsByUid(int userId, int page, int pageSize)
        {
            RenrenAyncRespArgs <GossipListEntity> resp = await RequestById(userId, page, pageSize);

            return(resp);
        }
        /// <summary>
        /// Request and update the visitors list by uid
        /// The wrapped convient method provided for outside call
        /// </summary>
        /// <returns></returns>
        public async Task <RenrenAyncRespArgs <VisitorsEntity> > RequestVisistorListByUid(int uid, int page = -1, int pageSize = -1)
        {
            RenrenAyncRespArgs <VisitorsEntity> resp = await RequestById(uid, page, pageSize);

            return(resp);
        }
        /// <summary>
        /// Request and update self user info
        /// The wrapped convient method provided for outside call
        /// </summary>
        /// <returns>The info result</returns>
        public async Task <RenrenAyncRespArgs <UserInfoEntity> > RequestMyUserInfo()
        {
            RenrenAyncRespArgs <UserInfoEntity> resp = await Request();

            return(resp);
        }
        /// <summary>
        /// Request and update the self visitors list
        /// The wrapped convient method provided for outside call
        /// </summary>
        /// <returns></returns>
        public async Task <RenrenAyncRespArgs <VisitorsEntity> > RequestMyVisitorList(int page = -1, int pageSize = -1)
        {
            RenrenAyncRespArgs <VisitorsEntity> resp = await Request(page, pageSize);

            return(resp);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Request and update the user info by uid
        /// The wrapped convient method provided for outside call
        /// </summary>
        /// <returns></returns>
        public async Task <RenrenAyncRespArgs <PageInfoEntity> > RequestUserInfoByUid(int uid)
        {
            RenrenAyncRespArgs <PageInfoEntity> resp = await RequestById(uid);

            return(resp);
        }
Exemplo n.º 20
0
        public async Task <RenrenAyncRespArgs <VideoGetEntity> > RequestVideoByUrl(string url)
        {
            RenrenAyncRespArgs <VideoGetEntity> resp = await RequestById(url);

            return(resp);
        }
        /// <summary>
        /// Request and update the blog comment list by uid
        /// The wrapped convient method provided for outside call
        /// \note: if the uid is null means requesting self friends list
        /// </summary>
        /// <param name="uid">user id</param>
        /// <param name="page">page count</param>
        /// <returns></returns>
        public async Task <RenrenAyncRespArgs <BlogCommentEntity> > RequestBlogCommentsByUid(int uid, long blogId, int page, int pageSize, string password)
        {
            RenrenAyncRespArgs <BlogCommentEntity> resp = await RequestById(blogId, uid, page, pageSize, password);

            return(resp);
        }
Exemplo n.º 22
0
        public async Task <RenrenAyncRespArgs <PhotoListEntity> > RequestPhotoListByAlbumId(int userId, long albumId, int page, int pageSize, string password)
        {
            RenrenAyncRespArgs <PhotoListEntity> resp = await RequestById(albumId, userId, page, pageSize, password);

            return(resp);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Request and update the status content by status comments id
        /// The wrapped convient method provided for outside call
        /// </summary>
        /// <param name="uid">user id</param>
        /// <param name="statusId">status id</param>
        /// <returns></returns>
        public async Task <RenrenAyncRespArgs <StatusCommentsEntity> > RequestStatusCommentsByUid(int uid, long statusId)
        {
            RenrenAyncRespArgs <StatusCommentsEntity> resp = await RequestById(statusId, uid);

            return(resp);
        }
Exemplo n.º 24
0
        // must: first parameter is id, and second is page
        protected async Task <object> Request(params object[] args)
        {
            //if (args.Length < 2) throw new ArgumentException(); // pls always input the the id and page

            RenrenAyncRespArgs <EntityType> resp = default(RenrenAyncRespArgs <EntityType>);

            // 处理需要缓存的情况
            if (this.NeedOfflineData)
            {
                // TODO:
                // 查看是否支持缓存
                // 查看是否存在缓存
                // 查看是否已经失效
                resp = await DoOfflineDataRequest(args);

                if (resp.LocalError == null && resp.RemoteError == null && resp.Result != null)
                {
                    this.Model = resp.Result;
                }
            }
            // 处理不需要缓存的情况
            else
            {
                object id   = args[0];
                int    page = (int)args[1];
                if (this[id, page] != null && this.ForceDataRequest == false)
                {
                    resp       = new RenrenAyncRespArgs <EntityType>((EntityType)this[id, page]);
                    this.Model = resp.Result;
                }
                else
                {
                    // TODO:
                    // we need to reflesh login token here through LoginTokenRefleshVisitor
                    // by which we can check the login status and reflesh the sessionkey and secrectkey
                    // also we can use it to login using different login methods, e.g. username nd password, or OAuth2.0
                    // if (LoginInfo == null)
                    //      var check = this.Accecpt(PasswordLoginTokenRefleshVisitor);
                    //      var check = this.Accecpt(OAuth20LoginTokenRefleshvVisitor);
                    resp = await DoRequest(args);

                    if (resp.LocalError == null && resp.RemoteError == null && resp.Result != null)
                    {
                        this.Model = resp.Result;
                        string key = string.Empty;
                        if (args.Length >= 2)
                        {
                            key = RRServiceFlyweight <IdType, EntityType> .GenerateKey((IdType)args[0], (int)page);
                        }
                        else
                        {
                            key = RRServiceFlyweight <IdType, EntityType> .GenerateDefaultKey();
                        }

                        this._flyweighter.Add(key, (EntityType)Model);
                    }
                }
            }

            return(resp);
        }
Exemplo n.º 25
0
        public async Task <RenrenAyncRespArgs <PhotoEntity> > RequestPhotoByPid(int userId, long photoId, string password)
        {
            RenrenAyncRespArgs <PhotoEntity> resp = await RequestById(photoId, userId, password);

            return(resp);
        }