From 1bb0c8d5cd9bf5bb577df9216e9c6eda866f95a9 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Sat, 25 Aug 2018 18:52:14 +0800 Subject: [PATCH] add sqlserver samples --- CAP.sln | 18 +++++++++--------- .../Controllers/ValuesController.cs | 6 ++---- .../Program.cs | 2 +- .../Sample.Kafka.SqlServer.csproj} | 5 +++-- .../Startup.cs | 10 ++++------ .../appsettings.json | 0 6 files changed, 19 insertions(+), 22 deletions(-) rename samples/{Sample.Kafka.MySql => Sample.Kafka.SqlServer}/Controllers/ValuesController.cs (89%) rename samples/{Sample.Kafka.MySql => Sample.Kafka.SqlServer}/Program.cs (92%) rename samples/{Sample.Kafka.MySql/Sample.Kafka.MySql.csproj => Sample.Kafka.SqlServer/Sample.Kafka.SqlServer.csproj} (70%) rename samples/{Sample.Kafka.MySql => Sample.Kafka.SqlServer}/Startup.cs (59%) rename samples/{Sample.Kafka.MySql => Sample.Kafka.SqlServer}/appsettings.json (100%) diff --git a/CAP.sln b/CAP.sln index bf7efad..3455243 100644 --- a/CAP.sln +++ b/CAP.sln @@ -58,13 +58,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.PostgreSql", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.PostgreSql.Test", "test\DotNetCore.CAP.PostgreSql.Test\DotNetCore.CAP.PostgreSql.Test.csproj", "{7CA3625D-1817-4695-881D-7E79A1E1DED2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Kafka.MySql", "samples\Sample.Kafka.MySql\Sample.Kafka.MySql.csproj", "{9CB51105-A85B-42A4-AFDE-A4FC34D9EA91}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.MongoDB.Test", "test\DotNetCore.CAP.MongoDB.Test\DotNetCore.CAP.MongoDB.Test.csproj", "{C143FCDF-E7F3-46F8-987E-A1BA38C1639D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetCore.CAP.MongoDB.Test", "test\DotNetCore.CAP.MongoDB.Test\DotNetCore.CAP.MongoDB.Test.csproj", "{C143FCDF-E7F3-46F8-987E-A1BA38C1639D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.MongoDB", "src\DotNetCore.CAP.MongoDB\DotNetCore.CAP.MongoDB.csproj", "{77C0AC02-C44B-49D5-B969-7D5305FC20A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetCore.CAP.MongoDB", "src\DotNetCore.CAP.MongoDB\DotNetCore.CAP.MongoDB.csproj", "{77C0AC02-C44B-49D5-B969-7D5305FC20A5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.RabbitMQ.MongoDB", "samples\Sample.RabbitMQ.MongoDB\Sample.RabbitMQ.MongoDB.csproj", "{4473DE19-E8D2-4B57-80A8-C8AAA2BFA20F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.RabbitMQ.MongoDB", "samples\Sample.RabbitMQ.MongoDB\Sample.RabbitMQ.MongoDB.csproj", "{4473DE19-E8D2-4B57-80A8-C8AAA2BFA20F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Kafka.SqlServer", "samples\Sample.Kafka.SqlServer\Sample.Kafka.SqlServer.csproj", "{CD276810-09A2-4105-8798-D65A8AA7C509}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -115,10 +115,6 @@ Global {7CA3625D-1817-4695-881D-7E79A1E1DED2}.Debug|Any CPU.Build.0 = Debug|Any CPU {7CA3625D-1817-4695-881D-7E79A1E1DED2}.Release|Any CPU.ActiveCfg = Release|Any CPU {7CA3625D-1817-4695-881D-7E79A1E1DED2}.Release|Any CPU.Build.0 = Release|Any CPU - {9CB51105-A85B-42A4-AFDE-A4FC34D9EA91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9CB51105-A85B-42A4-AFDE-A4FC34D9EA91}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9CB51105-A85B-42A4-AFDE-A4FC34D9EA91}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9CB51105-A85B-42A4-AFDE-A4FC34D9EA91}.Release|Any CPU.Build.0 = Release|Any CPU {C143FCDF-E7F3-46F8-987E-A1BA38C1639D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C143FCDF-E7F3-46F8-987E-A1BA38C1639D}.Debug|Any CPU.Build.0 = Debug|Any CPU {C143FCDF-E7F3-46F8-987E-A1BA38C1639D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -131,6 +127,10 @@ Global {4473DE19-E8D2-4B57-80A8-C8AAA2BFA20F}.Debug|Any CPU.Build.0 = Debug|Any CPU {4473DE19-E8D2-4B57-80A8-C8AAA2BFA20F}.Release|Any CPU.ActiveCfg = Release|Any CPU {4473DE19-E8D2-4B57-80A8-C8AAA2BFA20F}.Release|Any CPU.Build.0 = Release|Any CPU + {CD276810-09A2-4105-8798-D65A8AA7C509}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD276810-09A2-4105-8798-D65A8AA7C509}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD276810-09A2-4105-8798-D65A8AA7C509}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD276810-09A2-4105-8798-D65A8AA7C509}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -147,10 +147,10 @@ Global {9F3F9BFE-7B6A-4A7A-A6E6-8B517D611873} = {3A6B6931-A123-477A-9469-8B468B5385AF} {82C403AB-ED68-4084-9A1D-11334F9F08F9} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} {7CA3625D-1817-4695-881D-7E79A1E1DED2} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0} - {9CB51105-A85B-42A4-AFDE-A4FC34D9EA91} = {3A6B6931-A123-477A-9469-8B468B5385AF} {C143FCDF-E7F3-46F8-987E-A1BA38C1639D} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0} {77C0AC02-C44B-49D5-B969-7D5305FC20A5} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} {4473DE19-E8D2-4B57-80A8-C8AAA2BFA20F} = {3A6B6931-A123-477A-9469-8B468B5385AF} + {CD276810-09A2-4105-8798-D65A8AA7C509} = {3A6B6931-A123-477A-9469-8B468B5385AF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2E70565D-94CF-40B4-BFE1-AC18D5F736AB} diff --git a/samples/Sample.Kafka.MySql/Controllers/ValuesController.cs b/samples/Sample.Kafka.SqlServer/Controllers/ValuesController.cs similarity index 89% rename from samples/Sample.Kafka.MySql/Controllers/ValuesController.cs rename to samples/Sample.Kafka.SqlServer/Controllers/ValuesController.cs index 1f4adeb..da78c06 100644 --- a/samples/Sample.Kafka.MySql/Controllers/ValuesController.cs +++ b/samples/Sample.Kafka.SqlServer/Controllers/ValuesController.cs @@ -1,12 +1,10 @@ using System; -using System.Data; using System.Data.SqlClient; using Dapper; using DotNetCore.CAP; using Microsoft.AspNetCore.Mvc; -//using MySql.Data.MySqlClient; -namespace Sample.Kafka.MySql.Controllers +namespace Sample.Kafka.SqlServer.Controllers { [Route("api/[controller]")] public class ValuesController : Controller @@ -34,7 +32,7 @@ namespace Sample.Kafka.MySql.Controllers using (var transaction = connection.BeginTransaction(_capBus, autoCommit: false)) { //your business code - connection.Execute("insert into dbo.test1(tname) values('test');", transaction: (IDbTransaction)transaction.DbTransaction); + connection.Execute("insert into dbo.test1(tname) values('test');", transaction: transaction); _capBus.Publish("sample.rabbitmq.mysql", DateTime.Now); diff --git a/samples/Sample.Kafka.MySql/Program.cs b/samples/Sample.Kafka.SqlServer/Program.cs similarity index 92% rename from samples/Sample.Kafka.MySql/Program.cs rename to samples/Sample.Kafka.SqlServer/Program.cs index d92eedd..9fe450d 100644 --- a/samples/Sample.Kafka.MySql/Program.cs +++ b/samples/Sample.Kafka.SqlServer/Program.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -namespace Sample.Kafka.MySql +namespace Sample.Kafka.SqlServer { public class Program { diff --git a/samples/Sample.Kafka.MySql/Sample.Kafka.MySql.csproj b/samples/Sample.Kafka.SqlServer/Sample.Kafka.SqlServer.csproj similarity index 70% rename from samples/Sample.Kafka.MySql/Sample.Kafka.MySql.csproj rename to samples/Sample.Kafka.SqlServer/Sample.Kafka.SqlServer.csproj index e64e18b..6a4b68b 100644 --- a/samples/Sample.Kafka.MySql/Sample.Kafka.MySql.csproj +++ b/samples/Sample.Kafka.SqlServer/Sample.Kafka.SqlServer.csproj @@ -2,9 +2,10 @@ netcoreapp2.1 - Sample.Kafka.MySql + Sample.Kafka.SqlServer NU1701 NU1701 + Sample.Kafka.SqlServer @@ -12,7 +13,7 @@ - + diff --git a/samples/Sample.Kafka.MySql/Startup.cs b/samples/Sample.Kafka.SqlServer/Startup.cs similarity index 59% rename from samples/Sample.Kafka.MySql/Startup.cs rename to samples/Sample.Kafka.SqlServer/Startup.cs index 583a416..e74cae0 100644 --- a/samples/Sample.Kafka.MySql/Startup.cs +++ b/samples/Sample.Kafka.SqlServer/Startup.cs @@ -1,20 +1,18 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -namespace Sample.Kafka.MySql +namespace Sample.Kafka.SqlServer { public class Startup { - public const string ConnectionString = "Server=localhost;Database=testcap;UserId=root;Password=123123;"; - //public const string ConnectionString = "Server=(localdb)\\ProjectsV13;Integrated Security=SSPI;Database=testcap"; + public const string ConnectionString = "Server=localhost;Integrated Security=SSPI;Database=testcap"; public void ConfigureServices(IServiceCollection services) { services.AddCap(x => { - x.UseMySql(ConnectionString); - //x.UseSqlServer(ConnectionString); - x.UseKafka("192.168.10.110:9092"); + x.UseSqlServer(ConnectionString); + x.UseKafka("localhost:9092"); x.UseDashboard(); }); diff --git a/samples/Sample.Kafka.MySql/appsettings.json b/samples/Sample.Kafka.SqlServer/appsettings.json similarity index 100% rename from samples/Sample.Kafka.MySql/appsettings.json rename to samples/Sample.Kafka.SqlServer/appsettings.json