Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

57 строки
2.2 KiB

  1. using DotNetCore.CAP.EntityFrameworkCore;
  2. using Microsoft.AspNetCore.Builder;
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.Extensions.Configuration;
  5. using Microsoft.Extensions.DependencyInjection;
  6. using Microsoft.Extensions.Logging;
  7. namespace Sample.Kafka
  8. {
  9. public class Startup
  10. {
  11. public Startup(IHostingEnvironment env)
  12. {
  13. var builder = new ConfigurationBuilder()
  14. .SetBasePath(env.ContentRootPath)
  15. .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
  16. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
  17. .AddEnvironmentVariables();
  18. Configuration = builder.Build();
  19. }
  20. public IConfigurationRoot Configuration { get; }
  21. // This method gets called by the runtime. Use this method to add services to the container.
  22. public void ConfigureServices(IServiceCollection services)
  23. {
  24. services.AddDbContext<AppDbContext>();
  25. services.AddCap()
  26. .AddEntityFrameworkStores<AppDbContext>(x=> {
  27. //x.ConnectionString = "Server=192.168.2.206;Initial Catalog=Test;User Id=cmswuliu;Password=h7xY81agBn*Veiu3;MultipleActiveResultSets=True";
  28. x.ConnectionString = "Server=DESKTOP-M9R8T31;Initial Catalog=Test;User Id=sa;Password=P@ssw0rd;MultipleActiveResultSets=True";
  29. })
  30. .AddRabbitMQ(x =>
  31. {
  32. x.HostName = "localhost";
  33. // x.UserName = "admin";
  34. // x.Password = "123123";
  35. });
  36. //.AddKafka(x => x.Servers = "");
  37. // Add framework services.
  38. services.AddMvc();
  39. }
  40. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  41. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  42. {
  43. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  44. loggerFactory.AddDebug();
  45. app.UseMvc();
  46. app.UseCap();
  47. }
  48. }
  49. }