예제 #1
0
 public IList<String> GetRightsCodeList(string userName, string password)
 {
     Employee emp = new Employee();
     emp.EmployeeNo = userName;
     emp.Password = password;
     return ExecuteQueryForList<String>("GetRightsCodeListByEmployee", emp); ;
 }
예제 #2
0
 public Employee GetEmployee(string login, string password)
 {
     Employee emp = new Employee();
     emp.EmployeeNo = login;
     emp.Password = password;
     return ExecuteQueryForObject("GetEmployeeByLoginAndPassword", emp) as Employee;
 }
예제 #3
0
 /// <summary>
 /// 获取用户信息 0:数据库操作失败, 1:成功, 2:账号或者密码错误
 /// </summary>
 public int GetEmployee(string attendanceCard, out Employee employee)
 {
     int result = 0;
     try
     {
         _daoManager.OpenConnection();
         employee = _employeeDao.GetEmployee(attendanceCard);
         if (employee == null)
         {
             result = 2;
         }
         else
         {
             employee.RightsCodeList = _employeeDao.GetRightsCodeList(employee.EmployeeNo, employee.Password);
             result = 1;
         }
     }
     catch (Exception exception)
     {
         employee = null;
         LogHelper.GetInstance().Error("[GetEmployee]参数:AttendanceCard_" + attendanceCard, exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
     return result;
 }
예제 #4
0
 /// <summary>
 /// 获取用户信息 0:数据库操作失败, 1:成功, 2:账号或者密码错误
 /// </summary>
 public int GetEmployee(string userName, string password, out Employee employee)
 {
     int result = 0;
     try
     {
         _daoManager.OpenConnection();
         employee = _employeeDao.GetEmployee(userName, password);
         if (employee == null)
         {
             result = 2;
         }
         else
         {
             employee.RightsCodeList = _employeeDao.GetRightsCodeList(userName, password);
             result = 1;
         }
     }
     catch (Exception exception)
     {
         employee = null;
         LogHelper.GetInstance().Error("[GetEmployee]参数:UserName_" + userName, exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
     return result;
 }
예제 #5
0
        /// <summary>
        /// 获取用户信息 0:数据库操作失败, 1:成功, 2:账号或者密码错误
        /// </summary>
        public int EmployeeLogin(string userName, string userPassword, ref Employee employee)
        {
            int cByte = ParamFieldLength.PACKAGE_HEAD + ParamFieldLength.USER_NO + ParamFieldLength.USER_PWD;
            byte[] sendByte = new byte[cByte];
            int byteOffset = 0;
            Array.Copy(BitConverter.GetBytes((int)Command.ID_USERLOGIN), sendByte, BasicTypeLength.INT32);
            byteOffset = BasicTypeLength.INT32;
            Array.Copy(BitConverter.GetBytes(cByte), 0, sendByte, byteOffset, BasicTypeLength.INT32);
            byteOffset += BasicTypeLength.INT32;

            byte[] tempByte = null;
            //UserName
            tempByte = Encoding.UTF8.GetBytes(userName);
            Array.Copy(tempByte, 0, sendByte, byteOffset, tempByte.Length);
            byteOffset += ParamFieldLength.USER_NO;
            //UserPassword
            tempByte = Encoding.UTF8.GetBytes(userPassword);
            Array.Copy(tempByte, 0, sendByte, byteOffset, tempByte.Length);
            byteOffset += ParamFieldLength.USER_PWD;

            int result = 0;
            employee = null;
            using (SocketClient socket = new SocketClient(ConstantValuePool.BizSettingConfig.IPAddress, ConstantValuePool.BizSettingConfig.Port))
            {
                Byte[] receiveData = null;
                Int32 operCode = socket.SendReceive(sendByte, out receiveData);
                if (operCode == (int)RET_VALUE.SUCCEEDED)
                {
                    string strReceive = Encoding.UTF8.GetString(receiveData, ParamFieldLength.PACKAGE_HEAD, receiveData.Length - ParamFieldLength.PACKAGE_HEAD);
                    employee = JsonConvert.DeserializeObject<Employee>(strReceive);
                    result = 1;
                }
                else if (operCode == (int)RET_VALUE.ERROR_AUTHENTICATION)
                {
                    result = 2;
                }
                else
                {
                    result = 0;
                }
                socket.Close();
            }
            return result;
        }
예제 #6
0
 /// <summary>
 /// 获取用户信息 0:数据库操作失败, 1:成功, 2:账号不存在
 /// </summary>
 public int GetEmployeeByNo(string employeeNo, out Employee employee)
 {
     int result = 0;
     try
     {
         _daoManager.OpenConnection();
         employee = _employeeDao.GetEmployeeByNo(employeeNo);
         result = employee == null ? 2 : 1;
     }
     catch (Exception exception)
     {
         employee = null;
         LogHelper.GetInstance().Error("[GetEmployeeByNo]参数:EmployeeNo_" + employeeNo, exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
     return result;
 }