diff --git a/src/Archive/.vscode/launch.json b/src/Archive/.vscode/launch.json new file mode 100644 index 0000000..7fc25d8 --- /dev/null +++ b/src/Archive/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/app/bin/Debug/net6.0/app.dll", + "args": [], + "cwd": "${workspaceFolder}/app", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/src/Archive/.vscode/tasks.json b/src/Archive/.vscode/tasks.json new file mode 100644 index 0000000..e2af24a --- /dev/null +++ b/src/Archive/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/app/app.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/app/app.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/app/app.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/src/Archive/app/ArchiveController.cs b/src/Archive/app/ArchiveController.cs new file mode 100644 index 0000000..bad7df0 --- /dev/null +++ b/src/Archive/app/ArchiveController.cs @@ -0,0 +1,51 @@ +using System; + +namespace app +{ + class ArchiveController{ + static void Main(string[] args) + { + string dsName = "SQL"; + string cmd = ""; + Console.WriteLine("Hello World!"); + + //SQLConnection myconnection = new SQLConnection(); + + // Creating a DataSource Factory to make Data sources + DataSourceFactory dsFactory = new DataSourceFactory(); + + // Creating a SQL data source objects to gain access to the SQL database + IDataSource dataSource = dsFactory.getDataSource("SQL"); + + // Read from the database + dataSource.ReadData("a"); + + // Write to the database + dataSource.WriteData("Insert newName"); + + // Update the datasource + dataSource.UpdateData(); + + // Delete from the datasource + dataSource.DeleteData(); + + Console.WriteLine("-----------------"); + // Creating a Data Source for text files + IDataSource txtSource = dsFactory.getDataSource("txt"); + + // Read from the database + txtSource.ReadData("a"); + + // Write to the database + txtSource.WriteData("a"); + + // Update the datasource + txtSource.UpdateData(); + + // Delete from the datasource + txtSource.DeleteData(); + + } + } + +} diff --git a/src/Archive/app/DataSourceFactory.cs b/src/Archive/app/DataSourceFactory.cs new file mode 100644 index 0000000..b2d10b7 --- /dev/null +++ b/src/Archive/app/DataSourceFactory.cs @@ -0,0 +1,18 @@ + +class DataSourceFactory{ + public IDataSource getDataSource(string name){ + + if (name == "SQL"){ + return new SQLSource(); + } + else if (String.Equals(name, "TXT", StringComparison.OrdinalIgnoreCase)){ + return new TxtSource(); + } + else if(name == "XML"){ + return null; + } + else { + return null; + } + } +} \ No newline at end of file diff --git a/src/Archive/app/Factory.cs b/src/Archive/app/Factory.cs new file mode 100644 index 0000000..3b306b9 --- /dev/null +++ b/src/Archive/app/Factory.cs @@ -0,0 +1,6 @@ + +abstract class Factory{ + + //Method to make a datasource object + public abstract IDataSource getDataSource(string name); +} \ No newline at end of file diff --git a/src/Archive/app/IDataSource.cs b/src/Archive/app/IDataSource.cs new file mode 100644 index 0000000..6c8bf88 --- /dev/null +++ b/src/Archive/app/IDataSource.cs @@ -0,0 +1,15 @@ + +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(); +} \ No newline at end of file diff --git a/src/Archive/app/NewFactory.cs b/src/Archive/app/NewFactory.cs new file mode 100644 index 0000000..e69de29 diff --git a/src/Archive/app/SQLSource.cs b/src/Archive/app/SQLSource.cs new file mode 100644 index 0000000..feb9870 --- /dev/null +++ b/src/Archive/app/SQLSource.cs @@ -0,0 +1,41 @@ + +class SQLSource : IDataSource{ + //private SQLConnection conn; + + // public SQLSource(){ + // conn = new SQLConnection("usernamePasword"); + // } + + 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 WriteData(string cmd){ + Console.WriteLine("Writing data to a SQL database"); + return 0; + } + + public int DeleteData() { + Console.WriteLine("Deleting data from a SQL database"); + return 0; + } + + public int UpdateData() { + Console.WriteLine("Update data to a SQL database"); + return 0; + } +} \ No newline at end of file diff --git a/src/Archive/app/TxtSource.cs b/src/Archive/app/TxtSource.cs new file mode 100644 index 0000000..84bc3f0 --- /dev/null +++ b/src/Archive/app/TxtSource.cs @@ -0,0 +1,29 @@ + +class TxtSource : IDataSource{ + private string fileName; + public int ReadData(string a){ + try{ + Console.WriteLine("Access a text file"); + return 0; + } + catch (Exception e){ + Console.WriteLine(e.Message); + return -1; + } + } + + public int WriteData(string cmd){ + Console.WriteLine("Writing data to a text file"); + return 0; + } + + public int DeleteData() { + Console.WriteLine("Deleting data from a text file"); + return 0; + } + + public int UpdateData() { + Console.WriteLine("Update data to a text file"); + return 0; + } +} \ No newline at end of file diff --git a/src/Archive/app/app.csproj b/src/Archive/app/app.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/src/Archive/app/app.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + +