/// <summary> /// 更新信息 /// </summary> public int UpdateInfoForMember(SqlTransaction trans, MembershipUserModel memModel, long MemberId) { string key = "Cache_MembershipUser_Model_" + MemberId; CacheHelper.RemoveCache(key); return(memDAL.UpdateInfoForMember(trans, memModel, MemberId)); }
/// <summary> /// 更新信息 /// </summary> public int UpdateInfo(SqlTransaction trans, MembershipUserModel memModel, long SN) { string key = "Cache_MembershipUser_Model_" + SN; CacheHelper.RemoveCache(key); return(memDAL.UpdateInfo(trans, memModel, SN)); }
/// <summary> /// 从缓存读取信息 /// </summary> public MembershipUserModel GetCacheInfo(SqlTransaction trans, long SN) { string key = "Cache_MembershipUser_Model_" + SN; object value = CacheHelper.GetCache(key); if (value != null) { return((MembershipUserModel)value); } else { MembershipUserModel memModel = memDAL.GetInfo(trans, SN); CacheHelper.AddCache(key, memModel, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.Normal, null); return(memModel); } }
public ActionResult ApproveUsers() { ApproveUserModel objApproveUser = new ApproveUserModel(); objApproveUser.MembershipUsers = new List <MembershipUserModel>(); MembershipUserCollection obj = Membership.GetAllUsers(); foreach (MembershipUser item in obj) { MembershipUserModel objMembershipUser = new MembershipUserModel(); objMembershipUser.Email = item.Email; objMembershipUser.isApproved = item.IsApproved; objMembershipUser.id = (Guid)item.ProviderUserKey; objApproveUser.MembershipUsers.Add(objMembershipUser); } return(View(objApproveUser)); }
/// <summary> /// 登录 /// </summary> public bool Login(SqlTransaction trans, string DistributorId, string strLoginName, byte[] btyLoginPass, out EnumList.LoginStatus LoginStatus, out int LoginFailedCount) { bool IsLogin = memDAL.Login(trans, DistributorId, strLoginName, btyLoginPass, out LoginStatus); LoginFailedCount = 0; //记录错误密码 if (LoginStatus == EnumList.LoginStatus.帐号或密码有误) { MembershipUserModel memModel = GetModelByLoginName(trans, DistributorId, strLoginName, true); if (memModel != null) { Factory.MemberEventLog().InsertLog(trans, DistributorId, EnumList.MemberEventLogType.Login, memModel.MemberId, EnumList.OpStatus.失败.ToBoolean(), "密码有误!"); LoginFailedCount = Factory.MemberEventLog().GetLoginFailedCount(trans, memModel.MemberId); //锁定帐号 if (LoginFailedCount >= Config.LockLoginFailedCount) { memModel.Status = (byte)EnumList.MemberStatus.锁定; memDAL.UpdateInfo(trans, memModel, memModel.SN); } } } return(IsLogin); }
/// <summary> /// 插入信息 /// </summary> public int InsertInfo(SqlTransaction trans, MembershipUserModel memModel) { return(memDAL.InsertInfo(trans, memModel)); }
public ActionResult Employees(int?Page, string SortBy = "Username", bool Ascending = true) { List <MembershipUser> allUsers = GetAllUsers(); MembershipUserModel model = new MembershipUserModel(); model.Users = allUsers; //var pageNumber = Page ?? 1; var pageNumber = Page ?? 1; model.UsersPage = model.Users.ToPagedList(pageNumber, 10); switch (SortBy) { case "Username": if (Ascending) { model.UsersPage = allUsers.OrderBy (u => u.Username).ToPagedList(pageNumber, PAGE_SIZE); } else { model.UsersPage = allUsers.OrderByDescending (u => u.Username).ToPagedList(pageNumber, PAGE_SIZE); } break; case "CreationDate": if (Ascending) { model.UsersPage = allUsers.OrderBy (u => u.CreationDate).ToPagedList(pageNumber, PAGE_SIZE); } else { model.UsersPage = allUsers.OrderByDescending (u => u.CreationDate).ToPagedList(pageNumber, PAGE_SIZE); } break; case "Email": if (Ascending) { model.UsersPage = allUsers.OrderBy (u => u.Email).ToPagedList(pageNumber, PAGE_SIZE); } else { model.UsersPage = allUsers.OrderByDescending (u => u.Email).ToPagedList(pageNumber, PAGE_SIZE); } break; case "IsLockedout": if (Ascending) { model.UsersPage = allUsers.OrderBy (u => u.IsLockedout).ToPagedList(pageNumber, PAGE_SIZE); } else { model.UsersPage = allUsers.OrderByDescending (u => u.IsLockedout).ToPagedList(pageNumber, PAGE_SIZE); } break; case "CreatedBy": if (Ascending) { model.UsersPage = allUsers.OrderBy (u => u.CreatedBy).ToPagedList(pageNumber, PAGE_SIZE); } else { model.UsersPage = allUsers.OrderByDescending (u => u.CreatedBy).ToPagedList(pageNumber, PAGE_SIZE); } break; } model.SortAscending = Ascending; return(View(model)); }
/// <summary> /// 提交第三方登录注册绑定事务 /// </summary> /// <param name="trans"></param> /// <param name="listInput"></param> private void SubmitThirdPartyRegisterTrans(SqlTransaction trans, List <object> listInput, out List <object> listOut) { //获取参数 string DistributorId = (string)listInput[0]; string PrimaryCellPhone = (string)listInput[1]; string openid = (string)listInput[2]; string Provider = (string)listInput[3]; string nickname = (string)listInput[4]; int sex = (int)listInput[5]; string HeadPic = (string)listInput[6]; //事务处理 //注册会员 MembershipUserModel memModel = new MembershipUserModel(); memModel.MemberId = 0; memModel.DistributorId = DistributorId; memModel.UserName = Config.GetRndString(1, 4) + PrimaryCellPhone; memModel.PrimaryEmail = ""; memModel.IsEmail = EnumList.IsStatus.No.ToBoolean(); memModel.PrimaryCellPhone = PrimaryCellPhone; memModel.IsPhone = EnumList.IsStatus.Yes.ToBoolean(); memModel.Password = new byte[] { }; memModel.MemberLevel = ""; memModel.Status = (byte)EnumList.MemberStatus.启用; memModel.FailedPasswordAttemptCount = 0; memModel.Subscription = EnumList.IsStatus.No.ToBoolean(); memModel.CreationDate = DateTimeOffset.Now; memModel.LastUpdateDate = DateTimeOffset.Now; long SN = Factory.MembershipUser().InsertInfo(trans, memModel); //获取MemberId long MemberId = Factory.MembershipUser().GetValueByField(trans, "MemberId", SN).ToLong(); //会员资料 MembershipProfileModel memProModel = new MembershipProfileModel(); memProModel.DistributorId = DistributorId; memProModel.HeadPic = HeadPic; memProModel.MemberId = MemberId; memProModel.Name = nickname; memProModel.Alias = ""; memProModel.Gender = (byte)sex; memProModel.Birth = Convert.ToDateTime("1900-1-1"); memProModel.Zip = ""; memProModel.Country = ""; memProModel.Street = ""; memProModel.ContactEmail = ""; memProModel.Tel = ""; memProModel.CellPhoneNumber = PrimaryCellPhone; memProModel.Fax = ""; memProModel.CreationDate = DateTimeOffset.Now; memProModel.LastUpdateDate = DateTimeOffset.Now; memProModel.State = -1; memProModel.County = -1; memProModel.CityArea = -1; Factory.MembershipProfile().InsertInfo(trans, memProModel); //绑定第三方帐号 MembershipOAuthModel memOauthModel = new MembershipOAuthModel(); memOauthModel.MemberId = MemberId; memOauthModel.Provider = Provider; memOauthModel.OAuthId = openid; memOauthModel.CreationDate = DateTimeOffset.Now; int result = Factory.MembershipOAuth().InsertInfo(trans, memOauthModel); //日志 Factory.MemberEventLog().InsertLog(trans, DistributorId, EnumList.MemberEventLogType.Add, "会员SN为" + SN + "的会员注册成功!"); //返回值 listOut = new List <object>() { }; }
/// <summary> /// 取资料完整度 /// </summary> public int GetComplete(SqlTransaction trans, long MemberId) { int dec = 0; StringBuilder SqlQuery = new StringBuilder(); SqlQuery.Append(" and MemberId=@MemberId"); List <SqlParameter> listParams = new List <SqlParameter>(); listParams.Add(new SqlParameter("@MemberId", MemberId)); MembershipUserModel userModel = memDAL.GetModel(trans, SqlQuery, listParams); if (userModel != null) { if (userModel.IsPhone == Convert.ToBoolean(EnumList.IsStatus.Yes.ToInt())) { dec += 10; } if (userModel.IsEmail == Convert.ToBoolean(EnumList.IsStatus.Yes.ToInt())) { dec += 10; } if (userModel.Subscription) { dec += 10; } } MembershipProfileModel profileModel = Factory.MembershipProfile().GetModel(null, MemberId); if (profileModel != null) { if (!string.IsNullOrEmpty(profileModel.Name)) { dec += 10; } if (!string.IsNullOrEmpty(profileModel.Alias)) { dec += 10; } //if (profileModel.Gender != null) //{ // dec += 10; //} if (profileModel.Birth != null) { dec += 10; } if (profileModel.Zip != null) { dec += 10; } if (!string.IsNullOrEmpty(profileModel.Country) && profileModel.State > 0 && profileModel.County > 0 && profileModel.CityArea > 0 && !string.IsNullOrEmpty(profileModel.Street)) { dec += 10; } if (!string.IsNullOrEmpty(profileModel.ContactEmail) && !string.IsNullOrEmpty(profileModel.Tel) && !string.IsNullOrEmpty(profileModel.CellPhoneNumber) && !string.IsNullOrEmpty(profileModel.Fax)) { dec += 10; } } return(dec); }