Ejemplo n.º 1
0
 /// <summary>
 /// 编辑用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool EditUser(User_U user)
 {
     using (var factory = new BaseAccess(base._DBConfigPath))
     {
         try
         {
             var model = factory.Single <UserEntity>(user.ID);
             model = user.Adapter <UserEntity>(model);//将页面对象user的属性转换到数据库对象modle中
             factory.Update <UserEntity>(model, false);
             //处理用户分组
             var userDep = factory.Single <UserOrganizationEntity>(Specification <UserOrganizationEntity>
                                                                   .Create(c => c.UserID == user.ID && c.IsDefault == 1));
             if (userDep.OrganizationID != user.UserDeptID)
             {
                 userDep.OrganizationID = user.UserDeptID;
                 factory.Update <UserOrganizationEntity>(userDep, false);
             }
             factory.Commit();
             //清理缓存
             Manage.Open.CacheshipFactory.Instance.ClearSSOUserCache(user.ID);
             return(true);
         }
         catch (Exception ex)
         {
             factory.Rollback();
             return(false);
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 根据用户登录帐号获取用户对象
 /// </summary>
 /// <param name="LoginName"></param>
 /// <returns></returns>
 public UserInfo GetUserByLoginName(string LoginName, ref string errorMessage)
 {
     using (var factory = new BaseAccess(base._DBConfigPath))
     {
         try
         {
             var state = ((factory.DbContext).Connection).State;
             if (state != System.Data.ConnectionState.Open)
             {
                 //errorMessage=
             }
             var model = factory.Single <UserEntity>(Specification <UserEntity> .Create(c => c.UserLoginName == LoginName && c.RecordStatus != (int)RecordStatus.UnEnable));
             if (model != null)
             {
                 return(model.Adapter <UserInfo>(new UserInfo()));
             }
             else
             {
                 return(new UserInfo());
             }
         }
         catch (Exception ex)
         {
             errorMessage = ex.ToString();
             return(new UserInfo());
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 根据用户ID获取用户对象
 /// </summary>
 /// <param name="ID"></param>
 /// <returns></returns>
 public UserInfo GetUserInfoByID(string ID)
 {
     using (var factory = new BaseAccess(base._DBConfigPath))
     {
         var model = factory.Single <UserEntity>(Specification <UserEntity> .Create(c => c.ID == ID && c.RecordStatus != (int)RecordStatus.UnEnable));
         if (model != null)
         {
             return(model.Adapter <UserInfo>(new UserInfo()));
         }
         else
         {
             return(new UserInfo());
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 根据用户登录帐号获取用户对象
 /// </summary>
 /// <param name="LoginName"></param>
 /// <returns></returns>
 public UserInfo GetUserByLoginName(string LoginName)
 {
     using (var factory = new BaseAccess())
     {
         var model = factory.Single <UserEntity>(Specification <UserEntity> .Create(c => c.UserLoginName == LoginName && c.RecordStatus != (int)RecordStatus.UnEnable &&
                                                                                    c.UserType == (int)UserType.Administrators));
         if (model != null)
         {
             return(model.Adapter <UserInfo>(new UserInfo()));
         }
         else
         {
             return(new UserInfo());
         }
     }
 }