/// <summary> /// Begins the import process /// </summary> public void BeginImportProcess() { // Bring the loading screen to the front ActivateLoadingScreen("Importing Data..."); // Update the top handle bar model topHandleBarModel.Update("Loading...", "Loading..."); // Create a new instance of the overall reports CreateReport(ReportingType.KpaOverall); CreateReport(ReportingType.KpiOverall); if (AccessDatabaseUtils.US_PRPO_TableExists || AccessDatabaseUtils.MX_PRPO_TableExists) { DatabaseManager.DropCreateDb(); } else { DatabaseManager.CreateAccessDB(); } // Start the timer to check if the import has completed. ImportTimer.Start(); foreach (var file in processedFiles) { if (file is UsPrpoExcelFile) { // This file is a US PRPO file. // Start importing the Report ImportPrpoExcelFile(file); } else if (file is MxPrpoExcelFile) { // This file is a MX PRPO file. // Start importing the report ImportPrpoExcelFile(file); } } }
/// <summary> /// Triggered when the user drops any file into the region that allows a drop. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pnl_DragDropArea_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] filePaths = ((string[])e.Data.GetData(DataFormats.FileDrop)); try { DragDropUtils.ProcessFiles(filePaths); } catch (DragDropExceptions.DragDropFileOverloadException ex) { // An attempt of more than two files were dropped on the form. errorList.Clear(); errorList.Add(ex.Message); using (IOUtils.ErrorMessageBox errmsgbox = new IOUtils.ErrorMessageBox()) { if (errmsgbox.ShowDialog() == DialogResult.OK) { errmsgbox.Close(); } } } catch (DragDropExceptions.DragDropInvalidExtensionException ex) { // Files were dropped that had an invalid file extention errorList.Clear(); errorList.Add(ex.Message); using (IOUtils.ErrorMessageBox errmsgbox = new IOUtils.ErrorMessageBox()) { if (errmsgbox.ShowDialog() == DialogResult.OK) { errmsgbox.Close(); } } } catch (DragDropExceptions.DragDropInvalidExcelFileException ex) { // Files were dropped that were not PRPO files errorList.Clear(); errorList.Add(ex.Message); using (IOUtils.ErrorMessageBox errmsgbox = new IOUtils.ErrorMessageBox()) { if (errmsgbox.ShowDialog() == DialogResult.OK) { errmsgbox.Close(); } } } catch (Exception ex) { errorList.Clear(); errorList.Add(ex.Message); using (IOUtils.ErrorMessageBox errmsgbox = new IOUtils.ErrorMessageBox()) { if (errmsgbox.ShowDialog() == DialogResult.OK) { errmsgbox.Close(); Application.Exit(); } } } Importer.NumberOfImports = filePaths.Length; Importer.ImportComplete = false; Importer.CompletedImports = 0; Importer.ImportProgress += ImportProgress; Importer.importStarted = false; if (ExcelInfo.USUpdated || ExcelInfo.MXUpdated) { overallData = new KPA_KPI_Overall.Overall(); if (AccessUtils.US_PRPO_TableExists || AccessUtils.MX_PRPO_TableExists) { PRPO_DB_Utils.DropCreateDb(); } else { AccessUtils.CreateAccessDB(); } btn_DatabaseConnectionStatus.Invoke((MethodInvoker) delegate { btn_DatabaseConnectionStatus.Image = Properties.Resources.databaseConn_Disconnected_Icon; }); pnl_activePage.Controls.Clear(); pnl_loadingScreen.Visible = true; pnl_loadingScreen.BringToFront(); lbl_loadingStatus.Text = "Importing Data..."; ImportTimer.Start(); } } }