Program.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Newtonsoft.Json.Linq;
  2. using Sers.Gateway;
  3. using Vit.Core.Module.Log;
  4. using Vit.Core.Util.ConfigurationManager;
  5. using Vit.Extensions;
  6. namespace App.ServiceCenter
  7. {
  8. public class Program
  9. {
  10. public static void Main(string[] args)
  11. {
  12. // #1 Init
  13. Sers.ServiceCenter.ServiceCenter.Init();
  14. #region #2 init extension modules
  15. #region ##1 use Gover service manage module
  16. Sers.ServiceCenter.ServiceCenter.Instance.UseGover();
  17. #endregion
  18. #region ##2 load ServiceCenter ApiEvent BeforeCallApi
  19. var BeforeCallApi = Sers.Core.Module.Api.ApiEvent.EventBuilder.LoadEvent_BeforeCallApi(Appsettings.json.GetByPath<JArray>("Sers.ServiceCenter.BeforeCallApi"));
  20. if (BeforeCallApi != null) Sers.ServiceCenter.ServiceCenter.Instance.apiCenterService.BeforeCallApi += BeforeCallApi;
  21. #endregion
  22. // ##3 Load ApiLoadera then load apis from configuration (appsettings.json::Sers.LocalApiService.ApiLoaders )
  23. Sers.ServiceCenter.ServiceCenter.Instance.LoadApi();
  24. // ##4 Load system manage apis
  25. Sers.ServiceCenter.ServiceCenter.Instance.LoadSsApi(typeof(Sers.ServiceCenter.Controllers.ServiceStationController).Assembly);
  26. #endregion
  27. // #3 Start ServiceCenter
  28. if (!Sers.ServiceCenter.ServiceCenter.Start()) return;
  29. #region #4 Start gateway if needed
  30. try
  31. {
  32. GatewayHelp.Bridge();
  33. }
  34. catch (System.Exception ex)
  35. {
  36. Logger.Error(ex);
  37. return;
  38. }
  39. #endregion
  40. // #5 RunAwait
  41. Sers.ServiceCenter.ServiceCenter.RunAwait();
  42. }
  43. }
  44. }