Beispiel #1
0
        private void Fingerprint_OnFingerprintSucceeded()
        {
            //
            // Login successfully
            //
            // Create a session object to store UserLogin information
            _fingerprintFailed = 0;

            Session session = Session.Instance;

            session.IsFingerprintAuthenticated = true;
            LayerWeb.RunScript("$('[status-authentication]').text('');");
            LayerWeb.RunScript("$('.status-text').css('color','#000').text('Fingerprint authentication is successful.');");

            Thread.Sleep(1000);

            // if role = 0 (duty officer), redirect to NRIC.html
            // else (supervisee), redirect to Supervisee.html
            Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            if (user.Role == EnumUserRoles.DutyOfficer)
            {
                // navigate to Authentication_NRIC
                NavigateTo(NavigatorEnums.Authentication_NRIC);
            }
            else
            {
                // navigate to Supervisee page

                Trinity.SignalR.Client.Instance.UserLoggedIn(user.UserId);

                NavigateTo(NavigatorEnums.Supervisee);
            }
        }
Beispiel #2
0
        public void SaveProfile(string param, string dataChangeAll, string arrayDocumentScan, bool isSendNotiIfDontScanDocument)
        {
            Session session = Session.Instance;

            Trinity.BE.User user      = getSuperviseeLogin();
            var             data      = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, object> > >(param);
            List <string>   arrayScan = JsonConvert.DeserializeObject <List <string> >(arrayDocumentScan);

            Trinity.BE.UserProfile User_Profiles_New       = null;
            Trinity.BE.Address     Alternate_Addresses_New = null;
            Nullable <Guid>        IDDocuemnt = null;

            if (new DAL_UserProfile().ARKUpdateProfile(user.UserId, data, arrayScan, out User_Profiles_New, out Alternate_Addresses_New, out IDDocuemnt))
            {
                Trinity.BE.User currentUser = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
                new DAL_UpdateProfile().CreateRequest(
                    (Trinity.BE.UserProfile)data_old_update_profile[0],
                    (Trinity.BE.Address)data_old_update_profile[1],
                    User_Profiles_New,
                    Alternate_Addresses_New,
                    IDDocuemnt,
                    isSendNotiIfDontScanDocument,
                    (currentUser.Role == EnumUserRoles.DutyOfficer)
                    );
                if (isSendNotiIfDontScanDocument)
                {
                    Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(user.UserId, "Supervisee " + user.Name + " has updated profile.", "Please check Supervisee " + user.Name + "'s information!", EnumNotificationTypes.Notification);
                }
                else
                {
                    Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(user.UserId, "Supervisee " + user.Name + " has updated profile and scan documents.", "Please check Supervisee " + user.Name + "'s information!", EnumNotificationTypes.Notification);
                }
                LoadPageSupervisee();
            }
        }
Beispiel #3
0
        private void Main_OnFacialRecognitionFailed()
        {
            FacialRecognition.Instance.OnFacialRecognitionFailed     -= Main_OnFacialRecognitionFailed;
            FacialRecognition.Instance.OnFacialRecognitionSucceeded  -= Main_OnFacialRecognitionSucceeded;
            FacialRecognition.Instance.OnFacialRecognitionProcessing -= Main_OnFacialRecognitionProcessing;
            FacialRecognition.Instance.OnCameraInitialized           -= Main_OnCameraInitialized;

            this.Invoke((MethodInvoker)(() =>
            {
                FacialRecognition.Instance.Dispose();
            }));
            Session session = Session.Instance;

            Trinity.BE.User user         = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            string          errorMessage = "User '" + user.Name + "' cannot complete facial authentication";

            Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(user.UserId, "Facial authentication failed", errorMessage, EnumNotificationTypes.Error);

            // show message box to user
            CSCallJS.ShowMessage(LayerWeb, "Facial Authentication", "Facial authentication failed");
            //MessageBox.Show("Facial authentication failed", "Facial Authentication", MessageBoxButtons.OK, MessageBoxIcon.Error);

            // navigate to smartcard login page
            NavigateTo(NavigatorEnums.Authentication_SmartCard);

            // reset counter
            _fingerprintFailed = 0;
        }
Beispiel #4
0
        public void UpdateOperationSetting(string json)
        {
            var     model   = JsonConvert.DeserializeObject <Trinity.BE.SettingDetails>(json);
            Session session = Session.Instance;

            Trinity.BE.User dutyOfficer = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            model.Last_Updated_By   = dutyOfficer.UserId;
            model.Last_Updated_Date = DateTime.Now;

            var dalSetting = new DAL_Setting();
            CheckWarningSaveSetting checkWarningSaveSetting = dalSetting.CheckWarningSaveSetting(model.DayOfWeek);

            if (checkWarningSaveSetting != null && checkWarningSaveSetting.arrayDetail.Count > 0)
            {
                session[CommonConstants.SETTING_DETAIL] = model;
                // Show popup confirm with list Supervisee have appointment
                this._web.LoadPopupHtml("PopupConfirmDeleteAppointment.html", checkWarningSaveSetting);
                this._web.InvokeScript("showModal");
            }
            else
            {
                SettingUpdate settingUpdate = new SettingUpdate()
                {
                    CheckWarningSaveSetting = checkWarningSaveSetting,
                    SettingDetails          = model
                };
                dalSetting.UpdateSettingAndTimeSlot(settingUpdate);
            }
        }
Beispiel #5
0
        //private Trinity.BE.WorkingTimeshift SetSelectedTimes( Appointment appointment)
        //{
        //    var date = appointment.Date;

        //    Trinity.BE.WorkingTimeshift selectedTimes = new DAL_Setting().GetApptmtTime(date);
        //    SetSelectedTime(appointment, selectedTimes.Morning);
        //    SetSelectedTime(appointment, selectedTimes.Afternoon);
        //    SetSelectedTime(appointment, selectedTimes.Evening);
        //    this._web.LoadPageHtml("BookAppointment.html", new object[] { appointment, selectedTimes });
        //    return selectedTimes;
        //}

        //private static void SetSelectedTime(Appointment appointment, List<Trinity.BE.WorkingShiftDetails> selectedTimes)
        //{


        //    var item = selectedTimes.Where(d => appointment.Timeslot != null && appointment.Timeslot.StartTime != null && d.StartTime == appointment.Timeslot.StartTime.Value && d.EndTime == appointment.Timeslot.EndTime.Value).FirstOrDefault();
        //    if (item != null)
        //    {
        //        item.IsSelected = true;
        //    }

        //    if (!string.IsNullOrEmpty(appointment.Timeslot_ID))
        //    {


        //        var maxAppPerTimeslot = new DAL_Appointments().GetMaxNumberOfTimeslot(appointment.Timeslot_ID);
        //        foreach (var selectedItem in selectedTimes)
        //        {
        //            var count = new DAL_Appointments().CountListApptmtByTimeslot(appointment);
        //            if (count >= maxAppPerTimeslot)
        //            {
        //                selectedItem.IsAvailble = false;
        //            }
        //        }
        //    }
        //}

        public void UpdateTimeAppointment(string appointment_ID, string timeslot_ID)
        {
            if (new DAL_QueueNumber().IsInQueue(appointment_ID, EnumStation.ARK))
            {
                this._web.ShowMessage("You already registered a queue number!");
            }
            else
            {
                Trinity.BE.User supervisee = getSuperviseeLogin();

                bool updateResult = new DAL_Appointments().UpdateTimeslot_ID(appointment_ID, timeslot_ID);

                if (updateResult)
                {
                    Trinity.SignalR.Client.Instance.AppointmentBooked(supervisee.UserId, appointment_ID, timeslot_ID);
                    AppointmentDetails appointmentdetails = new DAL_Appointments().GetAppointmentDetails(appointment_ID);
                    if (BarcodePrinterUtil.Instance.GetDeviceStatus(EnumDeviceNames.ReceiptPrinter).Contains(EnumDeviceStatus.Connected))
                    {
                        ReceiptPrinterUtil.Instance.PrintAppointmentDetails(appointmentdetails);
                    }
                    else
                    {
                        Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(supervisee.UserId, "Lost connection to printer", "Lost connection to printer", EnumNotificationTypes.Error);
                        _web.ShowMessage("Lost connection to printer");
                    }
                    LoadPageSupervisee();
                }
                else
                {
                    this._web.ShowMessage("Book Appointment failed.<br/>Please try again!");
                }
            }
        }
Beispiel #6
0
        //Load Popup of UB label
        public void LoadPopupUBLabel(string json)
        {
            var data = JsonConvert.DeserializeObject <List <Trinity.BE.Label> >(json);

            Session session = Session.Instance;

            Trinity.BE.User dutyOfficer = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            data[0].OfficerNRIC = dutyOfficer.NRIC;
            data[0].OfficerName = dutyOfficer.Name;

            this._web.LoadPopupHtml("UBlabelPopup.html", data);
        }
Beispiel #7
0
        private void Fingerprint_OnFingerprintFailed()
        {
            // increase counter
            _fingerprintFailed++;

            // get USER_LOGIN
            Session session = Session.Instance;

            Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];

            // exceeded max failed
            if (_fingerprintFailed > 3)
            {
                // set message
                string errorMessage = "Unable to read " + user.Name + "'s fingerprint.";

                // Send Notification to duty officer
                Trinity.SignalR.Client.Instance.SendToAppDutyOfficers(user.UserId, "Fingerprint Authentication failed", errorMessage, EnumNotificationTypes.Error);

                //NavigateTo(NavigatorEnums.Authentication_SmartCard);
                //LayerWeb.ShowMessage("Authentication failed", "Fingerprint's Authenication failed!<br /> Please contact your officer.");

                //for testing purpose
                // Pause for 1 second and goto Facial Login Screen
                //Thread.Sleep(1000);
                _fingerprintFailed = 0;

                // Navigate to next page: Facial Authentication
                NavigateTo(NavigatorEnums.Authentication_Facial);

                return;
            }

            // display failed on UI
            LayerWeb.RunScript("$('.status-text').css('color','#000').text('Please place your finger on the reader');");
            LayerWeb.RunScript("$('[status-authentication]').text('FingerPrint Verification Failed : " + _fingerprintFailed + "');");

            // restart identification
            if (user != null)
            {
                List <byte[]> fingerprintTemplates = new List <byte[]>()
                {
                    user.LeftThumbFingerprint,
                    user.RightThumbFingerprint
                };

                FingerprintReaderUtil.Instance.StartIdentification(fingerprintTemplates, Fingerprint_OnIdentificationCompleted);
            }
            else
            {
                Debug.WriteLine("Fingerprint_OnFingerprintFailed warning: USER_LOGIN is null, can not restart identification.");
            }
        }
Beispiel #8
0
        public bool AddHoliday(string json)
        {
            var holiday    = JsonConvert.DeserializeObject <Trinity.DAL.DBContext.Holiday>(json);
            var dalSetting = new DAL_Setting();

            Session session = Session.Instance;

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

            dalSetting.AddHoliday(holiday.Holiday1, holiday.ShortDesc, holiday.Notes, dutyOfficer.Name, dutyOfficer.UserId);
            return(true);
        }
Beispiel #9
0
 public int GetMyAbsencesCount()
 {
     Trinity.BE.User supervisee = getSuperviseeLogin();
     if (supervisee != null)
     {
         return(new DAL_Appointments().CountAbsenceReport(supervisee.UserId));
     }
     else
     {
         return(0);
     }
 }
Beispiel #10
0
        public void LoadPopupBlock(string userId)
        {
            UserBlockedModel rawData = new UserBlockedModel();
            Session          session = Session.Instance;

            Trinity.BE.User dutyOfficer = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            rawData.OfficerNRIC = dutyOfficer.NRIC;
            rawData.OfficerName = dutyOfficer.Name;
            rawData.UserId      = userId;

            this._web.LoadPopupHtml("BlockedPopupDetail.html", rawData);
        }
Beispiel #11
0
        public void DeleteHoliday(string json)
        {
            var data = JsonConvert.DeserializeObject <List <Trinity.BE.Holiday> >(json);
            //DateTime dateHoliday = Convert.ToDateTime(date);
            var dalSetting = new DAL_Setting();

            Session session = Session.Instance;

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

            dalSetting.DeleteHoliday(data, dutyOfficer.Name);
        }
Beispiel #12
0
        public void ManualLogin(string username, string password)
        {
            EventCenter eventCenter = EventCenter.Default;

            UserManager <ApplicationUser> userManager = ApplicationIdentityManager.GetUserManager();
            ApplicationUser appUser = userManager.Find(username, password);

            if (appUser != null)
            {
                // Authenticated successfully
                // Check if the current user is an Duty Officer or not
                if (userManager.IsInRole(appUser.Id, EnumUserRoles.DutyOfficer))
                {
                    // Authorized successfully
                    Trinity.BE.User user = new Trinity.BE.User()
                    {
                        RightThumbFingerprint = appUser.RightThumbFingerprint,
                        LeftThumbFingerprint  = appUser.LeftThumbFingerprint,
                        IsFirstAttempt        = appUser.IsFirstAttempt,
                        Name        = appUser.Name,
                        NRIC        = appUser.NRIC,
                        Role        = EnumUserRoles.DutyOfficer,
                        SmartCardId = appUser.SmartCardId,
                        Status      = appUser.Status,
                        UserId      = appUser.Id
                    };
                    Session session = Session.Instance;
                    session.IsUserNamePasswordAuthenticated = true;
                    session.Role = EnumUserRoles.DutyOfficer;
                    session[CommonConstants.USER_LOGIN] = user;

                    eventCenter.RaiseEvent(new Trinity.Common.EventInfo()
                    {
                        Code = 0, Name = EventNames.LOGIN_SUCCEEDED
                    });
                }
                else
                {
                    eventCenter.RaiseEvent(new Trinity.Common.EventInfo()
                    {
                        Code = -2, Name = EventNames.LOGIN_FAILED, Message = "You do not have permission to access this page."
                    });
                }
            }
            else
            {
                eventCenter.RaiseEvent(new Trinity.Common.EventInfo()
                {
                    Code = -1, Name = EventNames.LOGIN_FAILED, Message = "Your username or password is incorrect."
                });
            }
        }
Beispiel #13
0
        public SettingModel GetSettings()
        {
            if (_isFocusQueue)
            {
                SmartCardReaderUtil.Instance.StopSmartCardMonitor();
                _isFocusQueue = false;
            }

            DAL_Setting dalSetting = new DAL_Setting();
            Session     session    = Session.Instance;

            Trinity.BE.User dutyOfficer = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            return(dalSetting.GetOperationSettings(dutyOfficer.UserId));
        }
Beispiel #14
0
        public void LoadNotications()
        {
            Session currentSession = Session.Instance;

            Trinity.BE.User user = getSuperviseeLogin();

            DAL_Notification dalNotification = new DAL_Notification();

            List <Trinity.BE.Notification> myNotifications = dalNotification.GetAllNotifications(user.UserId);

            var model = myNotifications;

            _web.LoadPageHtml("Notifications.html", myNotifications);
        }
Beispiel #15
0
        // Reporting for Queue Number
        public void ReportingForQueueNumber()
        {
            // Get current user

            Trinity.BE.User supervisee = getSuperviseeLogin();
            // Check if the current user is a duty officcer

            int absenceCount = 0;

            if (supervisee != null)
            {
                absenceCount = new DAL_Appointments().CountAbsenceReport(supervisee.UserId);
            }

            if (absenceCount == 0)
            {
                GetMyQueueNumber();
            }
            //else if (absenceCount >= 3 || supervisee.Status==EnumUserStatuses.Blocked)
            //{
            //    var eventCenter = Trinity.Common.Common.EventCenter.Default;
            //    //eventCenter.RaiseEvent(new Trinity.Common.EventInfo() { Name = EventNames.ABSENCE_MORE_THAN_3, Message = "You have been blocked for 3 or more absences \n Please report to the Duty Officer" });
            //    this._web.ShowMessage("You have been blocked for 3 or more absences <br/> Please report to the Duty Officer");
            //    //for testing purpose
            //    //notify to officer
            //    Trinity.SignalR.Client.Instance.SendToAllDutyOfficers(supervisee.UserId, "Supervisee got blocked for 3 or more absences", "Please check the Supervisee's information!", EnumNotificationTypes.Caution);
            //    //var dalUser = new DAL_User();

            //    //// Create absence reporting
            //    //var listAppointment = new DAL_Appointments().GetAbsentAppointments(supervisee.UserId);
            //    //session[CommonConstants.LIST_APPOINTMENT] = listAppointment;
            //    //_web.LoadPageHtml("ReasonsForQueue.html", listAppointment.Select(d => new
            //    //{
            //    //    ID = d.ID,
            //    //    GetDateTxt = d.GetDateTxt
            //    //}));
            //}
            else
            {
                var listAppointment = new DAL_Appointments().GetAbsentAppointments(supervisee.UserId);

                this._web.ShowMessage("You have been absent for " + absenceCount + " time(s).<br/>Please provide reason(s) and supporting document(s).");
                _web.LoadPageHtml("ReasonsForQueue.html", listAppointment.Select(d => new
                {
                    ID         = d.ID,
                    GetDateTxt = d.GetDateTxt
                }));
            }
        }
Beispiel #16
0
        public string GetNextAppointmentDate()
        {
            Session session = Session.Instance;

            Trinity.BE.User user = getSuperviseeLogin();
            if (user != null)
            {
                var _appointment = new DAL_Appointments().GetNextAppointment(user.UserId);
                if (_appointment != null)
                {
                    return(_appointment.Date.ToLongDateString());
                }
            }
            return(null);
        }
Beispiel #17
0
        public void LoadProfile()
        {
            Session session = Session.Instance;

            Trinity.BE.User user       = getSuperviseeLogin();
            var             dataReturn = new
            {
                Membership_Users    = user,
                User_Profiles       = new DAL_UserProfile().GetProfile(user.UserId),
                Primary_Addresses   = new DAL_UserProfile().GetAddByUserId(user.UserId, false),
                Alternate_Addresses = new DAL_UserProfile().GetAddByUserId(user.UserId, true)
            };

            data_old_update_profile = new object[] { dataReturn.User_Profiles, dataReturn.Alternate_Addresses };
            _web.LoadPageHtml("Profile.html", dataReturn);
        }
Beispiel #18
0
        private Trinity.BE.User getSuperviseeLogin()
        {
            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;
            }
            return(supervisee);
        }
Beispiel #19
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);
            }
        }
Beispiel #20
0
        public void Login(string username, string password)
        {
            var             dalUser = new DAL_User();
            ApplicationUser appUser = dalUser.Login(username, password);

            if (appUser != null)
            {
                if (dalUser.IsInRole(appUser.Id, EnumUserRoles.DutyOfficer))
                {
                    Trinity.BE.User user = new Trinity.BE.User()
                    {
                        UserId                = appUser.Id,
                        Status                = appUser.Status,
                        SmartCardId           = appUser.SmartCardId,
                        RightThumbFingerprint = appUser.RightThumbFingerprint,
                        LeftThumbFingerprint  = appUser.LeftThumbFingerprint,
                        Name           = appUser.Name,
                        NRIC           = appUser.NRIC,
                        IsFirstAttempt = appUser.IsFirstAttempt
                    };
                    user.Role = EnumUserRoles.DutyOfficer;
                    Session session = Session.Instance;
                    session.IsUserNamePasswordAuthenticated = true;
                    session.Role = EnumUserRoles.EnrolmentOfficer;
                    session[CommonConstants.USER_LOGIN] = user;
                    Trinity.SignalR.Client.Instance.UserLoggedIn(user.UserId);
                    EventCenter.Default.RaiseEvent(new Trinity.Common.EventInfo()
                    {
                        Code = 0, Name = EventNames.LOGIN_SUCCEEDED
                    });
                }
                else
                {
                    this._web.ShowMessage("You do not have permission to access this page.");
                }
            }
            else
            {
                this._web.ShowMessage("Your username or password is incorrect.");
            }
        }
Beispiel #21
0
        public void UpdateDisCard(string UserId, string UTResult)
        {
            Session session = Session.Instance;

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


            if (UTResult.Equals(EnumUTResult.NEG))
            {
                dalDrug.UpdateDiscardDrugResult(UserId, dutyOfficer.UserId);
                new Trinity.DAL.DAL_QueueNumber().UpdateQueueStatusByUserId(UserId, EnumStation.UT, EnumQueueStatuses.Finished, EnumStation.SSP, EnumQueueStatuses.NotRequired, string.Empty, EnumQueueOutcomeText.Processing);
                new Trinity.DAL.DAL_QueueNumber().UpdateQueueStatusByUserId(UserId, EnumStation.SSP, EnumQueueStatuses.NotRequired, EnumStation.DUTYOFFICER, EnumQueueStatuses.TabSmartCard, string.Empty, EnumQueueOutcomeText.TapSmartCardToContinue);
            }
            else
            {
                dalDrug.UpdateDiscardDrugResult(UserId, dutyOfficer.UserId);
                new Trinity.DAL.DAL_QueueNumber().UpdateQueueStatusByUserId(UserId, EnumStation.UT, EnumQueueStatuses.Finished, EnumStation.SSP, EnumQueueStatuses.NotRequired, string.Empty, EnumQueueOutcomeText.Processing);
                new Trinity.DAL.DAL_QueueNumber().UpdateQueueStatusByUserId(UserId, EnumStation.SSP, EnumQueueStatuses.NotRequired, EnumStation.DUTYOFFICER, EnumQueueStatuses.TabSmartCard, EnumMessage.SelectOutCome, EnumQueueOutcomeText.TapSmartCardToContinue);
            }
        }
Beispiel #22
0
        private void Main_OnFacialRecognitionSucceeded()
        {
            _fingerprintFailed = 0;
            LayerWeb.RunScript("$('.status-text').css('color','#000').text('You have been authenticated.');");
            FacialRecognition.Instance.OnFacialRecognitionFailed     -= Main_OnFacialRecognitionFailed;
            FacialRecognition.Instance.OnFacialRecognitionSucceeded  -= Main_OnFacialRecognitionSucceeded;
            FacialRecognition.Instance.OnFacialRecognitionProcessing -= Main_OnFacialRecognitionProcessing;
            FacialRecognition.Instance.OnCameraInitialized           -= Main_OnCameraInitialized;
            this.Invoke((MethodInvoker)(() =>
            {
                FacialRecognition.Instance.Dispose();
            }));

            //
            // Login successfully
            //
            // Create a session object to store UserLogin information
            Session session = Session.Instance;

            session.IsFacialAuthenticated = true;


            Thread.Sleep(1000);

            // if role = 0 (duty officer), redirect to NRIC.html
            // else (supervisee), redirect to Supervisee.html
            Trinity.BE.User user = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            if (user.Role == EnumUserRoles.DutyOfficer)
            {
                // navigate to Authentication_NRIC
                NavigateTo(NavigatorEnums.Authentication_NRIC);
            }
            else
            {
                Trinity.SignalR.Client.Instance.UserLoggedIn(user.UserId);
                // navigate to Supervisee page
                NavigateTo(NavigatorEnums.Supervisee);
            }
        }
Beispiel #23
0
 private void NRIC_OnNRICSucceeded()
 {
     // navigate to Supervisee page
     Trinity.BE.User currentUser = (Trinity.BE.User)Session.Instance[CommonConstants.USER_LOGIN];
     Trinity.BE.User supervisee  = currentUser;
     if (currentUser.Role == EnumUserRoles.DutyOfficer)
     {
         supervisee = (Trinity.BE.User)Session.Instance[CommonConstants.SUPERVISEE];
     }
     if (supervisee != null)
     {
         if (supervisee.Status == EnumUserStatuses.Blocked)
         {
             LayerWeb.ShowMessage("This supervisee was blocked");
         }
         else
         {
             Trinity.SignalR.Client.Instance.UserLoggedIn(supervisee.UserId);
             NavigateTo(NavigatorEnums.Supervisee);
         }
     }
 }
Beispiel #24
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
            });
        }
Beispiel #25
0
        private void GetCardInfoSucceeded(string cardUID)
        {
            DAL_User dAL_User = new DAL_User();

            Trinity.BE.User user = dAL_User.GetUserBySmartCardId(cardUID);

            if (user != null)
            {
                // Only enrolled supervisees are allowed to login
                if (user.Role.Equals(EnumUserRoles.Supervisee, StringComparison.InvariantCultureIgnoreCase) || user.Role.Equals(EnumUserRoles.DutyOfficer, StringComparison.InvariantCultureIgnoreCase))
                {
                    if (user.Status.Equals(EnumUserStatuses.New, StringComparison.InvariantCultureIgnoreCase))
                    {
                        SmartCard_OnSmartCardFailed("You haven't enrolled yet.", "Supervisee " + user.Name + " hasn't enrolled yet.");
                        return;
                    }
                    if (user.Role.Equals(EnumUserRoles.Supervisee, StringComparison.InvariantCultureIgnoreCase))
                    {
                        var smartCard = new DAL_IssueCard().GetIssueCardBySmartCardId(cardUID);
                        if (smartCard == null)
                        {
                            SmartCard_OnSmartCardFailed("Your smart card does not exist.", "The smart card " + cardUID + " does not exist.");
                            return;
                        }
                        else if (smartCard.Status.Equals(EnumIssuedCards.Inactive, StringComparison.InvariantCultureIgnoreCase))
                        {
                            SmartCard_OnSmartCardFailed("Your smart card does not work.", "The smart card " + cardUID + " does not work.");
                            return;
                        }
                        else if ((smartCard.Status.Equals(EnumIssuedCards.Active, StringComparison.InvariantCultureIgnoreCase) && smartCard.Expired_Date < DateTime.Today) || (user.Expired_Date.HasValue && user.Expired_Date.Value < DateTime.Today))
                        {
                            SmartCard_OnSmartCardFailed("Your smart card has already expired.", "The smart card " + cardUID + " has already expired.");
                            return;
                        }
                    }
                    Session session = Session.Instance;
                    session.IsSmartCardAuthenticated    = true;
                    session[CommonConstants.USER_LOGIN] = user;
                    this.LayerWeb.RunScript("$('.status-text').css('color','#000').text('Your smart card is authenticated.');");
                    // Stop SCardMonitor
                    SmartCardReaderUtil sCardMonitor = SmartCardReaderUtil.Instance;
                    sCardMonitor.StopSmartCardMonitor();
                    // raise succeeded event

                    new DAL_ActionLog().Insert(ActionName.TabSmartCard, user.UserId, string.Empty, EnumStation.ARK);
                    SmartCard_OnSmartCardSucceeded();
                }
                else
                {
                    SmartCard_OnSmartCardFailed("You do not have permission to login to this system.", "The user " + user.Name + " tries to access ARK for which he/she is not authorized.");
                }
            }
            else
            {
                // raise failed event

                if (string.IsNullOrEmpty(cardUID))
                {
                    SmartCard_OnSmartCardFailed("Unable to retrieve smart card information.", "The smart card " + cardUID + " cannot be read.");
                }
                else
                {
                    SmartCard_OnSmartCardFailed("Your smart card does not exist.", "The smart card " + cardUID + " does not exist.");
                }
            }
        }
Beispiel #26
0
        public void NavigateTo(NavigatorEnums navigatorEnum)
        {
            // navigate
            if (navigatorEnum == NavigatorEnums.Authentication_SmartCard)
            {
                LayerWeb.LoadPageHtml("Authentication/SmartCard.html");
                LayerWeb.RunScript("$('.status-text').css('color','#000').text('" + Resources.INFO_PLACE_SMARTCARD + "');");
                SmartCardReaderUtil.Instance.StopSmartCardMonitor();
                SmartCard.Instance.Start();
            }
            else if (navigatorEnum == NavigatorEnums.Authentication_Fingerprint)
            {
                try
                {
                    Session         session = Session.Instance;
                    Trinity.BE.User user    = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
                    LayerWeb.LoadPageHtml("Authentication/FingerPrint.html");
                    LayerWeb.RunScript("$('.status-text').css('color','#000').text('" + Resources.INFO_PLACE_THUMBPRINT + "');");
                    Fingerprint.Instance.Start(new System.Collections.Generic.List <byte[]>()
                    {
                        user.LeftThumbFingerprint, user.RightThumbFingerprint
                    });
                }
                catch (System.IO.FileNotFoundException ex)
                {
                    Console.WriteLine("File missing:\n");
                    Console.WriteLine(ex.FileName);
                }
            }
            else if (navigatorEnum == NavigatorEnums.Authentication_Facial)
            {
                Session         session = Session.Instance;
                Trinity.BE.User user    = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
                if ((user.User_Photo1 == null || user.User_Photo1.Length == 0) && (user.User_Photo2 == null || user.User_Photo2.Length == 0))
                {
                    //Trinity.BE.PopupModel popupModel = new Trinity.BE.PopupModel();
                    //popupModel.Title = "Authorization Failed";
                    //popupModel.Message = "User '" + user.Name + "' doesn't have any photos";
                    //popupModel.IsShowLoading = false;
                    //popupModel.IsShowOK = true;

                    //LayerWeb.InvokeScript("showPopupModal", JsonConvert.SerializeObject(popupModel));

                    // Navigate to smartcard login page
                    NavigateTo(NavigatorEnums.Authentication_SmartCard);
                    return;
                }
                LayerWeb.LoadPageHtml("Authentication/FacialRecognition.html");
                LayerWeb.RunScript("$('.status-text').css('color','#000').text('" + Resources.INFO_REMAIN_YOUR_FACE_STILL + "');");
                FacialRecognition.Instance.OnFacialRecognitionFailed     += Main_OnFacialRecognitionFailed;
                FacialRecognition.Instance.OnFacialRecognitionSucceeded  += Main_OnFacialRecognitionSucceeded;
                FacialRecognition.Instance.OnFacialRecognitionProcessing += Main_OnFacialRecognitionProcessing;
                FacialRecognition.Instance.OnCameraInitialized           += Main_OnCameraInitialized;

                List <byte[]> FaceJpg = new System.Collections.Generic.List <byte[]>()
                {
                    user.User_Photo1, user.User_Photo2
                };
                this.Invoke((MethodInvoker)(() =>
                {
                    Point startLocation = new Point((Screen.PrimaryScreen.Bounds.Size.Width / 2) - 800 / 2, (Screen.PrimaryScreen.Bounds.Size.Height / 2) - 450 / 2);
                    FacialRecognition.Instance.StartFacialRecognition(startLocation, FaceJpg);
                    //LayerWeb.RunScript("$('.status-text').css('color','#000').text('Face authentication');");
                }));
            }
            else if (navigatorEnum == NavigatorEnums.Authentication_NRIC)
            {
                _nric.Start();
            }
            else if (navigatorEnum == NavigatorEnums.Supervisee)
            {
                // Handle income notifications

                Session         session = Session.Instance;
                Trinity.BE.User user    = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
                if (user.Role == EnumUserRoles.Supervisee && user.Status == EnumUserStatuses.Blocked)
                {
                    LayerWeb.ShowMessageAsync(Resources.INFO_YOU_HAVE_BEEN_BLOCKED);
                    _jsCallCS.LogOut();
                    return;
                }
                _signalrClient = Client.Instance;
                _signalrClient.OnNewNotification += _signalrClient_OnNewNotification;
                if (this._timerCheckLogout != null)
                {
                    if (this._timerCheckLogout.Enabled)
                    {
                        this._timerCheckLogout.Stop();
                    }
                    this._timerCheckLogout.Start();
                }
                _supervisee.Start();
            }

            // set current page
            _currentPage = navigatorEnum;

            // display options in Authentication_SmartCard page
            if (_displayLoginButtonStatus && _currentPage == NavigatorEnums.Authentication_SmartCard)
            {
                _displayLoginButtonStatus = false;
                CSCallJS.DisplayLogoutButton(this.LayerWeb, _displayLoginButtonStatus);
            }

            // display options in the rest
            if (!_displayLoginButtonStatus && _currentPage != NavigatorEnums.Authentication_SmartCard)
            {
                _displayLoginButtonStatus = true;
                CSCallJS.DisplayLogoutButton(this.LayerWeb, _displayLoginButtonStatus);
            }
        }
Beispiel #27
0
        public void ProcessManualLogin(string username, string password)
        {
            try
            {
                BarcodeScannerUtil.Instance.Disconnect();

                EventCenter eventCenter = EventCenter.Default;

                //UserManager<ApplicationUser> userManager = ApplicationIdentityManager.GetUserManager();
                //ApplicationUser appUser = userManager.Find(username, password);
                var             dalUser = new DAL_User();
                ApplicationUser appUser = dalUser.Login(username, password);
                if (appUser != null)
                {
                    // Authenticated successfully
                    // Check if the current user is an Duty Officer or not
                    if (dalUser.IsInRole(appUser.Id, EnumUserRoles.DutyOfficer))
                    {
                        // Authorized successfully
                        Trinity.BE.User user = new Trinity.BE.User()
                        {
                            RightThumbFingerprint = appUser.RightThumbFingerprint,
                            LeftThumbFingerprint  = appUser.LeftThumbFingerprint,
                            IsFirstAttempt        = appUser.IsFirstAttempt,
                            Name        = appUser.Name,
                            NRIC        = appUser.NRIC,
                            Role        = EnumUserRoles.DutyOfficer,
                            SmartCardId = appUser.SmartCardId,
                            Status      = appUser.Status,
                            UserId      = appUser.Id
                        };
                        Session session = Session.Instance;
                        session.IsUserNamePasswordAuthenticated = true;
                        session.Role = EnumUserRoles.DutyOfficer;
                        session[CommonConstants.USER_LOGIN] = user;

                        eventCenter.RaiseEvent(new Trinity.Common.EventInfo()
                        {
                            Code = 0, Name = EventNames.LOGIN_SUCCEEDED
                        });

                        // Set application status is busy
                        ApplicationStatusManager.Instance.IsBusy = true;
                    }
                    else
                    {
                        eventCenter.RaiseEvent(new Trinity.Common.EventInfo()
                        {
                            Code = -2, Name = EventNames.LOGIN_FAILED, Message = "You do not have permission to access this page."
                        });
                    }
                }
                else
                {
                    // Enable scanner
                    if (BarcodeScannerUtil.Instance.GetDeviceStatus().Contains(EnumDeviceStatus.Connected))
                    {
                        System.Threading.Tasks.Task.Factory.StartNew(() => BarcodeScannerUtil.Instance.StartScanning(BarcodeScannerCallback));
                    }

                    eventCenter.RaiseEvent(new Trinity.Common.EventInfo()
                    {
                        Code = -1, Name = EventNames.LOGIN_FAILED, Message = "Your username or password is incorrect."
                    });
                }
            }
            finally
            {
                BarcodeScannerUtil.Instance.Disconnect();
            }
        }
Beispiel #28
0
        public void BookAppointment()
        {
            Session session     = Session.Instance;
            var     eventCenter = Trinity.Common.Common.EventCenter.Default;

            Trinity.BE.User supervisee = getSuperviseeLogin();


            // check supervisee have appoitment
            Trinity.DAL.DBContext.Appointment appointment = new DAL_Appointments().GetNextAppointment(supervisee.UserId);
            if (appointment != null && (appointment.Status == EnumAppointmentStatuses.Reported || appointment.Status == EnumAppointmentStatuses.Absent))
            {
                appointment = new DAL_Appointments().GetNextAppointmentByStatus(supervisee.UserId, EnumAppointmentStatuses.Pending);
            }

            if (appointment == null)
            {
                eventCenter.RaiseEvent(new Trinity.Common.EventInfo()
                {
                    Name = EventNames.ALERT_MESSAGE, Message = "You have no appointment today."
                });
                return;
            }

            // get timeslots of appoitment day
            List <Timeslot> timeslots = new DAL_Timeslots().GetTimeSlots(appointment.Date);

            if (timeslots == null)
            {
                eventCenter.RaiseEvent(new Trinity.Common.EventInfo()
                {
                    Name = EventNames.ALERT_MESSAGE, Message = "Have no timeslot to select. \nPlease contact Duty Officer."
                });
                return;
            }



            // set workingTimeshift
            Trinity.BE.WorkingTimeshift workingTimeshift = new Trinity.BE.WorkingTimeshift();
            workingTimeshift.Morning   = GetWorkingTimeshift(timeslots, appointment.Timeslot_ID, EnumTimeshift.Morning);
            workingTimeshift.Afternoon = GetWorkingTimeshift(timeslots, appointment.Timeslot_ID, EnumTimeshift.Afternoon);
            workingTimeshift.Evening   = GetWorkingTimeshift(timeslots, appointment.Timeslot_ID, EnumTimeshift.Evening);

            var appointmentBE = new Trinity.BE.Appointment()
            {
                ID = appointment.ID.ToString(),
                AbsenceReporting_ID = appointment.AbsenceReporting_ID,
                Timeslot_ID         = appointment.Timeslot_ID,
                UserId          = appointment.UserId,
                AppointmentDate = appointment.Date,
                ChangedCount    = appointment.ChangedCount,
                Status          = appointment.Status,
                ReportTime      = appointment.ReportTime,
                StartTime       = appointment.Timeslot != null ? appointment.Timeslot.StartTime : null,
                EndTime         = appointment.Timeslot != null ? appointment.Timeslot.EndTime : null
            };

            // redirect
            this._web.LoadPageHtml("BookAppointment.html", new object[] { appointmentBE, workingTimeshift });
        }
Beispiel #29
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
            //{

            //}
        }