Beispiel #1
0
 public void SubmitForm(SysUser userEntity, SysUserLogOn userLogOnEntity, string userId)
 {
     using (var db = base.BeginTransaction())
     {
         try
         {
             if (!string.IsNullOrEmpty(userId))
             {
                 userEntity.Id = userId;
                 this.Update(userEntity);
             }
             else
             {
                 userLogOnEntity.Id            = userEntity.Id;
                 userLogOnEntity.UserId        = userEntity.Id;
                 userLogOnEntity.UserSecretkey = Md5Hash.Md5(Common.CreateNo(), 16).ToLower();
                 userLogOnEntity.UserPassword  = Md5Hash.Md5(DESEncrypt.Encrypt(Md5Hash.Md5(userLogOnEntity.UserPassword, 32).ToLower(), userLogOnEntity.UserSecretkey).ToLower(), 32).ToLower();
                 this.Insert(userEntity);
                 SysUserLogOnRespository.Insert(userLogOnEntity);
             }
             this.Commit();
         }
         catch (Exception ex)
         {
             this.Rollback();
             Console.WriteLine(ex.ToString());
         }
     }
 }
 /// <summary>
 /// 密码加密
 /// </summary>
 /// <param name="password"></param>
 /// <returns></returns>
 private string EncodePassword(string password)
 {
     return(Md5Hash.Md5(DESEncrypt.Encrypt(password.ToLower(),
                                           ConstParameters.MemLoginUserKey).ToLower(), 32).ToLower());
 }