diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/ArchiveController.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/ArchiveController.cs
index 365fe4c..e76171b 100644
--- a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/ArchiveController.cs
+++ b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/ArchiveController.cs
@@ -1,4 +1,7 @@
-namespace TeamHobby.HobbyProjectGenerator.Archive
+
+using TeamHobby.HobbyProjectGenerator.DataAccess;
+
+namespace TeamHobby.HobbyProjectGenerator.Archive
{
public class ArchiveController
{
diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/TeamHobby.HobbyProjectGenerator.Archive.csproj b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/TeamHobby.HobbyProjectGenerator.Archive.csproj
index 8ec85f5..09da541 100644
--- a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/TeamHobby.HobbyProjectGenerator.Archive.csproj
+++ b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/TeamHobby.HobbyProjectGenerator.Archive.csproj
@@ -13,4 +13,12 @@
+
+
+
+
+
+
+
+
diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.DAL/TeamHobby.HobbyProjectGenerator.DAL.csproj b/Source Code/TeamHobby.HobbyProjectGenerator.DAL/TeamHobby.HobbyProjectGenerator.DAL.csproj
index 8b7e1cd..26710ee 100644
--- a/Source Code/TeamHobby.HobbyProjectGenerator.DAL/TeamHobby.HobbyProjectGenerator.DAL.csproj
+++ b/Source Code/TeamHobby.HobbyProjectGenerator.DAL/TeamHobby.HobbyProjectGenerator.DAL.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Class1.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Class1.cs
new file mode 100644
index 0000000..e92f039
--- /dev/null
+++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Class1.cs
@@ -0,0 +1,7 @@
+namespace TeamHobby.HobbyProjectGenerator.DataAccess
+{
+ public class Class1
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Contracts/IDataSource.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Contracts/IDataSource.cs
similarity index 83%
rename from Source Code/TeamHobby.HobbyProjectGenerator.Archive/Contracts/IDataSource.cs
rename to Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Contracts/IDataSource.cs
index a5d61f5..29dae3e 100644
--- a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Contracts/IDataSource.cs
+++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Contracts/IDataSource.cs
@@ -4,8 +4,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-//namespace TeamHobby.HobbyProjectGenerator.Archive.Contracts
-namespace TeamHobby.HobbyProjectGenerator.Archive
+
+namespace TeamHobby.HobbyProjectGenerator.DataAccess
{
public interface IDataSource
{
diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs
similarity index 83%
rename from Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs
rename to Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs
index 6ecbb93..ea7e9e3 100644
--- a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs
+++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs
@@ -6,34 +6,41 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Compression;
+using System.Data.Odbc;
-
-namespace TeamHobby.HobbyProjectGenerator.Archive
+namespace TeamHobby.HobbyProjectGenerator.DataAccess
{
- public class SQLSource : IDataSource
+ public class SqlDAO : IDataSource
{
- //private SqlConnection conn;
+ private OdbcConnection _conn;
- //public SQLSource(string info)
- //{
- // // Do I put using here to make sure the connection closed once the object is gone?
- // conn = new SqlConnection(info);
- // // Perhaps open the connection here?
- // // conn.Open();
- //}
+ public SqlDAO(string info)
+ {
+ try {
+ Console.WriteLine("Establising Connection");
+ _conn = new OdbcConnection(info);
+ Console.WriteLine("Connection established");
+ }
+ catch {
+ //conn = null;
+ Console.WriteLine("Error when creating a connection");
+ throw;
+ }
+
+ }
+
+ // Getter and setter for Odbc
+ public OdbcConnection Connection { get; set; }
// Makre sure to Check for instanceof() before casting to a SQLReader in the controller
- public Object ReadData(string cmd)
+ public Object? ReadData(string cmd)
{
try
{
- //conn.Open();
- //SqlCommand command = new SqlCommand(null, conn);
- //SqlCommand command = new SqlCommand(cmd, conn);
+ _conn.Open();
+ OdbcCommand command = new OdbcCommand(cmd, _conn);
- // conn.Execute();
- Console.WriteLine("Access a SQL database");
- Console.WriteLine("Select * from archive");
+ OdbcDataReader reader = command.ExecuteReader();
// Execute the command to query the data
//using SqlDataReader sqlReader = command.ExecuteReader();
@@ -43,7 +50,7 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
//conn.Close();
//conn.Dispose();
//return sqlReader;
- return new SqlConnection();
+ return reader;
}
catch (Exception e)
{
diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/RelationalDataSourceFactory.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/RelationalDataSourceFactory.cs
similarity index 90%
rename from Source Code/TeamHobby.HobbyProjectGenerator.Archive/RelationalDataSourceFactory.cs
rename to Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/RelationalDataSourceFactory.cs
index 94c44fc..ac8fda6 100644
--- a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/RelationalDataSourceFactory.cs
+++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/RelationalDataSourceFactory.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.Archive;
+using TeamHobby.HobbyProjectGenerator.DataAccess;
namespace TeamHobby.HobbyProjectGenerator.Archive
{
@@ -16,7 +17,7 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
{
if (String.Equals(name, "SQL", StringComparison.OrdinalIgnoreCase))
{
- return new SQLSource();
+ return null;
}
else
{
diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/TeamHobby.HobbyProjectGenerator.DataAccess.csproj b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/TeamHobby.HobbyProjectGenerator.DataAccess.csproj
new file mode 100644
index 0000000..b7a95b0
--- /dev/null
+++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/TeamHobby.HobbyProjectGenerator.DataAccess.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln
index d235326..2e9cc83 100644
--- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln
+++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln
@@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGener
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.Tests", "..\TeamHobby.UserManagement.Tests\TeamHobby.UserManagement.Tests.csproj", "{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DAL", "..\TeamHobby.HobbyProjectGenerator.DAL\TeamHobby.HobbyProjectGenerator.DAL.csproj", "{DCB0E160-1F6D-406E-8633-489CD564479B}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Models", "..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj", "{75DED6C2-D404-4E71-A58B-0F616DB5C062}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "main", "..\main\main.csproj", "{30C7EBF3-3957-46E5-86C1-C13356841ECA}"
@@ -17,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGener
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.Main", "..\TeamHobby.Main\TeamHobby.Main.csproj", "{ED126EFB-B337-42F9-BE4B-65A5AE90503B}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -29,9 +29,6 @@ Global
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = Release|Any CPU
- {DCB0E160-1F6D-406E-8633-489CD564479B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DCB0E160-1F6D-406E-8633-489CD564479B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DCB0E160-1F6D-406E-8633-489CD564479B}.Release|Any CPU.Build.0 = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = Release|Any CPU
@@ -47,6 +44,10 @@ Global
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Source Code/TeamHobby.Main/HobbyMain.cs b/Source Code/TeamHobby.Main/HobbyMain.cs
index 434c43a..c293745 100644
--- a/Source Code/TeamHobby.Main/HobbyMain.cs
+++ b/Source Code/TeamHobby.Main/HobbyMain.cs
@@ -34,7 +34,7 @@ public class HobbyMain
string connString = "user id=root;" + "password=Teamhobby;server=localhost;" + "Trusted_Connection=yes;" + "database=Alatreon; " + "connection timeout=5";
string connMariaDB = "server=localhost;port=3306;uid=root;pwd=Teamhobby;connection timeout=5";
- var conn = new SqlConnection(connString);
+ //var conn = new SqlConnection(connString);
diff --git a/Source Code/TeamHobby/Class1.cs b/Source Code/TeamHobby/Class1.cs
new file mode 100644
index 0000000..dd20082
--- /dev/null
+++ b/Source Code/TeamHobby/Class1.cs
@@ -0,0 +1,7 @@
+namespace TeamHobby
+{
+ public class Class1
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Source Code/TeamHobby/TeamHobby.csproj b/Source Code/TeamHobby/TeamHobby.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/Source Code/TeamHobby/TeamHobby.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs
index 586ed93..72ebc5a 100644
--- a/Source Code/main/Controller.cs
+++ b/Source Code/main/Controller.cs
@@ -1,5 +1,7 @@
using main;
using System;
+using System.Data.Odbc;
+using TeamHobby.HobbyProjectGenerator.DataAccess;
namespace TeamHobby.HobbyProjectGenerator.Main
@@ -30,7 +32,40 @@ namespace TeamHobby.HobbyProjectGenerator.Main
Console.WriteLine(value: $"username is {username}\npassword is {password}");
-
+
+ // Testing Data Access Layer
+ string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
+ "SERVER=localhost;" +
+ "DATABASE=hobby;" +
+ "UID=root;" +
+ "PASSWORD=Teamhobby;" +
+ "OPTION=3";
+ IDataSource datasource = new SqlDAO(dbInfo);
+
+ string sqlQuery = "Select * from log;";
+ Object result = datasource.ReadData(sqlQuery);
+ Console.WriteLine("type of Result: " + result.GetType());
+ OdbcDataReader reader = null;
+
+ if (result.GetType() == typeof(OdbcDataReader))
+ {
+ reader = (OdbcDataReader)result;
+
+ }
+
+ Console.WriteLine("Reading from the database");
+ while (reader.Read())
+ {
+ Console.WriteLine("Date={0} {1} {2} {3} {4} {5}", reader[0], reader[1], reader[2], reader[3], reader[4], reader[5]);
+ //Console.WriteLine("Col A: {0} ", reader[0]);
+ //Console.WriteLine("Column: " + reader.FieldCount);
+ //Console.WriteLine("Column={1}", reader[1]);
+ }
+
+
+
+
+
/* ExampleDAO z = new ExampleDAO();
z.UserData("Tomato");
Console.Read();*/
diff --git a/Source Code/main/main.csproj b/Source Code/main/main.csproj
index 3b75bc7..63f5952 100644
--- a/Source Code/main/main.csproj
+++ b/Source Code/main/main.csproj
@@ -11,4 +11,8 @@
+
+
+
+