LoadingViewModel.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. namespace ProximaAnalizer.ViewModels;
  2. internal partial class LoadingViewModel : ObservableObject
  3. {
  4. public LoadingViewModel(IRegionManager regionManager, IEventAggregator eventAggregator,SqlSugarCustom sqlSugarCustom)
  5. {
  6. this._regionManager = regionManager;
  7. this._eventAggregator = eventAggregator;
  8. this._sqlSugarCustom = sqlSugarCustom;
  9. Task.Factory.StartNew(Initialize);
  10. }
  11. private readonly IEventAggregator _eventAggregator;
  12. private readonly IRegionManager _regionManager;
  13. private readonly SqlSugarCustom _sqlSugarCustom;
  14. private void Initialize()
  15. {
  16. //Thread.Sleep(2000);
  17. string dbString = "Database=TINReal;Password=123456;Host=localhost;Username=postgres;Persist Security Info=True";
  18. this._sqlSugarCustom.Initialize(null);
  19. this._sqlSugarCustom.Open(dbString, SqlSugar.DbType.PostgreSQL,true);
  20. App.Current.Dispatcher.Invoke(() =>
  21. {
  22. _eventAggregator.GetEvent<WindowSwitch>().Page = Pages.RecipeStepNavi;
  23. _eventAggregator.GetEvent<WindowSwitch>().Publish();
  24. });
  25. }
  26. }