public void save() { ViewModel.getInstance().ProgressBarColor = Color.Green; ViewModel.getInstance().ProgressBar.Maximum = 100; ThesisRecord record = MainThread.getInstance().ThesisRecord; if (!validateInput(record)) { return; } ViewModel.getInstance().AllowInput(false); ViewModel.getInstance().MenuButtonEnabled = false; record.RecordId = DBEtdRecords.generateRecordId(); record.FilePath = record.RecordId + ".zip"; record.FullTextFilePath = record.RecordId + ".pdf"; string storageFolderPath = ReaderConfig.getInstance().StoragePath; if (!storageFolderPath.EndsWith(@"\")) { storageFolderPath += @"\"; } record.StorageFolderPath = storageFolderPath; FileUtils.CopyZipToStorage(); }
public void fileCopySuccess() { ThesisRecord record = MainThread.getInstance().ThesisRecord; record.CreateDate = DateTime.Now; List <ThesisRecord> recordList = new List <ThesisRecord>(); recordList.Add(record); int rowsInserted = DBEtdRecords.insertEtdRecords(recordList); if (rowsInserted == 1) { ViewModel.getInstance().ProgressBarColor = Color.Green; alert("Thesis record saved successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ViewModel.getInstance().MenuButtonEnabled = true; } else { string archiveFilePath = record.StorageFolderPath + record.FilePath; string fullTextFilePath = record.StorageFolderPath + record.FullTextFilePath; if (File.Exists(archiveFilePath)) { File.Delete(archiveFilePath); } if (File.Exists(fullTextFilePath)) { File.Delete(fullTextFilePath); } ViewModel.getInstance().ProgressBarColor = Color.Red; alert("Failed to insert record into database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ViewModel.getInstance().AllowInput(true); ViewModel.getInstance().MenuButtonEnabled = true; } }