refractoring

This commit is contained in:
QkoSad
2024-12-05 12:09:30 +02:00
parent 926436860c
commit 80040638a6
37 changed files with 814 additions and 682 deletions
+25 -26
View File
@@ -1,22 +1,22 @@
using System.Net;
using MySql.Data.MySqlClient;
namespace Server
{
public class CreateProcedure : Route
{
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
{
try
{
MySqlCommand cmd = new MySqlCommand();
namespace Server;
using (MySqlConnection conn = new MySqlConnection(connectionString))
{
conn.Open();
cmd.Connection = conn;
cmd.CommandText =
@"
public class CreateProcedure : Route
{
public static void HandleRequest(HttpListenerResponse response)
{
try
{
MySqlCommand cmd = new();
using (MySqlConnection conn = new(connectionString))
{
conn.Open();
cmd.Connection = conn;
cmd.CommandText =
@"
CREATE PROCEDURE fill_timelog ()
BEGIN
DECLARE j INT DEFAULT 1;
@@ -53,9 +53,9 @@ BEGIN
SET users = users + 1;
END WHILE;
END;";
cmd.ExecuteNonQuery();
cmd.CommandText =
@"CREATE PROCEDURE InitDB()
cmd.ExecuteNonQuery();
cmd.CommandText =
@"CREATE PROCEDURE InitDB()
BEGIN
DECLARE i INT DEFAULT 1;
TRUNCATE TABLE Timelog;
@@ -116,15 +116,14 @@ BEGIN
DROP TABLE temp_fname;
DROP TABLE temp_lname;
END;";
cmd.ExecuteNonQuery();
// prepare response
SendSuccess(response);
}
}
catch (Exception ex)
{
SendError(response, ex);
cmd.ExecuteNonQuery();
// prepare response
SendSuccess(response);
}
}
catch (Exception ex)
{
SendError(response, ex);
}
}
}