public List <UserInfoFull> GetAllUser(long locationId) { try { IQueryable <Common.User> query = GetDynamicQuery(); var temp = query.Where(p => (p.CompanyId == 0 || p.CompanyId == locationId)).ToList(); var listUser = new List <UserInfoFull>(); foreach (var u in temp) { var userInfo = new UserInfoFull { UserId = u.Id, UserName = u.Username, Password = u.Password, CompanyId = u.CompanyId, IsSuperUser = u.IsSuperUser, CreateDate = u.Createdate, ModifyDate = u.Modifydate, ExpiredDate = u.Expireddate, ScreenName = u.Screenname, LoginDate = u.Logindate, FailedLoginAttemp = u.FailedLoginAttemp, LockoutDate = u.LockoutDate, Status = u.Status, Description = u.Description, DisountPercent = u.DiscountPercent }; if (u.UserProfile != null) { userInfo.Code = u.UserProfile.Code; userInfo.Name = u.UserProfile.Name; userInfo.Phone = u.UserProfile.Phone; userInfo.Address = u.UserProfile.Address; userInfo.Email = u.UserProfile.Email; userInfo.Dob = u.UserProfile.Dob; } listUser.Add(userInfo); } return(listUser); } catch (SqlException ex) { _logger.Error("", ex); throw ObjectUtil.CreateFaultException(CodedException.SqlExceptionUnhandler, "Sql Exeption"); } catch (Exception ex) { _logger.Error("", ex); throw ObjectUtil.CreateFaultException(CodedException.Unhandler, "Unhandler Exception"); } }
/// <summary> /// 获取/绑定用户 /// </summary> /// <param name="appid"></param> /// <param name="sessionKey"></param> /// <param name="encryptedDataStr"></param> /// <param name="iv"></param> /// <returns>unionID</returns> public Users GetUser(string appid, string sessionKey, string encryptedDataStr, string iv) { var encryptedData = WXBizDataCrypt.DecryptData(sessionKey, encryptedDataStr, iv); logger.Debug($"用户完整信息:{encryptedData}"); UserInfoFull userinfoFull = JsonConvert.DeserializeObject <UserInfoFull>(encryptedData); if (userinfoFull.watermark.appid != appid) { throw new Exception("userinfofull.wartemark.appid 不等于 appid!"); } Users user = null; if (string.IsNullOrEmpty(userinfoFull.openId)) { throw new Exception("openId is null or empty!"); } user = _db.Users.SingleOrDefault(u => u.OpenId == userinfoFull.openId); if (user == null) { Users u = new Users(); u.Name = userinfoFull.nickName; u.Address = userinfoFull.country + userinfoFull.province + userinfoFull.city; u.CreateTime = DateTime.Now; u.LastTime = DateTime.Now; u.Sex = userinfoFull.gender; u.UserStatus = UserStatus.Ok; u.OpenId = userinfoFull.openId; u.UserTypeId = 1; _db.Users.Add(u); _db.SaveChanges(); return(u); } return(user); }