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.

97 lignes
2.6 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. namespace HKCardOUT
  15. {
  16. public class Bootstrapper : Bootstrapper<RootViewModel>
  17. {
  18. /// <summary>
  19. /// 程序启动
  20. /// </summary>
  21. protected override void OnStart()
  22. {
  23. HKLog.HKLogImport.Init("HKCardOUT");
  24. }
  25. protected override void ConfigureIoC(IStyletIoCBuilder builder)
  26. {
  27. builder.Bind<HKCore>().ToSelf();
  28. }
  29. /// <summary>
  30. /// 初始化系统相关参数配置
  31. /// </summary>
  32. protected override void Configure()
  33. {
  34. var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build();
  35. DataBus.ConnectionString = configer.GetConnectionString("Sqlite");
  36. DataBus.Cron = configer["Cron"];
  37. DataBus.SaasRoute = configer["SaasRoute"];
  38. DbContext.InitTable();
  39. base.Configure();
  40. }
  41. /// <summary>
  42. /// 初始化VM
  43. /// </summary>
  44. protected override void Launch()
  45. {
  46. base.Launch();
  47. }
  48. /// <summary>
  49. /// 加载首页VM
  50. /// </summary>
  51. /// <param name="rootViewModel"></param>
  52. protected override void DisplayRootView(object rootViewModel)
  53. {
  54. base.DisplayRootView(rootViewModel);
  55. }
  56. /// <summary>
  57. ///VM加载完毕
  58. /// </summary>
  59. protected override void OnLaunch()
  60. {
  61. QuartzCoreFactory.QuartzCore().AddJob<QuartzJob>(new QuartzMap
  62. {
  63. JobDetail = "定时推送订单",
  64. Cron = DataBus.Cron,
  65. JobName = "订单",
  66. JobGroup = "订单"
  67. });
  68. base.OnLaunch();
  69. }
  70. /// <summary>
  71. /// 退出
  72. /// </summary>
  73. /// <param name="e"></param>
  74. protected override void OnExit(ExitEventArgs e)
  75. {
  76. base.OnExit(e);
  77. }
  78. /// <summary>
  79. /// 全局异常捕获
  80. /// </summary>
  81. /// <param name="e"></param>
  82. protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
  83. {
  84. HKLog.HKLogImport.WriteError(e.Exception.InnerException != null ? e.Exception.InnerException : e.Exception);
  85. GC.Collect();
  86. }
  87. }
  88. }