/// <summary> /// 提交预约信息 /// </summary> /// <param name="bespeakInfo"></param> /// <returns></returns> public string SubmitBespeakInfo(ClassModel.BespeakLogInfo bespeakInfo) { string returnValue = ""; List <BespeakLogInfo> bespeak = seatManage.GetBespeakLogInfo(bespeakInfo.CardNo, bespeakInfo.BsepeakTime); List <BespeakLogInfo> seatbespeak = seatManage.GetBespeakLogInfoBySeatNo(bespeakInfo.SeatNo, bespeakInfo.BsepeakTime); List <ReadingRoomInfo> rooms = seatManage.GetReadingRooms(new List <string>() { bespeakInfo.ReadingRoomNo }, null, null); if (rooms.Count == 0) { throw new SeatBespeakException.BespeakSeatFailed("获取阅览室信息失败。"); } if (rooms[0].Setting.SeatBespeak.CanBookMultiSpan && rooms[0].Setting.SeatBespeak.SpecifiedTime) { if (bespeak.Count >= rooms[0].Setting.SeatBespeak.BespeakSeatCount) { throw new SeatBespeakException.BespeakSeatFailed("对不起,您一天最多预约" + rooms[0].Setting.SeatBespeak.BespeakSeatCount + "个座位。"); } foreach (BespeakLogInfo b in bespeak) { if (b.BsepeakTime == bespeakInfo.BsepeakTime && b.BsepeakState == BookingStatus.Waiting) { throw new SeatBespeakException.BespeakSeatFailed("对不起,同一时间段只能预约一个座位。"); } } foreach (BespeakLogInfo b in seatbespeak) { if (b.BsepeakTime == bespeakInfo.BsepeakTime) { throw new SeatBespeakException.BespeakSeatFailed("对不起,此时间段已被预约。"); } } } else { if (bespeak.Count > 0) { throw new SeatBespeakException.BespeakSeatFailed("对不起,当前日期您已有等待签到的座位。"); } foreach (BespeakLogInfo b in seatbespeak) { if (b.BsepeakState == EnumType.BookingStatus.Waiting) { throw new Exception("所选座位已经被预约。"); } } } List <BlackListInfo> blackLog = seatManage.GetBlacklistInfo(bespeakInfo.CardNo); if (blackLog.Count > 0) { throw new SeatBespeakException.BespeakSeatFailed("你已被记录黑名单,无法预约座位。"); } if (rooms[0].Setting.SeatBespeak.BespeakArea.BespeakType == BespeakAreaType.Percentage) { List <BespeakLogInfo> bespeaklogs = seatManage.GetBespeakLogInfoByRoomsNum(new List <string>() { bespeakInfo.ReadingRoomNo }, bespeakInfo.BsepeakTime); int canbookCount = (int)((rooms[0].SeatList.Seats.Count - rooms[0].SeatList.Seats.Where(u => u.Value.IsSuspended).ToArray().Count()) * rooms[0].Setting.SeatBespeak.BespeakArea.Scale); if (bespeaklogs.Count >= canbookCount) { throw new SeatBespeakException.BespeakSeatFailed("对不起当前阅览室已经没有可预约的座位。"); } } if (rooms.Count > 0) { ReadingRoomInfo r = rooms[0]; if (r.Setting.IsCanBespeakSeat(bespeakInfo.BsepeakTime)) { throw new SeatBespeakException.BespeakSeatFailed("对不起当前时间不开放预约。"); } if (dateBespeak(r.Setting.SeatBespeak, bespeakInfo.BsepeakTime, DateTime.Now))//验证日期是否合法。 { EnumType.HandleResult result = seatManage.AddBespeakLogInfo(bespeakInfo); if (result == EnumType.HandleResult.Successed) { string beginTime = bespeakInfo.BsepeakTime.AddMinutes(-double.Parse(r.Setting.SeatBespeak.ConfirmTime.BeginTime)).ToShortTimeString(); string endTime = bespeakInfo.BsepeakTime.AddMinutes(double.Parse(r.Setting.SeatBespeak.ConfirmTime.EndTime)).ToShortTimeString(); returnValue = string.Format("座位预约成功,请在{0}至{1}到图书馆刷卡确认", beginTime, endTime); } else { throw new SeatBespeakException.BespeakSeatFailed("所选座位已经被预约。"); } } else { throw new SeatBespeakException.BespeakSeatFailed("选择的日期不允许预约。"); } } return(returnValue); }
/// <summary> /// 获取 /// </summary> /// <param name="bespeakInfo"></param> /// <returns></returns> public string SubmitNowDayBespeakInfo(BespeakLogInfo bespeakInfo) { string returnValue = ""; List <BespeakLogInfo> seatbespeak = seatManage.GetBespeakLogInfoBySeatNo(bespeakInfo.SeatNo, bespeakInfo.BsepeakTime); List <ReadingRoomInfo> rooms = seatManage.GetReadingRooms(new List <string>() { bespeakInfo.ReadingRoomNo }, null, null); if (rooms.Count == 0) { throw new SeatBespeakException.BespeakSeatFailed("获取阅览室信息失败。"); } List <BespeakLogInfo> bespeak = seatManage.GetBespeakLogs(bespeakInfo.CardNo, null, bespeakInfo.BsepeakTime, 0, new List <SeatManage.EnumType.BookingStatus> { SeatManage.EnumType.BookingStatus.Confinmed, SeatManage.EnumType.BookingStatus.Waiting }); //.GetBespeakList(this.LoginId, null, date, 0, bespeakStatus); if (bespeak.Count >= rooms[0].Setting.SeatBespeak.BespeakSeatCount) { throw new SeatBespeakException.BespeakSeatFailed("对不起,您一天最多预约" + rooms[0].Setting.SeatBespeak.BespeakSeatCount + "个座位。"); } //判断读者是否有座位 if (!rooms[0].Setting.SeatBespeak.BespeatWithOnSeat) { SeatManage.ClassModel.EnterOutLogInfo eol = seatManage.GetEnterOutLogInfoByCardNo(bespeakInfo.CardNo); if (eol != null && eol.EnterOutState != SeatManage.EnumType.EnterOutLogType.Leave) { throw new SeatBespeakException.BespeakSeatFailed("您已有座位,不能再预约座位"); } } if (rooms[0].Setting.SeatBespeak.CanBookMultiSpan && rooms[0].Setting.SeatBespeak.SpecifiedTime) { foreach (BespeakLogInfo b in seatbespeak) { if (b.BsepeakTime == bespeakInfo.BsepeakTime) { throw new SeatBespeakException.BespeakSeatFailed("对不起,此时间段已被预约。"); } } foreach (BespeakLogInfo b in bespeak) { if (b.BsepeakTime == bespeakInfo.BsepeakTime && b.BsepeakState == BookingStatus.Waiting) { throw new SeatBespeakException.BespeakSeatFailed("对不起,同一时间段只能预约一个座位。"); } } if (bespeakInfo.SubmitTime == bespeakInfo.BsepeakTime) { foreach (BespeakLogInfo b in bespeak) { if (b.BsepeakTime == b.SubmitTime && b.BsepeakState == BookingStatus.Waiting) { throw new SeatBespeakException.BespeakSeatFailed("对不起,只能同时进行一次及时预约。"); } } } } else { foreach (BespeakLogInfo b in bespeak) { if (b.BsepeakState == BookingStatus.Waiting) { throw new SeatBespeakException.BespeakSeatFailed("对不起,您已有等待签到的座位。"); } } foreach (BespeakLogInfo b in seatbespeak) { if (b.BsepeakState == EnumType.BookingStatus.Waiting) { throw new Exception("所选座位已经被预约。"); } } } List <BlackListInfo> blackLog = seatManage.GetBlacklistInfo(bespeakInfo.CardNo); if (blackLog.Count > 0) { throw new SeatBespeakException.BespeakSeatFailed("你已被记录黑名单,无法预约座位。"); } if (rooms.Count > 0) { ReadingRoomInfo r = rooms[0]; EnumType.HandleResult result = seatManage.AddBespeakLogInfo(bespeakInfo); if (result == EnumType.HandleResult.Successed) { string beginTime; string endTime; if (bespeakInfo.SubmitTime == bespeakInfo.BsepeakTime) { beginTime = bespeakInfo.BsepeakTime.ToShortTimeString(); endTime = bespeakInfo.BsepeakTime.AddMinutes(r.Setting.SeatBespeak.SeatKeepTime).ToShortTimeString(); } else { beginTime = bespeakInfo.BsepeakTime.AddMinutes(-double.Parse(r.Setting.SeatBespeak.ConfirmTime.BeginTime)).ToShortTimeString(); endTime = bespeakInfo.BsepeakTime.AddMinutes(double.Parse(r.Setting.SeatBespeak.ConfirmTime.EndTime)).ToShortTimeString(); } returnValue = string.Format("座位预约成功,请在{0}至{1}到图书馆刷卡确认", beginTime, endTime); } else { throw new SeatBespeakException.BespeakSeatFailed("所选座位已经被预约。"); } } return(returnValue); }