kaveer
6/20/2019 - 12:41 PM

Typing pattern authentication

public static string search(string dna, string id)
  {
      BiometricViewModel biometric = new BiometricViewModel();

      if (!string.IsNullOrWhiteSpace(dna) && !string.IsNullOrWhiteSpace(id))
      {
          TypingEnrolViewModel request = new TypingEnrolViewModel();
          request.samples = new List<string>();

          int studentId = Convert.ToInt32(id);
          biometric = GetBiometricDetailsByStudentId(studentId);
          request.user_id = biometric.TypingId;
          request.samples.Add(dna);

          string jsonObject = new JavaScriptSerializer().Serialize(request);



          HttpResponse<String> response = Unirest.post("https://api.keytrac.net/anytext/authenticate")
          .header("Authorization", "XXXXXXXXXX")
          .header("Content-Type", "application/json")
          .body(jsonObject)
          .asJson<String>();

          var result = response.Body;
          var results = JsonConvert.DeserializeObject<TypingViewModel>(response.Body);
          if (results.score < 50)
          {
              AbortRegistraction(studentId);
              LogEvent(studentId, "Authentication fails did not recognised the registed student typing pattern with a score of " + results.score);
              return "Authentication fails did not recognised the registed student typing pattern with a score of " + results.score;
          }

          return "worked";
      }
      else
      {
          return "Fail to student details and typing pattern";
      }
  }