Commit 673bd335 authored by Savorboard's avatar Savorboard

upgrade to netcoreapp3.0

parent 71e3e1d4
...@@ -7,8 +7,23 @@ namespace Sample.RabbitMQ.MySql ...@@ -7,8 +7,23 @@ namespace Sample.RabbitMQ.MySql
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public override string ToString()
{
return $"Name:{Name}, Id:{Id}";
}
} }
public class Person2
{
public int Id { get; set; }
public string Name { get; set; }
public override string ToString()
{
return $"Name:{Name}, Id:{Id}";
}
}
public class AppDbContext : DbContext public class AppDbContext : DbContext
{ {
public const string ConnectionString = "Server=192.168.2.120;Database=captest;UserId=root;Password=123123;"; public const string ConnectionString = "Server=192.168.2.120;Database=captest;UserId=root;Password=123123;";
......
using System; using System;
using System.Collections.Generic;
using System.Data; using System.Data;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dapper; using Dapper;
...@@ -21,7 +22,11 @@ namespace Sample.RabbitMQ.MySql.Controllers ...@@ -21,7 +22,11 @@ namespace Sample.RabbitMQ.MySql.Controllers
[Route("~/without/transaction")] [Route("~/without/transaction")]
public async Task<IActionResult> WithoutTransaction() public async Task<IActionResult> WithoutTransaction()
{ {
await _capBus.PublishAsync("sample.rabbitmq.mysql", DateTime.Now); await _capBus.PublishAsync("sample.rabbitmq.mysql", new Person()
{
Id = 123,
Name = "Bar"
});
return Ok(); return Ok();
} }
...@@ -69,9 +74,9 @@ namespace Sample.RabbitMQ.MySql.Controllers ...@@ -69,9 +74,9 @@ namespace Sample.RabbitMQ.MySql.Controllers
[NonAction] [NonAction]
[CapSubscribe("sample.rabbitmq.mysql")] [CapSubscribe("sample.rabbitmq.mysql")]
public void Subscriber(DateTime time) public void Subscriber(Person2 p)
{ {
Console.WriteLine($@"{DateTime.Now}, Subscriber invoked, Sent time:{time}"); Console.WriteLine($@"{DateTime.Now} Subscriber invoked, Info: {p}");
} }
} }
} }
using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting;
namespace Sample.RabbitMQ.MySql namespace Sample.RabbitMQ.MySql
{ {
...@@ -7,13 +7,14 @@ namespace Sample.RabbitMQ.MySql ...@@ -7,13 +7,14 @@ namespace Sample.RabbitMQ.MySql
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
BuildWebHost(args).Run(); CreateHostBuilder(args).Build().Run();
} }
public static IWebHost BuildWebHost(string[] args) => public static IHostBuilder CreateHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
.UseStartup<Startup>() .ConfigureWebHostDefaults(webBuilder =>
.UseUrls("http://*:15173") {
.Build(); webBuilder.UseStartup<Startup>();
});
} }
} }
{ {
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": { "iisSettings": {
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "http://localhost:57171/", "applicationUrl": "http://localhost:49558",
"sslPort": 0 "sslPort": 44332
} }
}, },
"profiles": { "profiles": {
...@@ -20,10 +21,10 @@ ...@@ -20,10 +21,10 @@
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "cap", "launchUrl": "cap",
"applicationUrl": "http://localhost:5000",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production" "ASPNETCORE_ENVIRONMENT": "Development"
}, }
"applicationUrl": "http://localhost:57173/"
} }
} }
} }
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.6" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.4" /> </ItemGroup>
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\DotNetCore.CAP.MySql\DotNetCore.CAP.MySql.csproj" /> <ProjectReference Include="..\..\src\DotNetCore.CAP.MySql\DotNetCore.CAP.MySql.csproj" />
<ProjectReference Include="..\..\src\DotNetCore.CAP.RabbitMQ\DotNetCore.CAP.RabbitMQ.csproj" /> <ProjectReference Include="..\..\src\DotNetCore.CAP.RabbitMQ\DotNetCore.CAP.RabbitMQ.csproj" />
......
using System; using System;
using DotNetCore.CAP.Messages; using DotNetCore.CAP.Messages;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Sample.RabbitMQ.MySql namespace Sample.RabbitMQ.MySql
{ {
...@@ -26,12 +24,16 @@ namespace Sample.RabbitMQ.MySql ...@@ -26,12 +24,16 @@ namespace Sample.RabbitMQ.MySql
}; };
}); });
services.AddMvc(); services.AddControllers();
} }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app)
{ {
app.UseMvc(); app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment