Program.cs 3.4 KB

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