Added some file for Archiving and Dataaccess

This commit is contained in:
Lunastra 2021-12-04 00:30:24 -08:00
parent 82047e09e3
commit 92ad047db2
6 changed files with 134 additions and 1 deletions

View File

@ -0,0 +1,7 @@
namespace TeamHobby.HobbyProjectGenerator.Archive
{
public class ArchiveController
{
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//namespace TeamHobby.HobbyProjectGenerator.Archive.Contracts
namespace TeamHobby.HobbyProjectGenerator.Archive
{
public interface IDataSource
{
// Method for reading data, return 0 for sucessful operation
int ReadData(string cmd);
// Method for Writing data to a data source
int WriteData(string cmd);
//Method for deleteing data from a data source, 0 for successful
int DeleteData();
// Method for updating data from a data source, 0 for sucessful
int UpdateData();
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.Archive.Implementations;
namespace TeamHobby.HobbyProjectGenerator.Archive
{
public class DataSourceFactory
{
// Mehthod to create a specific data source suitable to the need
public IDataSource? getDataSource(string name)
{
try
{
if (String.Equals(name, "SQL", StringComparison.OrdinalIgnoreCase))
{
return new SQLSource();
}
else
{
return null;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}
}
}

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.Archive.Implementations
{
public class SQLSource : IDataSource
{
private SqlConnection conn;
public SQLSource(string info)
{
conn = new SqlConnection(info);
}
public int DeleteData()
{
throw new NotImplementedException();
}
public int ReadData(string cmd)
{
try
{
// conn.open();
// conn.Execute();
Console.WriteLine("Access a SQL database");
Console.WriteLine("Select * from archive");
// while (myReader)
// Print to console
// conn.close();
return 0;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return -1;
}
}
public int UpdateData()
{
throw new NotImplementedException();
}
public int WriteData(string cmd)
{
throw new NotImplementedException();
}
}
}

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

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31919.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator", "TeamHobby.HobbyProjectGenerator.csproj", "{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator", "TeamHobby.HobbyProjectGenerator.csproj", "{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.Archive", "..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj", "{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +17,10 @@ Global
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE