Ejemplo n.º 1
0
        public ShowsManager(ISettings settings)
            : base(settings)
        {
            _seriesManager = new ShowManager();

            var tempCollectionShowModels = Storage.GetShowModel();

            if (tempCollectionShowModels != null)
            {
                _serieCollection = new SerieCollection();
                _serieCollection.Set(tempCollectionShowModels);
            }
        }
Ejemplo n.º 2
0
        protected async void TimerUpdate(object state)
        {
            // Récupération des séries en locale.
            List <ShowInformation> seriesOnLocal = new List <ShowInformation>();

            foreach (var path in Settings.GetPathShows())
            {
                if (!Directory.Exists(path))
                {
                    continue;
                }

                IEnumerable <ShowInformation> tempSeries = _seriesManager.GetShowsInformation(path);

                if (tempSeries.Any())
                {
                    seriesOnLocal.AddRange(tempSeries);
                }
            }

            // Suppression des items en mémoire qui ne sont plus en local.
            _serieCollection?.UpdateShowInformations(seriesOnLocal);

            if (_serieCollection == null)
            {
                _serieCollection = new SerieCollection();
            }

            foreach (ShowInformation serieLocal in seriesOnLocal)
            {
                await Task.Delay(1000);

                Guid idShow = _serieCollection.GetIdShow(serieLocal.Titre);

                if (idShow == Guid.Empty)
                {
                    ShowModel showModel = await CreateNewShowModel(serieLocal);

                    Guid idTemp = _serieCollection.GetIdShow(showModel.TvShow.Name);

                    if (idTemp == Guid.Empty)
                    {
                        lock (_objetToLock)
                        {
                            _serieCollection.Add(showModel);
                        }
                    }
                    else
                    {
                        await GetSeasonAndEpisodeInformation(idTemp, serieLocal);
                    }
                }
                else
                {
                    await GetSeasonAndEpisodeInformation(idShow, serieLocal);
                }
            }

            var allNouveautes = _serieCollection.GetAllNouveautes();

            if (allNouveautes.Any())
            {
                // Sauvegarde
                Storage.SaveSeriesModels(_serieCollection);

                //await SendMailToUser(allNouveautes);
                _serieCollection.ResetNouveautes();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sauvegarde la collection de série.
 /// </summary>
 /// <param name="serieCollection"></param>
 internal void SaveSeriesModels(SerieCollection serieCollection)
 {
     SaveContent(serieCollection.Get(), FILE_SHOWS);
 }