/// <summary>
        /// 开馆处理
        /// </summary>
        /// <param name="readingRooms"></param>
        private void OpenReadingRoom(ReadingRoomInfo room)
        {
            DateTime nowDateTime = ServiceDateTime.Now;

            try
            {
                //获取昨天的进出记录
                List <EnterOutLogInfo> eolList = T_SM_EnterOutLog.GetEnterOutLogByStatus(null, room.No, null, enterOutLogTypeList, LogStatus.Valid, "1900-1-1", ServiceDateTime.Now.ToShortDateString());
                foreach (EnterOutLogInfo eol in eolList)
                {
                    if ((eol.EnterOutState == EnterOutLogType.ShortLeave) && (eol.Flag == Operation.Admin || eol.Flag == Operation.OtherReader))
                    {
                        //获取昨天的等待记录
                        List <WaitSeatLogInfo> wsllist = T_SM_SeatWaiting.GetWaitSeatList(null, eol.EnterOutLogID, null, null, new List <EnterOutLogType> {
                            EnterOutLogType.Waiting
                        });
                        if (wsllist.Count > 0)
                        {
                            wsllist[0].WaitingState    = EnterOutLogType.WaitingCancel;
                            wsllist[0].StatsChangeTime = nowDateTime;
                            T_SM_SeatWaiting.UpdateWaitLog(wsllist[0]);
                        }
                    }
                    eol.EnterOutState = EnterOutLogType.Leave;
                    eol.EnterOutTime  = nowDateTime;
                    eol.Flag          = Operation.Service;
                    eol.Remark        = string.Format("在{0},{1}号座位,闭馆释放座位", eol.ReadingRoomName, eol.SeatNo.Substring(eol.SeatNo.Length - room.Setting.SeatNumAmount));
                    int logdi = 0;
                    EnterOutOperate.AddEnterOutLog(eol, ref logdi);
                    WriteLog.Write(string.Format("监控服务:读者{0},{1}", eol.CardNo, eol.Remark));
                }
                //预约记录处理
                TimeSpan span = nowDateTime - DateTime.Parse("2010-1-1");
                List <BespeakLogInfo> blilist = T_SM_SeatBespeak.GetBespeakList(null, room.No, nowDateTime.AddDays(-1), span.Days, new List <BookingStatus> {
                    BookingStatus.Waiting
                });
                if (blilist.Count <= 0)
                {
                    return;
                }
                foreach (BespeakLogInfo bli in blilist.Where(bli => bli.BsepeakTime.Date < nowDateTime.Date))
                {
                    bli.CancelTime   = bli.BsepeakTime.AddMinutes(int.Parse(room.Setting.SeatBespeak.ConfirmTime.EndTime));
                    bli.CancelPerson = Operation.Service;
                    bli.BsepeakState = BookingStatus.Cencaled;
                    bli.Remark       = string.Format("读者,在{0},{1}号座位,预约,闭馆取消预约", bli.ReadingRoomName, bli.SeatNo.Substring(bli.SeatNo.Length - room.Setting.SeatNumAmount));
                    T_SM_SeatBespeak.UpdateBespeakList(bli);
                    WriteLog.Write(string.Format("监控服务:读者{0},{1}", bli.CardNo, bli.Remark));
                }
            }
            catch (Exception ex)
            {
                WriteLog.Write(string.Format("监控服务:执行开馆处理遇到错误:{0}", ex.Message));
            }
        }
        /// <summary>
        /// 闭馆处理
        /// </summary>
        /// <param name="readingRooms"></param>
        private void CloseReadingRoom(ReadingRoomInfo room)
        {
            DateTime nowDateTime = ServiceDateTime.Now;

            //添加记录状态
            try
            {
                //获取今天的进出记录
                List <EnterOutLogInfo> eolList = T_SM_EnterOutLog.GetEnterOutLogByStatus(null, room.No, null, enterOutLogTypeList, LogStatus.Valid, nowDateTime.ToShortDateString(), null);
                foreach (EnterOutLogInfo eol in eolList)
                {
                    if ((eol.EnterOutState == EnterOutLogType.ShortLeave) && (eol.Flag == Operation.Admin || eol.Flag == Operation.OtherReader))
                    {
                        //获取今天的的等待记录
                        List <WaitSeatLogInfo> wsllist = T_SM_SeatWaiting.GetWaitSeatList(null, eol.EnterOutLogID, null, null, new List <EnterOutLogType> {
                            EnterOutLogType.Waiting
                        });
                        if (wsllist.Count > 0)
                        {
                            wsllist[0].WaitingState    = EnterOutLogType.WaitingCancel;
                            wsllist[0].StatsChangeTime = nowDateTime;
                            T_SM_SeatWaiting.UpdateWaitLog(wsllist[0]);
                        }
                    }
                    eol.EnterOutState = EnterOutLogType.Leave;
                    eol.EnterOutTime  = nowDateTime;
                    eol.Flag          = Operation.Service;
                    eol.Remark        = string.Format("在{0},{1}号座位,闭馆释放座位", eol.ReadingRoomName, eol.SeatNo.Substring(eol.SeatNo.Length - room.Setting.SeatNumAmount));
                    int logdi = 0;
                    EnterOutOperate.AddEnterOutLog(eol, ref logdi);


                    //PushMsgInfo msg = new PushMsgInfo();
                    //msg.Title = "您好,您的座位已被释放";
                    //msg.MsgType = MsgPushType.ToTime;
                    //msg.StudentNum = eol.CardNo;
                    //msg.Message = eol.Remark;
                    //SeatManage.Bll.T_SM_ReaderNotice.SendPushMsg(msg);

                    WriteLog.Write(string.Format("监控服务:读者{0},{1}", eol.CardNo, eol.Remark));
                }
            }
            catch (Exception ex)
            {
                WriteLog.Write(string.Format("监控服务:执行闭馆处理遇到错误:{0}", ex.Message));
            }
        }
        /// <summary>
        /// 处理暂离和在座超时
        /// </summary>
        /// <param name="readingRooms"></param>
        public void EnterOutLogOperate()
        {
            try
            {
                DateTime nowDateTime           = ServiceDateTime.Now;
                List <EnterOutLogInfo> eolList = T_SM_EnterOutLog.GetEnterOutLogByStatus(null, null, null, enterOutLogTypeList, LogStatus.Valid, nowDateTime.ToShortDateString(), null);

                //遍历所有阅览室
                foreach (ReadingRoomInfo rri in roomList.Values.Where(rri => rri.Setting != null))
                {
                    DateTime seatOutTime = rri.Setting.RoomOpenSet.NowOpenTime(nowDateTime).AddMinutes(-rri.Setting.RoomOpenSet.OpenBeforeTimeLength);
                    if (rri.Setting.SeatUsedTimeLimit.Used && rri.Setting.SeatUsedTimeLimit.Mode == "Fixed")
                    {
                        foreach (DateTime ft in rri.Setting.SeatUsedTimeLimit.FixedTimes)
                        {
                            if (nowDateTime > ft)
                            {
                                seatOutTime = rri.Setting.SeatUsedTimeLimit.IsCanContinuedTime ? ft.AddMinutes(-rri.Setting.SeatUsedTimeLimit.CanDelayTime) : ft;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    //获取本阅览室的进出记录
                    foreach (EnterOutLogInfo eol in eolList.FindAll(u => u.ReadingRoomNo == rri.No))
                    {
                        switch (eol.EnterOutState)
                        {
                        case EnterOutLogType.SelectSeat:
                        case EnterOutLogType.ReselectSeat:
                        case EnterOutLogType.WaitingSuccess:
                        case EnterOutLogType.BookingConfirmation:
                            try
                            {
                                if (rri.Setting.SeatUsedTimeLimit.Used)
                                {
                                    //判断是否在座超时
                                    if (rri.Setting.SeatUsedTimeLimit.Mode == "Free")
                                    {
                                        if (eol.EnterOutTime.AddMinutes(rri.Setting.SeatUsedTimeLimit.UsedTimeLength) < nowDateTime)
                                        {
                                            SeatOverTimeOperator(rri.Setting, eol, nowDateTime);
                                        }
                                        //else if (eol.EnterOutTime.AddMinutes(rri.Setting.SeatUsedTimeLimit.UsedTimeLength - rri.Setting.SeatUsedTimeLimit.CanDelayTime) < nowDateTime)
                                        //{
                                        //    //推送续时提示
                                        //}
                                    }
                                    else if (rri.Setting.SeatUsedTimeLimit.Mode == "Fixed")
                                    {
                                        if (eol.EnterOutTime < seatOutTime)
                                        {
                                            SeatOverTimeOperator(rri.Setting, eol, nowDateTime);
                                        }
                                        //else if (eol.EnterOutTime.AddMinutes(rri.Setting.SeatUsedTimeLimit.UsedTimeLength - rri.Setting.SeatUsedTimeLimit.CanDelayTime) < seatOutTime)
                                        //{

                                        //}
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                WriteLog.Write(string.Format("监控服务:在座超时处理遇到异常{0}", ex.Message));
                            }
                            break;

                        case EnterOutLogType.ContinuedTime:
                            try
                            {
                                //判断是否续时超时
                                if (rri.Setting.SeatUsedTimeLimit.Used)
                                {
                                    if (rri.Setting.SeatUsedTimeLimit.Mode == "Free" && (eol.EnterOutTime.AddMinutes(rri.Setting.SeatUsedTimeLimit.DelayTimeLength) < nowDateTime))
                                    {
                                        SeatOverTimeOperator(rri.Setting, eol, nowDateTime);
                                    }
                                    else if (rri.Setting.SeatUsedTimeLimit.Mode == "Fixed" && eol.EnterOutTime < seatOutTime)
                                    {
                                        SeatOverTimeOperator(rri.Setting, eol, nowDateTime);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                WriteLog.Write(string.Format("监控服务:续时超时处理遇到异常{0}", ex.Message));
                            }
                            break;

                        case EnterOutLogType.ComeBack:
                        {
                            if (rri.Setting.SeatUsedTimeLimit.Used)
                            {
                                //操作最后一条选座或续时的记录
                                EnterOutLogInfo neweol = GetLastNoSeatTimeLog(eol);
                                if (neweol != null)
                                {
                                    eol.EnterOutTime  = neweol.EnterOutTime;
                                    eol.EnterOutState = neweol.EnterOutState;
                                    if (eol.EnterOutState == EnterOutLogType.ContinuedTime)
                                    {
                                        goto case EnterOutLogType.ContinuedTime;
                                    }
                                    else
                                    {
                                        goto case EnterOutLogType.BookingConfirmation;
                                    }
                                }
                            }
                            break;
                        }

                        case EnterOutLogType.ShortLeave:
                        {
                            if (eol.Flag == Operation.OtherReader && rri.Setting.NoManagement.Used && (eol.EnterOutTime.AddMinutes(rri.Setting.GetSeatHoldTime(eol.EnterOutTime)) < nowDateTime))
                            {
                                //判断座位等待处理
                                List <WaitSeatLogInfo> wslilist = T_SM_SeatWaiting.GetWaitSeatList(null, eol.EnterOutLogID, null, null, new List <EnterOutLogType> {
                                        EnterOutLogType.Waiting
                                    });
                                if (wslilist.Count > 0)
                                {
                                    WaitSeatOperate(rri, eol, wslilist, nowDateTime);
                                }
                            }
                            else
                            {
                                if (eol.Flag == Operation.Admin)
                                {
                                    if (rri.Setting.AdminShortLeave.IsUsed && (eol.EnterOutTime.AddMinutes(rri.Setting.AdminShortLeave.HoldTimeLength) < nowDateTime))
                                    {
                                        ShortLeaveOverTimeOperator(eol, rri.Setting, nowDateTime);
                                    }
                                    else if (!rri.Setting.AdminShortLeave.IsUsed && (eol.EnterOutTime.AddMinutes(NowReadingRoomState.GetSeatHoldTime(rri.Setting.SeatHoldTime, eol.EnterOutTime)) < nowDateTime))
                                    {
                                        ShortLeaveOverTimeOperator(eol, rri.Setting, nowDateTime);
                                    }
                                }
                                else if (eol.EnterOutTime.AddMinutes(NowReadingRoomState.GetSeatHoldTime(rri.Setting.SeatHoldTime, eol.EnterOutTime)) < nowDateTime)
                                {
                                    ShortLeaveOverTimeOperator(eol, rri.Setting, nowDateTime);
                                }
                            }
                        }
                        break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog.Write(string.Format("监控服务:处理当前的进出记录失败{0}", ex.Message));
            }
        }