private void ValidateProcessing(string streetlightImportSheet, StreetLightImportWorkSheet importWorkSheet, DataTable excelDataTable, ImportSpreadsheetRecordValidation recordValidation) { try { importWorkSheet.DataTableTOExcel(streetlightImportSheet, excelDataTable); #region Validate Job Edits if (recordValidation.m_nbrDataBaseChanges) { IGTJobManagementService jobService = GTClassFactory.Create <IGTJobManagementService>(); jobService.DataContext = m_oGTApp.DataContext; Recordset rsValidate = jobService.ValidatePendingEdits(); if (rsValidate != null && rsValidate.RecordCount > 0) { MessageBox.Show("The job has validation errors that will need to be resolved before it can be posted.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information); } } #endregion MessageBox.Show("Number of successful Add transactions: " + recordValidation.SuccessfulAddTransactions + Environment.NewLine + Environment.NewLine + "Number of unsuccessful Add transactions that resulted in a warning: " + recordValidation.WarningAddTransactions + Environment.NewLine + Environment.NewLine + "Number of unsuccessful Add transactions that resulted in an error: " + recordValidation.ErrorAddTransactions + Environment.NewLine + Environment.NewLine + "Number of successful Removal transactions: " + recordValidation.SuccessfulRemovalTransactions + Environment.NewLine + Environment.NewLine + "Number of unsuccessful Removal transactions that resulted in a warning: " + recordValidation.WarningRemovalTransactions + Environment.NewLine + Environment.NewLine + "Number of unsuccessful Removal transactions that resulted in an error: " + recordValidation.ErrorRemovalTransactions, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { throw; } }
public void Activate(IGTCustomCommandHelper CustomCommandHelper) { try { m_oGTApp = GTClassFactory.Create <IGTApplication>(); m_oGTCustomCommandHelper = CustomCommandHelper; if (m_oGTApp.DataContext.IsRoleGranted("PRIV_MGMT_STLT")) { if (Validate()) { string streetlightImportSheet = OpenFileDialog(); if (!String.IsNullOrEmpty(streetlightImportSheet)) { m_oGTApp.BeginWaitCursor(); StreetLightImportWorkSheet importWorkSheet = new StreetLightImportWorkSheet(); importWorkSheet.InitializeExcel(streetlightImportSheet); if (importWorkSheet.ExcelTable != null) { ImportSpreadsheetFormatValidation formatValidation = new ImportSpreadsheetFormatValidation(m_oGTApp.DataContext); m_oGTApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Street Light Import Tool : Validating Spreadsheet Format"); if (formatValidation.ValidateSpreadsheetFormat(importWorkSheet.ExcelTable)) { ImportSpreadsheetRecordValidation recordValidation = new ImportSpreadsheetRecordValidation(m_oGTApp, m_oGTTransactionManager); DataTable excelDataTable = recordValidation.ValidateSpreadsheetRecord(importWorkSheet.ExcelTable); ValidateProcessing(streetlightImportSheet, importWorkSheet, excelDataTable, recordValidation); } } m_oGTApp.EndWaitCursor(); } } ExitCommand(); } else { MessageBox.Show("User does not have PRIV_MGMT_STLT role.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); ExitCommand(); } } catch (Exception ex) { m_oGTApp.EndWaitCursor(); if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Rollback(); } if (ex.GetType().Name == "DuplicateNameException") { MessageBox.Show("WorkSheet contains duplicate column names.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Error in StreetLight Import Tool command: " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error); } ExitCommand(); } }