Exemple #1
0
        public StatisticService(
            IStatisticRepository statisticRepository, IAccountService accountService, StatisticManager statisticManager,
            Dictionary <string, IMt4MySqlRepository> repositories, IClientService clientServise, IService Service,
            IMailingService mailingService, ISignalService signalService, StatisticCalculator calculator, ICacheService cacheService
            )
        {
            try
            {
                ratesServer = ConfigurationManager.AppSettings["RatesServer"];
                this.statisticRepository           = statisticRepository;
                this.accountService                = accountService;
                this.clientService                 = clientServise;
                this.statisticManager              = statisticManager;
                this.mt4Repositories               = repositories;
                this.Service                       = Service;
                this.mailingService                = mailingService;
                this.cacheService                  = cacheService;
                this.signalService                 = signalService;
                statisticManager.StatisticUpdated += StatisticUpdated;

                FirstUpdatingStatistics();

#if !DEBUG
                UpdateOpenTradesRatio();
                UpdateActivities(Constants.ActivitiesCachingAmount);
#endif
            }
            catch (Exception ex)
            {
                Logger.Fatal("Fatal error at init: {0}", ex.ToString());
                throw;
            }
        }
Exemple #2
0
        public StatisticManager(IStatisticRepository statisticRepository, Dictionary <string, IMt4MySqlRepository> mt4Repositories, StatisticCalculator calculator)
        {
            this.statisticRepository = statisticRepository;
            this.mt4Repositories     = mt4Repositories;
            this.calculator          = calculator;

            calculationLock = new object();

            TaskManager.Initialize(new Registry());
            TaskManager.AddTask(UpdateStatistic, x => x.ToRunNow().DelayFor(5).Minutes());
            TaskManager.AddTask(UpdateStatistic, x => x.ToRunEvery(1).Days().At(1, 0));
        }