Skip to content
Snippets Groups Projects
Commit 49fa74cc authored by Daniel Cífka's avatar Daniel Cífka
Browse files

PPBKA3M-92-Implement registration method to database

Repair and compailing last chnage.
parent abbca648
No related branches found
No related tags found
1 merge request!5PPBKA3M-92-Implement registration method to database
......@@ -23,46 +23,9 @@ namespace MeshCompression.Core.Database
Console.WriteLine($"Disconnected...");
}
public List<DataPoint> GetExperimentData(ulong methodId, ulong metricId, ulong objectId)
{
List<DataPoint> experimentDataPoints = new List<DataPoint>();
try
{
string sql = "SELECT Rate, Error, Start, Stop FROM experiments WHERE Algorithms_ID = @MethodId AND Metrics_ID = @MetricId AND 3D_Objects_ID = @ObjectId";
using (var command = new MySqlCommand(sql, connection))
{
// Add parameter for the methodId
command.Parameters.AddWithValue("@MethodId", methodId);
command.Parameters.AddWithValue("@MetricId", metricId);
command.Parameters.AddWithValue("@ObjectId", objectId);
public void EndExperiment(ulong experimentId, Experiment experiment) => throw new NotImplementedException();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
double rate = (double)reader["Rate"];
double result = (double)reader["Error"];
DateTime start = (DateTime)reader["Start"];
DateTime end = (DateTime)reader["Stop"];
DataPoint dataPoint = new DataPoint(rate, result, start, end, methodId, metricId, objectId);
experimentDataPoints.Add(dataPoint);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("An error occurred: " + ex.Message.ToString());
}
return experimentDataPoints;
}
public List<DataPoint> GetExperimentData(ulong methodId, ulong metricId, ulong objectId) => throw new NotImplementedException();
public MethodFile GetMethodFileByName(string name)
{
MethodFile methodFile = null;
......@@ -83,9 +46,8 @@ namespace MeshCompression.Core.Database
var Name = reader["Name"].ToString();
var path = reader["Path"].ToString();
var DisplayName = reader["DisplayName"].ToString();
var Flags = Convert.ToInt32(reader["Flags"]);
methodFile = new MethodFile(Name, DisplayName, path, Flags);
methodFile = new MethodFile(Name, DisplayName, path);
}
}
}
......@@ -117,9 +79,8 @@ namespace MeshCompression.Core.Database
var Name = reader["Name"].ToString();
var path = reader["Path"].ToString();
var DisplayName = reader["DisplayName"].ToString();
var Flags = Convert.ToInt32(reader["Flags"]);
metricFile = new MetricFile(Name, DisplayName, path, Flags);
metricFile = new MetricFile(Name, DisplayName, path);
}
}
}
......@@ -165,19 +126,22 @@ namespace MeshCompression.Core.Database
return objFile;
}
public ulong RegisterExperiment(Experiment experiment) => throw new NotImplementedException();
public void RegisterMethodFile(MethodFile methodFile)
{
try
{
string sql = "INSERT INTO algorithm(Name, Path, Flags, DisplayName) VALUE (@Name, @Path, @Flags, @DisplayName)";
string sql = "INSERT INTO algorithm(Name, DisplayName, Path) VALUE (@Name, @DisplayName,@Path)";
using (var command = new MySqlCommand(sql, connection))
{
// Add parameters
command.Parameters.AddWithValue("@Name", methodFile.Name);
command.Parameters.AddWithValue("@Path", methodFile.Path);
command.Parameters.AddWithValue("@Flags", methodFile.Flags);
command.Parameters.AddWithValue("@DisplayName", methodFile.DisplayName);
command.Parameters.AddWithValue("@Path", methodFile.Path);
// Execute the command
int rowsAffected = command.ExecuteNonQuery();
......@@ -202,15 +166,15 @@ namespace MeshCompression.Core.Database
{
try
{
string sql = "INSERT INTO metric(Name, Path, Flags, DisplayName) VALUE (@Name, @Path, @Flags, @DisplayName)";
string sql = "INSERT INTO metric(Name, DisplayName, Path) VALUE (@Name, @DisplayName, @Path)";
using (var command = new MySqlCommand(sql, connection))
{
// Add parameters
command.Parameters.AddWithValue("@Name", metricFile.Name);
command.Parameters.AddWithValue("@Path", metricFile.Path);
command.Parameters.AddWithValue("@Flags", metricFile.Flags);
command.Parameters.AddWithValue("@DisplayName", metricFile.DisplayName);
command.Parameters.AddWithValue("@Path", metricFile.Path);
// Execute the command
int rowsAffected = command.ExecuteNonQuery();
......@@ -264,42 +228,8 @@ namespace MeshCompression.Core.Database
Console.WriteLine("An error occurred: " + ex.Message.ToString());
}
}
public void SaveExperimentDataPoint(DataPoint experimentDataPoint)
{
try
{
string sql = "INSERT INTO 3d_objects(Rate, Error, Start, End, 3D_Objects_ID, Metric_ID, Algorithm_ID) VALUE (@Rate, @Error, @Start, @End, @3D_Objects_ID, @Metric_ID, @Algorithm_ID)";
using (var command = new MySqlCommand(sql, connection))
{
// Add parameters
command.Parameters.AddWithValue("@Rate", experimentDataPoint.Rate);
command.Parameters.AddWithValue("@Error", experimentDataPoint.Result);
command.Parameters.AddWithValue("@Start", experimentDataPoint.Start);
command.Parameters.AddWithValue("@End", experimentDataPoint.End);
command.Parameters.AddWithValue("@3D_Objects_ID", experimentDataPoint.ObjectId);
command.Parameters.AddWithValue("@Metric_ID", experimentDataPoint.MetricId);
command.Parameters.AddWithValue("@Algorithm_ID", experimentDataPoint.MethodId);
// Execute the command
int rowsAffected = command.ExecuteNonQuery();
// Check if the insertion was successful
if (rowsAffected > 0)
{
Console.WriteLine("Record inserted successfully.");
}
else
{
Console.WriteLine("Failed to insert record.");
}
}
}
catch (Exception ex)
{
Console.WriteLine("An error occurred: " + ex.Message.ToString());
}
}
public void SaveExperimentDataPoint(DataPoint experimentDataPoint) => throw new NotImplementedException();
private void Connect()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment