private void GetQueueForSupervisee(string userId) { Session session = Session.Instance; Trinity.BE.User dutyOfficer = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; DAL_Appointments dalAppointment = new DAL_Appointments(); Trinity.DAL.DBContext.Appointment appointment = dalAppointment.GetAppointmentByDate(userId, DateTime.Today); if (appointment != null) { //var responseResult= _Appointment.GetTimeslotNearestAppointment(); DAL_QueueNumber dalQueue = new DAL_QueueNumber(); Trinity.DAL.DBContext.Timeslot timeslot = dalQueue.GetTimeSlotEmpty(); var response = dalAppointment.UpdateTimeslotForApptmt(appointment.ID, timeslot.Timeslot_ID); appointment = response; Trinity.DAL.DBContext.Queue queueNumber = dalQueue.InsertQueueNumber(appointment.ID, appointment.UserId, EnumStation.ARK, dutyOfficer.UserId); } }
private void GetMyQueueNumber() { // Get current user Session session = Session.Instance; Trinity.BE.User currentUser = (Trinity.BE.User)session[CommonConstants.USER_LOGIN]; Trinity.BE.User supervisee = null; if (currentUser.Role == EnumUserRoles.DutyOfficer) { supervisee = (Trinity.BE.User)session[CommonConstants.SUPERVISEE]; } else { supervisee = currentUser; } DAL_Appointments _Appointment = new DAL_Appointments(); Trinity.DAL.DBContext.Appointment appointment = new DAL_Appointments().GetAppointmentByDate(supervisee.UserId, DateTime.Today); var _dalQueue = new DAL_QueueNumber(); Trinity.DAL.DBContext.Queue queueNumber = null; if (!_dalQueue.IsUserAlreadyQueue(supervisee.UserId, DateTime.Today)) { if (appointment != null) { if (string.IsNullOrEmpty(appointment.Timeslot_ID) && currentUser.Role == EnumUserRoles.Supervisee) { _web.ShowMessage("You have not selected a timeslot!"); BookAppointment(); } else { queueNumber = _dalQueue.InsertQueueNumber(appointment.ID, appointment.UserId, EnumStation.ARK, currentUser.UserId); var dalLabel = new DAL_Labels(); string MarkingNumber = dalLabel.GetMarkingNumber(supervisee.UserId, DateTime.Today); if (string.IsNullOrEmpty(MarkingNumber)) { MarkingNumber = new DAL_SettingSystem().GenerateMarkingNumber(); } dalLabel.Insert(new Trinity.BE.Label { UserId = supervisee.UserId, Label_Type = EnumLabelType.TT, CompanyName = CommonConstants.COMPANY_NAME, MarkingNo = MarkingNumber, NRIC = supervisee.NRIC, Name = supervisee.Name, LastStation = EnumStation.ARK, Queue_ID = queueNumber.Queue_ID }); dalLabel.Insert(new Trinity.BE.Label { UserId = supervisee.UserId, Label_Type = EnumLabelType.MUB, CompanyName = CommonConstants.COMPANY_NAME, MarkingNo = MarkingNumber, NRIC = supervisee.NRIC, Name = supervisee.Name, LastStation = EnumStation.ARK, Queue_ID = queueNumber.Queue_ID }); Trinity.SignalR.Client.Instance.AppointmentReported(queueNumber.Queue_ID.ToString().Trim(), queueNumber.Appointment_ID.ToString().Trim()); Trinity.SignalR.Client.Instance.QueueInserted(queueNumber.Queue_ID.ToString().Trim()); APIUtils.FormQueueNumber.RefreshQueueNumbers(); this._web.ShowMessage("Your queue number is:" + queueNumber.QueuedNumber); } } else { queueNumber = _dalQueue.InsertQueueNumberFromDO(supervisee.UserId, EnumStation.ARK, currentUser.UserId); var dalLabel = new DAL_Labels(); string MarkingNumber = dalLabel.GetMarkingNumber(supervisee.UserId, DateTime.Today); if (string.IsNullOrEmpty(MarkingNumber)) { MarkingNumber = new DAL_SettingSystem().GenerateMarkingNumber(); } dalLabel.Insert(new Trinity.BE.Label { UserId = supervisee.UserId, Label_Type = EnumLabelType.TT, CompanyName = CommonConstants.COMPANY_NAME, MarkingNo = MarkingNumber, NRIC = supervisee.NRIC, Name = supervisee.Name, LastStation = EnumStation.ARK, Queue_ID = queueNumber.Queue_ID }); dalLabel.Insert(new Trinity.BE.Label { UserId = supervisee.UserId, Label_Type = EnumLabelType.MUB, CompanyName = CommonConstants.COMPANY_NAME, MarkingNo = MarkingNumber, NRIC = supervisee.NRIC, Name = supervisee.Name, LastStation = EnumStation.ARK, Queue_ID = queueNumber.Queue_ID }); Trinity.SignalR.Client.Instance.QueueInserted(queueNumber.Queue_ID.ToString().Trim()); APIUtils.FormQueueNumber.RefreshQueueNumbers(); this._web.ShowMessage("Your queue number is:" + queueNumber.QueuedNumber); } //if (appointment != null && string.IsNullOrEmpty(appointment.Timeslot_ID)) //{ // var eventCenter = Trinity.Common.Common.EventCenter.Default; // eventCenter.RaiseEvent(new Trinity.Common.EventInfo() { Name = EventNames.ALERT_MESSAGE, Message = "You have not selected the timeslot!\n Please go to Book Appointment page to select a timeslot." }); //} //else if (appointment != null && !string.IsNullOrEmpty(appointment.Timeslot_ID)) //{ // queueNumber = _dalQueue.InsertQueueNumber(appointment.ID, appointment.UserId, EnumStation.ARK, currentUser.UserId); // if (queueNumber != null) // { // Trinity.SignalR.Client.Instance.AppointmentBookedOrReported(appointment.ID.ToString().Trim(), EnumAppointmentStatuses.Reported); // Trinity.SignalR.Client.Instance.QueueInserted(queueNumber.Queue_ID.ToString().Trim()); // APIUtils.FormQueueNumber.RefreshQueueNumbers(); // var eventCenter = Trinity.Common.Common.EventCenter.Default; // eventCenter.RaiseEvent(new Trinity.Common.EventInfo() { Name = EventNames.ALERT_MESSAGE, Message = "Your queue number is:" + queueNumber.QueuedNumber }); // } // else // { // this._web.ShowMessage("Sorry all timeslots are fully booked!"); // } //} //else //{ //} } else { this._web.ShowMessage("You already registered a queue number!\n Please wait for your turn."); } //if (appointment == null && currentUser.Role == EnumUserRoles.Supervisee) //{ // var eventCenter = Trinity.Common.Common.EventCenter.Default; // eventCenter.RaiseEvent(new Trinity.Common.EventInfo() { Name = EventNames.ALERT_MESSAGE, Message = "You have no appointment today" }); //} //else //{ //} }