示例#1
0
        private async void frmUsers_Load(object sender, EventArgs e)
        {
            loadComboBoxes.loadRoles(cbRole, false);
            if (cbRole.Items.Count <= 0)
            {
                //MessageBox.error.
                //this.Close();
            }
            if (userId != null)
            {
                authUser = await apiService.GetById <Model.AuthUser>(userId);

                writeFields(authUser);

                var userImageList = await apiService_authUserImage.Get <List <Model.AuthUserImage> >(new AuthUserFaceSearchRequest()
                {
                    AuthUserId = (int)userId
                });

                if (userImageList.Count > 0)
                {
                    authUserImage = userImageList[0];
                    pbImage.Image = ByteToImage(authUserImage.AuthUserImage1);
                }
                pbQrCode.Image = ByteToImage(qRCodeHelper.GenerateQRCode(authUser.QrCode));
            }
        }
        public static System.Tuple <Model.AuthUser, bool> GetAuthenticatedUser(string loginId, string loginPassword)
        {
            Model.AuthUser user            = null;
            bool           operationResult = false;

            using (SqlConnection cn = DBHelper.MakeConnection())
            {
                SqlCommand cmd = new SqlCommand("uspSelectByUserId_tblUserMaster", cn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@userEmail", loginId);
                cn.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    if (rdr.Read())
                    {
                        user = new Model.UserMasterModel()
                        {
                            UserNo          = System.Convert.ToInt32(rdr["userNO"]),
                            userName        = rdr["userName"] as string,
                            UserProfileName = rdr["userProfileName"] as string,
                            Password        = rdr["userPasswd"] as string,
                            UserType        = rdr["userType"] as string,
                            UserStatus      = (Model.UserStatusType)System.Convert.ToInt16(rdr["userStatus"])
                        };
                        int sKey = System.Convert.ToInt32(rdr["serverKey"]);
                        cn.Close();
                        string encryptedLoginPassword = PasswordManager.EncryptPassword(loginPassword, (short)sKey);
                        operationResult = user.Password.Equals(encryptedLoginPassword);
                    }
                }
                return(new System.Tuple <Model.AuthUser, bool>(user, operationResult));
            }
        }
示例#3
0
 private void writeFields(Model.AuthUser authUser)
 {
     txtFirstName.Text            = authUser.FirstName;
     txtLastName.Text             = authUser.LastName;
     txtUserName.Text             = authUser.UserName;
     dtpAccountCreationDate.Value = (DateTime)authUser.AccountCreatingDate;
     dtpBirthDate.Value           = (DateTime)authUser.BirthDate;
     cbRole.SelectedValue         = authUser.RoleId;
 }
示例#4
0
        private async void scaning_Interval_Tick(object sender, EventArgs e)
        {
            numberBefore++;
            lblBefore.Text = numberBefore.ToString();
            //taking frame from picturebox pbCamera
            Bitmap frame        = pbCamera.Image.Clone() as Bitmap;
            bool   savingActive = false;

            //convert frame to grayscale maybe...
            //readQR returns null if user with given qr code does not exist
            if (frame != null)
            {
                if (act == action.idle || act == action.qr_recognition)
                {
                    act            = action.qr_recognition;
                    lblAction.Text = act.ToString();
                    user           = await readQR(frame, apiService_AuthUser);

                    if (user == null)
                    {
                        return;
                    }
                    else
                    {
                        act              = action.face_recognition;
                        lblAction.Text   = act.ToString();
                        lblLastUser.Text = user.FirstName + " " + user.LastName;
                        ticks           += 1;
                        lblTicks.Text    = ticks.ToString();
                        scaning_Interval.Dispose();
                        scaning_Interval.Stop();

                        if (act == action.face_recognition)
                        {
                            await trainRecognizer(user.Id);

                            var search = new Model.SearchRequest.PresenceSearchRequest()
                            {
                                EventId = (int)eventId, UserId = user.Id
                            };
                            var presenceList = await apiService_Presence.Get <List <Model.Presence> >(search);

                            presence = presenceList[0];
                            face_recognition.Start();
                        }
                        //scaning_Interval.Container.Dispose();
                        //act = action.face_detection;
                        //lblAction.Text = act.ToString();
                        //scaning_Interval.Dispose();
                        //face_recognition.Start();
                    }
                    numberAfter++;
                    lblAfter.Text = numberAfter.ToString();
                }
            }
        }