public static ReturnObject DeleteDevice(string current) { device_information page_object = new device_information(); DBConnection db_connection = new DBConnection(); ReturnObject return_object = new ReturnObject(); string branch_code = string.Empty; string device_location = string.Empty; string device_id = string.Empty; try { JObject current_data = JObject.Parse(current); device_location = current_data["device_location"].ToString(); device_id = current_data["device_id"].ToString(); page_object.UpdateDeviceLocation("D", device_location, device_id); return_object.status = "success"; return_object.return_data = "Device Location deleted successfully!"; } catch (Exception ex) { Logger.LogException(ex, page, "DELETE_DEVICE_LOCATION"); return_object.status = "error"; return_object.return_data = "An error occurred while deleting the Device Location. Please try again. If the error persists, please contact Support."; } finally { page_object.Dispose(); } return(return_object); }
public static ReturnObject GetDeviceData(int page_number, bool is_filter, string filters) { device_information page_object = new device_information(); DBConnection db_connection = new DBConnection(); DataTable device_location_data = new DataTable(); ReturnObject return_object = new ReturnObject(); int start_row = (page_number - 1) * 30; string query = string.Empty; try { query = "select dl.Deviceid as device_id, dl.DeviceLocation as device_location, lp.LastPunchDateTime as download_punch_time from Device_Location dl, LastDateSAXPush lp where dl.DeviceId = lp.Deviceid"; if (is_filter) { query = page_object.GetFilterQuery(filters, query); } query += " ORDER BY dl.DeviceLocation OFFSET " + start_row + " ROWS FETCH NEXT 30 ROWS ONLY"; device_location_data = db_connection.ReturnDataTable(query); return_object.status = "success"; return_object.return_data = JsonConvert.SerializeObject(device_location_data, Formatting.Indented); } catch (Exception ex) { Logger.LogException(ex, page, "GET_DEVICE_LOCATION_DATA"); return_object.status = "error"; return_object.return_data = "An error occurred while performing this operation. Please try again. If the error persists, please contact Support."; } finally { page_object.Dispose(); } return(return_object); }