Exemplo n.º 1
0
        public void TapSmartCardOnQueueSucceed(string queueId)
        {
            DAL_QueueNumber dalQueue    = new DAL_QueueNumber();
            var             queueDetail = dalQueue.GetQueueInfoByQueueID(new Guid(queueId));

            if (queueDetail != null)
            {
                string resultUT = GetResultUT(queueDetail.NRIC, queueDetail.Date);

                if (resultUT == EnumUTResult.NEG)
                {
                    var drugResult = new DAL_DrugResults().GetByNRICAndUploadedDate(queueDetail.NRIC, queueDetail.Date);
                    if (drugResult != null && drugResult.IsSealed.Value)
                    {
                        this._web.InvokeScript("openPopupOutcome", queueId);
                    }
                    else
                    {
                        dalQueue.UpdateQueueStatusByUserId(queueDetail.UserId, EnumStation.DUTYOFFICER, EnumQueueStatuses.Finished, EnumStation.DUTYOFFICER, EnumQueueStatuses.Finished, "", EnumQueueOutcomeText.UnconditionalRelease);

                        // Re-load queue
                        this._web.InvokeScript("reloadDataQueues");
                    }
                }
                else
                {
                    this._web.InvokeScript("openPopupOutcome", queueId);
                }
            }
        }
Exemplo n.º 2
0
 private void GetCardInfoSucceeded(string cardUID)
 {
     if (!_isFirstTimeLoaded)
     {
         Lib.LayerWeb.Invoke((MethodInvoker)(() =>
         {
             if (GetCurrentTab() == EnumDOTabName.Queue)
             {
                 DAL_User dAL_User = new DAL_User();
                 Trinity.BE.User user = dAL_User.GetUserBySmartCardId(cardUID);
                 if (user != null)
                 {
                     var queue = new DAL_QueueNumber().GetMyQueueToday(user.UserId);
                     if (queue != null && queue.QueueDetails.Any(d => d.Station == EnumStation.DUTYOFFICER && d.Status == EnumQueueStatuses.TabSmartCard))
                     {
                         if (_jsCallCS.GetResultUT(user.NRIC, DateTime.Now.Date) == EnumUTResult.NEG && queue.QueueDetails.Any(d => d.Station == EnumStation.SSP && d.Status == EnumQueueStatuses.NotRequired))
                         {
                             new DAL_QueueNumber().UpdateQueueStatusByUserId(user.UserId, EnumStation.DUTYOFFICER, EnumQueueStatuses.Finished, EnumStation.DUTYOFFICER, EnumQueueStatuses.Finished, string.Empty, EnumQueueOutcomeText.UnconditionalRelease);
                             this.LayerWeb.InvokeScript("reloadDataQueues");
                         }
                         else
                         {
                             this.LayerWeb.LoadPopupHtml("QueuePopupOutcome.html", new
                             {
                                 UserId = user.UserId,
                                 Name = user.Name
                             });
                         }
                     }
                 }
             }
         }));
     }
 }
Exemplo n.º 3
0
 public void QueueFinished(string UserId)
 {
     if (IsConnected)
     {
         Queue queue = new DAL_QueueNumber().GetMyQueueToday(UserId);
         HubProxy.Invoke("QueueFinished", queue);
     }
 }
Exemplo n.º 4
0
        private static List <Trinity.DAL.DBContext.Queue> GetAllNextQueue(List <Trinity.BE.Queue> allQueue)
        {
            var appointment = new DAL_Appointments().GetAppointmentByID(allQueue[0].AppointmentId);
            //var nextTimeslot = new DAL_Setting().GetNextTimeslotToday(appointment.Timeslot.StartTime.Value);
            var allNextQueue = new DAL_QueueNumber().GetAllQueueByNextimeslot(appointment.Timeslot.StartTime.Value, EnumStation.ARK);

            return(allNextQueue);
        }
Exemplo n.º 5
0
        public void SaveOutcome(string UserID, string outcome)
        {
            DAL_QueueNumber dalQueue = new DAL_QueueNumber();

            dalQueue.UpdateQueueStatusByUserId(UserID, EnumStation.DUTYOFFICER, EnumQueueStatuses.Finished, EnumStation.DUTYOFFICER, EnumQueueStatuses.Finished, "", outcome);

            // Re-load queue
            this._web.InvokeScript("reloadDataQueues");
        }
Exemplo n.º 6
0
        public void OnEventPrintFinished()
        {
            if (_PrintMUBSucceed && _PrintTTSucceed)
            {
                // Update queue status is finished
                Session         session     = Session.Instance;
                Trinity.BE.User currentUser = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
                if (currentUser == null)
                {
                    // Check why current user is null
                    this._web.RunScript("$('.status-text').css('color','#000').text('The current user is null');");
                    return;
                }
                Trinity.BE.User supervisee = null;
                if (currentUser.Role == EnumUserRoles.DutyOfficer)
                {
                    supervisee = (Trinity.BE.User)session[CommonConstants.SUPERVISEE];
                }
                else
                {
                    supervisee = currentUser;
                }
                var dalQueue = new DAL_QueueNumber();
                dalQueue.UpdateQueueStatusByUserId(supervisee.UserId, EnumStation.SSA, EnumQueueStatuses.Finished, EnumStation.UHP, EnumQueueStatuses.Processing, "", EnumQueueOutcomeText.Processing);
                //this._web.LoadPageHtml("PrintingMUBAndTTLabels.html");
                //this._web.RunScript("$('#WaitingSection').hide();$('#CompletedSection').show(); ; ");
                //this._web.RunScript("$('.status-text').css('color','#000').text('Please collect your labels');");
                //this._web.InvokeScript("countdownLogout");

                DeleteQRCodeImageFileTemp();

                CheckMUBPrintingLabellingProgress();
                this._web.RunScript("$('.status-text').css('color','#000').text('Printing and labelling is in progress...');");
                this._web.RunScript("$('#ConfirmBtn').html('Waiting...');");
                this._web.RunScript("$('#lblNextAction').text('CheckIfMUBIsRemoved');");
            }
            else
            {
                _popupModel.Title         = "Printing Failed";
                _popupModel.Message       = "Unable to print labels.\nPlease report to the Duty Officer";
                _popupModel.IsShowLoading = false;
                _popupModel.IsShowOK      = true;

                if (_PrintTTSucceed)
                {
                    _popupModel.Message = "Unable to print MUB labels.\nPlease report to the Duty Officer";
                }
                if (_PrintMUBSucceed)
                {
                    _popupModel.Message = "Unable to print TT labels.\nPlease report to the Duty Officer";
                }
                this._web.InvokeScript("showPopupModal", JsonConvert.SerializeObject(_popupModel));
            }
        }
Exemplo n.º 7
0
        private void PrintTTLabels_OnPrintTTLabelSucceeded(object sender, PrintMUBAndTTLabelsEventArgs e)
        {
            try
            {
                _PrintTTSucceed = true;
                var labelInfo = new Trinity.BE.Label
                {
                    UserId      = e.LabelInfo.UserId,
                    Label_Type  = EnumLabelType.TT,
                    CompanyName = e.LabelInfo.CompanyName,
                    MarkingNo   = e.LabelInfo.MarkingNo,
                    //DrugType = e.LabelInfo.DrugType,
                    NRIC          = e.LabelInfo.NRIC,
                    Name          = e.LabelInfo.Name,
                    Date          = DateTime.Now,
                    LastStation   = e.LabelInfo.LastStation,
                    PrintCount    = e.LabelInfo.PrintCount,
                    ReprintReason = e.LabelInfo.ReprintReason
                };

                var dalLabel = new DAL_Labels();
                var update   = dalLabel.UpdateLabel(labelInfo);
                if (update != null)
                {
                    var dalAppointment = new DAL_Appointments();
                    var dalQueue       = new DAL_QueueNumber();
                    var appointment    = dalAppointment.GetTodayAppointmentByUserId(labelInfo.UserId);
                    //var appointment = result.Data;

                    if (appointment != null)
                    {
                        var sskQueue = new DAL_QueueNumber().GetQueueDetailByAppointment(appointment, EnumStation.SSK);

                        dalQueue.UpdateQueueStatus(sskQueue.Queue_ID, EnumQueueStatuses.Finished, EnumStation.SSK);
                        dalQueue.UpdateQueueStatus(sskQueue.Queue_ID, EnumQueueStatuses.Processing, EnumStation.SSA);
                    }
                    //this._web.RunScript("$('#WaitingSection').hide();$('#CompletedSection').show(); ; ");
                    //this._web.RunScript("$('.status-text').css('color','#000').text('Please collect your labels');");

                    //DeleteQRCodeImageFileTemp();
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        public void LoadPopupQueue(string queue_ID)
        {
            var dalQueue = new DAL_QueueNumber();

            Trinity.BE.QueueInfo queueInfo = dalQueue.GetQueueInfoByQueueID(new Guid(queue_ID));
            if (queueInfo.CurrentStation == EnumStation.UT)
            {
                if (queueInfo.Status == EnumQueueStatuses.Finished || queueInfo.Status == EnumQueueStatuses.SelectSealOrDiscard)
                {
                    queueInfo.Status = GetResultUT(queueInfo.NRIC, queueInfo.Date.Date);
                }
                else if (queueInfo.Status != EnumQueueStatuses.Errors)
                {
                    queueInfo.Status = string.Empty;
                }
            }
            this._web.LoadPopupHtml("QueuePopupDetail.html", queueInfo);
        }
Exemplo n.º 10
0
        public void SaveDrugTest(string UserId, bool COCA, bool BARB, bool LSD, bool METH, bool MTQL, bool PCP, bool KET, bool BUPRE, bool CAT, bool PPZ, bool NPS)
        {
            Session session = Session.Instance;

            Trinity.BE.User dutyOfficer = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            DAL_DrugResults dalDrug     = new DAL_DrugResults();

            dalDrug.UpdateDrugSeal(UserId, COCA, BARB, LSD, METH, MTQL, PCP, KET, BUPRE, CAT, PPZ, NPS, dutyOfficer.UserId);
            var dalQueue = new DAL_QueueNumber();

            dalQueue.UpdateQueueStatusByUserId(UserId, EnumStation.UT, EnumQueueStatuses.Finished, EnumStation.SSP, EnumQueueStatuses.Processing, "Waiting for SSP", EnumQueueOutcomeText.Processing);


            var    user          = new DAL_User().GetUserById(UserId);
            var    dalLabel      = new DAL_Labels();
            string MarkingNumber = dalLabel.GetMarkingNumber(user.UserId, DateTime.Today);

            if (string.IsNullOrEmpty(MarkingNumber))
            {
                MarkingNumber = new DAL_SettingSystem().GenerateMarkingNumber();
            }
            var myQueue = dalQueue.GetMyQueueToday(user.UserId);

            dalLabel.Insert(new Trinity.BE.Label
            {
                UserId      = UserId,
                Label_Type  = EnumLabelType.UB,
                CompanyName = CommonConstants.COMPANY_NAME,
                MarkingNo   = MarkingNumber,
                NRIC        = user.NRIC,
                Name        = user.Name,
                DrugType    = dalDrug.GetResultUTByNRIC(user.NRIC, DateTime.Today),
                Queue_ID    = myQueue.Queue_ID,
                LastStation = EnumStation.DUTYOFFICER
            });
        }
Exemplo n.º 11
0
        public void Start()
        {
            Trinity.BE.User supervisee = _jsCallCS.getSuperviseeLogin();
            if (supervisee == null)
            {
                _jsCallCS.LogOut();
                return;
            }

            LabelInfo labelInfo = null;

            if (supervisee.Role.Equals(EnumUserRoles.USA, StringComparison.OrdinalIgnoreCase))
            {
                var dalLabel = new DAL_Labels();
                var lable    = dalLabel.GetByUserID(supervisee.UserId, EnumLabelType.MUB, DateTime.Today);
                if (lable == null)
                {
                    string 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.ALK
                    });
                    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.ALK
                    });
                    lable = dalLabel.GetByUserID(supervisee.UserId, EnumLabelType.MUB, DateTime.Today);
                }
                labelInfo = new LabelInfo
                {
                    UserId      = lable.UserId,
                    Name        = lable.Name,
                    NRIC        = lable.NRIC,
                    Label_Type  = EnumLabelType.MUB,
                    Date        = DateTime.Now.ToString("dd/MM/yyyy"),
                    CompanyName = lable.CompanyName,
                    LastStation = EnumStation.ALK,
                    MarkingNo   = lable.MarkingNo,
                    DrugType    = "NA",
                    QRCode      = lable.QRCode
                };
            }
            else if (supervisee.Role.Equals(EnumUserRoles.Supervisee, StringComparison.OrdinalIgnoreCase))
            {
                var dalQueue = new DAL_QueueNumber();
                var myQueue  = dalQueue.GetMyQueueToday(supervisee.UserId);
                if (myQueue == null)
                {
                    _web.ShowMessage("Please register for a queue number at " + EnumStation.ARK + " first.");
                    _jsCallCS.LogOut();
                    return;
                }
                else if (myQueue != null && myQueue.QueueDetails.Any(d => d.Station == EnumStation.ARK && d.Status == EnumQueueStatuses.Waiting))
                {
                    _web.ShowMessage("Please wait for your queue number to appear under the \"Now Serving\" list.");
                    _jsCallCS.LogOut();
                    return;
                }

                dalQueue.UpdateQueueStatusByUserId(supervisee.UserId, EnumStation.ARK, EnumQueueStatuses.Processing, EnumStation.ALK, EnumQueueStatuses.Processing, "Printing MUB/TT labels", EnumQueueOutcomeText.Processing);
                var    lable     = new DAL_Labels().GetByUserID(supervisee.UserId, EnumLabelType.MUB, DateTime.Today);
                string markingNo = lable.MarkingNo;
                labelInfo = new LabelInfo
                {
                    UserId      = lable.UserId,
                    Name        = lable.Name,
                    NRIC        = lable.NRIC,
                    Label_Type  = EnumLabelType.MUB,
                    Date        = DateTime.Now.ToString("dd/MM/yyyy"),
                    CompanyName = lable.CompanyName,
                    LastStation = EnumStation.ALK,
                    MarkingNo   = markingNo,
                    DrugType    = "NA",
                    QRCode      = lable.QRCode
                };
            }

            using (var ms = new System.IO.MemoryStream(labelInfo.QRCode))
            {
                System.IO.Directory.CreateDirectory(String.Format("{0}/Temp", CSCallJS.curDir));
                string fileName = String.Format("{0}/Temp/{1}", CSCallJS.curDir, "QRCode_" + supervisee.NRIC + ".png");
                if (System.IO.File.Exists(fileName))
                {
                    System.IO.File.Delete(fileName);
                }
                var bitmap = System.Drawing.Image.FromStream(ms);
                bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
            }
            //profile model
            _web.LoadPageHtml("SuperviseeParticulars.html", labelInfo);
            _main._isPrintingMUBTT = false;
            if (_main._timerCheckLogout != null)
            {
                if (_main._timerCheckLogout.Enabled)
                {
                    _main._timerCheckLogout.Stop();
                }
                _main._timerCheckLogout.Start();
            }
        }
Exemplo n.º 12
0
        public void RefreshQueueNumbers()
        {
            try
            {
                DAL_QueueNumber _DAL_QueueNumber = new DAL_QueueNumber();

                // Get list timeslot today
                List <Timeslot> timeslots = new DAL_Timeslots().GetTimeSlots(DateTime.Now).OrderBy(d => d.SortCategory).ThenBy(d => d.StartTime).ToList();

                List <Trinity.DAL.DBContext.Queue> allQueue = _DAL_QueueNumber.SSKGetQueueToDay();

                List <Trinity.DAL.DBContext.Queue> queueNowServing = allQueue.Where(d => d.QueueDetails.Any(c => c.Station == EnumStation.ARK && c.Status == EnumQueueStatuses.Processing)).OrderBy(d => d.QueueDetails.FirstOrDefault(c => c.Station == EnumStation.ARK).LastUpdatedDate).ToList();

                List <Trinity.DAL.DBContext.Queue> arrQueue = allQueue.Where(d => d.QueueDetails.Any(c => c.Station == EnumStation.ARK && c.Status == EnumQueueStatuses.Waiting)).OrderBy(d => d.Timeslot.SortCategory).ThenBy(d => d.Timeslot.StartTime).ToList();

                // get currentTimeslot
                Trinity.DAL.DBContext.Timeslot currentTimeslot = timeslots.FirstOrDefault(d => d.StartTime.Value <= DateTime.Now.TimeOfDay && d.EndTime.Value > DateTime.Now.TimeOfDay);
                // lấy ra timeslot nhỏ nhất vẫn còn người chờ
                Trinity.DAL.DBContext.Timeslot minTimeSlot  = arrQueue.Count > 0 ? arrQueue[0].Timeslot : null;
                Trinity.DAL.DBContext.Timeslot nextTimeSlot = null;
                string textTimeSlot  = string.Empty;
                string textBreakTime = string.Empty;

                //Nếu ko có currentTimeslot  hoặc time slot nhỏ hơn currentTimeslot vẫn còn queue chưa xong
                List <Trinity.DAL.DBContext.Queue> queueCurrent = new List <Queue>();
                List <Trinity.DAL.DBContext.Queue> queueOther   = new List <Queue>();
                if (currentTimeslot != null && minTimeSlot != null && minTimeSlot.EndTime.Value < currentTimeslot.StartTime)
                {
                    // Neu time slot nho hon hien tai chua het nguoi
                    currentTimeslot = minTimeSlot;
                }
                if (currentTimeslot != null)
                {
                    queueCurrent = arrQueue.Where(d => d.Timeslot_ID == currentTimeslot.Timeslot_ID).OrderBy(d => d.InTimeSlot).ThenBy(d => d.Priority).ToList();
                    textTimeSlot = (DateTime.Today + currentTimeslot.StartTime.Value).ToString("hh:mm tt") + " - " + (DateTime.Today + currentTimeslot.EndTime.Value).ToString("hh:mm tt");
                }
                //// Nếu Timeslot trên đã hết ==> lấy tiếp time slot
                //if (queueCurrent.Count == 0 && minTimeSlot != null)
                //{
                //    currentTimeslot = minTimeSlot;
                //    queueCurrent = arrQueue.Where(d => d.Timeslot_ID == currentTimeslot.Timeslot_ID).OrderBy(d => d.InTimeSlot).ThenBy(d => d.Priority).ToList();
                //    textTimeSlot = (DateTime.Today + currentTimeslot.StartTime.Value).ToString("hh:mm tt") + " - " + (DateTime.Today + currentTimeslot.EndTime.Value).ToString("hh:mm tt");
                //}


                // Show List Other
                if (currentTimeslot != null)
                {
                    nextTimeSlot = timeslots.FirstOrDefault(d => d.StartTime.Value >= currentTimeslot.EndTime.Value);
                    if (nextTimeSlot != null)
                    {
                        getQueueOther(queueOther, arrQueue, timeslots, nextTimeSlot);
                    }
                }
                else
                {
                    // get nextTimeSlot
                    nextTimeSlot = timeslots.FirstOrDefault(d => d.StartTime.Value >= DateTime.Now.TimeOfDay);
                    if (nextTimeSlot != null)
                    {
                        getQueueOther(queueOther, arrQueue, timeslots, nextTimeSlot);
                        textBreakTime = "BREAK TIME (Next operation time: " + (DateTime.Today + nextTimeSlot.StartTime.Value).ToString("hh:mm tt") + ")";
                    }
                    else
                    {
                        // if nextTimeSlot == null, get first timeslot of next day
                        Timeslot nextDayTimeSlot = new DAL_Timeslots().GetNextTimeSlotFromDB();
                        if (nextDayTimeSlot != null)
                        {
                            textBreakTime = "BREAK TIME (Next operation time: " + (DateTime.Today + nextDayTimeSlot.StartTime.Value).ToString("hh:mm tt") + ")";
                        }
                    }
                }

                //Nếu queueOther <8 lấy thêm những người bị block mà có lịch hôm nay
                if (queueOther.Count < 8)
                {
                    List <Trinity.DAL.DBContext.Membership_Users> arrayUserBlocked = new DAL_User().GetSuperviseeBlockedAppointmentsAvailable(DateTime.Today, 8 - queueOther.Count);
                    foreach (var item in arrayUserBlocked)
                    {
                        queueOther.Add(new Queue()
                        {
                            QueuedNumber = Trinity.Common.CommonUtil.GetQueueNumber(item.NRIC)
                        });
                    }
                }

                if (queueNowServing.Count < 5 && queueCurrent.Count > 0)
                {
                    int maxAdd = 5 - queueNowServing.Count;
                    maxAdd = queueCurrent.Count < maxAdd ? queueCurrent.Count : maxAdd;
                    for (int i = 0; i < maxAdd; i++)
                    {
                        Queue addNowServing = queueCurrent[0];
                        queueNowServing.Add(addNowServing);
                        queueCurrent.RemoveAt(0);
                        new DAL_QueueDetails().UpdateStatusQueueDetail(addNowServing.Queue_ID, EnumStation.ARK, EnumQueueStatuses.Processing);
                    }
                }

                //if (string.IsNullOrEmpty(textTimeSlot))
                //{
                //    var time = timeslots.FirstOrDefault(d => d.StartTime >= DateTime.Now.TimeOfDay);
                //    if (time != null)
                //        textTimeSlot = (DateTime.Today + time.StartTime.Value).ToString("hh:mm tt") + " - " + (DateTime.Today + time.EndTime.Value).ToString("hh:mm tt");
                //}

                wbQueueNumber.InvokeScript("ShowTimeSlot",
                                           string.IsNullOrEmpty(textTimeSlot) ? textBreakTime : textTimeSlot,
                                           JsonConvert.SerializeObject(queueNowServing.Select(d => new { d.QueuedNumber, d.Type })),
                                           JsonConvert.SerializeObject(queueCurrent.Select(d => new { d.QueuedNumber, d.Type }).Take(12)),
                                           JsonConvert.SerializeObject(queueOther.Select(d => new { d.QueuedNumber, d.Type }).Take(8))
                                           );
            }
            catch (Exception ex)
            {
                Trinity.Common.Utils.LogManager.Error("RefreshQueueNumbers: " + ex.ToString());
            }
        }
Exemplo n.º 13
0
        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
            //{

            //}
        }