Ejemplo n.º 1
0
        /// <summary>
        /// 删除会员
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool DeleteMember(Member model)
        {
            bool isSuccess = false;
            if (model != null)
            {
                var conf = new Configuration().Configure();
                ISession session = NHibernateHelper.GetSession();
                //配置NHibernate
                //在Configuration中添加HbmMapping
                conf.AddDeserializedMapping(NHibernateHelper.GetEntityMapping<Member>(), "MemberXML");
                //配置数据库架构元数据
                SchemaMetadataUpdater.QuoteTableAndColumns(conf);

                //建立SessionFactory
                var factory = conf.BuildSessionFactory();
                //打开Session做持久化数据
                using (session = factory.OpenSession())
                {
                    using (var tx = session.BeginTransaction())
                    {
                        session.Delete(model);
                        tx.Commit();
                        isSuccess = true;
                    }
                }
            }
            return isSuccess;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新会员信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool UpdateMember(Member model)
 {
     return OptionMember.UpdateMember(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 注册账号
        /// </summary>
        /// <param name="Email"></param>
        /// <param name="PassWord"></param>
        /// <param name="Msg"></param>
        /// <returns></returns>
        public bool RegistMember(string Email, string PassWord, ref string Msg, ref int ID)
        {
            IList<Member> list = OptionMember.GetAllMemberByEmail(Email);
            if (list.Count > 0)
            {
                if (list[0].Status != 3)
                {
                    Msg = "邮箱已注册,请直接登录";
                    ID = list[0].Id;
                    return false;
                }
                else
                {
                    list[0].LoginPWD = COM.Method.EncryptPWD(PassWord);
                    list[0].UpdateTime = DateTime.Now;
                    list[0].CreateTime = DateTime.Now;
                    list[0].VerifictionCode = COM.Method.GenerateVerifictionCode();
                    int limitMinutes = 30;
                    int.TryParse(ConfigurationManager.AppSettings["VerifictionCodeLimitMinutes"], out limitMinutes);
                    list[0].VerifictionCodeLimit = DateTime.Now.AddMinutes(limitMinutes);
                    Msg = String.Format("{0} [过期时间:{1:yyyy/MM/dd HH:mm:ss}]", list[0].VerifictionCode, list[0].VerifictionCodeLimit.Value);
                    ID = list[0].Id;
                    return OptionMember.UpdateMember(list[0]);
                }
            }
            else
            {
                Member model = new Member();

                model.Email = Email;
                model.LoginPWD = COM.Method.EncryptPWD(PassWord);
                model.Status = 3;//刚注册未验证
                model.LoginTimes = 0;
                model.Integral = 0;
                model.UpdateTime = DateTime.Now;
                model.CreateTime = DateTime.Now;
                model.VerifictionCode = COM.Method.GenerateVerifictionCode();
                int limitMinutes = 30;
                int.TryParse(ConfigurationManager.AppSettings["VerifictionCodeLimitMinutes"], out limitMinutes);
                model.VerifictionCodeLimit = DateTime.Now.AddMinutes(limitMinutes);
                model.Id =OptionMember.SaveMember(model);
                if (model.Id == -1)
                {
                    Msg = "注册失败!";
                    return false;
                }
                else
                {
                    Msg = String.Format("{0} [过期时间:{1:yyyy/MM/dd HH:mm:ss}]", model.VerifictionCode, model.VerifictionCodeLimit.Value);
                    ID = model.Id;
                    return true;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 会员登录
        /// </summary>
        /// <param name="Member"></param>
        /// <param name="Msg"></param>
        /// <returns></returns>
        public bool LoginMember(Member modelMember, ref string Msg)
        {
            bool isSuccess = false;
            try
            {
                IList<Member> list = OptionMember.GetMemberByOpenID(modelMember.OpenId);
                if (list.Count > 0)
                {
                    list[0].LoginTimes += 1;
                    list[0].Nickname = modelMember.Nickname;
                    //如果最后登录时间不是今天(也就是今天第一次登录)积分+10
                    if (list[0].LastLoginDateTime.Value.Date != DateTime.Now.Date && list[0].LastLoginDateTime < DateTime.Now)
                    {
                        list[0].Integral += 10;
                    }
                    list[0].LastLoginDateTime = list[0].CurrentLoginDateTime;
                    list[0].CurrentLoginDateTime = DateTime.Now;
                    list[0].UpdateTime = DateTime.Now;
                    list[0].PhotoURL = modelMember.PhotoURL;
                    isSuccess = OptionMember.UpdateMember(list[0]);
                }
                else
                {
                    Member model = new Member();
                    HistoryOfMemberUpdate modelHis = new HistoryOfMemberUpdate();
                    model.OpenId = modelMember.OpenId;
                    model.Nickname = modelMember.Nickname;
                    model.LastLoginDateTime = DateTime.Now;
                    model.CurrentLoginDateTime = DateTime.Now;
                    model.LoginTimes = 1;
                    model.Integral = 100;
                    model.Status = 0;
                    model.UpdateTime = DateTime.Now;
                    model.CreateTime = DateTime.Now;
                    model.PhotoURL = modelMember.PhotoURL;
                    modelHis.MemberId = OptionMember.SaveMember(model);
                    if (modelHis.MemberId != -1)
                    {
                        modelHis.CreateTime = DateTime.Now;

                        #region 会员历史信息
                        modelHis.OpenId = model.OpenId;
                        modelHis.Nickname = model.Nickname;
                        modelHis.Question1 = model.Question1;
                        modelHis.Question2 = model.Question2;
                        modelHis.Question3 = model.Question3;
                        modelHis.Anwser1 = model.Anwser1;
                        modelHis.Anwser2 = model.Anwser2;
                        modelHis.Anwser3 = model.Anwser3;
                        modelHis.Email = model.Email;
                        modelHis.Phone = model.Phone;
                        modelHis.LoginPWD = model.LoginPWD;
                        modelHis.Type = model.Type;
                        modelHis.Photo = model.Photo;
                        modelHis.PhotoURL = model.PhotoURL;
                        modelHis.Gender = model.Gender;
                        modelHis.Birthday = model.Birthday;
                        modelHis.Birthplace = model.Birthplace;
                        modelHis.Education = model.Education;
                        modelHis.Job = model.Job;
                        modelHis.Address = model.Address;
                        modelHis.LoginTimes = model.LoginTimes;
                        modelHis.LastLoginDateTime = model.LastLoginDateTime;
                        modelHis.CurrentLoginDateTime = model.CurrentLoginDateTime;
                        modelHis.Integral = model.Integral;
                        modelHis.Status = model.Status;
                        #endregion

                        OptionMember.SaveHistoryOfMemberUpdate(modelHis);
                        isSuccess = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Msg = ex.Message;
                isSuccess = false;
            }
            return isSuccess;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 会员登录
        /// </summary>
        /// <param name="LoginID"></param>
        /// <param name="PWD"></param>
        /// <param name="Msg"></param>
        /// <returns></returns>
        public bool LoginMember(string LoginID, string PWD, ref string Msg, ref Member model)
        {
            bool isSuccess = false;
            IList<Member> list = OptionMember.GetNormalMemberByEmail(LoginID);
            if (list.Count > 0)
            {
                if (!list[0].LoginPWD.Trim().Equals(COM.Method.EncryptPWD(PWD)))
                {
                    Msg = "账号或密码错误";
                    return false;
                }

                list[0].LoginTimes += 1;
                //如果最后登录时间不是今天(也就是今天第一次登录)积分+10
                if (list[0].LastLoginDateTime.HasValue && list[0].LastLoginDateTime.Value.Date != DateTime.Now.Date && list[0].LastLoginDateTime < DateTime.Now)
                {
                    list[0].Integral += 10;
                }
                list[0].LastLoginDateTime = list[0].CurrentLoginDateTime;
                list[0].CurrentLoginDateTime = DateTime.Now;
                list[0].UpdateTime = DateTime.Now;
                model = list[0];
                return OptionMember.UpdateMember(list[0]);
            }
            else
            {
                Msg = "账号或密码错误";//账号不存在
                return false;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 会员登录
 /// </summary>
 /// <param name="ID"></param>
 /// <param name="Msg"></param>
 /// <returns></returns>
 public bool LoginMember(int ID, ref string Msg, ref Member model)
 {
     bool isSuccess = false;
     IList<Member> list = OptionMember.GetNormalMemberByID(ID);
     if (list.Count > 0)
     {
         list[0].LoginTimes += 1;
         //如果最后登录时间不是今天(也就是今天第一次登录)积分+10
         if (list[0].LastLoginDateTime.HasValue && list[0].LastLoginDateTime.Value.Date != DateTime.Now.Date && list[0].LastLoginDateTime < DateTime.Now)
         {
             list[0].Integral += 10;
         }
         list[0].LastLoginDateTime = list[0].CurrentLoginDateTime;
         list[0].CurrentLoginDateTime = DateTime.Now;
         list[0].UpdateTime = DateTime.Now;
         model = list[0];
         return OptionMember.UpdateMember(list[0]);
     }
     else
     {
         Msg = "会员不存在";//会员不存在
         return false;
     }
 }