done
This commit is contained in:
+5
-7
@@ -23,9 +23,9 @@ namespace Server
|
||||
{
|
||||
try
|
||||
{
|
||||
// Open the connection
|
||||
// open connection
|
||||
conn.Open();
|
||||
// Prepare the SQL query
|
||||
// prepare SQL query
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
// get url params
|
||||
@@ -36,8 +36,7 @@ namespace Server
|
||||
string? offset = queryString["offset"];
|
||||
string? order = queryString["order"];
|
||||
order = order == "true" ? "ASC" : "DESC";
|
||||
// this shenanigan is needed to remove the "" around
|
||||
// group by
|
||||
// this shenanigan is needed to remove the "" around group by
|
||||
string sqlQ = @"SELECT u.f_name,u.l_name,u.mail,p.name,t.time,t.date,t.user
|
||||
FROM Timelog t
|
||||
INNER JOIN Project p ON p.id=t.project
|
||||
@@ -60,7 +59,7 @@ namespace Server
|
||||
cmd.Parameters.AddWithValue("@from", from);
|
||||
cmd.Parameters.AddWithValue("@to", to);
|
||||
|
||||
// Execute the query and read the results
|
||||
// execute query and read results
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
|
||||
List<All> entries = new List<All>();
|
||||
@@ -77,7 +76,7 @@ namespace Server
|
||||
mail = reader["mail"],
|
||||
});
|
||||
}
|
||||
// serialize the data to JSON
|
||||
// serialize JSON
|
||||
string jsonResponse = JsonConvert.SerializeObject(entries);
|
||||
// prepare response
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(jsonResponse);
|
||||
@@ -88,7 +87,6 @@ namespace Server
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Handle any connection errors
|
||||
string errorMessage = $"Error: {ex.Message}";
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(errorMessage);
|
||||
response.ContentType = "text/plain";
|
||||
|
||||
Reference in New Issue
Block a user