Created Logging Library

This commit is contained in:
colincreasman 2021-12-11 16:38:51 -08:00
parent 5e24218d94
commit 121dace628
6 changed files with 62 additions and 28 deletions

2
.gitignore vendored
View File

@ -423,3 +423,5 @@ healthchecksdb
.vscode/launch.json
.vscode/tasks.json
Source Code/.vscode/tasks.json
Source Code/.vscode/launch.json

View File

@ -0,0 +1,14 @@
using System;
namespace TeamHobby.HobbyProjectGenerator.Logging
{
public class Logger
{
public static void PrintTest()
{
Console.WriteLine("testing");
}
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -15,7 +15,9 @@ 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}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.Logging", "..\TeamHobby.HobbyProjectGenerator.Logging\TeamHobby.HobbyProjectGenerator.Logging.csproj", "{C0494115-838E-43A3-8896-133E5D1E874A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -48,6 +50,10 @@ Global
{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
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -2,7 +2,7 @@
using System;
using System.Data.Odbc;
using TeamHobby.HobbyProjectGenerator.DataAccess;
using TeamHobby.HobbyProjectGenerator.Logging;
namespace TeamHobby.HobbyProjectGenerator.Main
{
@ -26,6 +26,8 @@ namespace TeamHobby.HobbyProjectGenerator.Main
public static void Main(string[] args)
{
// Logger log = new Logger();
Logger.PrintTest();
//GetCredentials credentials = new GetCredentials();
//string? username = credentials.GetUserName();
//string? password = credentials.GetPassword();
@ -34,38 +36,38 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//Console.WriteLine(value: $"username is {username}\npassword is {password}");
// Creating the Factory class
string dbType = "sql";
RelationalDataSourceFactory dbFactory = new RelationalDataSourceFactory();
//string dbType = "sql";
//RelationalDataSourceFactory dbFactory = new RelationalDataSourceFactory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType,dbInfo);
//// Testing Data Access Layer
//string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
// "SERVER=localhost;" +
// "DATABASE=hobby;" +
// "UID=root;" +
// "PASSWORD=Teamhobby;" +
// "OPTION=3";
//IDataSource<string> datasource = dbFactory.getDataSource(dbType,dbInfo);
string sqlQuery = "Select * from log;";
Object result = datasource.ReadData(sqlQuery);
Console.WriteLine("type of Result: " + result.GetType());
OdbcDataReader reader = null;
//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;
//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]);
}
SqlDAO sqlDS = (SqlDAO)datasource;
//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]);
//}
//SqlDAO sqlDS = (SqlDAO)datasource;
// Closing the connection
sqlDS.getConnection().Close();
//// Closing the connection
//sqlDS.getConnection().Close();
// 2.Inserting Data into the database:
//string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " +

View File

@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Logging\TeamHobby.HobbyProjectGenerator.Logging.csproj" />
</ItemGroup>
</Project>