Преглед изворни кода

upgrade to netcoreapp3.0

master
Savorboard пре 5 година
родитељ
комит
673bd335d4
6 измењених фајлова са 50 додато и 27 уклоњено
  1. +15
    -0
      samples/Sample.RabbitMQ.MySql/AppDbContext.cs
  2. +8
    -3
      samples/Sample.RabbitMQ.MySql/Controllers/ValuesController.cs
  3. +9
    -8
      samples/Sample.RabbitMQ.MySql/Program.cs
  4. +8
    -7
      samples/Sample.RabbitMQ.MySql/Properties/launchSettings.json
  5. +3
    -4
      samples/Sample.RabbitMQ.MySql/Sample.RabbitMQ.MySql.csproj
  6. +7
    -5
      samples/Sample.RabbitMQ.MySql/Startup.cs

+ 15
- 0
samples/Sample.RabbitMQ.MySql/AppDbContext.cs Прегледај датотеку

@@ -7,8 +7,23 @@ namespace Sample.RabbitMQ.MySql
public int Id { 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 const string ConnectionString = "Server=192.168.2.120;Database=captest;UserId=root;Password=123123;";


+ 8
- 3
samples/Sample.RabbitMQ.MySql/Controllers/ValuesController.cs Прегледај датотеку

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using Dapper;
@@ -21,7 +22,11 @@ namespace Sample.RabbitMQ.MySql.Controllers
[Route("~/without/transaction")]
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();
}
@@ -69,9 +74,9 @@ namespace Sample.RabbitMQ.MySql.Controllers

[NonAction]
[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}");
}
}
}

+ 9
- 8
samples/Sample.RabbitMQ.MySql/Program.cs Прегледај датотеку

@@ -1,5 +1,5 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace Sample.RabbitMQ.MySql
{
@@ -7,13 +7,14 @@ namespace Sample.RabbitMQ.MySql
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
CreateHostBuilder(args).Build().Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://*:15173")
.Build();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

+ 8
- 7
samples/Sample.RabbitMQ.MySql/Properties/launchSettings.json Прегледај датотеку

@@ -1,10 +1,11 @@
{
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:57171/",
"sslPort": 0
"applicationUrl": "http://localhost:49558",
"sslPort": 44332
}
},
"profiles": {
@@ -20,10 +21,10 @@
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "cap",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
},
"applicationUrl": "http://localhost:57173/"
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}

+ 3
- 4
samples/Sample.RabbitMQ.MySql/Sample.RabbitMQ.MySql.csproj Прегледај датотеку

@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.4" />
</ItemGroup>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\DotNetCore.CAP.MySql\DotNetCore.CAP.MySql.csproj" />
<ProjectReference Include="..\..\src\DotNetCore.CAP.RabbitMQ\DotNetCore.CAP.RabbitMQ.csproj" />


+ 7
- 5
samples/Sample.RabbitMQ.MySql/Startup.cs Прегледај датотеку

@@ -1,9 +1,7 @@
using System;
using DotNetCore.CAP.Messages;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

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();
});
}
}
}

Loading…
Откажи
Сачувај