This commit is contained in:
SchreiberM
2017-02-17 14:38:36 +01:00
parent a7ab84cc3f
commit 4fbf33d5ab
6 changed files with 216 additions and 145 deletions

View File

@@ -32,7 +32,9 @@ Public Class ClassInit
Public Sub InitBasics()
Try
Dim UPDATE_ID As Integer
InitInstallPath()
If InitInstallPath() = False Then
End If
Dim sql = String.Format("SELECT * FROM TBDD_MODULES WHERE UPPER(NAME) = UPPER('Record-Organizer')")
Dim KONFIG_DT As DataTable = clsDatabase.Return_Datatable(sql, False)
If KONFIG_DT.Rows.Count = 1 Then
@@ -82,10 +84,10 @@ Public Class ClassInit
Else
MyServer_UpdatePath = String.Empty
End If
sql = String.Format("SELECT CASE VERSION_CLIENT WHEN '' THEN '1.0.0.0' ELSE VERSION_CLIENT END AS VERSION_CLIENT FROM VWDD_LOGIN_USER_HISTORY WHERE GUID = (select MAX(GUID) from VWDD_LOGIN_USER_HISTORY where USER_ID = {0} AND VERSION_CLIENT <> '' AND UPPER(MACHINE_NAME) = UPPER('{1}') AND UPPER(MODULE) = UPPER('{2}'))", USER_GUID, Environment.MachineName, "Record-Organizer")
sql = String.Format("SELECT CASE VERSION_CLIENT WHEN '' THEN '{3}' ELSE VERSION_CLIENT END AS VERSION_CLIENT FROM VWDD_LOGIN_USER_HISTORY WHERE GUID = (select MAX(GUID) from VWDD_LOGIN_USER_HISTORY where USER_ID = {0} AND VERSION_CLIENT <> '' AND UPPER(MACHINE_NAME) = UPPER('{1}') AND UPPER(MODULE) = UPPER('{2}'))", USER_GUID, Environment.MachineName, "Record-Organizer", VERSION_SERVER)
VERSION_USER = clsDatabase.Execute_Scalar(sql)
If IsNothing(VERSION_USER) Then
sql = String.Format("SELECT CASE VERSION_CLIENT WHEN '' THEN '1.0.0.0' ELSE VERSION_CLIENT END AS VERSION_CLIENT FROM VWDD_LOGIN_USER_HISTORY WHERE GUID = (select MAX(GUID) from VWDD_LOGIN_USER_HISTORY where USER_ID = {0} AND VERSION_CLIENT <> '' AND UPPER(MODULE) = UPPER('{1}'))", USER_GUID, "Record-Organizer")
sql = String.Format("SELECT CASE VERSION_CLIENT WHEN '' THEN '{2}' ELSE VERSION_CLIENT END AS VERSION_CLIENT FROM VWDD_LOGIN_USER_HISTORY WHERE GUID = (select MAX(GUID) from VWDD_LOGIN_USER_HISTORY where USER_ID = {0} AND VERSION_CLIENT <> '' AND UPPER(MODULE) = UPPER('{1}'))", USER_GUID, "Record-Organizer", VERSION_SERVER)
VERSION_USER = clsDatabase.Execute_Scalar(sql)
If IsNothing(VERSION_USER) Then
VERSION_USER = "1.0.0.0"
@@ -99,17 +101,49 @@ Public Class ClassInit
End Try
End Function
Public Sub InitInstallPath()
Dim RecExe_found As Boolean = False
Public Function InitInstallPath()
Try
Dim readValue = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Digital Data\Record Organizer", "Path", Nothing)
If Not IsNothing(readValue) Then
MY_INSTALL_PATH = readValue
Return True
Else
MY_INSTALL_PATH = readValue = ""
MY_INSTALL_PATH = ""
For Each s In Directory.GetLogicalDrives()
If RecExe_found = False Then
DirSearch(s)
End If
Next
If RecExe_found = False Then
MsgBox("Could not find the path for RecordOrganizer - Please check your installation!", MsgBoxStyle.Critical)
Return False
End If
End If
Catch ex As Exception
ClassLogger.Add("Unexpected Error in InitInstallPath: " & ex.Message, True)
Return False
End Try
End Function
Sub DirSearch(ByVal sDir As String)
Dim d As String
Dim f As String
Try
For Each d In Directory.GetDirectories(sDir)
If RecExe_found = False Then
For Each f In Directory.GetFiles(d, "DD-Record-Organizer.exe")
RecExe_found = True
MY_INSTALL_PATH = Path.GetDirectoryName(f)
Exit Sub
Next
End If
If RecExe_found = False Then
DirSearch(d)
End If
Next
Catch excpt As System.Exception
ClassLogger.Add("Unexpected Error in DirSearch: " & excpt.Message, True)
End Try
End Sub
Public Shared Function InsertEssential_Log(REFERENCE_KEY As Integer, REFERENCE_STRING As String, COMMENT As String)

View File

@@ -27,6 +27,7 @@ Partial Class frmVersionCheck
Me.pbStatus = New System.Windows.Forms.ProgressBar()
Me.Label1 = New System.Windows.Forms.Label()
Me.PictureBox2 = New System.Windows.Forms.PictureBox()
Me.Label2 = New System.Windows.Forms.Label()
CType(Me.PictureBox2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
@@ -66,6 +67,7 @@ Partial Class frmVersionCheck
'
'PictureBox2
'
Me.PictureBox2.BackColor = System.Drawing.Color.Transparent
Me.PictureBox2.Image = CType(resources.GetObject("PictureBox2.Image"), System.Drawing.Image)
Me.PictureBox2.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.PictureBox2.Location = New System.Drawing.Point(27, 36)
@@ -75,6 +77,18 @@ Partial Class frmVersionCheck
Me.PictureBox2.TabIndex = 5
Me.PictureBox2.TabStop = False
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.BackColor = System.Drawing.Color.Transparent
Me.Label2.Font = New System.Drawing.Font("Impact", 26.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.ForeColor = System.Drawing.Color.Yellow
Me.Label2.Location = New System.Drawing.Point(97, 153)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(134, 43)
Me.Label2.TabIndex = 7
Me.Label2.Text = "Updater"
'
'frmVersionCheck
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -82,8 +96,9 @@ Partial Class frmVersionCheck
Me.BackColor = System.Drawing.Color.DodgerBlue
Me.ClientSize = New System.Drawing.Size(551, 229)
Me.ControlBox = False
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.PictureBox2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.lblStatus)
Me.Controls.Add(Me.pbStatus)
Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
@@ -103,5 +118,6 @@ Partial Class frmVersionCheck
Friend WithEvents pbStatus As System.Windows.Forms.ProgressBar
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
Friend WithEvents Label2 As System.Windows.Forms.Label
End Class

View File

@@ -23,107 +23,109 @@ Public Class frmVersionCheck
Return _step * (100 / InitSteps)
End Function
Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
Dim JUMP_UPDATE As Boolean = False
'Try
Dim Init = New ClassInit()
bw.ReportProgress(CalcProgress(1), "Initializing Logger")
Init.InitLogger()
System.Threading.Thread.Sleep(200)
bw.ReportProgress(CalcProgress(3), "Initializing MySettings")
MySettings_Load()
System.Threading.Thread.Sleep(200)
bw.ReportProgress(CalcProgress(2), "Initializing Database")
If Init.InitDatabase() = True Then
Try
Dim JUMP_UPDATE As Boolean = False
'Try
Dim Init = New ClassInit()
bw.ReportProgress(CalcProgress(1), "Initializing Logger")
Init.InitLogger()
System.Threading.Thread.Sleep(200)
bw.ReportProgress(CalcProgress(3), "Initializing Basic-Configuration")
Init.InitBasics()
bw.ReportProgress(CalcProgress(3), "Initializing MySettings")
MySettings_Load()
System.Threading.Thread.Sleep(200)
bw.ReportProgress(CalcProgress(4), "Initializing User-Configuration")
If ClassInit.InitUser = False Then
Exit Sub
Else
VERSION_USER = CInt(VERSION_USER.ToString.Replace(".", ""))
VERSION_SERVER = CInt(VERSION_SERVER.ToString.Replace(".", ""))
If VERSION_USER = VERSION_SERVER Then
bw.ReportProgress(CalcProgress(2), "Initializing Database")
If Init.InitDatabase() = True Then
System.Threading.Thread.Sleep(200)
bw.ReportProgress(CalcProgress(3), "Initializing Basic-Configuration")
Init.InitBasics()
System.Threading.Thread.Sleep(200)
bw.ReportProgress(CalcProgress(4), "Initializing User-Configuration")
If ClassInit.InitUser = False Then
Exit Sub
End If
UPDATE_NECESSARY = True
If FORCE_UPDATE = False Then
If VERSIONS_FOR_FORCE_UPDATE.Contains(VERSION_USER) Then
ClassInit.InsertEssential_Log(USER_GUID, "USER-ID", String.Format("VersionChecker: ForceUpdate for User as Version '{0}' is used!", VERSION_USER))
FORCE_UPDATE = True
End If
End If
If FORCE_UPDATE = False Then
Dim msg = "Auf dem Server liegt ein Update für ADDI bereit!" & vbNewLine & "Wollen Sie das Update nun durchführen? Die Dauer ist abhängig von Ihrer Netzwerkverbindung!"
If USER_LANGUAGE <> "de-DE" Then
msg = "There is a new release available for ADDI!" & vbNewLine & "Would You like to install the update now? This might take some minutes!"
End If
Dim result As MsgBoxResult
result = MessageBox.Show(msg, "Confirmation:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = MsgBoxResult.No Then
UPDATE_CANCELLED = True
Else
VERSION_USER = CInt(VERSION_USER.ToString.Replace(".", ""))
VERSION_SERVER = CInt(VERSION_SERVER.ToString.Replace(".", ""))
If VERSION_USER = VERSION_SERVER Then
Exit Sub
End If
End If
UPDATE_NECESSARY = True
If FORCE_UPDATE = False Then
If VERSIONS_FOR_FORCE_UPDATE.Contains(VERSION_USER) Then
ClassInit.InsertEssential_Log(USER_GUID, "USER-ID", String.Format("VersionChecker: ForceUpdate for User as Version '{0}' is used!", VERSION_USER))
FORCE_UPDATE = True
End If
End If
If FORCE_UPDATE = False Then
Dim msg = "Auf dem Server liegt ein Update für ADDI bereit!" & vbNewLine & "Wollen Sie das Update nun durchführen? Die Dauer ist abhängig von Ihrer Netzwerkverbindung!"
If USER_LANGUAGE <> "de-DE" Then
msg = "There is a new release available for ADDI!" & vbNewLine & "Would You like to install the update now? This might take some minutes!"
End If
Dim result As MsgBoxResult
result = MessageBox.Show(msg, "Confirmation:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = MsgBoxResult.No Then
UPDATE_CANCELLED = True
Exit Sub
End If
End If
If MyServer_UpdatePath <> String.Empty Then
If Directory.Exists(MyServer_UpdatePath) Then
GetTempFolderGuid()
If FOLDER_TEMP <> String.Empty Then
bw.ReportProgress(CalcProgress(5), "Copying files to tempfolder")
' Make a reference to a directory.
Dim di As New DirectoryInfo(MyServer_UpdatePath)
' Get a reference to each file in that directory.
Dim fiArr As FileInfo() = di.GetFiles()
' Display the names of the files.
'Dim fri As FileInfo
Dim error_while_copying = False
For Each Upd_item As DataRow In DT_UPDATE_ITEMS.Rows
If error_while_copying = True Then
Exit For
End If
Dim updatefile2copy = Path.Combine(MyServer_UpdatePath, Upd_item.Item("ITEM_INFO"))
Dim tempfilename = Path.Combine(FOLDER_TEMP, Upd_item.Item("ITEM_INFO"))
If File.Exists(updatefile2copy) Then
Try
System.IO.File.Copy(updatefile2copy, tempfilename)
Catch ex As Exception
ClassLogger.Add(String.Format("Error while copying file {0} to {1}: " & ex.Message, updatefile2copy, tempfilename))
error_while_copying = True
End Try
Else
ClassLogger.Add(String.Format("UpdateFile {0} is not existing or accessible", updatefile2copy))
End If
Next
If MyServer_UpdatePath <> String.Empty Then
If Directory.Exists(MyServer_UpdatePath) Then
GetTempFolderGuid()
If FOLDER_TEMP <> String.Empty Then
bw.ReportProgress(CalcProgress(5), "Copying files to tempfolder")
' Make a reference to a directory.
Dim di As New DirectoryInfo(MyServer_UpdatePath)
' Get a reference to each file in that directory.
Dim fiArr As FileInfo() = di.GetFiles()
' Display the names of the files.
'Dim fri As FileInfo
Dim error_while_copying = False
For Each Upd_item As DataRow In DT_UPDATE_ITEMS.Rows
If error_while_copying = True Then
Exit For
End If
Dim updatefile2copy = Path.Combine(MyServer_UpdatePath, Upd_item.Item("ITEM_INFO"))
Dim tempfilename = Path.Combine(FOLDER_TEMP, Upd_item.Item("ITEM_INFO"))
If File.Exists(updatefile2copy) Then
Try
System.IO.File.Copy(updatefile2copy, tempfilename)
Catch ex As Exception
ClassLogger.Add(String.Format("Error while copying file {0} to {1}: " & ex.Message, updatefile2copy, tempfilename))
error_while_copying = True
End Try
Else
ClassLogger.Add(String.Format("UpdateFile {0} is not existing or accessible", updatefile2copy))
End If
Next
If error_while_copying = False Then
Replace_Files()
If error_while_copying = False Then
Replace_Files()
End If
Try
'Delete the tempfolder and all data
System.IO.Directory.Delete(FOLDER_TEMP, True)
Catch ex As Exception
End Try
Else
ClassLogger.Add(String.Format("The temporaryFolder could not be created!"))
End If
Try
'Delete the tempfolder and all data
System.IO.Directory.Delete(FOLDER_TEMP, True)
Catch ex As Exception
End Try
Else
ClassLogger.Add(String.Format("The temporaryFolder could not be created!"))
ClassLogger.Add(String.Format("The Updatepath '{0}'is not accessible or does not exist", MyServer_UpdatePath))
End If
Else
ClassLogger.Add(String.Format("The Updatepath '{0}'is not accessible or does not exist", MyServer_UpdatePath))
ClassLogger.Add(String.Format("NO ACTION: the Updatepath is empty"))
End If
Else
ClassLogger.Add(String.Format("NO ACTION: the Updatepath is empty"))
End If
End If
Else
ClassLogger.Add(String.Format(">> Database was not intialized!"), False)
End If
'Catch ex As Exception
' MsgBox("Unexpected Error in Init Classes: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
'End Try
Else
ClassLogger.Add(String.Format(">> Database was not intialized!"), False)
End If
Catch ex As Exception
ClassLogger.Add(String.Format(">> Unexpected Error in bwDoWork: " & ex.Message))
ClassLogger.Add(ex.StackTrace)
End Try
End Sub
Sub Replace_Files()
Try
@@ -314,13 +316,6 @@ Public Class frmVersionCheck
End Sub
Private Sub bw_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs)
' Bei Fehler MsgBox anzeigen und Programm beenden
If e.Error IsNot Nothing Then
MsgBox(e.Error.Message, MsgBoxStyle.Critical, "Unexpected Error in frmSplash")
Application.Exit()
End If
' Wenn kein Fehler, Splashscreen schließen
Me.Close()
End Sub
End Class