Example #1
0
        public BE.QueueInfo GetQueueInfoByQueueID(Guid queue_ID)
        {
            try
            {
                var dbQueue      = new DBContext.Queue();
                var queueDetails = new List <BE.QueueDetail>();
                if (EnumAppConfig.IsLocal)
                {
                    var queueData        = _localUnitOfWork.DataContext.Queues.FirstOrDefault(q => q.Queue_ID == queue_ID);
                    var queueDataDetails = _localUnitOfWork.DataContext.QueueDetails.Where(qd => qd.Queue_ID == queue_ID).ToList().Select(d => d.Map <BE.QueueDetail>()).ToList();

                    if (queueData != null)
                    {
                        dbQueue      = queueData;
                        queueDetails = queueDataDetails;
                        BE.QueueInfo queueInfo = SetQueueInfo(dbQueue, queueDetails);

                        return(queueInfo);
                    }
                    else
                    {
                        bool centralizeStatus;
                        var  centralData = CallCentralized.Get <BE.QueueInfo>(EnumAPIParam.QueueNumber, "GetQueueInfoByQueueID", out centralizeStatus, "queueId=" + queue_ID.ToString());
                        if (centralizeStatus)
                        {
                            return(centralData);
                        }
                    }
                }
                else
                {
                    var queueData        = _centralizedUnitOfWork.DataContext.Queues.FirstOrDefault(q => q.Queue_ID == queue_ID);
                    var queueDataDetails = _centralizedUnitOfWork.DataContext.QueueDetails.Where(qd => qd.Queue_ID == queue_ID).ToList().Select(d => d.Map <BE.QueueDetail>()).ToList();
                    if (queueData != null)
                    {
                        dbQueue      = queueData;
                        queueDetails = queueDataDetails;
                    }
                    BE.QueueInfo queueInfo = SetQueueInfo(dbQueue, queueDetails);

                    return(queueInfo);
                }
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Example #2
0
        private static BE.QueueInfo SetQueueInfo(DBContext.Queue dbQueue, List <BE.QueueDetail> queueDetails)
        {
            BE.QueueInfo queueInfo = new BE.QueueInfo();
            if (dbQueue != null)
            {
                queueInfo.Queue_ID       = dbQueue.Queue_ID;
                queueInfo.NRIC           = dbQueue.Membership_Users1.NRIC;
                queueInfo.Name           = dbQueue.Membership_Users1.Name;
                queueInfo.CurrentStation = dbQueue.CurrentStation;
                queueInfo.Status         = queueDetails.FirstOrDefault(qd => qd.Station.Equals(dbQueue.CurrentStation)).Status;
                queueInfo.QueueDetail    = queueDetails.Where(qd => qd.Message != null && qd.Message != "").ToList();
                queueInfo.UserId         = dbQueue.UserId;
                queueInfo.Date           = dbQueue.CreatedTime;
            }

            return(queueInfo);
        }
Example #3
0
        public DBContext.Queue UpdateQueueStatusByUserId(string userId, string currentStation, string statusCurrentStattion, string nextStation, string statusNextStation, string messageNextStation, string outcome)
        {
            DBContext.Queue dbQueue = _localUnitOfWork.DataContext.Queues.Include("Appointment").FirstOrDefault(d => d.UserId == userId && DbFunctions.TruncateTime(d.CreatedTime).Value == DateTime.Today);

            if (dbQueue == null)
            {
                return(null);
            }

            dbQueue.CurrentStation = nextStation;
            if (!string.IsNullOrEmpty(outcome))
            {
                dbQueue.Outcome = outcome;
            }
            DBContext.QueueDetail dbQueueDetailCurrent = _localUnitOfWork.DataContext.QueueDetails.FirstOrDefault(d => d.Queue_ID == dbQueue.Queue_ID && d.Station == currentStation);
            if (dbQueueDetailCurrent != null)
            {
                dbQueueDetailCurrent.Status = statusCurrentStattion;
                _localUnitOfWork.GetRepository <DBContext.QueueDetail>().Update(dbQueueDetailCurrent);
            }

            DBContext.QueueDetail dbQueueDetailNextStation = _localUnitOfWork.DataContext.QueueDetails.FirstOrDefault(d => d.Queue_ID == dbQueue.Queue_ID && d.Station == nextStation);
            if (dbQueueDetailNextStation != null)
            {
                dbQueueDetailNextStation.Status  = statusNextStation;
                dbQueueDetailNextStation.Message = messageNextStation;

                _localUnitOfWork.GetRepository <DBContext.QueueDetail>().Update(dbQueueDetailNextStation);
            }

            _localUnitOfWork.GetRepository <DBContext.Queue>().Update(dbQueue);

            _localUnitOfWork.Save();

            return(dbQueue);
        }
Example #4
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
            //{

            //}
        }