Example #1
0
        public GASender()
        {
            InitializeComponent();

            _logger = LogManager.GetLogger(GetType().Name);
            try
            {
                var busConfiguration = ConfigService.Instance.Bus;

                if (busConfiguration == null)
                {
                    throw new Exception("BusConfiguration must be set in config");
                }

                var kernel = new StandardKernel();

                kernel.Bind <IMessageBodySerializer>().To <DefaultJsonSerializer>().InSingletonScope();
                kernel.Bind <IBusLogger>().To <CustomNLogger>().InSingletonScope();

                NinjectContainerAdapter.CreateInstance(kernel);
                BusFactory.SetContainerFactory(NinjectContainerAdapter.GetInstance);
                _messageBus = BusFactory.CreateBus();

                _repository = new Repository.Repository(ConfigService.Instance.Payments.W1ConnectionString);

                _sendService = new PaymentsService(
                    _repository,
                    ConfigService.Instance.Common.GoogleAnaliticsUrl,
                    ConfigService.Instance.Common.TrackingId,
                    ConfigService.Instance.Payments.Interval,
                    ConfigService.Instance.Common.GoogleAnaliticsTimeout,
                    ConfigService.Instance.Payments.StartTime,
                    ConfigService.Instance);
            }
            catch (Exception exception)
            {
                _logger.Error(exception);
                throw;
            }
        }