Example #1
0
        static void Main(string[] args)
        {
            var logger = NinjectWebKernel.CreateKernel().Get <ILogger>();

            // hacks because of error with Entity Framework.
            // This forces the dmzconnection to use MySql.
            new DataContext();

            var personSync = new PersonSyncService(new GenericDmzRepository <Profile>(new DmzContext()),
                                                   new GenericRepository <Person>(new DataContext()),
                                                   NinjectWebKernel.CreateKernel().Get <IPersonService>());

            var driveSync = new DriveReportSyncService(new GenericDmzRepository <DriveReport>(new DmzContext()),
                                                       new GenericRepository <Core.DomainModel.DriveReport>(new DataContext()), new GenericRepository <Rate>(new DataContext()), new GenericRepository <LicensePlate>(new DataContext()), NinjectWebKernel.CreateKernel().Get <IDriveReportService>(), NinjectWebKernel.CreateKernel().Get <IRoute <RouteInformation> >(), NinjectWebKernel.CreateKernel().Get <IAddressCoordinates>(), NinjectWebKernel.CreateKernel().Get <IGenericRepository <Core.DomainModel.Employment> >(), NinjectWebKernel.CreateKernel().Get <ILogger>());

            var rateSync = new RateSyncService(new GenericDmzRepository <Core.DmzModel.Rate>(new DmzContext()),
                                               new GenericRepository <Rate>(new DataContext()));

            try
            {
                Console.WriteLine("DriveReportsSyncFromDmz");
                driveSync.SyncFromDmz();
            }
            catch (Exception ex)
            {
                logger.Log("Fejl under synkronisering af indberetninger fra DMZ. Mobilindberetninger er ikke synkroniserede.", "dmz", ex, 1);
                throw;
            }

            try
            {
                Console.WriteLine("PersonSyncToDmz");
                personSync.SyncToDmz();
            }
            catch (Exception ex)
            {
                logger.Log("Fejl under synkronisering af medarbejdere til DMZ. Mobil-app er ikke opdateret med nyeste medarbejderdata.", "dmz", ex, 1);
                throw;
            }

            try
            {
                Console.WriteLine("RateSyncToDmz");
                rateSync.SyncToDmz();
            }
            catch (Exception ex)
            {
                logger.Log("Fejl under synkronisering af takster til DMZ. Mobil-app er ikke opdateret med nyeste rater.", "dmz", ex, 1);
                throw;
            }

            Console.WriteLine("Done");
        }
Example #2
0
        static void Main(string[] args)
        {
            var logger = NinjectWebKernel.CreateKernel().Get <ILogger>();

            // hacks because of error with Entity Framework.
            // This forces the dmzconnection to use MySql.
            new DataContext();

            var personSync = new PersonSyncService(new GenericDmzRepository <Profile>(new DmzContext()),
                                                   new GenericRepository <Person>(new DataContext()), new GenericDmzRepository <Core.DmzModel.Employment>(new DmzContext()),
                                                   NinjectWebKernel.CreateKernel().Get <IPersonService>(), logger);

            var driveSync = new DriveReportSyncService(new GenericDmzRepository <DriveReport>(new DmzContext()),
                                                       new GenericRepository <Core.DomainModel.DriveReport>(new DataContext()), new GenericRepository <Rate>(new DataContext()), new GenericRepository <LicensePlate>(new DataContext()), NinjectWebKernel.CreateKernel().Get <IDriveReportService>(), NinjectWebKernel.CreateKernel().Get <IRoute <RouteInformation> >(), NinjectWebKernel.CreateKernel().Get <IAddressCoordinates>(), NinjectWebKernel.CreateKernel().Get <IGenericRepository <Core.DomainModel.Employment> >(), logger);

            var rateSync = new RateSyncService(new GenericDmzRepository <Core.DmzModel.Rate>(new DmzContext()),
                                               new GenericRepository <Rate>(new DataContext()), logger);

            var orgUnitSync = new OrgUnitSyncService(new GenericDmzRepository <Core.DmzModel.OrgUnit>(new DmzContext()),
                                                     new GenericRepository <Core.DomainModel.OrgUnit>(new DataContext()), logger);

            var userAuthSync = new UserAuthSyncService(new GenericRepository <Core.DomainModel.AppLogin>(new DataContext()),
                                                       new GenericDmzRepository <Core.DmzModel.UserAuth>(new DmzContext()), logger);

            var auditlogSync = new AuditlogSyncService(new GenericDmzRepository <Core.DmzModel.Auditlog>(new DmzContext()), new GenericRepository <Core.DomainModel.Auditlog>(new DataContext()), logger);

            logger.Debug("-------- DMZSYNC STARTED --------");

            try
            {
                logger.Debug("SyncFromDMZ started");
                Console.WriteLine("DriveReportsSyncFromDmz");
                driveSync.SyncFromDmz();
            }
            catch (Exception ex)
            {
                logger.Error($"Error during drivereport synchronization from DMZ", ex);
                logger.LogForAdmin("Fejl under synkronisering af indberetninger fra DMZ. Mobilindberetninger er ikke synkroniserede.");
                throw;
            }

            try
            {
                logger.Debug("OrgUnitSyncToDmz started");
                Console.WriteLine("OrgUnitSyncToDmz");
                orgUnitSync.SyncToDmz();
            }
            catch (Exception ex)
            {
                logger.Error($"Error during orgunit synchronization to DMZ", ex);
                logger.LogForAdmin("Fejl ved synkronisering af organisationsenheder til DMZ.");
                throw;
            }

            try
            {
                logger.Debug("PersonSyncToDmz started");
                Console.WriteLine("PersonSyncToDmz");
                personSync.SyncToDmz();
            }
            catch (Exception ex)
            {
                logger.Error($"Error during people synchronization to DMZ", ex);
                logger.LogForAdmin("Fejl ved synkronisering af medarbejdere til DMZ.");
                throw;
            }

            try
            {
                logger.Debug("RateSyncToDmz started");
                Console.WriteLine("RateSyncToDmz");
                rateSync.SyncToDmz();
            }
            catch (Exception ex)
            {
                logger.Error($"Error during rate synchronization from DMZ", ex);
                logger.LogForAdmin("Fejl ved synkronisering af takster til DMZ.");
                throw;
            }

            try
            {
                logger.Debug("UserAuthSyncToDmz started");
                Console.WriteLine("UserAuthSyncToDmz");
                userAuthSync.SyncToDmz();
            }
            catch (Exception ex)
            {
                logger.Error($"Error during userauth synchronization from DMZ", ex);
                logger.LogForAdmin("Fejl ved synkronisering af app-logins til DMZ. Nogle brugere vil muligvis ikke kunne logge på app.");
                throw;
            }

            try
            {
                logger.Debug("AuditlogSyncFromDmz started");
                Console.WriteLine("AuditlogSyncFromDmz");
                auditlogSync.SyncFromDmz();
            }
            catch (Exception ex)
            {
                logger.Error($"Error during auditlog synchronization from DMZ", ex);
                logger.LogForAdmin("Fejl ved synkronisering af auditlogs fra DMZ.");
                throw;
            }

            logger.Debug("-------- DMZSYNC FINISHED --------");
            Console.WriteLine("Done");
        }