您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Bootstrapper.cs 2.9 KiB

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