/// <summary> ///To Update the Device Location status to admin /// </summary> /// <param name="Ar"></param> /// <returns></returns> public HttpResponseMessage updateDeviceLocation(DeviceLocation DL) { ar = new WebApiResponse(); try { string qry = "select * from MDM_DeviceMaster where DeviceID='" + DL.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { if (!dr.IsClosed) { dr.Close(); } DeviceTrackingDetail DT = new DeviceTrackingDetail(); var list = DL.locations; foreach (var c in list) { qry = "insert into MDM_DeviceTrackingDetail(DeviceId,latitude,longitude,CreatedDate)values('" + DL.uuid + "','" + c.latitude + "','" + c.longitude + "','" + c.timestamp.ToString("yyyy-MM-dd HH:mm:ss") + "')"; rcnt = databaseHelper.ExecuteQuery(qry); } ar.response = true; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ar); qry = "delete from MDM_PushNotification where DeviceID='" + DL.uuid + "' and Command='GetDeviceLocation'"; rcnt = databaseHelper.ExecuteQuery(qry); return(response); } else { ar.errorCode = "Authentication Failed"; ar.response = false; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return(response); } } catch (Exception ex) { linfo.LogFile(enLogType.EXCEPTION, ex.Message, null); } finally { if (dr != null && !dr.IsClosed) { dr.Close(); } } return(null); }
/// <summary> ///To Update the Device Location status to admin /// </summary> /// <param name="Ar"></param> /// <returns></returns> public HttpResponseMessage updateDeviceLocation(DeviceLocation DL) { ar = new WebApiResponse(); try { string qry = "select * from MDM_DeviceMaster where DeviceID='" + DL.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { if (!dr.IsClosed) dr.Close(); DeviceTrackingDetail DT = new DeviceTrackingDetail(); var list = DL.locations; foreach (var c in list) { qry = "insert into MDM_DeviceTrackingDetail(DeviceId,latitude,longitude,CreatedDate)values('" + DL.uuid + "','" + c.latitude + "','" + c.longitude + "','" + c.timestamp.ToString("yyyy-MM-dd HH:mm:ss") + "')"; rcnt = databaseHelper.ExecuteQuery(qry); } ar.response = true; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ar); qry = "delete from MDM_PushNotification where DeviceID='" + DL.uuid + "' and Command='GetDeviceLocation'"; rcnt = databaseHelper.ExecuteQuery(qry); return response; } else { ar.errorCode = "Authentication Failed"; ar.response = false; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return response; } } catch(Exception ex) { linfo.LogFile(enLogType.EXCEPTION, ex.Message,null); } finally { if (dr != null && !dr.IsClosed) dr.Close(); } return null; }
/// <summary> ///To Get all the Log activities From the Device to Admin (database) /// </summary> /// <param name="Ar"></param> /// <returns></returns> public HttpResponseMessage logActivities(logActivities LA) { ar = new WebApiResponse(); try { string qry = "select * from MDM_DeviceMaster where DeviceID='" + LA.uuid + "'"; //linfo.LogFile(enLogType.QUERY, "Query = " + qry + "Device ID = " + LA.uuid, "Rizwan"); dr = databaseHelper.getDataReader(qry); if (dr.Read()) { ActivityLog la = new ActivityLog(); DeviceTrackingDetail dt = new DeviceTrackingDetail(); var list = LA.activity; string id = LA.uuid; if (!dr.IsClosed) { dr.Close(); } foreach (var c in list) { la.DeviceID = id; la.ActivityCode = c.activityCode; la.LogText = c.actitivyDetail; la.CreatedBy = 1; la.UpdatedBy = 1; la.LogDateTime = c.activityOn; la.activityType = c.activityType; if (c.activityCode == 2) { la.LogText = c.actitivyDetail + " Latitude : " + c.latitude + " Longitude : " + c.longitude; } qry = "insert into MDM_ActivityLog(LogText,DeviceID,EmployeeID,LogDateTime,ActivityCode,ActivityType)values('" + la.LogText + "','" + la.DeviceID + "','1','" + DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss") + "','" + la.ActivityCode + "','" + la.activityType + "')"; //linfo.LogFile(enLogType.QUERY, "\n\n Query = " + qry , "Rizwan"); rcnt = databaseHelper.ExecuteQuery(qry); } ar.response = true; response = Request.CreateResponse(HttpStatusCode.Created, ar); return(response); } else { ar.errorCode = "No Device Found"; ar.response = false; response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return(response); } } catch (Exception ex) { if (!dr.IsClosed) { dr.Close(); } linfo.LogFile(enLogType.EXCEPTION, "Function = logActivities() Error Message = " + ex.Message + " InnerException =" + ex.InnerException.ToString(), null); ar.errorCode = "Problem in logActivities() WS"; ar.response = false; response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); } finally { if (dr != null && !dr.IsClosed) { dr.Close(); } } return(response); }
/// <summary> ///To Get all the Log activities From the Device to Admin (database) /// </summary> /// <param name="Ar"></param> /// <returns></returns> public HttpResponseMessage logActivities(logActivities LA) { ar = new WebApiResponse(); try { string qry = "select * from MDM_DeviceMaster where DeviceID='" + LA.uuid + "'"; //linfo.LogFile(enLogType.QUERY, "Query = " + qry + "Device ID = " + LA.uuid, "Rizwan"); dr = databaseHelper.getDataReader(qry); if (dr.Read()) { ActivityLog la = new ActivityLog(); DeviceTrackingDetail dt = new DeviceTrackingDetail(); var list = LA.activity; string id = LA.uuid; if (!dr.IsClosed) dr.Close(); foreach (var c in list) { la.DeviceID = id; la.ActivityCode = c.activityCode; la.LogText = c.actitivyDetail; la.CreatedBy = 1; la.UpdatedBy = 1; la.LogDateTime = c.activityOn; la.activityType = c.activityType; if (c.activityCode == 2) { la.LogText = c.actitivyDetail + " Latitude : " + c.latitude + " Longitude : " + c.longitude; } qry = "insert into MDM_ActivityLog(LogText,DeviceID,EmployeeID,LogDateTime,ActivityCode,ActivityType)values('" + la.LogText + "','" + la.DeviceID + "','1','" + DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss") + "','" + la.ActivityCode + "','" + la.activityType + "')"; //linfo.LogFile(enLogType.QUERY, "\n\n Query = " + qry , "Rizwan"); rcnt = databaseHelper.ExecuteQuery(qry); } ar.response = true; response = Request.CreateResponse(HttpStatusCode.Created, ar); return response; } else { ar.errorCode = "No Device Found"; ar.response = false; response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return response; } } catch (Exception ex) { if (!dr.IsClosed) dr.Close(); linfo.LogFile(enLogType.EXCEPTION, "Function = logActivities() Error Message = "+ex.Message+" InnerException ="+ex.InnerException.ToString(),null); ar.errorCode = "Problem in logActivities() WS"; ar.response = false; response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); } finally { if (dr != null && !dr.IsClosed) dr.Close(); } return response; }