public ORFIDCheckInOut entry(RFIDCheckIn objCheckIn) { DALExceptionManagment objExceptionlog = new DALExceptionManagment(); ORFIDCheckInOut obj_CheckInOut = new ORFIDCheckInOut(); string resultMsg = string.Empty; try { using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString())) { using (SqlCommand sqlcmd_obj = new SqlCommand("CTAPP_PROC_INSERTRFIDCHECKINOUT", sqlconn_obj)) { sqlcmd_obj.CommandType = CommandType.StoredProcedure; sqlcmd_obj.Parameters.AddWithValue("@RFIDCheckInOutID", DBNull.Value); sqlcmd_obj.Parameters.AddWithValue("@LocationID", objCheckIn.locationId); sqlcmd_obj.Parameters.AddWithValue("@LotID", objCheckIn.lotId); sqlcmd_obj.Parameters.AddWithValue("@DeviceName", objCheckIn.deviceName); sqlcmd_obj.Parameters.AddWithValue("@BeaconID", objCheckIn.beaconId); sqlcmd_obj.Parameters.AddWithValue("@AvgTimeDuration", Convert.ToInt32(objCheckIn.avgTimeDuration)); sqlcmd_obj.Parameters.AddWithValue("@XCoordinate", objCheckIn.xCoordinate); sqlcmd_obj.Parameters.AddWithValue("@YCoordinate", objCheckIn.yCoordinate); sqlcmd_obj.Parameters.AddWithValue("@ErrorPrecision", objCheckIn.errorPrecision); DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeSeconds(objCheckIn.checkInTime).ToLocalTime(); DateTime checkInDateTime = dateTimeOffset.DateTime; sqlcmd_obj.Parameters.AddWithValue("@CheckInTime", checkInDateTime); sqlcmd_obj.Parameters.AddWithValue("@CheckOutTime", DBNull.Value); sqlconn_obj.Open(); SqlDataAdapter sqldap = new SqlDataAdapter(sqlcmd_obj); DataTable resultdt = new DataTable(); sqldap.Fill(resultdt); if (resultdt.Rows.Count > 0) { obj_CheckInOut.RFIDCheckInOutID = Convert.ToInt32(resultdt.Rows[0]["RFIDCheckInOutID"]); } else { obj_CheckInOut.RFIDCheckInOutID = 0; } } } } catch (Exception ex) { objExceptionlog.InsertException(ex.Message, "DALRFID", "Proc: " + "CTAPP_PROC_INSERTRFIDCHECKINOUT", "entry"); //throw; obj_CheckInOut.RFIDCheckInOutID = 0; } return(obj_CheckInOut); }
public HttpResponseMessage exit(RFIDCheckOut obj) { ObjAPIResponse = new RFIDAPIResponse(); var resp = new HttpResponseMessage(HttpStatusCode.OK); try { DALRFID dal_RFID = new DALRFID(); ORFIDCheckInOut resultobj = dal_RFID.exit(obj); //if (resultobj.RFIDCheckInOutID != 0) //{ // ObjAPIResponse.Result = true; // ObjAPIResponse.Message = "Success"; //} //else //{ // ObjAPIResponse.Result = false; // ObjAPIResponse.Message = "Fail"; // resp = new HttpResponseMessage(HttpStatusCode.InternalServerError); //} ObjAPIResponse.Result = true; ObjAPIResponse.Message = "Success"; resp.Content = new StringContent(JsonConvert.SerializeObject(ObjAPIResponse)); resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); } catch (Exception ex) { ObjAPIResponse.Result = true; ObjAPIResponse.Message = "Success"; /* * ObjAPIResponse.Result = false; * ObjAPIResponse.Message = "Please contact administrator : " + ex.Message; * resp = new HttpResponseMessage(HttpStatusCode.InternalServerError); */ resp.Content = new StringContent(JsonConvert.SerializeObject(ObjAPIResponse)); resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); } return(resp); }