Esempio n. 1
0
        /// <summary>
        /// 获取插入数据
        /// </summary>
        public string GetInsertSql(WindowLoginInfoOR windowlogininfo)
        {
            string sql = @"insert into t_windowlogininfo (ID,LoginTime,WindowNo,EmployNo,EmployName,Status,AlertTime)
            values ('@ID',now(),'@WindowNo','@EmployNo','@EmployName',Status,now())";
              sql = sql.Replace("@ID", windowlogininfo.Id);	//
              //sql = sql.Replace("@LoginTime", windowlogininfo.Logintime.ToString("yyyy-MM-dd HH:mm:ss"));	//
              sql = sql.Replace("@WindowNo", windowlogininfo.Windowno);	//
              sql = sql.Replace("@EmployNo", windowlogininfo.Employno);	//
              sql = sql.Replace("@EmployName", windowlogininfo.Employname);	//
              sql = sql.Replace("@Status", windowlogininfo.Status.ToString());	//
              //sql = sql.Replace("@AlertTime", windowlogininfo.Alerttime.ToString("yyyy-MM-dd HH:mm:ss"));	//

              return sql;
        }
Esempio n. 2
0
 /// <summary>
 /// 恢复服务
 /// </summary>
 /// <param name="_obj"></param>
 /// <returns></returns>
 public bool RestarServer(WindowLoginInfoOR _obj)
 {
     return UpdateLoginStatus(_obj);
 }
Esempio n. 3
0
 public void InsertLoginWindowInfo(WindowLoginInfoOR obj)
 {
     string sql = GetInsertSql(obj);
       dbMySql.ExecuteNoQuery(sql);
 }
Esempio n. 4
0
 /// <summary>
 /// 更新服务状态
 /// </summary>
 /// <param name="_obj"></param>
 /// <returns></returns>
 public bool UpdateLoginStatus(WindowLoginInfoOR _obj)
 {
     string sql = string.Format("update t_windowlogininfo set Status={0} ,AlertTime=now() where id='{1}'"
      , _obj.Status, _obj.Id);
       return dbMySql.ExecuteNoQuery(sql) > 0;
 }
Esempio n. 5
0
 /// <summary>
 /// 查询当前登录窗口的柜员
 /// </summary>
 /// <returns></returns>
 public List<WindowLoginInfoOR> SelectToDayLogins()
 {
     List<WindowLoginInfoOR> listLogins = new List<WindowLoginInfoOR>();
       string sql = string.Format("select * from t_WindowLoginInfo where  logintime > '{0}' and status != 1 order by logintime",
       DateTime.Now.ToString("yyyy-MM-dd"));
       DataTable dt = dbMySql.ExecuteQuery(sql);
       foreach (DataRow dr in dt.Rows)
       {
       WindowLoginInfoOR obj = new WindowLoginInfoOR(dr);
       listLogins.Add(obj);
       }
       return listLogins;
 }
Esempio n. 6
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="password"></param>
        /// <param name="windowid"></param>
        /// <returns></returns>
        public string getLogin(string userid, string password, string windowid)
        {
            ErrorLog.WriteLog("getLogin#F", userid);
            EmployeeOR _empOR = new EmployeeMySqlDA().SelectAEmployeeLogin(userid, password);
            if (_empOR == null)
            {
                return "用户名或密码错误";//用户名或密码错误
            }
            WindowOR _winOR = new WindowMySqlDA().SelectWindowByNo(windowid);
            if (_winOR == null)
            {
                return string.Format("窗口号:{0}不存在", windowid);
            }

            WindowLoginInfoOR _Log = GetLoginLog(userid, windowid);
            if (_Log == null)
            {
                //在内存中查询用户是否已经登录
                WindowLoginInfoOR _LoginRecordEmp = GetLoginLogByEmployeeNo(userid);
                if (_LoginRecordEmp != null && isHaveLoginInfo(_LoginRecordEmp))
                {
                    return string.Format("用户:{0}已经登录",userid);//用户已经登录
                }

                WindowLoginInfoOR _LoginRecordWin = GetLoginLogByWindowNo(windowid);
                if (_LoginRecordWin != null && isHaveLoginInfo(_LoginRecordWin))
                {
                    return string.Format("此窗口号:{0}已登录",windowid);//此窗口已登录
                }
            }
            else
            {
                if(isHaveLoginInfo(_Log))
                {
                    return string.Format("用户:{0},窗口号:{1}已经登录", userid, windowid);
                }
            }

            try
            {
                WindowLoginInfoOR _Login = new WindowLoginInfoOR();
                _Login.Windowno = windowid;
                _Login.Employname = _empOR.Name;
                _Login.Employno = _empOR.Employno;
                _Login.Alerttime = _Login.Logintime = DateTime.Now;
                _Login.Status = 0;
                _Login.BussinessRoleOn = BussRoleObj.GetBussinessRoleOn(_empOR, _winOR);
                _WindowLoginDA.InsertLoginWindowInfo(_Login);//写入数据库
                ListWindowLogins.Add(_Login);
            }
            catch (Exception ex)
            {
                ErrorLog.WriteLog("getLogin#ex", ex.Message);
                return ex.Message; //写入数据库出错。
            }
            return "0";
        }
Esempio n. 7
0
 private bool isHaveLoginInfo(WindowLoginInfoOR _Log)
 {
     int timeLen = GetTimeLen(_Log.GetDataTime, DateTime.Now);
     if (timeLen > 60)
     {
         _Log.Status = 1;
         _WindowLoginDA.UpdateLoginStatus(_Log);
         ListWindowLogins.Remove(_Log);
         return false;
     }
     return true;
 }