Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

106 lignes
2.9 KiB

  1. using HKCardOUT.ViewModels;
  2. using Stylet;
  3. using StyletIoC;
  4. using System;
  5. using System.Windows.Threading;
  6. using System.Windows;
  7. using Microsoft.Extensions.Configuration;
  8. using HKCardOUT.Helper;
  9. using HKCardOUT.QuartzUtil.Job;
  10. using HKCardOUT.QuartzUtil;
  11. using HKCardOUT.Logic;
  12. using HKCardOUT.Logic.Service;
  13. using ImTools;
  14. using XExten.Advance.LinqFramework;
  15. namespace HKCardOUT
  16. {
  17. public class Bootstrapper : Bootstrapper<RootViewModel>
  18. {
  19. /// <summary>
  20. /// 程序启动
  21. /// </summary>
  22. protected override void OnStart()
  23. {
  24. HKLog.HKLogImport.Init("HKCardOUT");
  25. }
  26. protected override void ConfigureIoC(IStyletIoCBuilder builder)
  27. {
  28. builder.Bind<HKCore>().ToSelf();
  29. }
  30. /// <summary>
  31. /// 初始化系统相关参数配置
  32. /// </summary>
  33. protected override void Configure()
  34. {
  35. var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build();
  36. DataBus.ConnectionString = configer.GetConnectionString("Sqlite");
  37. DataBus.Cron = configer["Cron"];
  38. DataBus.SaasRoute = configer["SaasRoute"];
  39. DataBus.StoreId = configer["StoreId"];
  40. DataBus.COM = configer["COM"];
  41. DataBus.IsTest = configer["IsTest"].AsBool();
  42. DataBus.AM = configer["AM"];
  43. DataBus.PM = configer["PM"];
  44. DataBus.AT = configer["AT"];
  45. DbContext.InitTable();
  46. RemoteService.PullShopInfo();
  47. base.Configure();
  48. }
  49. /// <summary>
  50. /// 初始化VM
  51. /// </summary>
  52. protected override void Launch()
  53. {
  54. base.Launch();
  55. }
  56. /// <summary>
  57. /// 加载首页VM
  58. /// </summary>
  59. /// <param name="rootViewModel"></param>
  60. protected override void DisplayRootView(object rootViewModel)
  61. {
  62. base.DisplayRootView(rootViewModel);
  63. }
  64. /// <summary>
  65. ///VM加载完毕
  66. /// </summary>
  67. protected override void OnLaunch()
  68. {
  69. QuartzCoreFactory.QuartzCore().AddJob<QuartzJob>(new QuartzMap
  70. {
  71. JobDetail = "定时推送订单",
  72. Cron = DataBus.Cron,
  73. JobName = "订单",
  74. JobGroup = "订单"
  75. });
  76. base.OnLaunch();
  77. }
  78. /// <summary>
  79. /// 退出
  80. /// </summary>
  81. /// <param name="e"></param>
  82. protected override void OnExit(ExitEventArgs e)
  83. {
  84. base.OnExit(e);
  85. }
  86. /// <summary>
  87. /// 全局异常捕获
  88. /// </summary>
  89. /// <param name="e"></param>
  90. protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
  91. {
  92. HKLog.HKLogImport.WriteError(e.Exception.InnerException != null ? e.Exception.InnerException : e.Exception);
  93. GC.Collect();
  94. }
  95. }
  96. }