Пример #1
0
        public Program()
        {
            Console.SetBufferSize(200, 500);
            ////Console.SetWindowSize(200, 70);

            XmlConfigurator.Configure();
            this.logger = LogManager.GetLogger(typeof(Program));

            this.container = new UnityContainer().LoadConfiguration();

            this.container.RegisterInstance(this.logger);
            this.container.RegisterInstance<ICrypto>(new Crypto());
            this.container.RegisterInstance<IFaultFactory>(new FaultFactory());

            #if Dev
            var clientService = new ClientService();
            this.container.BuildUp(clientService);
            #else
            var clientService = new ChannelFactory<IClientService>("OliveService").CreateChannel();
            #endif

            this.container.RegisterInstance<IClientService>(clientService);

            this.container.RegisterType<IOliveContext, OliveContext>();

            var rpcCredential = new NetworkCredential(
                this.settings.BitcoinDaemonUsername, this.settings.BitcoinDaemonPassword);
            this.container.RegisterInstance<IRpcClient>(new RpcClient
                {
                    Credential = rpcCredential,
            #if Dev
                    Hostname = "localhost",
            #else
                    Hostname = "oapp1.olive.local",
            #endif
                    PortNumber = this.settings.BitconDaemonPort
                });

            Console.WriteLine("Bitcoin Sync");
            Console.WriteLine();

            var sessionId = clientService.CreateSession(this.settings.ServiceEmail, this.settings.ServicePassword);

            while (true)
            {
            #if !Dev
            try
            {
            #endif
                this.ProcessWithdraws(sessionId);
                this.ProcessIncomingTransactions(sessionId);
                this.GenerateReceiveAddresses(sessionId);
            #if !Dev
            }
            catch (Exception e)
            {
                this.logger.Error("Unhandled exception: ", e);
            }
            #endif

                Thread.Sleep(5 * 1000);
            }

            Console.ReadLine();
        }