Esempio n. 1
0
        private ActionResult DoFbmsExcelImportForFileStream(Stream excelFileAsStream, string optionalOriginalFilename)
        {
            DateTime startTime = DateTime.Now;

            List <FbmsBudgetStageImportPayrecV3UnexpendedBalance> budgetStageImports;

            try
            {
                budgetStageImports = FbmsBudgetStageImportsHelper.LoadFbmsBudgetStageImportPayrecV3UnexpendedBalancesFromXlsFile(excelFileAsStream, FbmsExcelFileHeaderRowOffset);
            }
            catch (Exception ex)
            {
                return(Common_LoadFromXls_ExceptionHandler(excelFileAsStream, optionalOriginalFilename, ex));
            }

            // GROOT

            LoadFbmsRecordsFromExcelFileObjectsIntoStagingTable(budgetStageImports, out var countAddedBudgets, this.CurrentFirmaSession);
            DateTime endTime          = DateTime.Now;
            var      elapsedTime      = endTime - startTime;
            string   importTimeString = GetTaskTimeString("Import", elapsedTime);

            // Record that we uploaded
            var newImpProcessingForFbms = new ImpProcessing(ImpProcessingTableType.FBMS);

            newImpProcessingForFbms.UploadDate          = endTime;
            newImpProcessingForFbms.UploadPerson        = this.CurrentFirmaSession.Person;
            newImpProcessingForFbms.UploadedFiscalYears = null;
            HttpRequestStorage.DatabaseEntities.ImpProcessings.Add(newImpProcessingForFbms);
            HttpRequestStorage.DatabaseEntities.SaveChanges(this.CurrentFirmaSession);

            ProjectTaxonomyLeafTest.CallAllTaxonomyLeavesForAllProjectsToCheckForCrashes();

            SetMessageForDisplay($"{countAddedBudgets.ToGroupedNumeric()} FBMS records were successfully imported to database. </br>{importTimeString}.");
            // This is the right thing to return, since this starts off in a modal dialog
            return(new ModalDialogFormJsonResult());
        }
Esempio n. 2
0
        public ActionResult DoPublishingProcessing(ManageExcelUploadsAndEtlViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                throw new SitkaDisplayErrorException("Not expecting model state to be bad; not running publishing processing.");
            }

            bool     wasErrorDuringProcessing = false;
            DateTime startTime = DateTime.Now;

            try
            {
                DoPublishingSql(Logger);

                //int blah = 2;
                //if (1 == blah-1)
                //{
                //    //throw new Exception("Fake exception to test ideas..");
                //}

                // If we get this far, we've succeeded.
                // Log last import as successful.
                var processedDateTime                 = DateTime.Now;
                var latestImportProcessingForFbms     = ImpProcessing.GetLatestImportProcessingForGivenType(HttpRequestStorage.DatabaseEntities, ImpProcessingTableType.FBMS);
                var latestImportProcessingForPnBudget = ImpProcessing.GetLatestImportProcessingForGivenType(HttpRequestStorage.DatabaseEntities, ImpProcessingTableType.PNBudget);
                if (latestImportProcessingForFbms == null || latestImportProcessingForPnBudget == null)
                {
                    // We don't expect this to really happen once things are running smoothly, but in the short
                    // term I want to know about it.
                    SetErrorForDisplay($"Could not find processing records for last upload (ImpProcessing)");
                }
                else
                {
                    latestImportProcessingForFbms.LastProcessedDate       = processedDateTime;
                    latestImportProcessingForFbms.LastProcessedPerson     = CurrentFirmaSession.Person;
                    latestImportProcessingForPnBudget.LastProcessedDate   = processedDateTime;
                    latestImportProcessingForPnBudget.LastProcessedPerson = CurrentFirmaSession.Person;
                    HttpRequestStorage.DatabaseEntities.SaveChanges(this.CurrentFirmaSession);
                }
            }
            catch (Exception e)
            {
                SetErrorForDisplay($"Problem executing Publishing: {e.Message}");
                wasErrorDuringProcessing = true;
            }

            ProjectTaxonomyLeafTest.CallAllTaxonomyLeavesForAllProjectsToCheckForCrashes();

            DateTime endTime              = DateTime.Now;
            var      elapsedTime          = endTime - startTime;
            string   processingTimeString = GetTaskTimeString("Publishing", elapsedTime);

            if (!wasErrorDuringProcessing)
            {
                SetMessageForDisplay($"Publishing Processing completed Successfully.<br/>{processingTimeString}");
            }
            else
            {
                // Apparently at the moment we can only have one error/warning, so since I want TWO messages, resorting to
                // an error and a warning.
                SetWarningForDisplay($"Publishing Processing had problems.<br/>{processingTimeString}");
            }
            return(RedirectToAction(new SitkaRoute <ExcelUploadController>(x => x.ManageExcelUploadsAndEtl())));
        }