public bool Connect() { LoadMemberSettings(); string dataProviderString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Mode=Share Deny None;Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;"; if (TvMovie.DatabasePath != String.Empty) { dataProviderString = string.Format(dataProviderString, TvMovie.DatabasePath); } else { return(false); } try { _databaseConnection = new OleDbConnection(dataProviderString); } catch (Exception connex) { Log.Info("TVMovie: Exception creating OleDbConnection: {0}", connex.Message); return(false); } string sqlSelect = "SELECT * FROM Sender WHERE (Favorit = true) AND (GueltigBis >=Now()) ORDER BY Bezeichnung ASC;"; DataSet tvMovieTable = new DataSet("Sender"); try { _databaseConnection.Open(); using (OleDbCommand databaseCommand = new OleDbCommand(sqlSelect, _databaseConnection)) { using (OleDbDataAdapter databaseAdapter = new OleDbDataAdapter(databaseCommand)) { try { databaseAdapter.FillSchema(tvMovieTable, SchemaType.Source, "Sender"); databaseAdapter.Fill(tvMovieTable); } catch (Exception dsex) { Log.Info("TVMovie: Exception filling Sender DataSet - {0}\n{1}", dsex.Message, dsex.StackTrace); return(false); } } } } catch (System.Data.OleDb.OleDbException ex) { Log.Info("TVMovie: Error accessing TV Movie Clickfinder database while reading stations: {0}", ex.Message); Log.Info("TVMovie: Exception: {0}", ex.StackTrace); _canceled = true; return(false); } catch (Exception ex2) { Log.Info("TVMovie: Exception: {0}, {1}", ex2.Message, ex2.StackTrace); _canceled = true; return(false); } finally { _databaseConnection.Close(); } try { _tvmEpgChannels = new List <TVMChannel>(); foreach (DataRow sender in tvMovieTable.Tables["Table"].Rows) { string senderId = sender["ID"].ToString(); string senderKennung = sender["SenderKennung"].ToString(); string senderBez = sender["Bezeichnung"].ToString(); // these are non-vital for now. string senderUrl = String.Empty; string senderSort = "-1"; string senderZeichen = @"tvmovie_senderlogoplatzhalter.gif"; // Somehow TV Movie's db does not necessarily contain these columns... try { senderUrl = sender["Webseite"].ToString(); } catch (Exception) {} try { senderSort = sender["SortNrTVMovie"].ToString(); } catch (Exception) {} try { senderZeichen = sender["Zeichen"].ToString(); } catch (Exception) {} TVMChannel current = new TVMChannel(senderId, senderKennung, senderBez, senderUrl, senderSort, senderZeichen ); _tvmEpgChannels.Add(current); } } catch (Exception ex) { Log.Info("TVMovie: Exception: {0}, {1}", ex.Message, ex.StackTrace); } _channelList = GetChannels(); return(true); }
public bool Connect() { LoadMemberSettings(); string dataProviderString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Mode=Share Deny None;Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;"; if (TvMovie.DatabasePath != String.Empty) dataProviderString = string.Format(dataProviderString, TvMovie.DatabasePath); else return false; try { _databaseConnection = new OleDbConnection(dataProviderString); } catch (Exception connex) { Log.Info("TVMovie: Exception creating OleDbConnection: {0}", connex.Message); return false; } string sqlSelect = "SELECT * FROM Sender WHERE (Favorit = true) AND (GueltigBis >=Now()) ORDER BY Bezeichnung ASC;"; DataSet tvMovieTable = new DataSet("Sender"); try { _databaseConnection.Open(); using (OleDbCommand databaseCommand = new OleDbCommand(sqlSelect, _databaseConnection)) { using (OleDbDataAdapter databaseAdapter = new OleDbDataAdapter(databaseCommand)) { try { databaseAdapter.FillSchema(tvMovieTable, SchemaType.Source, "Sender"); databaseAdapter.Fill(tvMovieTable); } catch (Exception dsex) { Log.Info("TVMovie: Exception filling Sender DataSet - {0}\n{1}", dsex.Message, dsex.StackTrace); return false; } } } } catch (System.Data.OleDb.OleDbException ex) { Log.Info("TVMovie: Error accessing TV Movie Clickfinder database while reading stations: {0}", ex.Message); Log.Info("TVMovie: Exception: {0}", ex.StackTrace); _canceled = true; return false; } catch (Exception ex2) { Log.Info("TVMovie: Exception: {0}, {1}", ex2.Message, ex2.StackTrace); _canceled = true; return false; } finally { _databaseConnection.Close(); } try { _tvmEpgChannels = new List<TVMChannel>(); foreach (DataRow sender in tvMovieTable.Tables["Table"].Rows) { string senderId = sender["ID"].ToString(); string senderKennung = sender["SenderKennung"].ToString(); string senderBez = sender["Bezeichnung"].ToString(); // these are non-vital for now. string senderUrl = String.Empty; string senderSort = "-1"; string senderZeichen = @"tvmovie_senderlogoplatzhalter.gif"; // Somehow TV Movie's db does not necessarily contain these columns... try { senderUrl = sender["Webseite"].ToString(); } catch (Exception) {} try { senderSort = sender["SortNrTVMovie"].ToString(); } catch (Exception) {} try { senderZeichen = sender["Zeichen"].ToString(); } catch (Exception) {} TVMChannel current = new TVMChannel(senderId, senderKennung, senderBez, senderUrl, senderSort, senderZeichen ); _tvmEpgChannels.Add(current); } } catch (Exception ex) { Log.Info("TVMovie: Exception: {0}, {1}", ex.Message, ex.StackTrace); } _channelList = GetChannels(); return true; }