Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Log.Logger = StandardLoggerConfigurator.GetEnrichedLogger();
            Log.Logger.Information("Starting migration...");

            try
            {
                var settings = new Configuration();
                var migrator = new DbMigrator(settings);

                Log.Logger.Information("Migrating " + settings.TargetDatabase);

                foreach (var pendingMigration in migrator.GetPendingMigrations())
                {
                    Log.Logger.Debug("Pending migration: " + pendingMigration);
                }

                migrator.Update();
            }
            catch (Exception e)
            {
                Log.Logger.Error(e, "Error during migration");
                throw;
            }
            Log.Logger.Information("Migration done without problems...");
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            Log.Logger = StandardLoggerConfigurator.GetEnrichedLogger();

            using (var wrapper = new TopshelfWrapper <Worker>(
                       () =>
            {
                Mapper.Initialize(cfg =>
                {
                    cfg.CreateMap <FileProcessedEvent, FileReadyForCleanupEvent>();
                    cfg.CreateMap <FileUploadedEvent, FileReadyForProcessingEvent>();
                    cfg.CreateMap <FileReadyForProcessingEvent, FileProcessedEvent>();
                });
            },
                       s =>
            {
                var appSettings = new AppSettings();
                var repository = new Repository(appSettings);
                var subscriptionService = new SubscriptionService(repository);
                var mailSender = new MailSender();
                var radapter = new Radapter(appSettings);
                IBusAdapter bus = new BusAdapter(appSettings);
                var mailMessageService = new MailMessageService(appSettings, subscriptionService);

                s.ConstructUsing(name => new Worker(bus, appSettings,
                                                    new HandleSendEmailConfirmingUpload(bus, mailMessageService, mailSender, appSettings),
                                                    new HandleProcessUploadedFileThroughR(bus, appSettings, radapter),
                                                    new HandleSendEmailWithResults(bus, mailMessageService, mailSender, appSettings),
                                                    new HandleUpdateSubscriptionDatabase(subscriptionService)));
            }))
            {
                wrapper.Run();
            }
        }
Exemplo n.º 3
0
        protected void Application_Start()
        {
            Log.Logger = StandardLoggerConfigurator.GetEnrichedLogger();
            Log.Logger.Information("Starting...");

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Log.Logger.Information("Done app start...");
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Log.Logger = StandardLoggerConfigurator.GetEnrichedLogger();
            Log.Logger.Information("Starting migration...");

            try
            {
                var settings = new Configuration();
                var migrator = new DbMigrator(settings);
                migrator.Update();
            }
            catch (Exception e)
            {
                Log.Logger.Error(e, "Error during migration");
                throw;
            }
            Log.Logger.Information("Migration done without problems...");
        }
Exemplo n.º 5
0
        private static void Main(string[] args)
        {
            Log.Logger = StandardLoggerConfigurator.GetEnrichedLogger();

            try
            {
                var appSettings = new AppSettings();

                HostFactory.Run(x =>        //1
                {
                    x.Service <Worker>(s => //2
                    {
                        try
                        {
                            s.ConstructUsing(name => new Worker(appSettings)); //3
                            s.WhenStarted(tc =>
                            {
                                Log.Logger.Information("Starting service");
                                tc.Start();
                                Log.Logger.Information("Service started.");
                            }); //4
                            s.WhenStopped(tc =>
                            {
                                Log.Logger.Information("Stopping service.");
                                tc.Stop();
                                Log.Logger.Information("Service stopped.");
                            }); //5
                            s.WhenPaused(tc =>
                            {
                                Log.Logger.Information("Pausing service.");
                                tc.Stop();
                                Log.Logger.Information("Service paused.");
                            }); //5

                            s.WhenContinued(tc =>
                            {
                                Log.Logger.Information("Continuing service.");
                                tc.Start();
                                Log.Logger.Information("Service continued.");
                            }); //5
                            s.WhenSessionChanged((w, sca) =>
                            {
                                Log.Logger.Information("Session changed: " + w);
                                Log.Logger.Information("Session changed: " + sca);
                            });
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex, "Fra program");
                            throw;
                        }
                    });
                    x.RunAsLocalSystem();                      //6

                    x.SetDescription(appSettings.Description); //7
                    x.SetDisplayName(appSettings.DisplayName); //8
                    x.SetServiceName(appSettings.ServiceName); //9
                });                                            //10        }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Yderste");
                throw;
            }
        }