/// <summary> /// 更新信息 /// </summary> public int UpdateInfo(SqlTransaction trans, MembershipProfileModel memModel, long SN) { string key = "Cache_MembershipProfile_Model_" + SN; CacheHelper.RemoveCache(key); return(memDAL.UpdateInfo(trans, memModel, SN)); }
/// <summary> /// 更新信息 /// </summary> public int UpdateInfoForMember(SqlTransaction trans, MembershipProfileModel memModel, long MemberId) { string key = "Cache_MembershipProfile_Model_" + MemberId; CacheHelper.RemoveCache(key); return(memDAL.UpdateInfoForMember(trans, memModel, MemberId)); }
/// <summary> /// 从缓存读取信息 /// </summary> public MembershipProfileModel GetCacheInfo(SqlTransaction trans, long SN) { string key = "Cache_MembershipProfile_Model_" + SN; object value = CacheHelper.GetCache(key); if (value != null) { return((MembershipProfileModel)value); } else { MembershipProfileModel memModel = memDAL.GetInfo(trans, SN); CacheHelper.AddCache(key, memModel, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.Normal, null); return(memModel); } }
/// <summary> /// 插入信息 /// </summary> public int InsertInfo(SqlTransaction trans, MembershipProfileModel memModel) { return(memDAL.InsertInfo(trans, memModel)); }
/// <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); }