示例#1
0
        public override void Validate(string userName, string password)
        {
            try
            {
                if (string.IsNullOrEmpty(userName))
                    throw new ArgumentNullException("用户名");
                if (string.IsNullOrEmpty(password))
                    throw new ArgumentNullException("密码");

                CurrentUser = SysUserAdapter.GetUser(userName);

                if (CurrentUser == null ||
                    !(CurrentUser.UserName.Trim().ToLower() == userName.Trim().ToLower() && CurrentUser.Password == password))
                {
                    throw new FaultException("用户名或者密码错误!");
                }
                if (CurrentUser.IsLock)
                {
                    throw new FaultException("账号已被锁定!");
                }
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
示例#2
0
 /// <summary>
 /// 创建新的 SysUser 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="userName">UserName 属性的初始值。</param>
 /// <param name="password">Password 属性的初始值。</param>
 /// <param name="roleCode">RoleCode 属性的初始值。</param>
 /// <param name="isLock">IsLock 属性的初始值。</param>
 /// <param name="isAdmin">IsAdmin 属性的初始值。</param>
 /// <param name="checkComputer">CheckComputer 属性的初始值。</param>
 /// <param name="valid">Valid 属性的初始值。</param>
 public static SysUser CreateSysUser(global::System.Int32 id, global::System.String userName, global::System.String password, global::System.String roleCode, global::System.Boolean isLock, global::System.Boolean isAdmin, global::System.Boolean checkComputer, global::System.Boolean valid)
 {
     SysUser sysUser = new SysUser();
     sysUser.ID = id;
     sysUser.UserName = userName;
     sysUser.Password = password;
     sysUser.RoleCode = roleCode;
     sysUser.IsLock = isLock;
     sysUser.IsAdmin = isAdmin;
     sysUser.CheckComputer = checkComputer;
     sysUser.Valid = valid;
     return sysUser;
 }
示例#3
0
 /// <summary>
 /// 用于向 SysUser EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToSysUser(SysUser sysUser)
 {
     base.AddObject("SysUser", sysUser);
 }
示例#4
0
 public void UpdateUser(SysUser user)
 {
     SysUserAdapter.Update(user);
 }
示例#5
0
 public void InsertUser(SysUser user)
 {
     SysUserAdapter.Insert(user);
 }
示例#6
0
 public void InsertEmployeeWithUser(CoEmployee employee, SysUser user)
 {
     CoEmployeeAdapter.InsertWithUser(employee, user);
 }
示例#7
0
 /// <summary>
 /// 新增用户
 /// </summary>
 public static void Insert(SysUser user)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该用户是否存在
         if (context.SysUser.FirstOrDefault(obj => obj.UserName.Trim().ToLower() == user.UserName.Trim().ToLower() && obj.Valid == true) != null)
             throw new FaultException(string.Format("用户名[{0}]已存在!", user.UserName));
         context.SysUser.AddObject(user);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("SysUserAdapter01", Define.Insert, user));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
示例#8
0
        /// <summary>
        /// 修改用户
        /// </summary>
        public static void Update(SysUser user)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该用户是否存在
                SysUser _user = context.SysUser.FirstOrDefault(obj => obj.ID == user.ID);
                if (_user == null)
                    throw new FaultException(string.Format("该用户[{0}]不存在!", user.UserName));
                EntityObjectHelper.Copyto(user, ref _user); //利用反射动态赋值

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("SysUserAdapter03", Define.Update, _user));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
示例#9
0
 /// <summary>
 /// 新增员工,与用户
 /// </summary>
 public static void InsertWithUser(CoEmployee employee, SysUser user)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该员工是否存在
         context.CoEmployee.Any(obj => obj.Valid == true);
         if (context.CoEmployee.FirstOrDefault(obj => obj.Code.Trim().ToLower() == employee.Code.Trim().ToLower() && obj.Valid == true) != null)
             throw new FaultException(string.Format("员工编号[{0}]已存在!", employee.Code));
         context.CoEmployee.AddObject(employee);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoEmployeeAdapter02", Define.Insert, employee));   //记录日志
         //查找该用户是否存在
         if (context.SysUser.FirstOrDefault(obj => obj.UserName.Trim().ToLower() == user.UserName.Trim().ToLower()) != null)
             throw new FaultException(string.Format("用户名[{0}]已存在!", user.UserName));
         context.SysUser.AddObject(user);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoEmployeeAdapter03", Define.Insert, user));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }