/// <summary> /// 添加违规记录 /// </summary> /// <param name="eol">进出记录</param> /// <param name="type">违规类型</param> /// <param name="note">提示信息</param> private static void AddViolationRecordByEnterOutLog(EnterOutLogInfo eol, ViolationRecordsType type, string note, ReadingRoomSetting roomSetting, DateTime nowDateTime) { try { if (roomSetting.BlackListSetting.Used && !roomSetting.BlackListSetting.ViolateRoule[type]) { return; } if (!regulationRulesSetting.BlacklistSet.Used || !regulationRulesSetting.BlacklistSet.ViolateRoule[type]) { return; } ViolationRecordsLogInfo vrli = new ViolationRecordsLogInfo(); vrli.CardNo = eol.CardNo; vrli.SeatID = eol.SeatNo; if (vrli.SeatID.Length > roomSetting.SeatNumAmount) { vrli.SeatID = vrli.SeatID.Substring(vrli.SeatID.Length - roomSetting.SeatNumAmount); } vrli.ReadingRoomID = eol.ReadingRoomNo; vrli.EnterOutTime = nowDateTime.ToString(); vrli.EnterFlag = type; vrli.Remark = note; T_SM_ViolateDiscipline.AddViolationRecords(vrli); WriteLog.Write(string.Format("监控服务:读者{0},{1},记录违规", vrli.CardNo, vrli.Remark)); } catch (Exception ex) { WriteLog.Write(string.Format("监控服务:添加违规记录发生错误:" + ex.Message)); } }
/// <summary> /// 违规记录超时处理 /// </summary> public void ViolationRecordsOperating() { try { DateTime NowDateTime = ServiceDateTime.Now; //违规记录超时处理 List <ViolationRecordsLogInfo> listvr = T_SM_ViolateDiscipline.GetViolationRecordsLog(null, null); if (listvr.Count > 0) { foreach (ViolationRecordsLogInfo vrli in listvr) { if (roomList[vrli.ReadingRoomID].Setting.BlackListSetting.Used && DateTime.Parse(vrli.EnterOutTime).AddDays(roomList[vrli.ReadingRoomID].Setting.BlackListSetting.ViolateFailDays) < NowDateTime) { vrli.Flag = LogStatus.Fail; T_SM_ViolateDiscipline.UpdateViolationRecords(vrli); //ReaderNoticeInfo notice = new ReaderNoticeInfo(); //notice.CardNo = vrli.CardNo; //notice.Type = NoticeType.DeleteViolation; //notice.Note = string.Format("{0}记录的违规,{1},过期", vrli.EnterOutTime, vrli.Remark); //T_SM_ReaderNotice.AddReaderNotice(notice); } else if (regulationRulesSetting.BlacklistSet.Used && DateTime.Parse(vrli.EnterOutTime).AddDays(regulationRulesSetting.BlacklistSet.ViolateFailDays) < NowDateTime) { vrli.Flag = LogStatus.Fail; T_SM_ViolateDiscipline.UpdateViolationRecords(vrli); WriteLog.Write(string.Format("监控服务:读者{0},违规记录过期", vrli.CardNo)); //ReaderNoticeInfo notice = new ReaderNoticeInfo(); //notice.CardNo = vrli.CardNo; //notice.Type = NoticeType.DeleteViolation; //notice.Note = string.Format("{0}记录的违规,{1},过期", vrli.EnterOutTime, vrli.Remark); //T_SM_ReaderNotice.AddReaderNotice(notice); } else if (!regulationRulesSetting.BlacklistSet.Used && !roomList[vrli.ReadingRoomID].Setting.BlackListSetting.Used) { vrli.Flag = LogStatus.Fail; T_SM_ViolateDiscipline.UpdateViolationRecords(vrli); WriteLog.Write(string.Format("监控服务:读者{0},违规记录过期", vrli.CardNo)); //ReaderNoticeInfo notice = new ReaderNoticeInfo(); //notice.CardNo = vrli.CardNo; //notice.Type = NoticeType.DeleteViolation; //notice.Note = string.Format("{0}记录的违规,{1},过期", vrli.EnterOutTime, vrli.Remark); //T_SM_ReaderNotice.AddReaderNotice(notice); } } } } catch (Exception e) { WriteLog.Write(string.Format("监控服务:违规记录超时处理遇到异常:{0}", e.Message)); } }
public string StuViolateDiscipline(string stuNo, string startDate, string EndDate) { try { if (!Verifylicensing()) { return("非法操作,此接口未进行授权!"); } List <ViolationRecordsLogInfo> list = T_SM_ViolateDiscipline.GetViolationRecords(stuNo, null, startDate + " 00:00:00", EndDate + " 23:59:59", SeatManage.EnumType.LogStatus.None, SeatManage.EnumType.LogStatus.None); XmlDocument xmlDoc = new XmlDocument(); //创建开头 XmlDeclaration dec = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null); xmlDoc.AppendChild(dec); //创建根节点 XmlElement root = xmlDoc.CreateElement("StuViolateDiscipline"); xmlDoc.AppendChild(root); for (int i = 0; i < list.Count; i++) { XmlElement logNode = xmlDoc.CreateElement("Log"); string cardNo = list[i].CardNo; string seatId = list[i].SeatID; string readingRoomName = list[i].ReadingRoomName; string enterOutTime = list[i].EnterOutTime.ToString(); string violateType = list[i].Remark; string handleState = ""; switch (list[i].BlacklistID) { case "-1": handleState = "未处理"; break; default: handleState = "已加入黑名单"; break; } logNode.SetAttribute("SeatNo", seatId); logNode.SetAttribute("RoomName", readingRoomName); logNode.SetAttribute("DateTime", enterOutTime); logNode.SetAttribute("Describe", violateType); logNode.SetAttribute("HandleResult", handleState); root.AppendChild(logNode); } return(xmlDoc.OuterXml); } catch (Exception ex) { return(ex.Message); } }
public JsonResult SaveNewViolate() { JsonResult result = null; SeatManage.ClassModel.RegulationRulesSetting regulationRulesSetting = T_SM_SystemSet.GetRegulationRulesSetting(); string CardNo = Request.Params["txtNum"].Trim(); string SeatNo = Request.Params["txtSeat"].Trim(); string seatnoremark = ""; if (!string.IsNullOrEmpty(SeatNo)) { seatnoremark = SeatNo + "号座位,"; } string Remark = Request.Params["txtRemark"].Trim(); // txtRemark.Text; ViolationRecordsType Type = (ViolationRecordsType)int.Parse(Request.Params["selectVrType"].Trim()); string ReadingRoomNo = Request.Params["selectRooms"].Trim(); //ddlroom.SelectedValue; ReadingRoomInfo room = SeatManage.Bll.T_SM_ReadingRoom.GetSingleRoomInfo(ReadingRoomNo); if (room.Setting.IsRecordViolate) { ViolationRecordsLogInfo vrli = new ViolationRecordsLogInfo(); vrli.CardNo = CardNo; vrli.SeatID = SeatNo; vrli.ReadingRoomID = ReadingRoomNo; vrli.EnterOutTime = ServiceDateTime.Now.ToString(); vrli.EnterFlag = Type; vrli.Remark = string.Format("在{0},{1}被管理员{2},手动记录违规,备注{3}", room.Name, seatnoremark, this.LoginId, Remark); if (T_SM_ViolateDiscipline.AddViolationRecords(vrli)) { result = Json(new { status = "yes", message = "添加成功" }, JsonRequestBehavior.AllowGet); } else { result = Json(new { status = "no", message = "添加失败" }, JsonRequestBehavior.AllowGet); // FineUI.Alert.Show("添加失败!"); } } return(result); }
/// <summary> /// 保存设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { SeatManage.ClassModel.RegulationRulesSetting regulationRulesSetting = T_SM_SystemSet.GetRegulationRulesSetting(); string CardNo = txtCardno.Text; string SeatNo = txtseatno.Text; string seatnoremark = ""; if (!string.IsNullOrEmpty(SeatNo)) { seatnoremark = SeatNo + "号座位,"; } string Remark = txtRemark.Text; ViolationRecordsType Type = (ViolationRecordsType)int.Parse(ddltype.SelectedValue); string ReadingRoomNo = ddlroom.SelectedValue; ReadingRoomInfo room = SeatManage.Bll.T_SM_ReadingRoom.GetSingleRoomInfo(ReadingRoomNo); if (room.Setting.IsRecordViolate) { ViolationRecordsLogInfo vrli = new ViolationRecordsLogInfo(); vrli.CardNo = CardNo; vrli.SeatID = SeatNo; vrli.ReadingRoomID = ReadingRoomNo; vrli.EnterOutTime = ServiceDateTime.Now.ToString(); vrli.EnterFlag = Type; vrli.Remark = string.Format("在{0},{1}被管理员{2},手动记录违规,备注{3}", room.Name, seatnoremark, this.LoginId, Remark); if (T_SM_ViolateDiscipline.AddViolationRecords(vrli)) { PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); FineUI.Alert.Show("添加成功!"); } else { FineUI.Alert.Show("添加失败!"); } } }
/// <summary> /// 开始计算 /// </summary> public static bool Upload() { try { DateTime sdt; string lastdate = GetLastDate(); if (!string.IsNullOrEmpty(lastdate)) { sdt = DateTime.Parse(lastdate); } else { sdt = SeatManage.Bll.T_SM_EnterOutLog_bak.GetFristLogDate(); } if (sdt <= DateTime.Parse("2000-1-1")) { return(true); } AMS.ServiceProxy.FileOperate fileOperate = new ServiceProxy.FileOperate(); sdt = sdt.AddDays(1); while (true) { //获取进出记录 List <EnterOutLogInfo> enterOutLogList = T_SM_EnterOutLog_bak.GetStatisticsLogsByDate(sdt); List <BespeakLogInfo> bespeakLogList = T_SM_SeatBespeak.GetBespeakList(null, null, sdt, 0, null); List <ViolationRecordsLogInfo> violationLogList = T_SM_ViolateDiscipline.GetViolationRecords(null, null, sdt.ToShortDateString(), sdt.Date.AddDays(1).AddSeconds(-1).ToString(), LogStatus.None, LogStatus.None); List <BlackListInfo> blacklistList = T_SM_Blacklist.GetAllBlackListInfo(null, LogStatus.None, sdt.ToShortDateString(), sdt.Date.AddDays(1).AddSeconds(-1).ToString()); if (enterOutLogList.Count <= 0 && bespeakLogList.Count <= 0 && violationLogList.Count <= 0 && sdt >= ServiceDateTime.Now.Date.AddDays(-1)) { break; } StringBuilder eolsb = new StringBuilder(); StringBuilder blisb = new StringBuilder(); StringBuilder vrisb = new StringBuilder(); StringBuilder bllsb = new StringBuilder(); foreach (EnterOutLogInfo eol in enterOutLogList) { //记录内容 eolsb.Append(eol.EnterOutLogID + ","); eolsb.Append(eol.EnterOutLogNo + ","); eolsb.Append(eol.EnterOutState + ","); eolsb.Append(eol.EnterOutTime + ","); //座位信息 eolsb.Append(eol.TerminalNum + ","); eolsb.Append(eol.SeatNo + ","); eolsb.Append(eol.ReadingRoomNo + ","); eolsb.Append(eol.ReadingRoomName + ","); //备注 eolsb.Append(eol.Flag + ","); eolsb.Append(eol.Remark + ","); //读者信息 eolsb.Append(eol.CardNo + ","); eolsb.Append(eol.ReaderName + ","); eolsb.Append(eol.Sex + ","); vrisb.Append(eol.DeptName + ","); vrisb.Append(eol.TypeName + ";"); eolsb.AppendLine(); } foreach (BespeakLogInfo bli in bespeakLogList) { blisb.Append(bli.BsepeaklogID + ","); blisb.Append(bli.BsepeakTime + ","); blisb.Append(bli.BsepeakState + ","); blisb.Append(bli.SubmitTime + ","); blisb.Append(bli.CancelPerson + ","); blisb.Append(bli.CancelTime + ","); blisb.Append(bli.SeatNo + ","); blisb.Append(bli.ReadingRoomNo + ","); blisb.Append(bli.ReadingRoomName + ","); blisb.Append(bli.Remark + ","); blisb.Append(bli.CardNo + ","); blisb.Append(bli.ReaderName + ","); blisb.Append(bli.Sex + ","); vrisb.Append(bli.DeptName + ","); vrisb.Append(bli.TypeName + ";"); blisb.AppendLine(); } foreach (ViolationRecordsLogInfo vri in violationLogList) { vrisb.Append(vri.ID + ","); vrisb.Append(vri.BlacklistID + ","); vrisb.Append(vri.WarningState + ","); vrisb.Append(vri.EnterFlag + ","); vrisb.Append(vri.EnterOutTime + ","); vrisb.Append(vri.Flag + ","); vrisb.Append(vri.SeatID + ","); vrisb.Append(vri.ReadingRoomID + ","); vrisb.Append(vri.ReadingRoomName + ","); vrisb.Append(vri.Remark + ","); vrisb.Append(vri.CardNo + ","); vrisb.Append(vri.ReaderName + ","); vrisb.Append(vri.Sex + ","); vrisb.Append(vri.DeptName + ","); vrisb.Append(vri.TypeName + ";"); vrisb.AppendLine(); } foreach (BlackListInfo bli in blacklistList) { bllsb.Append(bli.ID + ","); bllsb.Append(bli.AddTime + ","); bllsb.Append(bli.BlacklistState + ","); bllsb.Append(bli.OutBlacklistMode + ","); bllsb.Append(bli.OutTime + ","); bllsb.Append(bli.ReadingRoomID + ","); bllsb.Append(bli.ReadingRoomName + ","); bllsb.Append(bli.ReMark + ","); bllsb.Append(bli.CardNo + ","); bllsb.Append(bli.ReaderName + ","); bllsb.Append(bli.Sex + ","); bllsb.Append(bli.DeptName + ","); bllsb.Append(bli.TypeName + ";"); bllsb.AppendLine(); } try { string filedateName = sdt.Year + "-" + sdt.Month + "-" + sdt.Day; SaveLog("EOL_" + filedateName, eolsb.ToString()); SaveLog("BSL_" + filedateName, blisb.ToString()); SaveLog("VRL_" + filedateName, vrisb.ToString()); SaveLog("BLL_" + filedateName, bllsb.ToString()); //压缩文件 string fileDircetoryPath = AppDomain.CurrentDomain.BaseDirectory + "StatisticsTmp\\"; SeatManage.SeatManageComm.ZipUtil.ZipFile(fileDircetoryPath + "EOL_" + filedateName, fileDircetoryPath + "ZEOL_" + filedateName); SeatManage.SeatManageComm.ZipUtil.ZipFile(fileDircetoryPath + "BSL_" + filedateName, fileDircetoryPath + "ZBSL_" + filedateName); SeatManage.SeatManageComm.ZipUtil.ZipFile(fileDircetoryPath + "VRL_" + filedateName, fileDircetoryPath + "ZVRL_" + filedateName); SeatManage.SeatManageComm.ZipUtil.ZipFile(fileDircetoryPath + "BLL_" + filedateName, fileDircetoryPath + "ZBLL_" + filedateName); //上传文件 fileOperate.UpdateFile(fileDircetoryPath + "ZEOL_" + filedateName, ServiceSet.SchoolNums + "_ZEOL_" + filedateName, SeatManageSubsystem.EnterOutLog); fileOperate.UpdateFile(fileDircetoryPath + "ZBSL_" + filedateName, ServiceSet.SchoolNums + "_ZBSL_" + filedateName, SeatManageSubsystem.BespeakLog); fileOperate.UpdateFile(fileDircetoryPath + "ZVRL_" + filedateName, ServiceSet.SchoolNums + "_ZVRL_" + filedateName, SeatManageSubsystem.ViolateDiscipline); fileOperate.UpdateFile(fileDircetoryPath + "ZBLL_" + filedateName, ServiceSet.SchoolNums + "_ZBLL_" + filedateName, SeatManageSubsystem.Blistlist); //删除缓存文件 Directory.Delete(fileDircetoryPath, true); SetLastDate(sdt.ToShortDateString()); sdt = sdt.AddDays(1); if (sdt >= ServiceDateTime.Now.Date) { break; } } catch (Exception ex) { SeatManage.SeatManageComm.WriteLog.Write(string.Format("统计{0}记录失败:{1}", sdt.ToShortDateString(), ex.Message)); return(false); } } return(true); } catch (Exception ex) { SeatManage.SeatManageComm.WriteLog.Write(string.Format("统计记录失败:{0}", ex.Message)); return(false); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["LoginId"] == null) { Response.Redirect("../Login.aspx"); } if (!IsPostBack) { BindReadingRoomList(Session[CookiesManager.LoginID].ToString()); GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } cmd = Request.Form["subCmd"]; if (cmd != null) { #region 座位相关操作 switch (cmd) { case "search": //查询座位 try { GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } catch { } break; case "ShortLeave": //设置暂离 try { string seatStr = hidSeatNo.Value; string[] noArr = seatStr.Split(','); string seatNo = ""; for (int i = 0; i < noArr.Length; i++) { seatNo = noArr[i].Trim(); EnterOutLogInfo enterOutLog = T_SM_EnterOutLog.GetUsingEnterOutLogBySeatNo(seatNo); if (enterOutLog != null && enterOutLog.EnterOutState != EnterOutLogType.ShortLeave) { ReadingRoomInfo roomInfo = T_SM_ReadingRoom.GetSingleRoomInfo(enterOutLog.ReadingRoomNo); enterOutLog.EnterOutState = EnterOutLogType.ShortLeave; enterOutLog.Flag = Operation.Admin; enterOutLog.Remark = string.Format("在{0},{1}号座位,被管理员{2},通过手持设备设置为暂离", roomInfo.Name, enterOutLog.ShortSeatNo, Session["LoginID"]); int newId = -1; HandleResult result = EnterOutOperate.AddEnterOutLog(enterOutLog, ref newId); if (result == HandleResult.Successed) { Page.RegisterStartupScript("", "<script>alert('设置读者暂离成功');</script>"); GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } else { Page.RegisterStartupScript("", "<script>alert('设置读者暂离失败');</script>"); } } } } catch { } break; case "ReleaseShortLeave": //取消暂离 try { string seatStr = hidSeatNo.Value; string[] noArr = seatStr.Split(','); string seatNo = ""; for (int i = 0; i < noArr.Length; i++) { seatNo = noArr[i].Trim(); EnterOutLogInfo enterOutLog = T_SM_EnterOutLog.GetUsingEnterOutLogBySeatNo(seatNo); if (enterOutLog != null && enterOutLog.EnterOutState == EnterOutLogType.ShortLeave) { ReadingRoomInfo roomInfo = T_SM_ReadingRoom.GetSingleRoomInfo(enterOutLog.ReadingRoomNo); enterOutLog.EnterOutState = EnterOutLogType.ComeBack; enterOutLog.Flag = Operation.Admin; enterOutLog.Remark = string.Format("在{0},{1}号座位,被管理员{2},通过手持设备取消暂离,恢复为在座", roomInfo.Name, enterOutLog.ShortSeatNo, Session["LoginID"]); int newId = -1; HandleResult result = EnterOutOperate.AddEnterOutLog(enterOutLog, ref newId); if (result == HandleResult.Successed) { List <WaitSeatLogInfo> waitSeatLogs = T_SM_SeatWaiting.GetWaitSeatList("", enterOutLog.EnterOutLogID, null, null, null); WaitSeatLogInfo waitSeatLog = null; if (waitSeatLogs.Count > 0) { waitSeatLog = waitSeatLogs[0]; waitSeatLog.NowState = LogStatus.Fail; waitSeatLog.OperateType = Operation.OtherReader; waitSeatLog.WaitingState = EnterOutLogType.WaitingCancel; if (T_SM_SeatWaiting.UpdateWaitLog(waitSeatLog)) { Page.RegisterStartupScript("", "<script>alert('取消读者暂离成功');</script>"); GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } else { Page.RegisterStartupScript("", "<script>alert('取消读者暂离成功,取消读者等待失败');</script>"); GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } } else { Page.RegisterStartupScript("", "<script>alert('取消读者暂离成功');</script>"); GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } } else { Page.RegisterStartupScript("", "<script>alert('取消读者暂离失败');</script>"); } } } } catch { } break; case "Release": //释放座位 try { string seatStr = hidSeatNo.Value; string[] noArr = seatStr.Split(','); string seatNo = ""; for (int i = 0; i < noArr.Length; i++) { seatNo = noArr[i].Trim(); EnterOutLogInfo enterOutLog = T_SM_EnterOutLog.GetUsingEnterOutLogBySeatNo(seatNo); if (enterOutLog != null && enterOutLog.EnterOutState != EnterOutLogType.Leave) { ReadingRoomInfo roomInfo = T_SM_ReadingRoom.GetSingleRoomInfo(enterOutLog.ReadingRoomNo); enterOutLog.EnterOutState = EnterOutLogType.Leave; enterOutLog.Flag = Operation.Admin; enterOutLog.Remark = string.Format("在{0},{1}号座位,被管理员{2},通过手持设备设置离开", roomInfo.Name, enterOutLog.ShortSeatNo, Session["LoginID"]); int newId = -1; HandleResult result = EnterOutOperate.AddEnterOutLog(enterOutLog, ref newId); if (result == HandleResult.Successed) { RegulationRulesSetting rulesSet = T_SM_SystemSet.GetRegulationRulesSetting(); if (roomInfo.Setting.IsRecordViolate) { if (roomInfo.Setting.BlackListSetting.Used) { if (roomInfo.Setting.BlackListSetting.ViolateRoule[ViolationRecordsType.LeaveByAdmin]) { ViolationRecordsLogInfo violationRecords = new ViolationRecordsLogInfo(); violationRecords.CardNo = enterOutLog.CardNo; violationRecords.SeatID = enterOutLog.SeatNo.Substring(enterOutLog.SeatNo.Length - roomInfo.Setting.SeatNumAmount, roomInfo.Setting.SeatNumAmount); violationRecords.ReadingRoomID = enterOutLog.ReadingRoomNo; violationRecords.EnterOutTime = ServiceDateTime.Now.ToString(); violationRecords.EnterFlag = ViolationRecordsType.LeaveByAdmin; violationRecords.Remark = string.Format("在{0},{1}号座位,被管理员{2},通过手持设备设置离开", roomInfo.Name, enterOutLog.ShortSeatNo, Session["LoginID"]); violationRecords.BlacklistID = "-1"; T_SM_ViolateDiscipline.AddViolationRecords(violationRecords); } } else if (rulesSet.BlacklistSet.Used && rulesSet.BlacklistSet.ViolateRoule[ViolationRecordsType.LeaveByAdmin]) { ViolationRecordsLogInfo violationRecords = new ViolationRecordsLogInfo(); violationRecords.CardNo = enterOutLog.CardNo; violationRecords.SeatID = enterOutLog.SeatNo.Substring(enterOutLog.SeatNo.Length - roomInfo.Setting.SeatNumAmount, roomInfo.Setting.SeatNumAmount); violationRecords.ReadingRoomID = enterOutLog.ReadingRoomNo; violationRecords.EnterOutTime = ServiceDateTime.Now.ToString(); violationRecords.EnterFlag = ViolationRecordsType.LeaveByAdmin; violationRecords.Remark = string.Format("在{0},{1}号座位,被管理员{2},通过手持设备设置离开", roomInfo.Name, enterOutLog.ShortSeatNo, Session["LoginID"]); violationRecords.BlacklistID = "-1"; T_SM_ViolateDiscipline.AddViolationRecords(violationRecords); } } Page.RegisterStartupScript("", "<script>alert('设置读者离开成功');</script>"); GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } else { Page.RegisterStartupScript("", "<script>alert('设置读者离开失败');</script>"); } } } } catch { } break; case "onTime": //计时 try { string seatStr = hidSeatNo.Value; string[] noArr = seatStr.Split(','); string seatNo = ""; for (int i = 0; i < noArr.Length; i++) { seatNo = noArr[i].Trim(); EnterOutLogInfo enterOutLog = T_SM_EnterOutLog.GetUsingEnterOutLogBySeatNo(seatNo); if (enterOutLog != null && enterOutLog.EnterOutState != EnterOutLogType.ShortLeave) { DateTime markTime = ServiceDateTime.Now; EnterOutOperate.UpdateMarkTime(enterOutLog.EnterOutLogID, markTime); GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } } } catch { } break; case "offTime": //取消计时 try { string seatStr = hidSeatNo.Value; string[] noArr = seatStr.Split(','); string seatNo = ""; for (int i = 0; i < noArr.Length; i++) { seatNo = noArr[i].Trim(); EnterOutLogInfo enterOutLog = T_SM_EnterOutLog.GetUsingEnterOutLogBySeatNo(seatNo); if (enterOutLog != null && !string.IsNullOrEmpty(enterOutLog.MarkTime.ToString()) && enterOutLog.MarkTime.CompareTo(DateTime.Parse("1900/1/1")) != 0) { DateTime markTime = DateTime.Parse("1900-1-1"); EnterOutOperate.UpdateMarkTime(enterOutLog.EnterOutLogID, markTime); GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } } } catch { } break; case "AddBlacklist": try { string seatStr = hidSeatNo.Value; string[] noArr = seatStr.Split(','); string seatNo = ""; int newId = -1; RegulationRulesSetting rulesSet = T_SM_SystemSet.GetRegulationRulesSetting(); for (int i = 0; i < noArr.Length; i++) { newId = -1; seatNo = noArr[i].Trim(); EnterOutLogInfo enterOutLog = T_SM_EnterOutLog.GetUsingEnterOutLogBySeatNo(seatNo); if (enterOutLog != null && enterOutLog.EnterOutState != EnterOutLogType.Leave) { ReadingRoomInfo roomInfo = T_SM_ReadingRoom.GetSingleRoomInfo(enterOutLog.ReadingRoomNo); if (roomInfo != null && roomInfo.Setting.BlackListSetting.Used) { BlackListInfo blacklistModel = new BlackListInfo(); blacklistModel.AddTime = ServiceDateTime.Now; blacklistModel.ReadingRoomID = roomInfo.No; blacklistModel.BlacklistState = LogStatus.Valid; blacklistModel.CardNo = enterOutLog.CardNo; blacklistModel.OutBlacklistMode = roomInfo.Setting.BlackListSetting.LeaveBlacklist; if (blacklistModel.OutBlacklistMode == LeaveBlacklistMode.AutomaticMode) { blacklistModel.ReMark = string.Format("管理员{0}通过手持设备{0}把读者加入黑名单,记录黑名单{1}天", Session["LoginID"], roomInfo.Setting.BlackListSetting.LimitDays); blacklistModel.OutTime = blacklistModel.AddTime.AddDays(roomInfo.Setting.BlackListSetting.LimitDays); } else { blacklistModel.ReMark = string.Format("管理员{0}通过手持设备把读者加入黑名单,手动离开黑名单", Session["LoginID"]); } blacklistModel.ReadingRoomID = roomInfo.No; newId = T_SM_Blacklist.AddBlackList(blacklistModel); } else if (rulesSet.BlacklistSet.Used) { BlackListInfo blacklistModel = new BlackListInfo(); blacklistModel.AddTime = ServiceDateTime.Now; blacklistModel.OutTime = blacklistModel.AddTime.AddDays(rulesSet.BlacklistSet.LimitDays); blacklistModel.BlacklistState = LogStatus.Valid; blacklistModel.CardNo = enterOutLog.CardNo; blacklistModel.OutBlacklistMode = rulesSet.BlacklistSet.LeaveBlacklist; if (blacklistModel.OutBlacklistMode == LeaveBlacklistMode.AutomaticMode) { blacklistModel.ReMark = string.Format("管理员{0}通过手持设备把读者加入黑名单,记录黑名单{1}天", Session["LoginID"], rulesSet.BlacklistSet.LimitDays); blacklistModel.OutTime = blacklistModel.AddTime.AddDays(rulesSet.BlacklistSet.LimitDays); } else { blacklistModel.ReMark = string.Format("管理员{0}通过手持设备把读者加入黑名单,手动离开黑名单", Session["LoginID"]); } blacklistModel.ReadingRoomID = roomInfo.No; newId = T_SM_Blacklist.AddBlackList(blacklistModel); } else { Page.RegisterStartupScript("", "<script>alert('对不起,此阅览室以及图书馆没有启用黑名单功能');</script>"); return; } if (newId > 0) { enterOutLog.EnterOutState = EnterOutLogType.Leave; enterOutLog.Flag = Operation.Admin; enterOutLog.Remark = string.Format("在{0},{1}号座位,被管理员{2},通过手持设备设置离开", roomInfo.Name, enterOutLog.ShortSeatNo, Session["LoginID"]); HandleResult result = EnterOutOperate.AddEnterOutLog(enterOutLog, ref newId); if (result == HandleResult.Successed) { Page.RegisterStartupScript("", "<script>alert('设置读者黑名单成功');</script>"); GetSeatList(selectReadingRomm.Items[selectReadingRomm.SelectedIndex].Value, selectSeatState.Items[selectSeatState.SelectedIndex].Value); } else { Page.RegisterStartupScript("", "<script>alert('设置读者黑名单失败');</script>"); } } } } } catch { } break; case "LoginOut": HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } Response.Redirect("../Login.aspx"); break; } #endregion } }
/// <summary> /// 开始计算 /// </summary> private void Statistics() { try { List <ReadingRoomInfo> rooms = ClientConfigOperate.GetReadingRooms(null); DateTime sdt = SeatUsageDataOperating.GetLastRoomUsageStatisticsDate(); if (sdt <= DateTime.Parse("2000-1-1")) { return; } sdt = sdt.AddDays(1); while (true) { //获取进出记录 List <EnterOutLogInfo> enterOutLogList = T_SM_EnterOutLog_bak.GetStatisticsLogsByDate(sdt); List <BespeakLogInfo> bespeakLogList = T_SM_SeatBespeak.GetBespeakList(null, null, sdt, 0, null); List <ViolationRecordsLogInfo> violationLogList = T_SM_ViolateDiscipline.GetViolationRecords(null, null, sdt.ToShortDateString(), sdt.Date.AddDays(1).AddSeconds(-1).ToString(), LogStatus.None, LogStatus.None); //List<BlackListInfo> blacklistList = T_SM_Blacklist.GetAllBlackListInfo(null, LogStatus.None, sdt.ToShortDateString(), sdt.Date.AddDays(1).AddSeconds(-1).ToString()); if (enterOutLogList.Count <= 0 && bespeakLogList.Count <= 0 && violationLogList.Count <= 0 && sdt >= ServiceDateTime.Now.Date.AddDays(-1)) { break; } Dictionary <string, SeatManage.ClassModel.RoomUsageStatistics> roomDir = rooms.ToDictionary(room => room.No, room => new SeatManage.ClassModel.RoomUsageStatistics()); //基本数据及排序处理 foreach (ReadingRoomInfo room in rooms) { roomDir[room.No].StatisticsDate = sdt; roomDir[room.No].ReadingRoomNo = room.No; roomDir[room.No].SeatAllCount = room.SeatList.Seats.Count; roomDir[room.No].OpenTime = DateTime.Parse(room.Setting.GetRoomOpenTimeByDate(sdt).BeginTime); roomDir[room.No].CloseTime = DateTime.Parse(room.Setting.GetRoomOpenTimeByDate(sdt).EndTime); roomDir[room.No].RoomUsageTime = (int)(roomDir[room.No].CloseTime - roomDir[room.No].OpenTime).TotalMinutes; roomDir[room.No].SeatUsageCount = enterOutLogList.FindAll(u => u.ReadingRoomNo == room.No).GroupBy(u => u.SeatNo).Count(); roomDir[room.No].UsedReaderCount = enterOutLogList.FindAll(u => u.ReadingRoomNo == room.No).GroupBy(u => u.CardNo).Count(); roomDir[room.No].CanBesapeakSeat = room.Setting.SeatBespeak.BespeakArea.BespeakType == BespeakAreaType.Percentage ? (int)room.Setting.SeatBespeak.BespeakArea.Scale * room.SeatList.Seats.Count : room.SeatList.Seats.Count(u => u.Value.CanBeBespeak); roomDir[room.No].BespeakedSeat = bespeakLogList.FindAll(u => u.ReadingRoomNo == room.No).GroupBy(u => u.SeatNo).Count(); } foreach (ViolationRecordsLogInfo vrl in violationLogList) { roomDir[vrl.ReadingRoomID].ViolationRecordCount++; switch (vrl.EnterFlag) { case ViolationRecordsType.BookingTimeOut: roomDir[vrl.ReadingRoomID].VRBookingTimeOut++; break; case ViolationRecordsType.LeaveByAdmin: roomDir[vrl.ReadingRoomID].VRLeaveByAdmin++; break; case ViolationRecordsType.LeaveNotReadCard: roomDir[vrl.ReadingRoomID].VRLeaveNotReadCard++; break; case ViolationRecordsType.SeatOutTime: roomDir[vrl.ReadingRoomID].VRSeatOutTime++; break; case ViolationRecordsType.ShortLeaveByAdminOutTime: roomDir[vrl.ReadingRoomID].VRShortLeaveByAdminOutTime++; break; case ViolationRecordsType.ShortLeaveByReaderOutTime: roomDir[vrl.ReadingRoomID].VRShortLeaveByReaderOutTime++; break; case ViolationRecordsType.ShortLeaveByServiceOutTime: roomDir[vrl.ReadingRoomID].VRShortLeaveByServiceOutTime++; break; case ViolationRecordsType.ShortLeaveOutTime: roomDir[vrl.ReadingRoomID].VRShortLeaveOutTime++; break; } } //预约记录处理 foreach (BespeakLogInfo bli in bespeakLogList) { roomDir[bli.ReadingRoomNo].AllBespeakCount++; if (bli.BsepeakTime.Date == bli.SubmitTime.Date) { switch (bli.BsepeakState) { case BookingStatus.Cencaled: switch (bli.CancelPerson) { case Operation.Admin: case Operation.Reader: roomDir[bli.ReadingRoomNo].NowDayBespeakCancel++; break; case Operation.Service: roomDir[bli.ReadingRoomNo].NowDayBespeakOverTime++; break; } break; case BookingStatus.Confinmed: roomDir[bli.ReadingRoomNo].NowDayBespeakCheck++; break; } roomDir[bli.ReadingRoomNo].NowDayBespeakCount++; } else { switch (bli.BsepeakState) { case BookingStatus.Cencaled: switch (bli.CancelPerson) { case Operation.Admin: case Operation.Reader: roomDir[bli.ReadingRoomNo].BespeakCancel++; break; case Operation.Service: roomDir[bli.ReadingRoomNo].BespeakOverTime++; break; } break; case BookingStatus.Confinmed: roomDir[bli.ReadingRoomNo].BespeakCheck++; break; } roomDir[bli.ReadingRoomNo].BespeakCount++; } } foreach (EnterOutLogInfo eol in enterOutLogList) { //刷卡次数 if (!string.IsNullOrEmpty(eol.TerminalNum) && !(eol.EnterOutState == EnterOutLogType.ContinuedTime && eol.Flag == Operation.Service)) { roomDir[eol.ReadingRoomNo].RushCardOperatingCount++; } //记录类型 switch (eol.EnterOutState) { case EnterOutLogType.BookingConfirmation: roomDir[eol.ReadingRoomNo].CheckBespeakCount++; if (string.IsNullOrEmpty(eol.TerminalNum)) { roomDir[eol.ReadingRoomNo].CkeckBespeakInOtherClient++; } else { roomDir[eol.ReadingRoomNo].CheckBespeakInSeatClient++; } break; case EnterOutLogType.ComeBack: roomDir[eol.ReadingRoomNo].ComeBackCount++; switch (eol.Flag) { case Operation.Admin: roomDir[eol.ReadingRoomNo].ComeBackByAdmin++; break; case Operation.OtherReader: roomDir[eol.ReadingRoomNo].ComeBackByOtherReader++; break; case Operation.Reader: roomDir[eol.ReadingRoomNo].ComeBackByReader++; if (string.IsNullOrEmpty(eol.TerminalNum)) { roomDir[eol.ReadingRoomNo].ComeBackInOtherClient++; } else { roomDir[eol.ReadingRoomNo].ComeBackInSeatClient++; } break; } EnterOutLogInfo slEOL = enterOutLogList.FindLast(u => u.EnterOutState == EnterOutLogType.ShortLeave && u.EnterOutLogNo == eol.EnterOutLogNo && u.EnterOutTime < eol.EnterOutTime); if (slEOL != null) { roomDir[eol.ReadingRoomNo].ShortLeaveTime += (int)(slEOL.EnterOutTime - eol.EnterOutTime).TotalMinutes; } break; case EnterOutLogType.ContinuedTime: roomDir[eol.ReadingRoomNo].ContinueTimeCount++; switch (eol.Flag) { case Operation.Service: roomDir[eol.ReadingRoomNo].ContinueTimeByService++; break; case Operation.Reader: roomDir[eol.ReadingRoomNo].ContinueTimeByReader++; if (string.IsNullOrEmpty(eol.TerminalNum)) { roomDir[eol.ReadingRoomNo].ContinueTimeInOtherClient++; } else { roomDir[eol.ReadingRoomNo].ContinueTimeInSeatClient++; } break; } break; case EnterOutLogType.Leave: roomDir[eol.ReadingRoomNo].LeaveCount++; roomDir[eol.ReadingRoomNo].ReaderUsageCount++; switch (eol.Flag) { case Operation.Service: roomDir[eol.ReadingRoomNo].LeaveByService++; break; case Operation.Admin: roomDir[eol.ReadingRoomNo].LeaveByAdmin++; break; case Operation.Reader: roomDir[eol.ReadingRoomNo].LeaveByReader++; if (string.IsNullOrEmpty(eol.TerminalNum)) { roomDir[eol.ReadingRoomNo].LeaveInOtherClient++; } else { roomDir[eol.ReadingRoomNo].LeaveInSeatClient++; } break; } EnterOutLogInfo enterEOL = enterOutLogList.Find(u => (u.EnterOutState == EnterOutLogType.BookingConfirmation || u.EnterOutState == EnterOutLogType.ReselectSeat || u.EnterOutState == EnterOutLogType.SelectSeat || u.EnterOutState == EnterOutLogType.WaitingSuccess) && u.EnterOutLogNo == eol.EnterOutLogNo); if (enterEOL != null) { roomDir[eol.ReadingRoomNo].SeatUsageTime += (int)(eol.EnterOutTime - enterEOL.EnterOutTime).TotalMinutes; } break; case EnterOutLogType.ReselectSeat: roomDir[eol.ReadingRoomNo].ReselectSeatCount++; if (string.IsNullOrEmpty(eol.TerminalNum)) { roomDir[eol.ReadingRoomNo].ReselectSeatInOtherClient++; } else { roomDir[eol.ReadingRoomNo].ReselectSeatInSeatClient++; } break; case EnterOutLogType.SelectSeat: roomDir[eol.ReadingRoomNo].SelectSeatCount++; switch (eol.Flag) { case Operation.Admin: roomDir[eol.ReadingRoomNo].SelectSeatByAdmin++; break; case Operation.Reader: roomDir[eol.ReadingRoomNo].SelectSeatByReader++; if (string.IsNullOrEmpty(eol.TerminalNum)) { roomDir[eol.ReadingRoomNo].SelectSeatInOtherClient++; } else { roomDir[eol.ReadingRoomNo].SelectSeatInSeatClient++; } break; } break; case EnterOutLogType.ShortLeave: roomDir[eol.ReadingRoomNo].ShortLeaveCount++; switch (eol.Flag) { case Operation.OtherReader: roomDir[eol.ReadingRoomNo].ShortLeaveByOtherReader++; break; case Operation.Service: roomDir[eol.ReadingRoomNo].ShortLeaveByService++; break; case Operation.Admin: roomDir[eol.ReadingRoomNo].ShortLeaveByAdmin++; break; case Operation.Reader: roomDir[eol.ReadingRoomNo].ShortLeaveByReader++; if (string.IsNullOrEmpty(eol.TerminalNum)) { roomDir[eol.ReadingRoomNo].ShortLeaveInOtherClient++; } else { roomDir[eol.ReadingRoomNo].ShortLeaveInSeatClient++; } break; } break; case EnterOutLogType.WaitingSuccess: roomDir[eol.ReadingRoomNo].WaitSeatCount++; break; } } foreach (SeatManage.ClassModel.RoomUsageStatistics roomUS in roomDir.Values.Where(roomUS => !SeatUsageDataOperating.AddRoomUsageStatistics(roomUS))) { WriteLog.Write(string.Format("数据统计服务:添加阅览室:{0} {1} 数据统计出错", roomUS.ReadingRoomNo, roomUS.StatisticsDate)); throw new Exception(string.Format("数据统计服务:添加阅览室:{0} {1} 数据统计出错", roomUS.ReadingRoomNo, roomUS.StatisticsDate)); } sdt = sdt.AddDays(1); if (sdt >= ServiceDateTime.Now.Date) { break; } roomDir = null; } WriteLog.Write("数据统计服务:统计阅览室完成使用情况完成"); } catch (Exception ex) { WriteLog.Write(string.Format("数据统计服务:统计阅览室使用情况失败:{0}", ex.Message)); } }