Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

100 rader
2.7 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. DataBus.StoreId = configer["StoreId"];
  39. DataBus.COM = configer["COM"];
  40. DbContext.InitTable();
  41. RemoteService.PullShopInfo();
  42. base.Configure();
  43. }
  44. /// <summary>
  45. /// 初始化VM
  46. /// </summary>
  47. protected override void Launch()
  48. {
  49. base.Launch();
  50. }
  51. /// <summary>
  52. /// 加载首页VM
  53. /// </summary>
  54. /// <param name="rootViewModel"></param>
  55. protected override void DisplayRootView(object rootViewModel)
  56. {
  57. base.DisplayRootView(rootViewModel);
  58. }
  59. /// <summary>
  60. ///VM加载完毕
  61. /// </summary>
  62. protected override void OnLaunch()
  63. {
  64. QuartzCoreFactory.QuartzCore().AddJob<QuartzJob>(new QuartzMap
  65. {
  66. JobDetail = "定时推送订单",
  67. Cron = DataBus.Cron,
  68. JobName = "订单",
  69. JobGroup = "订单"
  70. });
  71. base.OnLaunch();
  72. }
  73. /// <summary>
  74. /// 退出
  75. /// </summary>
  76. /// <param name="e"></param>
  77. protected override void OnExit(ExitEventArgs e)
  78. {
  79. base.OnExit(e);
  80. }
  81. /// <summary>
  82. /// 全局异常捕获
  83. /// </summary>
  84. /// <param name="e"></param>
  85. protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
  86. {
  87. HKLog.HKLogImport.WriteError(e.Exception.InnerException != null ? e.Exception.InnerException : e.Exception);
  88. GC.Collect();
  89. }
  90. }
  91. }