Skip to content

Commit

Permalink
Merge pull request #4 from perago-cymru/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
glenatron authored Mar 31, 2022
2 parents e9e7a7a + dfd366b commit 0277204
Show file tree
Hide file tree
Showing 52 changed files with 873 additions and 161 deletions.
6 changes: 6 additions & 0 deletions MCS-Extractor-CMD/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
</startup>
</configuration>
55 changes: 55 additions & 0 deletions MCS-Extractor-CMD/CommandLineExtractor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MCSDataImport;

namespace MCS_Extractor_CMD
{
class CommandLineExtractor
{
static void Main(string[] args)
{
Console.WriteLine("MCS Extractor command line tool.");
var conf = StorageSettings.GetInstance();
if ( conf.DatabasePlatform == DatabasePlatform.unset )
{
Console.WriteLine("Could not read a configuration platform, have you run the MCS Extractor?");
Environment.Exit(1);
}
Console.WriteLine("Platform: {0}", conf.DatabasePlatform);
Console.WriteLine("ConnectionString: {0}", conf.ConnectionString);

var importer = new CSVImporter(conf.DatabasePlatform, conf.ConnectionString, conf.DatabaseName);
var csvHandler = new CSVFileHandler(conf.StoragePath, conf.DatabasePlatform, conf.ConnectionString, conf.DatabaseName);
var files = csvHandler.GetFileList();

if (0 < files.Count)
{
for (int fn = 0; fn < files.Count; fn++)
{
if (importer.ImportMapping(files[fn]))
{

Console.Write("Imported: "+files[fn]);

}
else
{
Console.WriteLine("Could not import " + files[fn] + " as no mapping is recognised, please run MCS Extractor");

}
}
}
else
{

Console.WriteLine( "No new files to import." );


}
Environment.Exit(0);
}
}
}
59 changes: 59 additions & 0 deletions MCS-Extractor-CMD/MCS-Extractor-CMD.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MCS_Extractor_CMD</RootNamespace>
<AssemblyName>MCS-Extractor-CMD</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CommandLineExtractor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MCSDataImport\MCSDataImport.csproj">
<Project>{b0867f8f-415e-46bd-9b9b-d46c8e4cf97c}</Project>
<Name>MCSDataImport</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
36 changes: 36 additions & 0 deletions MCS-Extractor-CMD/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MCS-Extractor-CMD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MCS-Extractor-CMD")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ed4f8aff-ad8c-40bf-975b-0f1aefe97354")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
8 changes: 8 additions & 0 deletions MCS-Extractor-Installer/MCS-Extractor-Installer.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
</WixExtension>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MCS-Extractor-CMD\MCS-Extractor-CMD.csproj">
<Name>MCS-Extractor-CMD</Name>
<Project>{ed4f8aff-ad8c-40bf-975b-0f1aefe97354}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\MCS-Extractor\MCS-Extractor.csproj">
<Name>MCS-Extractor</Name>
<Project>{84b9461a-4c3b-4846-99f1-0759534f06a6}</Project>
Expand Down
21 changes: 18 additions & 3 deletions MCS-Extractor-Installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'
xmlns:ui='http://schemas.microsoft.com/wix/UIExtension'>
<Product Id="755303bf-ad0e-47bd-b32e-51ddb8ff7dad" Name="MCS_Extractor_Installer"
Language="1033" Version="1.0.4.0" Manufacturer="Perago-Wales"
Language="1033" Version="1.0.5.2" Manufacturer="Perago-Wales"
UpgradeCode="759fdfe9-5cc7-46f4-9e59-15805e3f8f64">

<Package
Expand All @@ -15,6 +15,7 @@

<Feature Id="ProductFeature" Title="MCS_Extractor_Installer" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="CommandLineComponents" />
<ComponentGroupRef Id="PGSQLComponents" />
<ComponentGroupRef Id="MSSQLComponents" />
<ComponentGroupRef Id="DownloadFolderGroup" />
Expand Down Expand Up @@ -47,10 +48,21 @@

<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="ProductComponent">
<File Id="MCSExtractorExe" Name="MCS_Extractor.exe" DiskId="1" Source="$(var.MCS-Extractor.TargetPath)" KeyPath="yes" />
<Component Id="ProductComponent" Guid="498CE7A5-BC35-4D4F-A086-030B190166C7">
<File Id="MCSExtractorExe" Name="MCS-Extractor.exe" DiskId="1" Source="$(var.MCS-Extractor.TargetPath)" KeyPath="yes" />
<File Id="MCSExtractorConfig" Name="MCS-Extractor.exe.config" DiskId="1" Source="$(var.MCS-Extractor.TargetDir)" KeyPath="no" >
<Permission User="Everyone" GenericAll="yes" />
</File>
</Component>

</ComponentGroup>

<ComponentGroup Id="CommandLineComponents" Directory="INSTALLFOLDER">
<Component Id="CommandLineComponent" Guid="0cceef16-aeaf-11ec-b909-0242ac120002">
<File Id="MCSCommandLineExe" Name="MCS-Extractor-CMD.exe" DiskId="1" Source="$(var.MCS-Extractor-CMD.TargetPath)" KeyPath="no" />
</Component>
</ComponentGroup>

<ComponentGroup Id="PGSQLComponents" Directory="PostgresFolder" >
<Component Id="PGTemplateSQLComponent" Guid="666eb58a-018d-4ca2-bf55-24c4dd4edc40" >
<File Id="PGTemplateSQL" Name="template.sql" DiskId="1" Source="$(var.MCS-Extractor.ProjectDir)\Sql\postgres\template.sql" KeyPath="no" />
Expand All @@ -63,6 +75,9 @@
<Component Id="MSDatabaseSQLComponent" Guid="4e259e2c-9ecb-11ec-b909-0242ac120002" >
<File Id="MSDatabaseSQL" Name="database.sql" DiskId="1" Source="$(var.MCS-Extractor.ProjectDir)\Sql\mssql\database.sql" KeyPath="no" />
</Component>
<Component Id="MSTemplateSQLComponent" Guid="F63FD18F-209D-427A-A6BC-51DA9C92DFED" >
<File Id="MSTemplateSQL" Name="template.sql" DiskId="1" Source="$(var.MCS-Extractor.ProjectDir)\Sql\mssql\template.sql" KeyPath="no" />
</Component>
</ComponentGroup>
<ComponentGroup Id="DownloadFolderGroup">
<Component Id="DownloadFolderComponent" Directory="DownloadFolder" Guid="3189febc-351d-402f-a3ae-6224b0bcb129">
Expand Down
20 changes: 20 additions & 0 deletions MCS-Extractor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ReadMe.md = ReadMe.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MCSDataImport", "MCSDataImport\MCSDataImport.csproj", "{B0867F8F-415E-46BD-9B9B-D46C8E4CF97C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MCS-Extractor-CMD", "MCS-Extractor-CMD\MCS-Extractor-CMD.csproj", "{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -34,6 +38,22 @@ Global
{708CFC24-30DB-44DB-8372-017CC3F92789}.Release|Any CPU.ActiveCfg = Release|x86
{708CFC24-30DB-44DB-8372-017CC3F92789}.Release|x86.ActiveCfg = Release|x86
{708CFC24-30DB-44DB-8372-017CC3F92789}.Release|x86.Build.0 = Release|x86
{B0867F8F-415E-46BD-9B9B-D46C8E4CF97C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0867F8F-415E-46BD-9B9B-D46C8E4CF97C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0867F8F-415E-46BD-9B9B-D46C8E4CF97C}.Debug|x86.ActiveCfg = Debug|Any CPU
{B0867F8F-415E-46BD-9B9B-D46C8E4CF97C}.Debug|x86.Build.0 = Debug|Any CPU
{B0867F8F-415E-46BD-9B9B-D46C8E4CF97C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0867F8F-415E-46BD-9B9B-D46C8E4CF97C}.Release|Any CPU.Build.0 = Release|Any CPU
{B0867F8F-415E-46BD-9B9B-D46C8E4CF97C}.Release|x86.ActiveCfg = Release|Any CPU
{B0867F8F-415E-46BD-9B9B-D46C8E4CF97C}.Release|x86.Build.0 = Release|Any CPU
{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}.Debug|x86.ActiveCfg = Debug|Any CPU
{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}.Debug|x86.Build.0 = Debug|Any CPU
{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}.Release|Any CPU.Build.0 = Release|Any CPU
{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}.Release|x86.ActiveCfg = Release|Any CPU
{ED4F8AFF-AD8C-40BF-975B-0F1AEFE97354}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 2 additions & 4 deletions MCS-Extractor/App.config
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
</startup>
<appSettings>
<add key="CurrentUserDisplayName" value="ben" />
<add key="CurrentUserId" value="1" />
<add key="DatabaseName" value="my_council_services_extract" />
<add key="DataDirectory" value="Downloaded" />
<add key="DatabasePlatform" value="" />
<add key="ConnectionString" value="Host=localhost;Port=5432;username=;password=;" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand Down
7 changes: 4 additions & 3 deletions MCS-Extractor/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Configuration;

using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using MCSDataImport;
using MCS_Extractor.FirstRun;
using MCS_Extractor.FirstRun.Postgres;
using MCS_Extractor.FirstRun.Microsoft;
Expand All @@ -23,12 +24,12 @@ private void Application_Startup(object sender, StartupEventArgs e)
if (first.IsFirstRun)
{
switch (first.Platform) {
case "postgres":
case DatabasePlatform.Postgres:
var firstRun = new PostgresFirstRunWindow();
//firstRun.Owner = this;
firstRun.Show();
break;
case "mssql":
case DatabasePlatform.MSSQL:
var msRun = new MicrosoftFirstRunWindow();
msRun.Show();
break;
Expand Down
42 changes: 19 additions & 23 deletions MCS-Extractor/FirstRun/ConfigurationChanged.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MCSDataImport;

namespace MCS_Extractor.FirstRun
{
public class ConfigurationChanged
{
private StorageSettings settings;

public ConfigurationChanged()
{

settings = StorageSettings.GetInstance();
}

public void SetDatabaseCredentials(string username, string password)
{
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var connectionString = ConfigurationManager.AppSettings["ConnectionString"];

// Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var connectionString = settings.ConnectionString;// ConfigurationManager.AppSettings["ConnectionString"];
var components = connectionString.Split(';');
for ( int i =0; i<components.Length; i++)
{
Expand All @@ -31,36 +34,29 @@ public void SetDatabaseCredentials(string username, string password)
}
}
connectionString = String.Join(";", components);
UpdateAppSettings("ConnectionString", connectionString);
settings.ConnectionString= connectionString;
}

public void SetConnectionString(string newConnect)
public void SetConnectionString(string newConnectionString)
{
UpdateAppSettings("ConnectionString", newConnect);
settings.ConnectionString = newConnectionString;
}

public void SetDatabasePlatform(string newPlatform)
{
var viablePlatforms = new string[] { "mssql", "postgres" };
if ( !viablePlatforms.Contains(newPlatform) )
var platform = DatabasePlatform.unset;
switch (newPlatform)
{
throw new Exception(String.Format("\"{0}\" is not a valid database platform.", newPlatform));
case "mssql": platform = DatabasePlatform.MSSQL;
break;
case "postgres": platform = DatabasePlatform.Postgres;
break;
default: throw new Exception(String.Format("\"{0}\" is not a valid database platform.", newPlatform));
}
UpdateAppSettings("DatabasePlatform", newPlatform);

settings.DatabasePlatform= platform;
}

private void UpdateAppSettings(string theKey, string theValue)
{
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (ConfigurationManager.AppSettings.AllKeys.Contains(theKey))
{
configuration.AppSettings.Settings[theKey].Value = theValue;
}

configuration.Save(ConfigurationSaveMode.Modified);

ConfigurationManager.RefreshSection("appSettings");
}

}
}
Loading

0 comments on commit 0277204

Please sign in to comment.