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.

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