Beispiel #1
0
        internal userinfo RegisterTaoBaoSession(OAuth2Base oa)
        {
            string sessionKey;
            if ((oa as TaoBaoOAuth2).IsUseSandBox)
            {
                sessionKey = "6101925c77e6ac6b8ddaa3606de6fd7d21401fc18e51eb43598702902";
            }
            else
            {
                sessionKey = oa.AccessToken;
            }
            var tbService = new TaobaoService();
            userinfo info = tbService.GetUserInfoBySessionKey(sessionKey);
            if (info == null)
            {
                User user = tbService.GetSellerUserInfo(sessionKey);
                info = tbService.GetUserInfoByTBUserId(user.UserId.ToString());
                if (info == null)
                {
                    info = new userinfo();
                }
                info.Nick = user.Nick;
                info.TB_UserId = user.UserId.ToString();
                info.AuthDate = DateTime.Now;
                info.ExpireTime = DateTime.Now.AddDays(1); //Test case, in the real environment, it is not like this.
                info.LastLogin = DateTime.Now;

                info.AccessToken = sessionKey;
                if ((oa as TaoBaoOAuth2).IsUseSandBox)
                {
                    info.RefreshToken = sessionKey;

                }
                else
                {
                    info.RefreshToken = oa.RefreshToken;
                    info.ExpireTime = oa.ExpireTime;
                }
                tbService.SaveUserInfo(info);
            }
            return info;
        }
 /// <summary>
 /// 创建新的 userinfo 对象。
 /// </summary>
 /// <param name="userId">UserId 属性的初始值。</param>
 /// <param name="tB_UserId">TB_UserId 属性的初始值。</param>
 /// <param name="accessToken">AccessToken 属性的初始值。</param>
 /// <param name="refreshToken">RefreshToken 属性的初始值。</param>
 /// <param name="nick">Nick 属性的初始值。</param>
 /// <param name="lastLogin">LastLogin 属性的初始值。</param>
 /// <param name="expireTime">ExpireTime 属性的初始值。</param>
 /// <param name="authDate">AuthDate 属性的初始值。</param>
 public static userinfo Createuserinfo(global::System.Int64 userId, global::System.String tB_UserId, global::System.String accessToken, global::System.String refreshToken, global::System.String nick, global::System.DateTime lastLogin, global::System.DateTime expireTime, global::System.DateTime authDate)
 {
     userinfo userinfo = new userinfo();
     userinfo.UserId = userId;
     userinfo.TB_UserId = tB_UserId;
     userinfo.AccessToken = accessToken;
     userinfo.RefreshToken = refreshToken;
     userinfo.Nick = nick;
     userinfo.LastLogin = lastLogin;
     userinfo.ExpireTime = expireTime;
     userinfo.AuthDate = authDate;
     return userinfo;
 }
Beispiel #3
0
 public void SaveUserInfo(userinfo userInfo)
 {
     uiAccessor.AddOrUpdateUserInfo(userInfo);
 }
 /// <summary>
 /// 用于向 userinfo EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddTouserinfo(userinfo userinfo)
 {
     base.AddObject("userinfo", userinfo);
 }