25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

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