Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database cleanup #34

Merged
merged 4 commits into from Sep 7, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Addons/generic.EmberCore.BulkRename/clsAPIRenamer.vb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Public Class FileFolderRenamer
Dim mePath As String = String.Concat(Functions.AppPath, "Images", Path.DirectorySeparatorChar, "Flags")

_movies.Clear()
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLNewcommand.CommandText = String.Concat("SELECT Path FROM Sources;")
Using SQLReader As SQLite.SQLiteDataReader = SQLNewcommand.ExecuteReader()
While SQLReader.Read
Expand Down Expand Up @@ -276,7 +276,7 @@ Public Class FileFolderRenamer
MovieFile.FileSource = _tmpMovie.FileSource
MovieFile.Country = _tmpMovie.Movie.Country
Dim mFolders As New List(Of String)
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLNewcommand.CommandText = String.Concat("SELECT Path FROM Sources;")
Using SQLReader As SQLite.SQLiteDataReader = SQLNewcommand.ExecuteReader()
While SQLReader.Read
Expand Down
2 changes: 1 addition & 1 deletion Addons/generic.EmberCore.BulkRename/dlgBulkRename.vb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Public Class dlgBulkRenamer
Dim _curMovie As New Structures.DBMovie

' Load nfo movies using path from DB
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
Dim _tmpPath As String = String.Empty
Dim iProg As Integer = 0
SQLNewcommand.CommandText = String.Concat("SELECT COUNT(id) AS mcount FROM movies;")
Expand Down
2 changes: 1 addition & 1 deletion Addons/generic.EmberCore.MovieExport/dlgExportMovies.vb
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Public Class dlgExportMovies
' Clean up Movies List if any
_movies.Clear()
' Load nfo movies using path from DB
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
Dim _tmpMovie As New Structures.DBMovie
Dim _ID As Integer
Dim iProg As Integer = 0
Expand Down
6 changes: 3 additions & 3 deletions Addons/generic.EmberCore.NMT/dlgNMTMovies.vb
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ Public Class dlgNMTMovies

Private Function GetMovieFileInfo(ByVal MovieID As String) As MediaInfo.Fileinfo
Dim fi As New MediaInfo.Fileinfo
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.SQLcn.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT * FROM MoviesVStreams WHERE MovieID = ", MovieID, ";")
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
Dim video As MediaInfo.Video
Expand All @@ -831,7 +831,7 @@ Public Class dlgNMTMovies
End Using
End Using

Using SQLcommand As SQLite.SQLiteCommand = Master.DB.SQLcn.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT * FROM MoviesAStreams WHERE MovieID = ", MovieID, ";")
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
Dim audio As MediaInfo.Audio
Expand All @@ -845,7 +845,7 @@ Public Class dlgNMTMovies
End While
End Using
End Using
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.SQLcn.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT * FROM MoviesSubs WHERE MovieID = ", MovieID, ";")
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
Dim subtitle As MediaInfo.Subtitle
Expand Down
4 changes: 2 additions & 2 deletions Addons/generic.EmberCore.OfflineHolder/dlgOfflineHolder.vb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Public Class dlgOfflineHolder
End If

If cbSources.SelectedIndex >= 0 Then
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLNewcommand.CommandText = String.Concat("SELECT Path FROM Sources WHERE Name = """, cbSources.SelectedItem.ToString, """;")
Using SQLReader As SQLite.SQLiteDataReader = SQLNewcommand.ExecuteReader()
If SQLReader.Read Then
Expand Down Expand Up @@ -511,7 +511,7 @@ Public Class dlgOfflineHolder
End Using

'load all the movie folders from settings
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLNewcommand.CommandText = String.Concat("SELECT Name FROM Sources;")
Using SQLReader As SQLite.SQLiteDataReader = SQLNewcommand.ExecuteReader()
While SQLReader.Read
Expand Down
6 changes: 3 additions & 3 deletions Addons/generic.EmberCore.WebServer/Server/clsWebContent.vb
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ Public Class ProccessPages
End Function
Private Function GetMovieFileInfo(ByVal MovieID As String) As MediaInfo.Fileinfo
Dim fi As New MediaInfo.Fileinfo
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.SQLcn.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT * FROM MoviesVStreams WHERE MovieID = ", MovieID, ";")
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
Dim video As MediaInfo.Video
Expand All @@ -447,7 +447,7 @@ Public Class ProccessPages
End Using
End Using

Using SQLcommand As SQLite.SQLiteCommand = Master.DB.SQLcn.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT * FROM MoviesAStreams WHERE MovieID = ", MovieID, ";")
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
Dim audio As MediaInfo.Audio
Expand All @@ -461,7 +461,7 @@ Public Class ProccessPages
End While
End Using
End Using
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.SQLcn.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT * FROM MoviesSubs WHERE MovieID = ", MovieID, ";")
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
Dim subtitle As MediaInfo.Subtitle
Expand Down
8 changes: 4 additions & 4 deletions Addons/scraper.EmberCore/TVScraper/clsScrapeTVDB.vb
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ Public Class Scraper
tmpTVDBShow.Show = Master.DB.LoadTVFullShowFromDB(_ID)
tmpTVDBShow.AllSeason = Master.DB.LoadTVAllSeasonFromDB(_ID)

Using SQLCount As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLCount As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
If OnlySeason = 999 Then
SQLCount.CommandText = String.Concat("SELECT COUNT(ID) AS eCount FROM TVEps WHERE TVShowID = ", _ID, " AND Missing = 0;")
Else
SQLCount.CommandText = String.Concat("SELECT COUNT(ID) AS eCount FROM TVEps WHERE TVShowID = ", _ID, " AND Season = ", OnlySeason, " AND Missing = 0;")
End If
Using SQLRCount As SQLite.SQLiteDataReader = SQLCount.ExecuteReader
If Convert.ToInt32(SQLRCount("eCount")) > 0 Then
Using SQLCommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLCommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
If OnlySeason = 999 Then
SQLCommand.CommandText = String.Concat("SELECT ID, Lock FROM TVEps WHERE TVShowID = ", _ID, " AND Missing = 0;")
Else
Expand Down Expand Up @@ -818,10 +818,10 @@ Public Class Scraper

Me.bwTVDB.ReportProgress(tmpTVDBShow.Episodes.Count, "max")

Using SQLTrans As SQLite.SQLiteTransaction = Master.DB.BeginTransaction
Using SQLTrans As SQLite.SQLiteTransaction = Master.DB.MediaDBConn.BeginTransaction()
If Master.eSettings.DisplayMissingEpisodes Then
'clear old missing episode from db
Using SQLCommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLCommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLCommand.CommandText = String.Concat("DELETE FROM TVEps WHERE Missing = 1 AND TVShowID = ", Master.currShow.ShowID, ";")
SQLCommand.ExecuteNonQuery()
End Using
Expand Down
8 changes: 4 additions & 4 deletions Ember Media Manager/dlgDeleteConfirm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Public Class dlgDeleteConfirm
With tvwFiles
If .Nodes.Count = 0 Then Return False

Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.BeginTransaction 'Only on Batch Mode
Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.MediaDBConn.BeginTransaction() 'Only on Batch Mode
For Each ItemParentNode As TreeNode In .Nodes
Select Case Me._deltype
Case Enums.DelType.Movies
Expand Down Expand Up @@ -222,7 +222,7 @@ Public Class dlgDeleteConfirm
Case Enums.DelType.Seasons
Dim tSeason As New Structures.DBTV

Using SQLDelCommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLDelCommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
For Each Season As KeyValuePair(Of Long, Long) In ItemsToDelete
hadError = False

Expand All @@ -235,7 +235,7 @@ Public Class dlgDeleteConfirm
SQLDelCommand.CommandText = String.Concat("SELECT ID, TVEpPathID FROM TVEps WHERE TVShowID = ", Season.Value, " AND Season = ", Season.Key, ";")
Using SQLDelReader As SQLite.SQLiteDataReader = SQLDelCommand.ExecuteReader
While SQLDelReader.Read
Using SQLCommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLCommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLCommand.CommandText = String.Concat("SELECT TVEpPath FROM TVEpPaths WHERE ID = ", SQLDelReader("TVEpPathID"), ";")
Using SQLReader As SQLite.SQLiteDataReader = SQLCommand.ExecuteReader
If SQLReader.HasRows Then
Expand Down Expand Up @@ -286,7 +286,7 @@ Public Class dlgDeleteConfirm
Case Enums.DelType.Episodes
Dim tEp As New Structures.DBTV

Using SQLCommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLCommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
For Each Ep As Long In ItemsToDelete.Keys
hadError = False

Expand Down
6 changes: 3 additions & 3 deletions Ember Media Manager/dlgMovieSource.vb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Public Class dlgMovieSource
If String.IsNullOrEmpty(Me.txtSourceName.Text) Then
pbValid.Image = My.Resources.invalid
Else
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT ID FROM Sources WHERE Name LIKE """, Me.txtSourceName.Text.Trim, """ AND ID != ", Me._id, ";")
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
If Not String.IsNullOrEmpty(SQLreader("ID").ToString) Then
Expand Down Expand Up @@ -126,8 +126,8 @@ Public Class dlgMovieSource

Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Try
Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.BeginTransaction
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.MediaDBConn.BeginTransaction()
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
If Me._id >= 0 Then
SQLcommand.CommandText = String.Concat("UPDATE sources SET name = (?), path = (?), recursive = (?), foldername = (?), single = (?) WHERE ID =", Me._id, ";")
Else
Expand Down
4 changes: 2 additions & 2 deletions Ember Media Manager/dlgSetsManager.vb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Public Class dlgSetsManager
If Not String.IsNullOrEmpty(sSet) Then alSets.Add(sSet)
Next

Using SQLcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
Dim tmpMovie As New Structures.DBMovie
Dim iProg As Integer = 0
SQLcommand.CommandText = String.Concat("SELECT COUNT(id) AS mcount FROM movies;")
Expand Down Expand Up @@ -457,7 +457,7 @@ Public Class dlgSetsManager
Try
Me.SetControlsEnabled(False)

Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.BeginTransaction
Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.MediaDBConn.BeginTransaction()
For Each tMovie As Movies In mSet.Movies
If Not Master.eSettings.YAMJSetsCompatible Then
tMovie.DBMovie.Movie.AddSet(mSet.Set, 0)
Expand Down
10 changes: 5 additions & 5 deletions Ember Media Manager/dlgSettings.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2950,7 +2950,7 @@ Public Class dlgSettings
Dim lvItem As ListViewItem
Master.DB.LoadTVSourcesFromDB()
lvTVSources.Items.Clear()
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = "SELECT * FROM TVSources;"
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
While SQLreader.Read
Expand Down Expand Up @@ -3023,8 +3023,8 @@ Public Class dlgSettings
If MsgBox(Master.eLang.GetString(418, "Are you sure you want to remove the selected sources? This will remove the movies from these sources from the Ember database."), MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Master.eLang.GetString(104, "Are You Sure?")) = MsgBoxResult.Yes Then
Me.lvMovies.BeginUpdate()

Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.BeginTransaction
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.MediaDBConn.BeginTransaction()
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
Dim parSource As SQLite.SQLiteParameter = SQLcommand.Parameters.Add("parSource", DbType.String, 0, "source")
While Me.lvMovies.SelectedItems.Count > 0
parSource.Value = lvMovies.SelectedItems(0).SubItems(1).Text
Expand Down Expand Up @@ -3119,8 +3119,8 @@ Public Class dlgSettings
If MsgBox(Master.eLang.GetString(418, "Are you sure you want to remove the selected sources? This will remove the TV Shows from these sources from the Ember database."), MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Master.eLang.GetString(104, "Are You Sure?")) = MsgBoxResult.Yes Then
Me.lvTVSources.BeginUpdate()

Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.BeginTransaction
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.MediaDBConn.BeginTransaction()
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
Dim parSource As SQLite.SQLiteParameter = SQLcommand.Parameters.Add("parSource", DbType.String, 0, "source")
While Me.lvTVSources.SelectedItems.Count > 0
parSource.Value = lvTVSources.SelectedItems(0).SubItems(1).Text
Expand Down
8 changes: 4 additions & 4 deletions Ember Media Manager/dlgTVSource.vb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Public Class dlgTVSource
If String.IsNullOrEmpty(Me.txtSourceName.Text) Then
pbValid.Image = My.Resources.invalid
Else
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT ID FROM TVSources WHERE Name LIKE """, Me.txtSourceName.Text.Trim, """ AND ID != ", Me._id, ";")
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
If Not String.IsNullOrEmpty(SQLreader("ID").ToString) Then
Expand All @@ -94,7 +94,7 @@ Public Class dlgTVSource
Me.SetUp()
Try
If Me._id >= 0 Then
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT * FROM TVSources WHERE ID = ", Me._id, ";")
Using SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
Me.txtSourceName.Text = SQLreader("Name").ToString
Expand All @@ -114,8 +114,8 @@ Public Class dlgTVSource

Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Try
Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.BeginTransaction
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLtransaction As SQLite.SQLiteTransaction = Master.DB.MediaDBConn.BeginTransaction()
Using SQLcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
If Me._id >= 0 Then
SQLcommand.CommandText = String.Concat("UPDATE TVSources SET name = (?), path = (?) WHERE ID =", Me._id, ";")
Else
Expand Down
2 changes: 1 addition & 1 deletion Ember Media Manager/dlgUpdateMedia.vb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Public Class dlgUpdateMedia
End Sub

Private Sub CheckNewAndMark()
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.CreateCommand
Using SQLNewcommand As SQLite.SQLiteCommand = Master.DB.MediaDBConn.CreateCommand()
SQLNewcommand.CommandText = String.Concat("SELECT COUNT(id) AS ncount FROM movies WHERE new = 1;")
Using SQLcount As SQLite.SQLiteDataReader = SQLNewcommand.ExecuteReader()
rbUpdateModifier_New.Enabled = Convert.ToInt32(SQLcount("ncount")) > 0
Expand Down
Loading