private void QAImporterAsync() { backgroundWorker1.ReportProgress(0, null); toolStripStatusLabel1.Text = "Importing..."; QuestionImporter.QAformatImporter(openFileDialog1.FileName); backgroundWorker1.ReportProgress(90, null); toolStripStatusLabel1.Text = "Saving imported entries to database..."; new FileManager().writeFileWithGeneratedPath(QuestionMemoryDB.getDB(), "QuestionDB", "txt"); backgroundWorker1.ReportProgress(100, null); toolStripStatusLabel1.Text = "Done!"; }
private void backgroundReadDB() { FileManager fm = new FileManager(); backgroundWorker1.ReportProgress(0, null); toolStripStatusLabel1.Text = "Loading database from default file..."; QuestionMemoryDB.setDB((QuestionMemoryDB)fm.readFileWithGeneratedPath("QuestionDB", "txt", typeof(QuestionMemoryDB))); backgroundWorker1.ReportProgress(50, null); toolStripStatusLabel1.Text = "Preparing database..."; QuestionMemoryDB.getDB().sort(); backgroundWorker1.ReportProgress(100, null); toolStripStatusLabel1.Text = "Done!"; }
private void SearchForm_Load(object sender, EventArgs e) { FileManager fm = new FileManager(); qdb = QuestionMemoryDB.getDB(); if (qdb.allQuestion.Count < 1) { DialogResult dr = MessageBox.Show("No question found. Please import database first.", "Empty Database", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } //fm.writeFileWithGeneratedPath(qdb, "QuestionDB","txt"); //qdb = (QuestionMemoryDB)fm.readFileWithGeneratedPath("QuestionDB", "txt", typeof(QuestionMemoryDB)); //QuestionMemoryDB.setDB(qdb); }