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();
            }
        }
Example #2
0
        private static void Main(string[] args)
        {
            Log.Logger = StandardLoggerConfigurator
                         .GetLoggerConfig().MinimumLevel
                         .Debug()
                         .CreateLogger();

            Log.Logger.Information("Starting Service with args: " + string.Join("|", args));

            using (var container = ServiceIoC.Initialize())
            {
                Log.Logger.Debug("WhatDoIHave" + "\n" + container.WhatDoIHave());

                Log.Logger.Information("Container created.");

                using (var wrapper = new TopshelfWrapper <WorkerDirWatcher>(
                           () => {},
                           s =>
                {
                    s.ConstructUsing(name =>
                    {
                        try
                        {
                            var instance = container.GetInstance <WorkerDirWatcher>();
                            Log.Logger.Debug("I have instance of WorkerDirWatcher!");
                            return(instance);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                            throw;
                        }
                    });
                }))
                {
                    try
                    {
                        wrapper.Run();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
            }
        }