private void DoPunchIn(string enrollmentId) { PunchManager punchManager = new PunchManager(); UserVoiceManager mgr = new UserVoiceManager(); EmployeeEnrollment enrollment = mgr.GetEmployeeEnrollment(enrollmentId); if (enrollment != null) { Punch p = new Punch { ClientId = enrollment.ClientId, EmployeeUid = enrollment.EmployeeUid, DepartmentUid = enrollment.DepartmentUid, PunchDateTime = DateTime.Now, PunchSourceTypeId = (byte)1, //manual PunchActivityTypeId = (byte)1, //work PunchStatusTypeId = (byte)1, //auto LaborAssociations = new System.Collections.Generic.List <LaborPunchAssociation>(), IsActive = true, CanBeProcessed = true, UserKey = Guid.Parse("C00E2729-9FFA-E511-8893-005056BD7869") }; punchManager.InsertPunch(p); } else { throw new Exception("Enrollment record could not be read from cosmosdb"); } }
public HttpResponseMessage GetEmployeeByEnrollmentId(string enrollmentId) { try { UserVoiceManager manager = new UserVoiceManager(); var result = manager.GetEmployeeEnrollment(enrollmentId); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (System.Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage SaveUserVoiceData(EmployeeEnrollment employeeEnrollment) { try { UserVoiceManager manager = new UserVoiceManager(); string result = string.Empty; result = manager.SaveUserVoiceData(employeeEnrollment); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (System.Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage CreateEnrollment(string userId, string pw, int clientId, long employeeUid, long departmentUid, [FromBody] byte[] voiceData) { var voiceItWrapper = new VoiceItWrapper(); string result = string.Empty; result = voiceItWrapper.createEnrollmentByByteData(userId, pw, voiceData); if (string.IsNullOrEmpty(result)) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "The server did not respond back with a result")); } var enrollmentResponse = JsonConvert.DeserializeObject <EnrollmentResponse>(result); if (enrollmentResponse == null) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error while deserializing response from voice auth server")); } string enrollmentResponseCode = enrollmentResponse.ResponseCode; if (enrollmentResponseCode == Constants.EnrollmentSuccessResponseCode) { var userVoiceManager = new UserVoiceManager(); userVoiceManager.SaveUserVoiceData(new EmployeeEnrollment { ClientId = clientId, EnrollmentId = enrollmentResponse.EnrollmentID, EmployeeUid = employeeUid, DepartmentUid = departmentUid }); return(Request.CreateResponse(HttpStatusCode.OK, enrollmentResponse)); } else if (Constants.EnrollmentErrorResponseCodes.ContainsKey(enrollmentResponseCode)) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Constants.EnrollmentErrorResponseCodes[enrollmentResponseCode])); } else { return(Request.CreateResponse(HttpStatusCode.OK)); } }
public HttpResponseMessage SaveVoiceData([FromBody] byte[] voiceData) { //var wrapper = new VoiceItWrapper(); //var result1 = wrapper.createEnrollmentByByteData("mohit", "mohit", voiceData); //byte[] voiceData = System.Text.Encoding.UTF8.GetBytes(voiceDataString); if (voiceData.Length <= 0) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "No Voice data found")); } try { var fileName = "Test_" + DateTime.Now.Ticks.ToString() + ".wav"; UserVoiceManager manager = new UserVoiceManager(); string result = string.Empty; result = manager.SaveVoiceData(voiceData, fileName); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (System.Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }