Пример #1
0
        /// <summary>
        /// workerthread which will update the database with the new epg received
        /// </summary>
        private void UpdateDatabaseThread()
        {
            Thread.CurrentThread.Priority = ThreadPriority.Lowest;

            //if card is not idle anymore we return
            if (IsCardIdle(_user) == false)
            {
                _currentTransponder.InUse = false;
                return;
            }
            Log.Epg("Epg: card:{0} Updating database with new programs", _user.CardId);
            bool timeOut = false;

            _dbUpdater.ReloadConfig();
            try
            {
                foreach (EpgChannel epgChannel in _epg)
                {
                    _dbUpdater.UpdateEpgForChannel(epgChannel);
                    if (_state != EpgState.Updating)
                    {
                        Log.Epg("Epg: card:{0} stopped updating state changed", _user.CardId);
                        timeOut = true;
                        return;
                    }
                    if (IsCardIdle(_user) == false)
                    {
                        Log.Epg("Epg: card:{0} stopped updating card not idle", _user.CardId);
                        timeOut = true;
                        return;
                    }
                }
                _epg.Clear();
                Schedule.SynchProgramStatesForAll();
                Log.Epg("Epg: card:{0} Finished updating the database.", _user.CardId);
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
            finally
            {
                if (timeOut == false)
                {
                    _currentTransponder.OnTimeOut();
                }
                if (_state != EpgState.Idle && _user.CardId >= 0)
                {
                    _tvController.StopGrabbingEpg(_user);
                    _tvController.PauseCard(_user);
                }
                _currentTransponder.InUse = false;
                _state       = EpgState.Idle;
                _user.CardId = -1;
                _tvController.Fire(this, new TvServerEventArgs(TvServerEventType.ProgramUpdated));
            }
        }
Пример #2
0
        private void UpdateDatabaseThread()
        {
            if (_epg == null)
            {
                return;
            }

            _updateThreadRunning          = true;
            Thread.CurrentThread.Priority = ThreadPriority.Lowest;
            _dbUpdater.ReloadConfig();
            foreach (EpgChannel epgChannel in _epg)
            {
                _dbUpdater.UpdateEpgForChannel(epgChannel);
            }
            Schedule.SynchProgramStatesForAll();
            Log.Log.Epg("TimeshiftingEpgGrabber: Finished updating the database.");
            _epg.Clear();
            _epg = null;
            _card.IsEpgGrabbing  = false;
            _updateThreadRunning = false;
        }