added c# backend

This commit is contained in:
QkoSad
2024-11-24 19:45:56 +02:00
parent 3b572380bb
commit 4496672d19
83 changed files with 3792 additions and 43 deletions
+41
View File
@@ -0,0 +1,41 @@
using System;
using System.Net;
using System.Text;
using MySql.Data.MySqlClient;
namespace Server
{
public class Reset
{
public static void run(MySqlConnection conn, HttpListenerRequest request, HttpListenerResponse response)
{
try
{
// Open the connection
conn.Open();
// Prepare the SQL query
MySqlCommand myCommand = new MySqlCommand();
myCommand.Connection = conn;
myCommand.CommandText = "CALL InitDB";
MySqlDataReader reader = myCommand.ExecuteReader();
response.StatusCode = (int)HttpStatusCode.OK;
response.StatusDescription = "Status OK";
}
catch (Exception ex)
{
response.StatusCode = (int)HttpStatusCode.BadRequest;
string errorMessage = $"Error: {ex.Message}";
byte[] buffer = Encoding.UTF8.GetBytes(errorMessage);
response.ContentType = "text/plain";
response.ContentLength64 = buffer.Length;
response.OutputStream.Write(buffer, 0, buffer.Length);
}
finally
{
conn.Close();
}
}
}
}