Esempio n. 1
0
        static void Main(string[] args)
        {
            var ninjectKernel = NinjectWebKernel.CreateKernel();

            ILogger _logger = NinjectWebKernel.CreateKernel().Get <ILogger>();

            _logger.Debug($"-------- DBUPDATER STARTED --------");

            IAddressHistoryService historyService = new AddressHistoryService(ninjectKernel.Get <IGenericRepository <Employment> >(), ninjectKernel.Get <IGenericRepository <AddressHistory> >(), ninjectKernel.Get <IGenericRepository <PersonalAddress> >());

            var service = new UpdateService(ninjectKernel.Get <IGenericRepository <Employment> >(),
                                            ninjectKernel.Get <IGenericRepository <OrgUnit> >(),
                                            ninjectKernel.Get <IGenericRepository <Person> >(),
                                            ninjectKernel.Get <IGenericRepository <CachedAddress> >(),
                                            ninjectKernel.Get <IGenericRepository <PersonalAddress> >(),
                                            ninjectKernel.Get <IAddressLaunderer>(),
                                            ninjectKernel.Get <IAddressCoordinates>(), new DataProvider(),
                                            ninjectKernel.Get <IMailSender>(),
                                            historyService,
                                            ninjectKernel.Get <IGenericRepository <DriveReport> >(),
                                            ninjectKernel.Get <IDriveReportService>(),
                                            ninjectKernel.Get <ISubstituteService>(),
                                            ninjectKernel.Get <IGenericRepository <Substitute> >());

            service.MigrateOrganisations();
            service.MigrateEmployees();
            historyService.UpdateAddressHistories();
            historyService.CreateNonExistingHistories();
            service.UpdateLeadersOnExpiredOrActivatedSubstitutes();
            service.AddLeadersToReportsThatHaveNone();

            _logger.Debug($"-------- DBUPDATER FINISHED --------");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var ninjectKernel = NinjectWebKernel.GetKernel();

            ILogger         logger         = ninjectKernel.Get <ILogger>();
            ICustomSettings customSettings = ninjectKernel.Get <ICustomSettings>();

            logger.Debug($"-------- DBUPDATER STARTED --------");

            IAddressHistoryService historyService = new AddressHistoryService(ninjectKernel.Get <IGenericRepository <Employment> >(), ninjectKernel.Get <IGenericRepository <AddressHistory> >(), ninjectKernel.Get <IGenericRepository <PersonalAddress> >());

            var service = new UpdateService(ninjectKernel.Get <IGenericRepository <Employment> >(),
                                            ninjectKernel.Get <IGenericRepository <OrgUnit> >(),
                                            ninjectKernel.Get <IGenericRepository <Person> >(),
                                            ninjectKernel.Get <IGenericRepository <CachedAddress> >(),
                                            ninjectKernel.Get <IGenericRepository <PersonalAddress> >(),
                                            ninjectKernel.Get <IAddressLaunderer>(),
                                            ninjectKernel.Get <IAddressCoordinates>(),
                                            new DataProvider(ninjectKernel.Get <ILogger>(), ninjectKernel.Get <ICustomSettings>()),
                                            ninjectKernel.Get <IMailService>(),
                                            historyService,
                                            ninjectKernel.Get <IGenericRepository <DriveReport> >(),
                                            ninjectKernel.Get <IDriveReportService>(),
                                            ninjectKernel.Get <ISubstituteService>(),
                                            ninjectKernel.Get <IGenericRepository <Substitute> >());

            var dbSync = customSettings.DbIntegration ?? "SOFD";

            logger.Debug($"Database integration = {dbSync}");

            switch (dbSync)
            {
            case "IDM":
                service.MigrateOrganisationsIDM();
                service.MigrateEmployeesIDM();
                break;

            case "SOFD":
                service.MigrateOrganisations();
                service.MigrateEmployees();
                break;

            default:
                logger.Error("Could not read database integration type, check CustomSettings.config. DBUpdater will NOT run.");
                return;
            }

            historyService.UpdateAddressHistories();
            historyService.CreateNonExistingHistories();
            service.UpdateLeadersOnExpiredOrActivatedSubstitutes();
            service.AddLeadersToReportsThatHaveNone();
            logger.Debug($"-------- DBUPDATER FINISHED --------");
        }