コード例 #1
0
        public void StartDemons()
        {
            if (DemonsStarted)
            {
                return;
            }
            _demonStoped = false;

            DemonRunner.Start(() =>
            {
                //действие выполняется по интервалу
                if (_demonStoped || _inProgress)
                {
                    return;
                }
                _inProgress = true;
                try
                {
                    var provider      = _svp.GetService <IDbProvider>();
                    var motherService = _svp.GetService <IMothershipService>();
                    var mjs           = _svp.GetService <IUMotherJumpService>();
                    var storeSevice   = _svp.GetService <IStoreService>();
                    var planetService = _svp.GetService <IGDetailPlanetService>();

                    // todo  можно завернуть в транзакцию но скорее всего пойдут конфликты,
                    provider.ContextAction(connection =>
                    {
                        connection.OpenIfClosed();
                        try
                        {
                            // Console.WriteLine("_motherFactory");
                            _motherRunner.PushDemon(connection, motherService, mjs, storeSevice);
                            // Console.WriteLine("_planetFactory");
                            _planetRunner.PushDemon(connection, planetService, storeSevice);
                            // Console.WriteLine("_taskFactory");
                            _taskRunner.PushDemon(connection);
                        }

                        finally
                        {
                            connection.CloseIfOpened();
                        }

                        return(true);
                    });
                    _inProgress = false;
                }
                catch (Exception e)
                {
                    _inProgress = false;
                    Console.WriteLine(e);
                    throw e;
                }
            });
        }
コード例 #2
0
 public void StopDemons()
 {
     _demonStoped = true;
     DemonRunner.Stop();
 }