Program.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using CoreEntity.TimedTask;
  7. using Microsoft.AspNetCore;
  8. using Microsoft.AspNetCore.Hosting;
  9. using Microsoft.Extensions.Configuration;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using Microsoft.Extensions.Logging;
  12. using Quartz.Spi;
  13. //using SupplierWeb.TimedTask;
  14. using ZcPeng.PublicLibrary;
  15. namespace SupplierWeb
  16. {
  17. public class Program
  18. {
  19. //注册各种服务
  20. static void RegisterServices(IServiceCollection services)
  21. {
  22. //日志相关
  23. //services.AddSingleton<ILoggerFactory, LoggerFactory>();
  24. //services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
  25. //services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace));
  26. //定时任务相关
  27. //services.AddSingleton<IJobFactory, MyServiceJobFactory>();
  28. //services.AddSingleton<PushJob>();
  29. }
  30. public static void Main(string[] args)
  31. {
  32. // 在应用程序启动时运行的代码
  33. //填写默认的SQL SERVER数据库连接字符串
  34. //DataAccess.connectionString = "Data Source=YourDataSource;Initial Catalog=YourDb;Persist Security Info=True;User ID=YourUserId;Password=YourPassword";
  35. //DataAccess.connectionString
  36. // = "Data Source =localhost\\MSSQLSERVER12; Initial Catalog = ERPSupplierPortal; Persist Security Info = True; User ID = sa; Password = pzc4213;Pooling=true;MAX Pool Size=512;Min Pool Size=50;Connection Lifetime=30";
  37. //DataAccess.connectionString
  38. // = "Data Source =192.168.50.30; Initial Catalog = LJHYBZK; Persist Security Info = True; User ID = sa; Password = xq!@#2014;Pooling=true;MAX Pool Size=512;Min Pool Size=50;Connection Lifetime=30";
  39. DataAccess.connectionString
  40. = "Data Source =192.168.20.122; Initial Catalog = MemberData; Persist Security Info = True; User ID = ljhyPortal2016; Password =testliangjian@#!)2016;Pooling=true;MAX Pool Size=512;Min Pool Size=50;Connection Lifetime=30";
  41. BuildWebHost(args).Run();
  42. }
  43. public static IWebHost BuildWebHost(string[] args) =>
  44. WebHost.CreateDefaultBuilder(args)
  45. .UseContentRoot(Directory.GetCurrentDirectory())
  46. .ConfigureAppConfiguration((hostingContext, config) => {
  47. var env = hostingContext.HostingEnvironment;
  48. config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
  49. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
  50. config.AddEnvironmentVariables();
  51. })
  52. .ConfigureLogging((hostingContext, logging) => {
  53. logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
  54. logging.AddConsole();
  55. logging.AddDebug();
  56. })
  57. .UseStartup<Startup>()
  58. .UseUrls(new string[] { "http://*:57252" })
  59. .Build();
  60. public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
  61. WebHost.CreateDefaultBuilder(args)
  62. .UseUrls("http://*:5080")
  63. .UseKestrel()
  64. //.UseUrls(new string[] { "http://*:44383" }) 没有作用
  65. .UseStartup<Startup>();
  66. }
  67. }