Exemplo n.º 1
0
        public void CloseCurrentErfassungsperiod(ErfassungsabschlussModel erfassungsabschlussModel)
        {
            Guid closedPeriodId;

            try
            {
                var closedPeriod = CloseCurrentPeriod(erfassungsabschlussModel);
                closedPeriodId = closedPeriod.Id;
                var currentPeriod = CreateNewPeriod(closedPeriod);
                erfassungsPeriodService.InvalidateCurrentErfassungsPeriodCache();
                CreateNewErfassungsPeriodData(closedPeriod, currentPeriod);

                ereignisLogService.LogEreignis(EreignisTyp.Jahresabschluss,
                                               new Dictionary <string, object> {
                    { "abgeschlossene jahr", closedPeriod.Erfassungsjahr.Year }
                });
                transactionScopeProvider.CurrentTransactionScope.Commit();
            }
            catch (Exception e)
            {
                Loggers.ApplicationLogger.Warn(String.Format("Error during CloseCurrentErfassungsperiod: {0}", e.ToString()));
                transactionScopeProvider.CurrentTransactionScope.Rollback();
                throw;
            }
            finally
            {
                transactionScopeProvider.ResetCurrentTransactionScope();
            }
            //Run the DeleteNotUsedData in its own transaction to avoid deadlocks in the database
            DeleteNotUsedData(closedPeriodId);
        }