public static bool updateStudent(student ThisStudent)
 {
     return true;
 }
        private static student _getStudentFromStudentNumber(string StudentNumber)
        {
            SqlConnection conn = new SqlConnection(conRegistrationDB);
            conn.Open();
            string query = "SELECT [student_number],[card_number],[OldCards],[firstname],[lastname],[IDNumber]";
            query = query + ",[LeftPinkieTemplate],[LeftRingTemplate],[LeftMiddleTemplate],[LeftMiddleImage],[LeftIndexTemplate] ,[LeftThumbTemplate]";
            query = query + ",[RightThumbTemplate],[RightIndexTemplate],[RightMiddleTemplate],[RightRingTemplate],[RightPinkieTemplate]";
            query = query + " FROM [RegistrationDB].[dbo].[registration] WHERE (Deleted is null OR Deleted != 'True') AND ([student_number] = '" + StudentNumber + "') ";
            SqlCommand cmd = new SqlCommand(query, conn);
            DataTable dt = new DataTable();
            dt.Load(cmd.ExecuteReader());
            student _student = new student();
            _student.StudentNumber = StudentNumber;
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                if (dr.IsNull("firstname")) { _student.FirstName = null; } else { _student.FirstName = (string)dr["firstname"]; };
                if (dr.IsNull("lastname")) { _student.LastName = null; } else { _student.LastName = (string)dr["lastname"]; };
                if (dr.IsNull("IDNumber")) { _student.IDNumber = null; } else { _student.IDNumber = (string)dr["IDNumber"]; };
                if (dr.IsNull("card_number")) { _student.CardNumber = null; } else { _student.CardNumber = (string)dr["card_number"]; };
                if (dr.IsNull("OldCards")) { _student.CardHistory = null; } else { _student.CardHistory = (string)dr["OldCards"]; };
                if (dr.IsNull("student_number")) { _student.StudentNumber = null; } else { _student.StudentNumber = (string)dr["student_number"];};
                if (dr.IsNull("LeftPinkieTemplate")) { _student.LeftPinkie = null; } else { _student.LeftPinkie = new NFRecord((byte[])dr["LeftPinkieTemplate"]); };
                if (dr.IsNull("LeftRingTemplate")) { _student.LeftRing = null; } else { _student.LeftRing = new NFRecord((byte[])dr["LeftRingTemplate"]);};
                if (dr.IsNull("LeftMiddleTemplate")) { _student.LeftMiddle = null; } else {  _student.LeftMiddle = new NFRecord((byte[])dr["LeftMiddleTemplate"]);};
                if (dr.IsNull("LeftIndexTemplate")) { _student.LeftIndex = null; } else { _student.LeftIndex = new NFRecord((byte[])dr["LeftIndexTemplate"]);};
                if (dr.IsNull("LeftThumbTemplate")) {_student.LeftThumb = null;} else {_student.LeftThumb = new NFRecord((byte[])dr["LeftThumbTemplate"]); };
                if (dr.IsNull("RightThumbTemplate")) { _student.RightThumb = null; } else { _student.RightThumb = new NFRecord((byte[])dr["RightThumbTemplate"]);};
                if (dr.IsNull("RightIndexTemplate")) { _student.RightIndex = null; } else { _student.RightIndex = new NFRecord((byte[])dr["RightIndexTemplate"]);};
                if (dr.IsNull("RightMiddleTemplate")) { _student.RightMiddle = null; } else { _student.RightMiddle = new NFRecord((byte[])dr["RightMiddleTemplate"]);};
                if (dr.IsNull("RightRingTemplate")) { _student.RightRing = null; } else { _student.RightRing = new NFRecord((byte[])dr["RightRingTemplate"]);};
                if (dr.IsNull("RightPinkieTemplate")) { _student.RightPinkie = null; } else { _student.RightPinkie = new NFRecord((byte[])dr["RightPinkieTemplate"]);};
                if (dr.IsNull("LeftPinkieTemplate")) { _student.LeftPinkie = null; } else { _student.template[0] = (byte[])dr["LeftPinkieTemplate"]; };
                if (dr.IsNull("LeftRingTemplate")) { _student.LeftRing = null; } else { _student.template[1] = (byte[])dr["LeftRingTemplate"]; };
                if (dr.IsNull("LeftMiddleTemplate")) { _student.LeftMiddle = null; } else { _student.template[2] = (byte[])dr["LeftMiddleTemplate"]; };
                if (dr.IsNull("LeftIndexTemplate")) { _student.LeftIndex = null; } else { _student.template[3] = (byte[])dr["LeftIndexTemplate"]; };
                if (dr.IsNull("LeftThumbTemplate")) { _student.LeftThumb = null; } else { _student.template[4] = (byte[])dr["LeftThumbTemplate"]; };
                if (dr.IsNull("RightThumbTemplate")) { _student.RightThumb = null; } else { _student.template[5] = (byte[])dr["RightThumbTemplate"]; };
                if (dr.IsNull("RightIndexTemplate")) { _student.RightIndex = null; } else { _student.template[6] = (byte[])dr["RightIndexTemplate"]; };
                if (dr.IsNull("RightMiddleTemplate")) { _student.RightMiddle = null; } else { _student.template[7] = (byte[])dr["RightMiddleTemplate"]; };
                if (dr.IsNull("RightRingTemplate")) { _student.RightRing = null; } else { _student.template[8] = (byte[])dr["RightRingTemplate"]; };
                if (dr.IsNull("RightPinkieTemplate")) { _student.RightPinkie = null; } else { _student.template[9] = (byte[])dr["RightPinkieTemplate"]; };

                _student.Enrolled = true;
            }
            else
            {
                _student.StudentNumber = StudentNumber;
                _student.Enrolled = false;
            }
            conn.Close();
            return _student;
        }
 public static bool enrolNewStudent(student NewStudent)
 {
     return false;
 }
Exemple #4
0
        private bool VerifyFingerprint(student originalStudent, NFRecord template2)
        {
            const string Components = "Biometrics.FingerExtraction,Biometrics.FingerMatching";
            bool matched = false;
            NFExtractor extractor = null;
            NMatcher matcher = null;
            try
            {
                // obtain license
                if (!NLicense.ObtainComponents("/local", 5000, Components))
                {
                    Console.WriteLine(@"Could not obtain licenses for components: {0}", Components);
                    matched = false;
                }

                // create an extractor
                extractor = new NFExtractor();

                // extract reference template
                NBuffer referenceTemplate = template2.Save();

                //For each finger in the NFRecord

                // extract candidate template
                NBuffer leftPinkie;
                NBuffer leftRing;
                NBuffer leftMiddle;
                NBuffer leftIndex;
                NBuffer leftThumb;
                NBuffer rightThumb;
                NBuffer rightIndex;
                NBuffer rightMiddle;
                NBuffer rightRing;
                NBuffer rightPinkie;
                int scoreLeftPinkie = 0;
                int scoreLeftRing = 0;
                int scoreLeftMiddle = 0;
                int scoreLeftIndex = 0;
                int scoreLeftThumb = 0;
                int scoreRightPinkie = 0;
                int scoreRightRing = 0;
                int scoreRightMiddle = 0;
                int scoreRightIndex = 0;
                int scoreRightThumb = 0;

                // create a matcher
                matcher = new NMatcher();
                if (originalStudent.LeftPinkie != null)
                {
                    leftPinkie = originalStudent.LeftPinkie.Save();
                    scoreLeftPinkie = matcher.Verify(referenceTemplate, leftPinkie);
                }

                if (originalStudent.LeftRing != null)
                {
                    leftRing = originalStudent.LeftRing.Save();
                    scoreLeftRing= matcher.Verify(referenceTemplate, leftRing);
                }

                if (originalStudent.LeftMiddle != null)
                {
                    leftMiddle = originalStudent.LeftMiddle.Save();
                    scoreLeftMiddle= matcher.Verify(referenceTemplate, leftMiddle);
                }
                if (originalStudent.LeftIndex != null)
                {
                    leftIndex = originalStudent.LeftIndex.Save();
                    scoreLeftIndex= matcher.Verify(referenceTemplate, leftIndex);
                }
                if (originalStudent.LeftThumb != null)
                {
                    leftThumb = originalStudent.LeftThumb.Save();
                    scoreLeftThumb = matcher.Verify(referenceTemplate, leftThumb);
                }
                if (originalStudent.RightThumb != null)
                {
                    rightThumb = originalStudent.RightThumb.Save();
                    scoreRightThumb = matcher.Verify(referenceTemplate, rightThumb);
                }

                if (originalStudent.RightIndex !=null)
                {
                    rightIndex = originalStudent.RightIndex.Save();
                    scoreRightIndex = matcher.Verify(referenceTemplate, rightIndex);
                }
                if (originalStudent.RightMiddle != null)
                {
                    rightMiddle = originalStudent.RightMiddle.Save();
                    scoreRightMiddle = matcher.Verify(referenceTemplate, rightMiddle);
                }
                if (originalStudent.RightRing != null)
                {
                    rightRing = originalStudent.RightRing.Save();
                    scoreRightRing = matcher.Verify(referenceTemplate, rightRing);
                }
                if (originalStudent.RightPinkie != null)
                {
                    rightPinkie = originalStudent.RightPinkie.Save();
                    scoreRightPinkie = matcher.Verify(referenceTemplate, rightPinkie);
                }

                if (scoreLeftPinkie > 0)
                {
                    matched = true;
                    matchedFingerID = 1;
                }
                if (scoreLeftRing > 0)
                {
                    matched = true;
                    matchedFingerID = 2;
                }

                if (scoreLeftMiddle > 0)
                {
                    matched = true;
                    matchedFingerID = 3;
                }
                if (scoreLeftIndex > 0)
                {
                    matched = true;
                    matchedFingerID = 4;
                }
                if (scoreLeftThumb > 0)
                {
                    matched = true;
                    matchedFingerID = 5;
                }
                if (scoreRightPinkie > 0)
                {
                    matched = true;
                    matchedFingerID = 6;
                }
                if (scoreRightRing > 0)
                {
                    matched = true;
                    matchedFingerID = 7;
                }
                if (scoreRightMiddle > 0)
                {
                    matched = true;
                    matchedFingerID = 8;
                }
                if (scoreRightIndex > 0)
                {
                    matched = true;
                    matchedFingerID = 9;
                }
                if (scoreRightThumb > 0)
                {
                    matched = true;
                    matchedFingerID = 10;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                //INeurotecException neurotecException = ex as INeurotecException;
                //if (neurotecException != null)
                //{
                //    return neurotecException.Code;
                //}
                matched = false;
            }
            finally
            {
                NLicense.ReleaseComponents(Components);

                if (extractor != null)
                {
                    extractor.Dispose();
                }
                if (matcher != null)
                {
                    matcher.Dispose();
                }

            }
            return matched;
        }