public RODBView(string dbfile) { InitializeComponent(); KeyDown += (s, ves) => { switch (ves.Key) { case Key.Escape: Close(); break; } }; _localdb = dbfile; FileAttributeHelper.RmvAttribute(_localdb, FileAttributes.ReadOnly); _db = A0DbModel.GetLclFl(dbfile); Loaded += onLoaded; samePC.IsEnabled = _localdb.Contains(Environment.MachineName); } // using AsLink.UI;
async void onLoaded(object s, RoutedEventArgs e) { vizroot.IsEnabled = false; try { tbInfo.Text = $"Loading ... "; tbCurVer.Text = $"{VerHelper.CurVerStr(".NET 5.0")}"; var itemsSrc = await DbLogHelper.AllPCsAsync(); tbInfo.Text = $"Loading {itemsSrc.Count} PCs... "; var _localdb = OneDrive.Folder($@"{DbLogHelper._dbSubP}LocalDb({Environment.MachineName}).mdf"); FileAttributeHelper.RmvAttribute(_localdb, FileAttributes.ReadOnly); var _db = A0DbModel.GetLclFl(_localdb); await _db.PcLogics.LoadAsync(); await _db.EvOfInts.LoadAsync(); //foreach (PcLogic item in ((List<PcLogic>)pcLogicDataGridRO.ItemsSource).Where(r => !r.MachineName.Equals(Environment.MachineName, StringComparison.OrdinalIgnoreCase))) _db.PcLogics.Local.Add(item); ((CollectionViewSource)(FindResource("pcLogicViewSource"))).Source = _db.PcLogics.Local; ((CollectionViewSource)(FindResource("evOfIntViewSource"))).Source = _db.EvOfInts.Local; tbInfo.Text = $"{_db.PcLogics.Local.Count} PCs with {_db.EvOfInts.Local.Count} events."; pcLogicDataGridRO.ItemsSource = itemsSrc; foreach (var item in itemsSrc) { if (item.MachineName.Equals(Environment.MachineName, StringComparison.OrdinalIgnoreCase)) { pcLogicDataGridRO.SelectedItem = item; } } pcLogicDataGridRO.Focus(); } catch (Exception ex) { ex.Pop();; } finally { vizroot.IsEnabled = true; } }