public void ImportData([NotNull] Action updateGraph) { var pbw = new ProgressbarWindow("Importing...", "Importing " + _csvImporter.Entries.Count + " datapoints.", _csvImporter.Entries.Count + _tp.DatapointsCount); pbw.Show(); var t = new Thread(() => { Logger.Info("Importing " + _csvImporter.Entries.Count + " datapoints..."); var startcount = _tp.DatapointsCount; for (var i = 0; i < _csvImporter.Entries.Count; i++) { var ce = _csvImporter.Entries[i]; Logger.Get().SafeExecute(() => _tp.AddNewTimepoint(ce.TimeSinceStart, ce.Value, false)); } while (startcount + _csvImporter.Entries.Count != _tp.DatapointsCount) { Thread.Sleep(10); } _tp.SaveToDB(pbw.UpdateValue); lock (_tp.ObservableDatapoints) { Logger.Get().SafeExecute(_tp.ObservableDatapoints.Sort); } Logger.Get().SafeExecute(pbw.Close); Logger.Get().SafeExecute(updateGraph); }); t.Start(); Logger.Info("Imported all data points."); }
private void BtnMakePreview([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { var pbw = new ProgressbarWindow("Making preview", "Making Preview and creating households", 1); pbw.Show(); var stp = Presenter; void MakePreview() { try { stp.GeneratePreview(); Logger.Get().SafeExecuteWithWait(() => LstHouseEntries.ResizeColummns()); if (pbw.IsVisible) { Logger.Get().SafeExecuteWithWait(pbw.Close); } } catch (DataIntegrityException dix) { Logger.Error(dix.Message); MessageWindowHandler.Mw.ShowDataIntegrityMessage(dix); } catch (Exception ex) { Logger.Exception(ex); MessageWindowHandler.Mw.ShowDebugMessage(ex); } } var t = new Thread(() => MakePreview()); t.Start(); }
private void BtnGetPreview([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { var pbw = new ProgressbarWindow("Loading..", "Generating Preview", Presenter.ApplicationPresenter.CurrentCategories?.Count ?? 0); pbw.Show(); var filename = Presenter.FileName; var dm = Presenter.ThisMerger; var t = new Thread(() => { try { dm.RunFindItems(filename, pbw.UpdateValue); Logger.Get().SafeExecute(pbw.Close); Logger.Get().SafeExecute(() => LstItemsToImport.ResizeColummns()); } catch (Exception ex) { Logger.Exception(ex); MessageWindowHandler.Mw.ShowDebugMessage(ex); } }); t.Start(); }
public void ImportData() { Logger.Info("Importing " + _csvImporter.Entries.Count + " datapoints..."); for (var i = 0; i < _csvImporter.Entries.Count; i++) { var ce = _csvImporter.Entries[i]; var date = ce.Time; _dbp.AddNewDatePoint(date, ce.Value, false); } _dbp.Datapoints.Sort(); var pbw = new ProgressbarWindow("Importing...", "Importing " + _csvImporter.Entries.Count + " entries.", _csvImporter.Entries.Count); pbw.Show(); var t = new Thread(() => { _dbp.SaveToDB(pbw.UpdateValue); Logger.Get().SafeExecute(pbw.Close); }); t.Start(); Logger.Info("Imported all data points."); }
private void BtnImportNow([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { var pbw = new ProgressbarWindow("Importing...", "Importing items...", Presenter.ThisMerger.ItemsToImport.Count); pbw.Show(); Presenter.ThisMerger.DisplayMessageBox = true; var dm = Presenter.ThisMerger; var t = new Thread(() => { dm.RunImport(pbw.UpdateValue); Logger.Get().SafeExecute(pbw.Close); var oldPath = Shell.DB3Path; if (oldPath == null) { throw new LPGException("Old path was null"); } Logger.Get().SafeExecute(() => { Presenter.ApplicationPresenter.Shell.CloseDB(); Presenter.ApplicationPresenter.Shell.OpenDatabase(oldPath); }); }); t.Start(); }