예제 #1
0
        public IEnumerable <DBSeriesInfo> FetchSeriesInfosForPrograms(IEnumerable <DBProgram> programs)
        {
            // First index the programs by series ID, with a sample program for each series.
            Dictionary <string, DBProgram> sampleProgramsBySeriesID = new Dictionary <string, DBProgram>();

            foreach (DBProgram program in programs)
            {
                // Only fetch seriesInfo for series.
                if (!program.IsSeries())
                {
                    continue;
                }
                // Skip any series we already have cached.
                string seriesId = SeriesIDByProgramID(program.programID);
                if (seriesInfoById_.ContainsKey(seriesId))
                {
                    continue;
                }
                sampleProgramsBySeriesID[seriesId] = program;
            }

            // Fetch any series already in the DB.
            var dbSeriesInfos = DBManager.instance.GetSeriesInfoByIDs(new HashSet <string>(sampleProgramsBySeriesID.Keys));

            foreach (var dbSeriesInfo in dbSeriesInfos)
            {
                seriesInfoById_[dbSeriesInfo.Key] = dbSeriesInfo.Value;
                sampleProgramsBySeriesID.Remove(dbSeriesInfo.Key);
            }

            // Create seriesInfos from the sample programs
            foreach (var kv in sampleProgramsBySeriesID)
            {
                seriesInfoById_[kv.Key] = new DBSeriesInfo(kv.Value);
            }

            // Download additional generic series info from SchedulesDirect and add it to our cache for these series.
            Dictionary <string, SDGenericProgramDescription> downloadedProgramDescriptions =
                DownloadSeriesByIDs(sampleProgramsBySeriesID.Keys);

            // Loop through and add any successfully downloaded.
            foreach (var kv in downloadedProgramDescriptions)
            {
                SDGenericProgramDescription genericDescription = kv.Value;
                seriesInfoById_[SeriesIDByProgramID(kv.Key)].AddGenericDescription(genericDescription);
            }

            List <DBSeriesInfo> updatedSeries = new List <DBSeriesInfo>();

            foreach (string key in sampleProgramsBySeriesID.Keys)
            {
                updatedSeries.Add(seriesInfoById_[key]);
            }
            DBManager.instance.SaveSeriesInfos(updatedSeries);
            return(seriesInfoById_.Values);
        }
예제 #2
0
 public void AddGenericDescription(SDGenericProgramDescription genericDescription)
 {
     description      = genericDescription.description1000;
     shortDescription = genericDescription.description100;
 }
예제 #3
0
 public void AddGenericDescription(SDGenericProgramDescription genericDescription)
 {
     description = genericDescription.description1000;
     shortDescription = genericDescription.description100;
 }