public string GetUserNick(int id) { tb_UserEntity ue = new tb_UserEntity(); ue.id = id; try { ue.Retrieve(); } catch (PlException plex) { //获取失败了,主键有误 } if (ue.IsPersistent) { return ue.nick; } else { return ""; } }
private void AddUserOrUpdateUser(string nick) { tbClient = new DefaultTopClient(Config.ServerURL, Config.Appkey, Config.Secret); UserGetRequest userReq = new UserGetRequest(); userReq.Fields = "user_id,uid,nick,sex,buyer_credit,seller_credit,location,created,last_visit,birthday,type,status,alipay_no,alipay_account,alipay_account,email,consumer_protection,alipay_bind"; userReq.Nick = nick; UserGetResponse userResp = tbClient.Execute(userReq); if (userResp.IsError) { return;//userResp.ErrorMsg 读取用户信息失败,错误信息写入日志 } //用户信息保存或修改到数据库,并获取level tb_UserEntity userE = new tb_UserEntity(); userE.email = userResp.User.Email == null ? "" : userResp.User.Email; userE.nick = userResp.User.Nick; userE.type = userResp.User.Type; string authEndTime = GetAuthEndTime(nick);//到期会员时间获取 try { userE.authEndTime = authEndTime == "" ? DateTime.Now.AddDays(-1) : Convert.ToDateTime(authEndTime); if (userE.authEndTime < DateTime.Now) { userE.syslevel = ((int)Util.Enum.UserSysLevel.Experience).ToString(); } else { userE.syslevel = ((int)Util.Enum.UserSysLevel.Member).ToString(); } } catch (Exception ex) { //日期格式转换错误 return; } userE.SessionKey = Request.QueryString["top_session"]; loginAction.AddUserOrUpdateUser(userE); }
public static void Save(tb_UserEntity obj) { if (obj!=null) { obj.Save(); } }
/// <summary>根据主键获取一个实体</summary> public static tb_UserEntity RetrieveAtb_UserEntity(int id) { tb_UserEntity obj=new tb_UserEntity(); obj.id=id; obj.Retrieve(); if (obj.IsPersistent) { return obj; } else { return null; } }