LoadingViewModel.cs 1.1 KB

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