using HKCardOUT.ViewModels; using Stylet; using StyletIoC; using System; using System.Windows.Threading; using System.Windows; using Microsoft.Extensions.Configuration; using HKCardOUT.Helper; using HKCardOUT.QuartzUtil.Job; using HKCardOUT.QuartzUtil; namespace HKCardOUT { public class Bootstrapper : Bootstrapper { /// /// 程序启动 /// protected override void OnStart() { HKLog.HKLogImport.Init("HKCardOUT"); } protected override void ConfigureIoC(IStyletIoCBuilder builder) { } /// /// 初始化系统相关参数配置 /// protected override void Configure() { var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build(); DataBus.ConnectionString = configer.GetConnectionString("Sqlite"); DataBus.Cron = configer["Cron"]; DataBus.SaasRoute = configer["SaasRoute"]; base.Configure(); } /// /// 初始化VM /// protected override void Launch() { base.Launch(); } /// /// 加载首页VM /// /// protected override void DisplayRootView(object rootViewModel) { base.DisplayRootView(rootViewModel); } /// ///VM加载完毕 /// protected override void OnLaunch() { QuartzCoreFactory.QuartzCore().AddJob(new QuartzMap { JobDetail = "定时推送订单", Cron = DataBus.Cron, JobName = "订单", JobGroup = "订单" }); base.OnLaunch(); } /// /// 退出 /// /// protected override void OnExit(ExitEventArgs e) { base.OnExit(e); } /// /// 全局异常捕获 /// /// protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e) { HKLog.HKLogImport.WriteError(e.Exception.InnerException != null ? e.Exception.InnerException : e.Exception); GC.Collect(); } } }