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);
        }
        public void StartSupporting(AndereBenutzerrollenEinnehmenModel andereBenutzerrollenEinnehmenModel)
        {
            var userName = andereBenutzerrollenEinnehmenModel.UserName;

            if (string.IsNullOrEmpty(userName))
            {
                StopSupporting();
                return;
            }

            if (!securityService.IsUserExists(userName))
            {
                throw new InvalidOperationException(string.Format("Username {0} does not exists!", userName));
            }

            if (!securityService.GetCurrentRollen().Contains(Rolle.Applikationssupporter))
            {
                throw new SecurityException("Unathorized!");
            }

            sessionService.SupportedUserInfo = new SupportedUserInfo {
                UserName = userName
            };
            securityService.SetCurrentApplicationMode(ApplicationMode.Mandant);

            ereignisLogService.LogEreignis(EreignisTyp.RolleEinnehmen, new Dictionary <string, object> {
                { "benutzer", userName }
            });
        }
        public void SaveArbeitsmodusModel(ArbeitsmodusModel arbeitsmodusModel)
        {
            ErfassungsPeriod currentErfassungsPeriod = erfassungsPeriodService.GetCurrentErfassungsPeriod();

            var previousNetzErfassungsmodus = currentErfassungsPeriod.NetzErfassungsmodus;

            currentErfassungsPeriod.NetzErfassungsmodus = arbeitsmodusModel.NetzErfassungsmodus;

            transactionScopeProvider.Update(currentErfassungsPeriod);

            ereignisLogService.LogEreignis(EreignisTyp.Arbeitsmoduswechsel, new Dictionary <string, object> {
                { "alt", previousNetzErfassungsmodus }, { "neu", arbeitsmodusModel.NetzErfassungsmodus }
            });
        }
Beispiel #4
0
 public ActionResult LogUserLogin(string returnUrl)
 {
     if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
     {
         ereignisLogService.LogEreignis(EreignisTyp.AnmeldenimSystem, new Dictionary <string, object>());
         var notInitializedMandanten = securityService.GetNotInitializedMandanten();
         if (notInitializedMandanten.Any())
         {
             Loggers.ApplicationLogger.Warn(string.Format(" User: {1} - Nicht initializierte Mandanten: {0}",
                                                          string.Join(", ", notInitializedMandanten), System.Web.HttpContext.Current.User.Identity.Name));
         }
     }
     return(Redirect(GetRedirectUrl(returnUrl)));
 }
        public ActionResult Export(List <Guid> ids, bool exportBackground, string tempFileName)
        {
            if (ids != null)
            {
                RemoveOldPackages();

                var inspektionsrouten = inspektionsRouteGISService.GetCurrentEntities().Where(ir => ids.Contains(ir.Id));
                ereignisLogService.LogEreignis(EreignisTyp.InspektionsRoutenExport, new Dictionary <string, object>()
                {
                    { "Inspektionsrouten", string.Join(", ", inspektionsrouten.Select(ir => ir.Bezeichnung)) }
                });

                var cogModelList = new List <CheckOutsGISModel>();
                foreach (var id in ids)
                {
                    var cogModel = new CheckOutsGISModel();
                    cogModel.InspektionsRouteGIS = id;
                    cogModel.Mandant             = sessionService.SelectedMandantId;
                    cogModel.CheckOutDatum       = DateTime.Now;
                    cogModelList.Add(cogModel);
                }

                var memoryStream = packageService.Export(checkOutService.CheckOutData(ids, exportBackground), cogModelList).Stream as MemoryStream;
                var filePath     = Server.MapPath(String.Format(exportFilePattern, tempFileName));
                using (var fs = new FileStream(filePath, FileMode.Create))
                {
                    memoryStream.WriteTo(fs);
                    fs.Flush();
                }
                inspektionsRouteGISService.LockInspektionsRouten(ids);

                foreach (var id in ids)
                {
                    var inspektionsroute = inspektionsRouteGISService.GetInspektionsRouteById(id);
                    inspektionsRouteStatusverlaufService.HistorizeRouteExportiert(inspektionsroute);
                }
            }
            return(new EmsgEmptyResult());
        }
Beispiel #6
0
        //Note: Not called when customerrors = "On" http://stackoverflow.com/questions/6508415/application-error-not-firing-when-customerrors-on
        protected void Application_Error(object sender, EventArgs args)
        {
            Exception lastError = HttpContext.Current.Server.GetLastError() ?? httpRequestService.LastException;

            Guid trackId = Guid.NewGuid();

            httpRequestService.LastErrorTrackId = trackId;
            var    userinfo  = securityService.GetCurrentUserInfo();
            string errorText = "";

            if (userinfo != null)
            {
                errorText = String.Format("CurrentUser: {0}, CurrentMandant: {1}", userinfo.CurrentUserName, userinfo.CurrentMandantName) + Environment.NewLine;
            }

            Loggers.ApplicationLogger.Error(errorText + string.Format("[TrackingId: {0}][{1}]{2}", trackId, ErrorLoggingContextInfoStore.CurrentErrorLoggingContextInfo, lastError.Message), lastError);

            if (HttpContext.Current.Session != null)
            {
                ereignisLogService.LogEreignis(EreignisTyp.Systemfehler, new Dictionary <string, object> {
                    { "fehler", lastError.Message }
                });
            }
        }
Beispiel #7
0
        public ImportResult CheckInData(ImportResult importResult)
        {
            try
            {
                DTOContainer dtoContainer                 = importResult.dtocontainer;
                var          zustandsAbschnitte           = dtoContainer.DataTransferObjects.Where(dto => dto.GetType() == typeof(ZustandsabschnittGISDTO)).Select(sd => sd as ZustandsabschnittGISDTO);
                var          schadendetailList            = dtoContainer.DataTransferObjects.Where(dto => dto.GetType() == typeof(SchadendetailDTO)).Select(sd => sd as SchadendetailDTO);
                var          schadengruppeList            = dtoContainer.DataTransferObjects.Where(dto => dto.GetType() == typeof(SchadengruppeDTO)).Select(sd => sd as SchadengruppeDTO);
                var          deletedZustandsabschnittList = zustandsAbschnitte.Where(z => z.IsDeleted && (!z.IsAdded)).Select(z => z.Id);


                IList <ZustandsabschnittGISDTO> zustandsabschnitteToValidate = new List <ZustandsabschnittGISDTO>();
                zustandsabschnitteToValidate = zustandsabschnitteToValidate.Concat(zustandsAbschnitte.Where(z => !z.IsDeleted && (z.IsEdited || z.IsAdded))).ToList();

                foreach (var za in zustandsabschnitteToValidate)
                {
                    var result = zustandsabschnittGISDTOService.Validate(za, deletedZustandsabschnittList.ToList(), zustandsabschnitteToValidate);
                    foreach (string error in result)
                    {
                        importResult.Errors.Add(error);
                    }
                }

                if (importResult.Errors.Count == 0)
                {
                    foreach (Guid id in deletedZustandsabschnittList)
                    {
                        try
                        {
                            zustandsabschnittGISDTOService.DeleteEntity(id);
                        }
                        catch { }
                    }

                    foreach (var za in zustandsabschnitteToValidate)
                    {
                        if (za.Shape.SRID == 0)
                        {
                            za.Shape.SRID = GisConstants.SRID;
                        }
                        zustandsabschnittGISDTOService.CreateOrUpdateEntityFromDTO(za);
                        FahrBahnZustandDTO zustand = new FahrBahnZustandDTO()
                        {
                            Erfassungsmodus   = za.Erfassungsmodus,
                            Schadendetails    = za.Erfassungsmodus == ZustandsErfassungsmodus.Detail ? schadendetailList.Where(sd => sd.ZustandsabschnittId == za.Id && !sd.IsDeleted).ToList() : new List <SchadendetailDTO>(),
                            Schadengruppen    = za.Erfassungsmodus == ZustandsErfassungsmodus.Grob ? schadengruppeList.Where(sg => sg.ZustandsabschnittId == za.Id && !sg.IsDeleted).ToList() : new List <SchadengruppeDTO>(),
                            ZustandsAbschnitt = za.Id,
                            Zustandsindex     = za.Zustandsindex
                        };
                        fahrbahnZustandDTOService.UpdateFahrbahnZustand(zustand);
                    }
                }
                if (importResult.Errors.Count == 0)
                {
                    foreach (var kvp in importResult.descriptor.CheckOutsGISInspektionsroutenList)
                    {
                        var cogModel = checkOutsGISService.GetById(kvp.Key);
                        cogModel.CheckInDatum = timeService.Now;
                        checkOutsGISService.UpdateEntity(cogModel);
                        inspektionsRouteGISService.UnLockInspektionsRouten(importResult.InspektionsRouten);
                        foreach (var ir in importResult.InspektionsRouten)
                        {
                            inspektionsRouteStatusverlaufService.HistorizeRouteImportiert(inspektionsRouteGISService.GetInspektionsRouteById(ir));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Loggers.ApplicationLogger.Error(e.Message, e);
                importResult.Errors.Add("Error When Importing");
            }
            var inspektionsrouten = inspektionsRouteGISService.GetCurrentEntities().Where(ir => importResult.InspektionsRouten.Contains(ir.Id));

            ereignisLogService.LogEreignis(EreignisTyp.InspektionsRoutenImport, new Dictionary <string, object>()
            {
                { "Inspektionsrouten", string.Join(", ", inspektionsrouten.Select(ir => ir.Bezeichnung)) }, { "Fehleranzahl", importResult.Errors.Count }
            });
            return(importResult);
        }
Beispiel #8
0
 protected void LogImportEreigniss(int errorCount)
 {
     ereignisLogService.LogEreignis(EreignisTyp.XmlImport, new Dictionary <string, object> {
         { "fehleranzahl", errorCount }
     });
 }
Beispiel #9
0
        /// <summary>
        /// Starts the AchsenUpdate Service
        /// </summary>
        public void StartAchsenUpdate()
        {
            ITransactionScope transactionScope = new TransactionScopeFactory(nHibernateConfigurationProvider).CreateReadWrite();
            Mandant           mandant          = securityService.GetCurrentMandant();

            var crit = transactionScope.Session.QueryOver <AchsenLock>();

            crit.Where(al => al.Mandant == mandant && al.LockType == LockingType.AchsenUpdate && al.IsLocked == true);
            var achsLocklist = crit.List();

            if (achsLocklist.Count > 0)
            {
                throw new Exception(String.Format(localizationService.GetLocalizedError(ValidationError.UpdateRunning), mandant.MandantDisplayName, achsLocklist.Single().LockStart));
            }

            AchsenLock achsLock = new AchsenLock();

            achsLock.Mandant   = mandant;
            achsLock.LockStart = timeService.Now;
            achsLock.IsLocked  = true;
            achsLock.LockType  = LockingType.AchsenUpdate;
            achsLock.Id        = Guid.NewGuid();

            transactionScope.Session.Save(achsLock);
            transactionScope.Commit();
            transactionScope.Dispose();

            try
            {
                AchsenUpdate.AchsenAutoUpdate updater = new AchsenUpdate.AchsenAutoUpdate
                                                        (
                    transactionScopeProvider.CurrentTransactionScope.Session,
                    mandant,
                    erfassungsPeriodService.GetCurrentErfassungsPeriod(mandant),
                    mandant.OwnerId
                                                        );



                updater.ReferenceUpdater = new ReferenceUpdater(transactionScopeProvider.CurrentTransactionScope.Session,
                                                                erfassungsPeriodService.GetCurrentErfassungsPeriod(mandant));
                updater.Start();

                if (updater.Statistics.SegmentCount() == 0 && updater.Statistics.AxisCount() == 0 && updater.Statistics.SectorCount() == 0)
                {
                    throw new EmsgException(EmsgExceptionType.NoAxisToUpdate);
                }

                ereignisLogService.LogEreignis(EreignisTyp.Achsenupdate, new Dictionary <string, object> {
                    { "Mandant", mandant.MandantDisplayName }, { "OwnerId", mandant.OwnerId }
                });
            }
            catch (EmsgException e)
            {
                Loggers.ApplicationLogger.Error(String.Format("Exception '{0}' for {1} with MandantId {2}", e.EmsgExceptionType, mandant.MandantDisplayName, mandant.Id));

                throw new Exception(localizationService.GetLocalizedEnum <EmsgExceptionType>(e.EmsgExceptionType));
            }
            catch (Exception e)
            {
                Loggers.ApplicationLogger.Error(String.Format("Error while running Achsenupdate for Mandant {0} with MandantId {1}", mandant.MandantDisplayName, mandant.Id), e);
                throw new Exception(localizationService.GetLocalizedError(ValidationError.UnexpectedAchsenUpdateError));
            }
            finally
            {
                transactionScope  = new TransactionScopeFactory(nHibernateConfigurationProvider).CreateReadWrite();
                achsLock.IsLocked = false;
                achsLock.LockEnd  = timeService.Now;
                transactionScope.Session.Update(achsLock);
                transactionScope.Commit();
                transactionScope.Dispose();
            }
        }