From 82c0aa4b5f27f48d91af9e3c41933e4e4c3b1a44 Mon Sep 17 00:00:00 2001 From: Dario Ragusa Date: Sun, 15 May 2022 21:42:46 +0200 Subject: [PATCH] Multimedia section #2 --- JWLibrary-VideosAdder/AddVideos.vb | 74 ++++++++++++--- JWLibrary-VideosAdder/FindWatchtower.vb | 83 ++++++++++++++++ JWLibrary-VideosAdder/FindWeekWT.vb | 55 +++++++++++ JWLibrary-VideosAdder/Form1.Designer.vb | 23 ++++- JWLibrary-VideosAdder/Form1.vb | 63 +++++++++++-- .../JWLibrary-VideosAdder.vbproj | 14 ++- JWLibrary-VideosAdder/ManageWatchtower.vb | 20 ++++ .../My Project/AssemblyInfo.vb | 10 +- .../My Project/Resources.Designer.vb | 2 +- .../My Project/Settings.Designer.vb | 50 +++++----- JWLibrary-VideosAdder/app.config | 23 +++++ Setup/Setup.vdproj | 94 ++++++++++++------- 12 files changed, 423 insertions(+), 88 deletions(-) create mode 100644 JWLibrary-VideosAdder/FindWatchtower.vb create mode 100644 JWLibrary-VideosAdder/FindWeekWT.vb create mode 100644 JWLibrary-VideosAdder/ManageWatchtower.vb create mode 100644 JWLibrary-VideosAdder/app.config diff --git a/JWLibrary-VideosAdder/AddVideos.vb b/JWLibrary-VideosAdder/AddVideos.vb index 7a30587..38d221f 100644 --- a/JWLibrary-VideosAdder/AddVideos.vb +++ b/JWLibrary-VideosAdder/AddVideos.vb @@ -3,24 +3,28 @@ Imports Devart.Data.SQLite Imports System.IO Module AddVideos - Sub AddImg(ByVal dbDir As String, ByVal vidList As List(Of String)) + Sub AddVideo(ByVal dbDirWT As String, ByVal docID As Integer, ByVal dbDir As String, ByVal vidList As List(Of String)) If Not System.IO.File.Exists(dbDir) Then Return Using SQLCon As New SQLiteConnection(String.Format("Data Source = {0}", dbDir)) - Dim insertMediaKeyQuery As String = "INSERT INTO MediaKey(KeySymbol, MediaType, DocumentId, MepsLanguageIndex, IssueTagNumber, Track, BookNumber) VALUES(@KeySymbol, @MediaType, @DocumentId, @MepsLanguageIndex, @IssueTagNumber, @Track, @BookNumber)" + Dim trackList As List(Of Integer) = New List(Of Integer) + Dim insertMediaKeyQuery As String = "INSERT INTO MediaKey(MediaKeyId, KeySymbol, MediaType, DocumentId, MepsLanguageIndex, IssueTagNumber, Track, BookNumber) VALUES(@MediaKeyId, @KeySymbol, @MediaType, @DocumentId, @MepsLanguageIndex, @IssueTagNumber, @Track, @BookNumber)" Dim insertVideoQuery As String = "INSERT INTO Video(MediaKeyId, Title, Version, MimeType, BitRate, FrameRate, Duration, Checksum, FileSize, FrameHeight, FrameWidth, Label, Subtitled, DownloadUrl, FilePath, Source) VALUES(@MediaKeyId, @Title, @Version, @MimeType, @BitRate, @FrameRate, @Duration, @Checksum, @FileSize, @FrameHeight, @FrameWidth, @Label, @Subtitled, @DownloadUrl, @FilePath, @Source)" SQLCon.Open() For Each Video In vidList + Dim NewID = GetLastMediaKeyID(dbDir) + 1 Dim mediaKeyCMD As New SQLiteCommand(insertMediaKeyQuery, SQLCon) Dim videoCMD As New SQLiteCommand(insertVideoQuery, SQLCon) - mediaKeyCMD.Parameters.AddWithValue("@KeySymbol", "custom") + mediaKeyCMD.Parameters.AddWithValue("@MediaKeyId", NewID) + mediaKeyCMD.Parameters.AddWithValue("@KeySymbol", "sjjm") ' Fake song mediaKeyCMD.Parameters.AddWithValue("@MediaType", "1") mediaKeyCMD.Parameters.AddWithValue("@DocumentId", "0") mediaKeyCMD.Parameters.AddWithValue("@MepsLanguageIndex", "4") - mediaKeyCMD.Parameters.AddWithValue("@IssueTagNumber", Format(Now, "yyyyMMdd")) - mediaKeyCMD.Parameters.AddWithValue("@Track", Format(Now, "hhmmss")) + mediaKeyCMD.Parameters.AddWithValue("@IssueTagNumber", 0) + mediaKeyCMD.Parameters.AddWithValue("@Track", NewID + 1000) mediaKeyCMD.Parameters.AddWithValue("@BookNumber", "0") mediaKeyCMD.ExecuteNonQuery() - videoCMD.Parameters.AddWithValue("@MediaKeyId", CStr(GetLastMediaKeyID(dbDir))) + trackList.Add(NewID + 1000) + videoCMD.Parameters.AddWithValue("@MediaKeyId", NewID) videoCMD.Parameters.AddWithValue("@Title", Video.Split("\").Last.Replace(".mp4", "").Replace(".MP4", "")) videoCMD.Parameters.AddWithValue("@Version", "1") videoCMD.Parameters.AddWithValue("@MimeType", "video/mp4") @@ -33,13 +37,13 @@ Module AddVideos videoCMD.Parameters.AddWithValue("@FrameWidth", "1280") 'No matter videoCMD.Parameters.AddWithValue("@Label", "720p") 'No matter videoCMD.Parameters.AddWithValue("@Subtitled", "0") - videoCMD.Parameters.AddWithValue("@DownloadUrl", "https://github.com/Miaosi001") 'No matter + videoCMD.Parameters.AddWithValue("@DownloadUrl", "https://github.com/darioragusa") 'No matter videoCMD.Parameters.AddWithValue("@FilePath", Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) & "\JWLibrary\" & Video.ToString.Split("\").Last) videoCMD.Parameters.AddWithValue("@Source", "0") videoCMD.ExecuteNonQuery() Next -_End: SQLCon.Dispose() : SQLCon.Close() : GC.Collect() : GC.WaitForPendingFinalizers() + AddVideoToWT(dbDirWT, docID, trackList) End Using End Sub @@ -47,7 +51,7 @@ _End: If Not System.IO.File.Exists(dbDir) Then Return -1 Dim lastID As Integer = 0 Using sqlCon As New SQLiteConnection(String.Format("Data Source = {0}", dbDir)) - Dim readIdQuery As String = "SELECT MediaKeyId FROM MediaKey" + Dim readIdQuery As String = "SELECT MAX(MediaKeyId) FROM MediaKey" sqlCon.Open() Using command = sqlCon.CreateCommand() command.CommandText = readIdQuery @@ -64,8 +68,7 @@ _End: Function GetDuration(ByVal MovieFullPath As String) As String If File.Exists(MovieFullPath) Then Dim objShell As Object = CreateObject("Shell.Application") - Dim objFolder As Object = _ - objShell.Namespace(Path.GetDirectoryName(MovieFullPath)) + Dim objFolder As Object = objShell.Namespace(Path.GetDirectoryName(MovieFullPath)) For Each strFileName In objFolder.Items If strFileName.Name = Path.GetFileName(MovieFullPath) Then Dim duration = objFolder.GetDetailsOf(strFileName, 27).ToString @@ -83,4 +86,53 @@ _End: Return "" End If End Function + + Sub AddVideoToWT(ByVal dbDir As String, ByVal docID As Integer, ByVal trackList As List(Of Integer)) + If Not System.IO.File.Exists(dbDir) Then Return + Using SQLCon As New SQLiteConnection(String.Format("Data Source = {0}", dbDir)) + Dim insertMultimediaQuery As String = "INSERT INTO Multimedia(MultimediaId, DataType, MajorType, MinorType, MimeType, KeySymbol, Track, CategoryType, MepsLanguageIndex) VALUES(@MultimediaId, @Data, @Major, @Minor, @Mime, @KeySymbol, @Track, @Category, @Meps)" + Dim insertDocumentMultimediaQuery As String = "INSERT INTO DocumentMultimedia(DocumentId, MultimediaId) VALUES(@Document, @Multimedia)" + Dim newID As Integer = GetLastMultimediaID(dbDir) + 1 + If newID <> -1 Then + SQLCon.Open() + For Each track In trackList + Dim multimediaCMD As New SQLiteCommand(insertMultimediaQuery, SQLCon) + Dim documentMultimediaCMD As New SQLiteCommand(insertDocumentMultimediaQuery, SQLCon) + multimediaCMD.Parameters.AddWithValue("@MultimediaId", newID) + multimediaCMD.Parameters.AddWithValue("@Data", 2) + multimediaCMD.Parameters.AddWithValue("@Major", 2) + multimediaCMD.Parameters.AddWithValue("@Minor", 3) + multimediaCMD.Parameters.AddWithValue("@Mime", "video/mp4") + multimediaCMD.Parameters.AddWithValue("@KeySymbol", "sjjm") + multimediaCMD.Parameters.AddWithValue("@Track", track) + multimediaCMD.Parameters.AddWithValue("@Category", -1) + multimediaCMD.Parameters.AddWithValue("@Meps", 4) + multimediaCMD.ExecuteNonQuery() + documentMultimediaCMD.Parameters.AddWithValue("@Document", CStr(docID)) + documentMultimediaCMD.Parameters.AddWithValue("@Multimedia", newID) + documentMultimediaCMD.ExecuteNonQuery() + newID += 1 + Next + End If + SQLCon.Dispose() : SQLCon.Close() : GC.Collect() : GC.WaitForPendingFinalizers() + End Using + End Sub + + Function GetLastMultimediaID(ByVal dbDir As String) As Integer + If Not System.IO.File.Exists(dbDir) Then Return -1 + Dim lastID As Integer = -1 + Using sqlCon As New SQLiteConnection(String.Format("Data Source = {0}", dbDir)) + Dim readWeekQuery As String = "SELECT Max(MultimediaId) FROM Multimedia" + sqlCon.Open() + Using command = sqlCon.CreateCommand() + command.CommandText = readWeekQuery + Using reader = command.ExecuteReader() + While reader.Read() + lastID = reader.GetInt32(0) + End While + End Using + End Using + sqlCon.Dispose() : sqlCon.Close() : GC.Collect() : GC.WaitForPendingFinalizers() + End Using : Return lastID + End Function End Module diff --git a/JWLibrary-VideosAdder/FindWatchtower.vb b/JWLibrary-VideosAdder/FindWatchtower.vb new file mode 100644 index 0000000..ba3010e --- /dev/null +++ b/JWLibrary-VideosAdder/FindWatchtower.vb @@ -0,0 +1,83 @@ +Imports System.IO +Imports Devart.Data +Imports Devart.Data.SQLite + +Module FindWatchtower + Function findWatchtowerDirectory() As String + Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\Packages" + If IO.Directory.Exists(path) Then + For Each Dir As String In Directory.GetDirectories(path) + If LCase(Dir).Contains("watchtower") Then + path = Dir & "\LocalState\Publications" + Exit For + End If + Next + End If + If IO.Directory.Exists(path) Then Return path Else Return "" + End Function + + Function existWhatchtowerDirectory() As Boolean + If findWatchtowerDirectory() <> "" Then Return True Else Return False + End Function + + Function findCurrentWatchtowers() As List(Of String) 'I used an array in case there were multiple languages + Dim wtPath As String = findWatchtowerDirectory() + Dim collectionPath As String = wtPath.Replace("\Publications", "\Data\pub_collections.db") + Dim pubArray As New List(Of publication) + If System.IO.File.Exists(collectionPath) Then + Using sqlCon As New SQLiteConnection(String.Format("Data Source = {0}", collectionPath)) + Dim query As String = "SELECT IssueTagNumber, FirstDatedTextDateOffset, LastDatedTextDateOffset, KeySymbol FROM Publication" + sqlCon.Open() + Using command = sqlCon.CreateCommand() + command.CommandText = query + Using reader = command.ExecuteReader() + While reader.Read() + Dim pub As publication = New publication + pub.tagNumber = reader.GetString(0) + pub.firstDate = reader.GetString(1) + pub.lastDate = reader.GetString(2) + pub.keySymbol = reader.GetString(3) + pubArray.Add(pub) 'Getting all publications + End While + End Using + End Using + sqlCon.Dispose() : sqlCon.Close() : GC.Collect() : GC.WaitForPendingFinalizers() + End Using + End If + + Dim wtArray As New List(Of publication) + For Each pub In pubArray + If pub.keySymbol = "w" Then wtArray.Add(pub) 'Keeping only watchtowers + Next + + Dim currentTagN As String = "" + For Each pub In wtArray + Dim firstDate As Date = DateTime.ParseExact(pub.firstDate, "yyyyMMdd", Nothing) + Dim lastDate As Date = DateTime.ParseExact(pub.lastDate, "yyyyMMdd", Nothing) + Dim todayDate As Date = Now.Date + If firstDate <= todayDate And todayDate <= lastDate Then 'Period checking + currentTagN = pub.tagNumber + Exit For + End If + Next + + Dim wtDirArray As New List(Of String) + For Each pubDirectory In IO.Directory.EnumerateDirectories(wtPath) + Dim pubName As String = pubDirectory.ToString.Split("\").Last + If Not pubName.Contains("w_") Or currentTagN.Length < 6 Then GoTo _endFor + If pubName.StartsWith("w_") And pubName.EndsWith(currentTagN.Substring(0, 6)) Then 'Getting watchtower directories + wtDirArray.Add(pubDirectory) + End If +_endFor: + Next + + Return wtDirArray + End Function +End Module + +Structure publication + Dim keySymbol As String + Dim tagNumber As String + Dim firstDate As String + Dim lastDate As String +End Structure \ No newline at end of file diff --git a/JWLibrary-VideosAdder/FindWeekWT.vb b/JWLibrary-VideosAdder/FindWeekWT.vb new file mode 100644 index 0000000..ea3b41c --- /dev/null +++ b/JWLibrary-VideosAdder/FindWeekWT.vb @@ -0,0 +1,55 @@ +Imports Devart.Data +Imports Devart.Data.SQLite + +Module FindWeekWT + Function GetWeekN(ByVal dbDir As String) As Integer + If Not System.IO.File.Exists(dbDir) Then Return -1 + Dim returnID As Integer = -1 + Using sqlCon As New SQLiteConnection(String.Format("Data Source = {0}", dbDir)) + Dim readWeekQuery As String = "SELECT DatedTextId, FirstDateOffset, LastDateOffset FROM DatedText" + sqlCon.Open() + Using command = sqlCon.CreateCommand() + command.CommandText = readWeekQuery + Using reader = command.ExecuteReader() + While reader.Read() + Dim id = reader.GetInt32(0) + Dim firstDate = reader.GetString(1) + Dim lastDate = reader.GetString(2) + If CheckWTWeek(firstDate, lastDate) Then returnID = id + End While + End Using + End Using + sqlCon.Dispose() : sqlCon.Close() : GC.Collect() : GC.WaitForPendingFinalizers() + End Using : Return returnID + End Function + + Function CheckWTWeek(ByVal firstDate As String, ByVal lastDate As String) As Boolean + Dim startDate As Date = DateTime.ParseExact(firstDate, "yyyyMMdd", Nothing) + Dim endDate As Date = DateTime.ParseExact(lastDate, "yyyyMMdd", Nothing) + If Now.Date >= startDate And Now.Date <= endDate Then Return True Else Return False + End Function + + Function GetDocumentID(ByVal dbDir As String, ByVal weekN As Integer) As Integer + If Not System.IO.File.Exists(dbDir) Then Return -1 + Dim returnID As Integer = -1 + Using sqlCon As New SQLiteConnection(String.Format("Data Source = {0}", dbDir)) + Dim readWeekQuery As String = "SELECT DocumentId, Class FROM Document" + sqlCon.Open() + Using command = sqlCon.CreateCommand() + command.CommandText = readWeekQuery + Dim actWeekN As Integer = 1 + Using reader = command.ExecuteReader() + While reader.Read() + Dim id = reader.GetInt32(0) + Dim class_ = reader.GetInt32(1) + If class_ = 40 Then + If weekN = actWeekN Then returnID = id + actWeekN += 1 + End If + End While + End Using + End Using + sqlCon.Dispose() : sqlCon.Close() : GC.Collect() : GC.WaitForPendingFinalizers() + End Using : Return returnID + End Function +End Module \ No newline at end of file diff --git a/JWLibrary-VideosAdder/Form1.Designer.vb b/JWLibrary-VideosAdder/Form1.Designer.vb index ca73b94..5ae1ee9 100644 --- a/JWLibrary-VideosAdder/Form1.Designer.vb +++ b/JWLibrary-VideosAdder/Form1.Designer.vb @@ -29,12 +29,14 @@ Partial Class Form1 Me.ButtonDelete = New System.Windows.Forms.Button() Me.ListBoxVid = New System.Windows.Forms.ListBox() Me.ButtonAdd = New System.Windows.Forms.Button() + Me.ButtonRestoreAll = New System.Windows.Forms.Button() Me.Panel1.SuspendLayout() Me.Panel2.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' + Me.Panel1.Controls.Add(Me.ButtonRestoreAll) Me.Panel1.Controls.Add(Me.ButtonAdd_Menu) Me.Panel1.Location = New System.Drawing.Point(11, 5) Me.Panel1.Name = "Panel1" @@ -52,7 +54,7 @@ Partial Class Form1 Me.ButtonAdd_Menu.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.ButtonAdd_Menu.Font = New System.Drawing.Font("Verdana", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.ButtonAdd_Menu.ForeColor = System.Drawing.Color.Blue - Me.ButtonAdd_Menu.Location = New System.Drawing.Point(3, 48) + Me.ButtonAdd_Menu.Location = New System.Drawing.Point(3, 42) Me.ButtonAdd_Menu.Name = "ButtonAdd_Menu" Me.ButtonAdd_Menu.Size = New System.Drawing.Size(312, 61) Me.ButtonAdd_Menu.TabIndex = 12 @@ -131,6 +133,23 @@ Partial Class Form1 Me.ButtonAdd.Text = "→" Me.ButtonAdd.UseVisualStyleBackColor = True ' + 'ButtonRestoreAll + ' + Me.ButtonRestoreAll.Cursor = System.Windows.Forms.Cursors.Hand + Me.ButtonRestoreAll.FlatAppearance.BorderColor = System.Drawing.Color.White + Me.ButtonRestoreAll.FlatAppearance.BorderSize = 0 + Me.ButtonRestoreAll.FlatAppearance.MouseDownBackColor = System.Drawing.Color.White + Me.ButtonRestoreAll.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White + Me.ButtonRestoreAll.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.ButtonRestoreAll.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.ButtonRestoreAll.ForeColor = System.Drawing.Color.Red + Me.ButtonRestoreAll.Location = New System.Drawing.Point(37, 124) + Me.ButtonRestoreAll.Name = "ButtonRestoreAll" + Me.ButtonRestoreAll.Size = New System.Drawing.Size(240, 31) + Me.ButtonRestoreAll.TabIndex = 17 + Me.ButtonRestoreAll.Text = "Restore original publications" + Me.ButtonRestoreAll.UseVisualStyleBackColor = True + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -156,5 +175,5 @@ Partial Class Form1 Friend WithEvents ButtonDelete As System.Windows.Forms.Button Friend WithEvents ListBoxVid As System.Windows.Forms.ListBox Friend WithEvents ButtonAdd As System.Windows.Forms.Button - + Friend WithEvents ButtonRestoreAll As Button End Class diff --git a/JWLibrary-VideosAdder/Form1.vb b/JWLibrary-VideosAdder/Form1.vb index f75a896..9e52d7d 100644 --- a/JWLibrary-VideosAdder/Form1.vb +++ b/JWLibrary-VideosAdder/Form1.vb @@ -13,15 +13,32 @@ Public Class Form1 End Sub Private Sub ButtonAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAdd.Click - Dim collectionDir As String = findCollectionDirectory() - If collectionDir = "" Then - MsgBox(Strings.Error3Text, MsgBoxStyle.Exclamation, Me.Text) + Dim wtDir = findCurrentWatchtowers() + If wtDir.Count = 0 Then + MsgBox(Strings.Error4Text, MsgBoxStyle.Critical, Me.Text) + Return End If - Dim VideoDir As String = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) & "\JWLibrary" - For Each vidDir In vidList - System.IO.File.Copy(vidDir, VideoDir & "\" & vidDir.ToString.Split("\").Last, True) + For Each directory In wtDir + makeBackup(directory) + Dim dbDir As String = directory & "\" & directory.Split("\").Last & ".db" + Dim weekN As Integer = GetWeekN(dbDir) + If weekN = -1 Then + MsgBox(Strings.Error5Text, MsgBoxStyle.Exclamation, Me.Text) : Exit Sub + End If + Dim docID As Integer = GetDocumentID(dbDir, weekN) + + + Dim collectionDir As String = findCollectionDirectory() + If collectionDir = "" Then + MsgBox(Strings.Error3Text, MsgBoxStyle.Exclamation, Me.Text) + End If + Dim VideoDir As String = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) & "\JWLibrary" + For Each vidDir In vidList + System.IO.File.Copy(vidDir, VideoDir & "\" & vidDir.ToString.Split("\").Last, True) + Next + AddVideo(dbDir, docID, collectionDir, vidList) Next - AddImg(collectionDir, vidList) + MsgBox(Strings.Text2, MsgBoxStyle.OkOnly, Me.Text) Application.Restart() 'I have to close otherwise it gives error @@ -61,11 +78,15 @@ Public Class Form1 Strings.Error1Text = "Cartella di JW Library non trovata" Strings.Error2Text = "Chiudi JW Library per continuare" Strings.Error3Text = "Collezione non trovata" + Strings.Error4Text = "Torre di Guardia attuale non trovata" + Strings.Error5Text = "Settimana non trovata" Strings.Text1 = "Video" Strings.Text2 = "Il mio lavoro qui è finito" + Strings.Text3 = "Pubblicazioni ripristinate" ButtonSelect.Text = "Seleziona i video da aggiungere" ButtonDelete.Text = "Elimina" ButtonAdd_Menu.Text = "Aggiungi video" + ButtonRestoreAll.Text = "Ripristina pubblicazioni originali" End If End Sub @@ -73,8 +94,11 @@ Public Class Form1 Shared Error1Text As String = "JW Library folder not found" Shared Error2Text As String = "Close JW Library to continue" Shared Error3Text As String = "Collection not found" + Shared Error4Text As String = "Current Watchtower not found" + Shared Error5Text As String = "Week not found" Shared Text1 As String = "Videos" Shared Text2 As String = "My job here is done" + Shared Text3 As String = "Publications restored" End Structure Function findCollectionDirectory() As String @@ -89,4 +113,29 @@ Public Class Form1 End If If IO.File.Exists(path) Then Return path Else Return "" End Function + + Private Sub ButtonRestoreAll_Click(sender As Object, e As EventArgs) Handles ButtonRestoreAll.Click + If Not ChecKJW() Then Return + For Each directory In findCurrentWatchtowers() + If Not directory.ToString.EndsWith("_back") Then + restoreBackup(directory) + End If + Next + MsgBox(Strings.Text3, MsgBoxStyle.OkOnly, Me.Text) + End Sub + + Function ChecKJW() As Boolean +_check: + Dim proc() As Process + proc = Process.GetProcessesByName("JWLibrary") + If proc.Count > 0 Then + Dim result = MsgBox(Strings.Error2Text, MsgBoxStyle.RetryCancel, Me.Text) + If result = MsgBoxResult.Cancel Then + Return False + Else + GoTo _check + End If + End If + Return True + End Function End Class diff --git a/JWLibrary-VideosAdder/JWLibrary-VideosAdder.vbproj b/JWLibrary-VideosAdder/JWLibrary-VideosAdder.vbproj index fae196c..7358315 100644 --- a/JWLibrary-VideosAdder/JWLibrary-VideosAdder.vbproj +++ b/JWLibrary-VideosAdder/JWLibrary-VideosAdder.vbproj @@ -1,5 +1,5 @@  - + Debug x86 @@ -13,8 +13,9 @@ JWLibrary-VideosAdder 512 WindowsForms - v4.0 - Client + v4.8 + + publish\ true Disk @@ -40,6 +41,7 @@ bin\Debug\ JWLibrary-VideosAdder.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + false x86 @@ -50,6 +52,7 @@ bin\Release\ JWLibrary-VideosAdder.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + false On @@ -99,6 +102,8 @@ + + Form @@ -106,10 +111,12 @@ Form1.vb Form + True Application.myapp + True True @@ -134,6 +141,7 @@ + MyApplicationCodeGenerator Application.Designer.vb diff --git a/JWLibrary-VideosAdder/ManageWatchtower.vb b/JWLibrary-VideosAdder/ManageWatchtower.vb new file mode 100644 index 0000000..4f7cb0b --- /dev/null +++ b/JWLibrary-VideosAdder/ManageWatchtower.vb @@ -0,0 +1,20 @@ +Imports System.IO +Imports Devart.Data +Imports Devart.Data.SQLite + +Module ManageWatchtower + Function exsistBackup(ByVal directory As String) As Boolean + Return IO.Directory.Exists(directory + "_back") + End Function + + Sub makeBackup(ByVal directory As String) + If exsistBackup(directory) Then Return + My.Computer.FileSystem.CopyDirectory(directory, directory + "_back") + End Sub + + Sub restoreBackup(ByVal directory As String) + If Not IO.Directory.Exists(directory + "_back") Then Return + My.Computer.FileSystem.DeleteDirectory(directory, FileIO.DeleteDirectoryOption.DeleteAllContents) + My.Computer.FileSystem.MoveDirectory(directory + "_back", directory) + End Sub +End Module \ No newline at end of file diff --git a/JWLibrary-VideosAdder/My Project/AssemblyInfo.vb b/JWLibrary-VideosAdder/My Project/AssemblyInfo.vb index f12b399..f98d1b2 100644 --- a/JWLibrary-VideosAdder/My Project/AssemblyInfo.vb +++ b/JWLibrary-VideosAdder/My Project/AssemblyInfo.vb @@ -11,14 +11,14 @@ Imports System.Runtime.InteropServices - - + + 'The following GUID is for the ID of the typelib if this project is exposed to COM - + ' Version information for an assembly consists of the following four values: ' @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/JWLibrary-VideosAdder/My Project/Resources.Designer.vb b/JWLibrary-VideosAdder/My Project/Resources.Designer.vb index 581bd24..52eecc8 100644 --- a/JWLibrary-VideosAdder/My Project/Resources.Designer.vb +++ b/JWLibrary-VideosAdder/My Project/Resources.Designer.vb @@ -22,7 +22,7 @@ Namespace My.Resources ''' ''' A strongly-typed resource class, for looking up localized strings, etc. ''' - _ diff --git a/JWLibrary-VideosAdder/My Project/Settings.Designer.vb b/JWLibrary-VideosAdder/My Project/Settings.Designer.vb index b5d9c3f..b00f85e 100644 --- a/JWLibrary-VideosAdder/My Project/Settings.Designer.vb +++ b/JWLibrary-VideosAdder/My Project/Settings.Designer.vb @@ -13,42 +13,42 @@ Option Explicit On Namespace My - - _ + + _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) - + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + #Region "My.Settings Auto-Save Functionality" #If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean + Private Shared addedHandler As Boolean - Private Shared addedHandlerLockObject As New Object + Private Shared addedHandlerLockObject As New Object - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub #End If #End Region - + Public Shared ReadOnly Property [Default]() As MySettings Get - + #If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If #End If Return defaultInstance End Get diff --git a/JWLibrary-VideosAdder/app.config b/JWLibrary-VideosAdder/app.config new file mode 100644 index 0000000..b5cb6d5 --- /dev/null +++ b/JWLibrary-VideosAdder/app.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Setup/Setup.vdproj b/Setup/Setup.vdproj index ed33975..74c1435 100644 --- a/Setup/Setup.vdproj +++ b/Setup/Setup.vdproj @@ -27,50 +27,50 @@ } "Entry" { - "MsmKey" = "8:_19DD1B41CA77490B87E0FEF772B2FE9C" - "OwnerKey" = "8:_UNDEFINED" + "MsmKey" = "8:_1612FBA2EFD7CF3749EFC6B602E9E034" + "OwnerKey" = "8:_0EBE42C70FF14BA8BF34BE8EC590294B" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_32FB641BFAEC4E19916478AFAEF67609" - "OwnerKey" = "8:_UNDEFINED" + "MsmKey" = "8:_1612FBA2EFD7CF3749EFC6B602E9E034" + "OwnerKey" = "8:_A405CEC463EFDD2D91CB57091763E87D" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_9FC75D3F5CB5C057B5DB473D7C81FBF8" - "OwnerKey" = "8:_0EBE42C70FF14BA8BF34BE8EC590294B" + "MsmKey" = "8:_19DD1B41CA77490B87E0FEF772B2FE9C" + "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_9FC75D3F5CB5C057B5DB473D7C81FBF8" - "OwnerKey" = "8:_DC63748DADDBD18FFD1934EF74BB6463" + "MsmKey" = "8:_32FB641BFAEC4E19916478AFAEF67609" + "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_DC63748DADDBD18FFD1934EF74BB6463" + "MsmKey" = "8:_A405CEC463EFDD2D91CB57091763E87D" "OwnerKey" = "8:_0EBE42C70FF14BA8BF34BE8EC590294B" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_9FC75D3F5CB5C057B5DB473D7C81FBF8" + "OwnerKey" = "8:_0EBE42C70FF14BA8BF34BE8EC590294B" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_DC63748DADDBD18FFD1934EF74BB6463" + "OwnerKey" = "8:_A405CEC463EFDD2D91CB57091763E87D" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_0EBE42C70FF14BA8BF34BE8EC590294B" + "OwnerKey" = "8:_1612FBA2EFD7CF3749EFC6B602E9E034" "MsmSig" = "8:_UNDEFINED" } } @@ -98,6 +98,14 @@ "PrerequisitesLocation" = "2:1" "Url" = "8:" "ComponentsUrl" = "8:" + "Items" + { + "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.7.2" + { + "Name" = "8:Microsoft .NET Framework 4.7.2 (x86 and x64)" + "ProductCode" = "8:.NETFramework,Version=v4.7.2" + } + } } } "Release" @@ -122,6 +130,14 @@ "PrerequisitesLocation" = "2:1" "Url" = "8:" "ComponentsUrl" = "8:" + "Items" + { + "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.7.2" + { + "Name" = "8:Microsoft .NET Framework 4.7.2 (x86 and x64)" + "ProductCode" = "8:.NETFramework,Version=v4.7.2" + } + } } } } @@ -144,7 +160,7 @@ { "Name" = "8:.NET Framework" "Message" = "8:[VSDNETMSG]" - "FrameworkVersion" = "8:.NETFramework,Version=v4.0,Profile=Client" + "FrameworkVersion" = "8:v4.0 Client" "AllowLaterVersions" = "11:FALSE" "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=131000" } @@ -172,10 +188,21 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } - "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_19DD1B41CA77490B87E0FEF772B2FE9C" + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_1612FBA2EFD7CF3749EFC6B602E9E034" { - "SourcePath" = "8:..\\ICO\\Ico.ico" - "TargetName" = "8:Ico.ico" + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:Devart.Data, Version=5.0.2296.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL" + "ScatterAssemblies" + { + "_1612FBA2EFD7CF3749EFC6B602E9E034" + { + "Name" = "8:Devart.Data.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:Devart.Data.dll" + "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_BA9B136265B14D09A2ADB91A079B9064" "Condition" = "8:" @@ -189,13 +216,13 @@ "PackageAs" = "3:1" "Register" = "3:1" "Exclude" = "11:FALSE" - "IsDependency" = "11:FALSE" + "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } - "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_32FB641BFAEC4E19916478AFAEF67609" + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_19DD1B41CA77490B87E0FEF772B2FE9C" { - "SourcePath" = "8:..\\JWLibrary-VideosAdder\\sqlite3.def" - "TargetName" = "8:sqlite3.def" + "SourcePath" = "8:..\\ICO\\Ico.ico" + "TargetName" = "8:Ico.ico" "Tag" = "8:" "Folder" = "8:_BA9B136265B14D09A2ADB91A079B9064" "Condition" = "8:" @@ -212,16 +239,10 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_9FC75D3F5CB5C057B5DB473D7C81FBF8" + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_32FB641BFAEC4E19916478AFAEF67609" { - "AssemblyRegister" = "3:1" - "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Devart.Data, Version=5.0.2296.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL" - "ScatterAssemblies" - { - } - "SourcePath" = "8:Devart.Data.dll" - "TargetName" = "8:" + "SourcePath" = "8:..\\JWLibrary-VideosAdder\\sqlite3.def" + "TargetName" = "8:sqlite3.def" "Tag" = "8:" "Folder" = "8:_BA9B136265B14D09A2ADB91A079B9064" "Condition" = "8:" @@ -235,16 +256,21 @@ "PackageAs" = "3:1" "Register" = "3:1" "Exclude" = "11:FALSE" - "IsDependency" = "11:TRUE" + "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_DC63748DADDBD18FFD1934EF74BB6463" + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_A405CEC463EFDD2D91CB57091763E87D" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:Devart.Data.SQLite, Version=5.14.1504.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL" "ScatterAssemblies" { + "_A405CEC463EFDD2D91CB57091763E87D" + { + "Name" = "8:Devart.Data.SQLite.dll" + "Attributes" = "3:512" + } } "SourcePath" = "8:Devart.Data.SQLite.dll" "TargetName" = "8:" @@ -320,15 +346,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:JWLibrary-VideosAdder" - "ProductCode" = "8:{0D3BC030-65C5-4F35-AFE0-8E90F257FDE4}" - "PackageCode" = "8:{388DADDE-7F9D-401F-B7AC-6D1DA0A22FCE}" + "ProductCode" = "8:{4FF9ACBB-D79B-48C1-BD64-831A7685F31D}" + "PackageCode" = "8:{E62E4107-140E-4985-9D47-5FF4D9E94B30}" "UpgradeCode" = "8:{2879D969-971C-40DC-8124-CCF0AAF9B606}" "AspNetVersion" = "8:2.0.50727.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:TRUE" - "ProductVersion" = "8:1.0.0" + "ProductVersion" = "8:1.0.1" "Manufacturer" = "8:Dario Ragusa" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:https://github.com/Miaosi001"