public void Run() { SatelliteDatabase satelliteDatabase = new SatelliteDatabase(); satelliteDatabase.Load(); TVDatabase tvDatabase = new TVDatabase(); tvDatabase.Load(); epgDatabase = new EPGDatabase(); epgDatabase.Load(); Collection<TuningSpec> tuningCollection = new Collection<TuningSpec>(); foreach (TVStation tvStation in tvDatabase.StationCollection) { TuningSpec tuningSpec = findTuningSpec(tuningCollection, tvStation); if (tuningSpec == null) { TuningSpec newTuningSpec = new TuningSpec(); newTuningSpec.Satellite = tvStation.Satellite; newTuningSpec.OriginalNetworkID = tvStation.OriginalNetworkID; newTuningSpec.TransportStreamID = tvStation.TransportStreamID; newTuningSpec.Frequency = tvStation.Frequency; newTuningSpec.SymbolRate = tvStation.SymbolRate; newTuningSpec.Tag = new EPGGraph(satelliteDatabase[tvStation.Satellite], newTuningSpec); tuningCollection.Add(newTuningSpec); } } bool end = false; DateTime lastUpdateTime = DateTime.Now; TimeSpan interval = new TimeSpan(0, 1, 0); while (!end) { foreach (TuningSpec tuningSpec in tuningCollection) { EPGGraph currentGraph = tuningSpec.Tag as EPGGraph; currentGraph.Play(); EITController eitController = new EITController(); while (!eitController.Finished && !end) { Collection<EITEntry> eitCollection = eitController.ProcessEITSections(currentGraph); updateSchedule(eitCollection); if (lastUpdateTime + interval < DateTime.Now) { epgDatabase.UpdateDatabase(); lastUpdateTime = DateTime.Now; } } currentGraph.Stop(); } Thread.Sleep(2000); } }
public void Run() { SatelliteDatabase satelliteDatabase = new SatelliteDatabase(); satelliteDatabase.Load(); TVDatabase tvDatabase = new TVDatabase(); tvDatabase.Load(); epgDatabase = new EPGDatabase(); epgDatabase.Load(); Collection <TuningSpec> tuningCollection = new Collection <TuningSpec>(); foreach (TVStation tvStation in tvDatabase.StationCollection) { TuningSpec tuningSpec = findTuningSpec(tuningCollection, tvStation); if (tuningSpec == null) { TuningSpec newTuningSpec = new TuningSpec(); newTuningSpec.Satellite = tvStation.Satellite; newTuningSpec.OriginalNetworkID = tvStation.OriginalNetworkID; newTuningSpec.TransportStreamID = tvStation.TransportStreamID; newTuningSpec.Frequency = tvStation.Frequency; newTuningSpec.SymbolRate = tvStation.SymbolRate; newTuningSpec.Tag = new EPGGraph(satelliteDatabase[tvStation.Satellite], newTuningSpec); tuningCollection.Add(newTuningSpec); } } bool end = false; DateTime lastUpdateTime = DateTime.Now; TimeSpan interval = new TimeSpan(0, 1, 0); while (!end) { foreach (TuningSpec tuningSpec in tuningCollection) { EPGGraph currentGraph = tuningSpec.Tag as EPGGraph; currentGraph.Play(); EITController eitController = new EITController(); while (!eitController.Finished && !end) { Collection <EITEntry> eitCollection = eitController.ProcessEITSections(currentGraph); updateSchedule(eitCollection); if (lastUpdateTime + interval < DateTime.Now) { epgDatabase.UpdateDatabase(); lastUpdateTime = DateTime.Now; } } currentGraph.Stop(); } Thread.Sleep(2000); } }