You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Bootstrapper.cs 2.5 KiB

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