From 466b273736e5fa67b1487b6450d7a186887782a3 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Fri, 6 Apr 2018 19:15:17 -0500 Subject: [PATCH] removing app.config and web.config and putting in code starting support for mysql (for linux) --- .vs/config/applicationhost.config | 1022 +++++++++++++++++ .../ProfanityDeterment.csproj | 2 +- Plugins/SimpleStats/StatsPlugin.csproj | 2 +- Plugins/Welcome/WelcomePlugin.csproj | 2 +- SharedLibrary/App.config | 36 - .../Database/ContextConfiguration.cs | 30 + SharedLibrary/Database/DatabaseContext.cs | 8 +- SharedLibrary/SharedLibrary.csproj | 12 +- SharedLibrary/Utilities.cs | 2 + WebfrontCore/Startup.cs | 12 + WebfrontCore/Views/Penalty/List.cshtml | 2 +- WebfrontCore/WebfrontCore.csproj | 14 +- WebfrontCore/app.config | 37 - WebfrontCore/appsettings.json | 4 + WebfrontCore/web.config | 14 - 15 files changed, 1097 insertions(+), 102 deletions(-) create mode 100644 .vs/config/applicationhost.config delete mode 100644 SharedLibrary/App.config create mode 100644 SharedLibrary/Database/ContextConfiguration.cs delete mode 100644 WebfrontCore/app.config delete mode 100644 WebfrontCore/web.config diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config new file mode 100644 index 000000000..5441f24fc --- /dev/null +++ b/.vs/config/applicationhost.config @@ -0,0 +1,1022 @@ + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/ProfanityDeterment/ProfanityDeterment.csproj b/Plugins/ProfanityDeterment/ProfanityDeterment.csproj index 316a45359..99cc8c839 100644 --- a/Plugins/ProfanityDeterment/ProfanityDeterment.csproj +++ b/Plugins/ProfanityDeterment/ProfanityDeterment.csproj @@ -72,6 +72,6 @@ - copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\" + copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\" \ No newline at end of file diff --git a/Plugins/SimpleStats/StatsPlugin.csproj b/Plugins/SimpleStats/StatsPlugin.csproj index 48d1ee465..267017545 100644 --- a/Plugins/SimpleStats/StatsPlugin.csproj +++ b/Plugins/SimpleStats/StatsPlugin.csproj @@ -156,7 +156,7 @@ - copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\" + copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\" -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SharedLibrary/Database/ContextConfiguration.cs b/SharedLibrary/Database/ContextConfiguration.cs new file mode 100644 index 000000000..3228b25d5 --- /dev/null +++ b/SharedLibrary/Database/ContextConfiguration.cs @@ -0,0 +1,30 @@ +using System; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +using System.Data.Entity.SqlServerCompact; +using System.Data.SqlServerCe; + +namespace SharedLibrary.Database +{ + class ContextConfiguration : DbConfiguration + { + public ContextConfiguration() + { + if (!Utilities.IsRunningOnMono()) + { + SetExecutionStrategy("System.Data.SqlServerCe.4.0", () => new DefaultExecutionStrategy()); + SetProviderFactory("System.Data.SqlServerCe.4.0", new SqlCeProviderFactory()); + SetProviderServices("System.Data.SqlServerCe.4.0", SqlCeProviderServices.Instance); + SetDefaultConnectionFactory(new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0")); + } + + else + { + /* SetExecutionStrategy("MySql.Data.MySqlClient", () => new DefaultExecutionStrategy()); + SetProviderFactory("MySql.Data.MySqlClient", new MySql.Data.MySqlClient.MySqlClientFactory()); + SetProviderServices("MySql.Data.MySqlClient", new MySql.Data.MySqlClient.MySqlProviderServices()); + SetDefaultConnectionFactory(new MySql.Data.Entity.MySqlConnectionFactory());*/ + } + } + } +} diff --git a/SharedLibrary/Database/DatabaseContext.cs b/SharedLibrary/Database/DatabaseContext.cs index cbe8403d7..72dfe1e60 100644 --- a/SharedLibrary/Database/DatabaseContext.cs +++ b/SharedLibrary/Database/DatabaseContext.cs @@ -11,10 +11,12 @@ using System.Reflection; using System.Data.Entity.Infrastructure; using System.Data.Entity.SqlServerCompact; using System.IO; +using System.Data.Common; namespace SharedLibrary.Database { + [DbConfigurationType(typeof(ContextConfiguration))] public class DatabaseContext : DbContext { public DbSet Clients { get; set; } @@ -22,7 +24,9 @@ namespace SharedLibrary.Database public DbSet AliasLinks { get; set; } public DbSet Penalties { get; set; } - public DatabaseContext() : base("DefaultConnection") + public static string ConnectionString; + + public DatabaseContext() : base(ConnectionString) { System.Data.Entity.Database.SetInitializer(new MigrateDatabaseToLatestVersion()); //Database.CreateIfNotExists(); @@ -62,7 +66,7 @@ namespace SharedLibrary.Database directoryFiles = Directory.GetFiles($@"{Environment.CurrentDirectory}\bin\x86\Debug\Plugins").Where(f => f.Contains(".dll")); } - catch(Exception) + catch (Exception) { directoryFiles = Directory.GetFiles($@"{Environment.CurrentDirectory}\Plugins").Where(f => f.Contains(".dll")); } diff --git a/SharedLibrary/SharedLibrary.csproj b/SharedLibrary/SharedLibrary.csproj index e815d056d..ea9c8b611 100644 --- a/SharedLibrary/SharedLibrary.csproj +++ b/SharedLibrary/SharedLibrary.csproj @@ -148,6 +148,7 @@ + @@ -209,7 +210,6 @@ - @@ -240,6 +240,12 @@ 1.1.2 + + 6.10.6 + + + 6.10.6 + 11.0.1 @@ -261,12 +267,12 @@ - if not exist "$(ProjectDir)LibSQLCE\x86" md "$(TargetDir)x86" + if not exist "$(ProjectDir)LibSQLCE\x86" md "$(TargetDir)x86" xcopy /y "$(ProjectDir)LibSQLCE\x86" "$(TargetDir)x86\" - if not exist "$(SolutionDir)BUILD" mkdir "$(SolutionDir)BUILD" + if not exist "$(SolutionDir)BUILD" mkdir "$(SolutionDir)BUILD" if not exist "$(SolutionDir)BUILD\userraw\scripts" mkdir "$(SolutionDir)BUILD\userraw\scripts" -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/WebfrontCore/appsettings.json b/WebfrontCore/appsettings.json index 407850b38..282edf0ca 100644 --- a/WebfrontCore/appsettings.json +++ b/WebfrontCore/appsettings.json @@ -9,5 +9,9 @@ }, "Web": { "Address": "http://127.0.0.1:5000" + }, + "ConnectionStrings": { + "WindowsConnection": "Data Source=|DataDirectory|\\Database.sdf", + "LinuxConnection": "server=server;user=user;database=db;password=pass" } } diff --git a/WebfrontCore/web.config b/WebfrontCore/web.config deleted file mode 100644 index dc0514fca..000000000 --- a/WebfrontCore/web.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - -