diff --git a/BARCODE/Repair_pc_ids.txt b/BARCODE/Repair_pc_ids.1.txt similarity index 100% rename from BARCODE/Repair_pc_ids.txt rename to BARCODE/Repair_pc_ids.1.txt diff --git a/BARCODE/Repair_pc_ids.2.txt b/BARCODE/Repair_pc_ids.2.txt new file mode 100644 index 0000000..e9ab0ce --- /dev/null +++ b/BARCODE/Repair_pc_ids.2.txt @@ -0,0 +1,30 @@ +1463671755 +7020175153 +5404717746 +3296685637 +0736311783 +9076156940 +5837970452 +4352106486 +9547078358 +1798072890 +1389587524 +3541155156 +8190600237 +2774273532 +4811090670 +1317029903 +6191218542 +6626901383 +0898950400 +2743029532 +9237839921 +4168614523 +9812526007 +2588574302 +1200837449 +8481657818 +4044723385 +8222876041 +0008935301 +0061659415 diff --git a/ISEN-Repair Inventory Manager/About.vb b/ISEN-Repair Inventory Manager/About.vb index 0fcfe28..a783039 100644 --- a/ISEN-Repair Inventory Manager/About.vb +++ b/ISEN-Repair Inventory Manager/About.vb @@ -13,7 +13,7 @@ ' TODO: personnalisez les informations d'assembly de l'application dans le volet "Application" de la ' boîte de dialogue Propriétés du projet (sous le menu "Projet"). Me.LabelProductName.Text = My.Application.Info.ProductName - Me.LabelVersion.Text = String.Format("Version {0}.{1}", My.Application.Info.Version.Major, My.Application.Info.Version.Minor) + Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version) Me.LabelCopyright.Text = My.Application.Info.Copyright Me.LabelCompanyName.Text = My.Application.Info.CompanyName Me.TextBoxDescription.Text = My.Application.Info.Description diff --git a/ISEN-Repair Inventory Manager/AddMachine.vb b/ISEN-Repair Inventory Manager/AddMachine.vb index bda5c5a..0c982ab 100644 --- a/ISEN-Repair Inventory Manager/AddMachine.vb +++ b/ISEN-Repair Inventory Manager/AddMachine.vb @@ -30,7 +30,7 @@ Public Class AddMachine Try Main.StatusLabel.Text = "Tentative d'ajout de l'ordinateur à la base de données..." - Using con As New SQLiteConnection("URI=file:db.sqlite") + Using con As New SQLiteConnection("URI=file:" & Main.dbLocFile) con.Open() Dim cmd As New SQLiteCommand(con) cmd.CommandText = "INSERT INTO computers_desc VALUES ('" & NewIDBox.Text & "','" & NewNameBox.Text & "'," & NewEtatBox.SelectedIndex & "," & CheckToNumeric(NewSerieCheckBox) & ",'" & Replace(NewDetailsBox.Text, "'", "_*_") & "',0,'N/A','" & NewGivenByBox.Text & "');" @@ -42,9 +42,12 @@ Public Class AddMachine Main.log.Info("Computer " & NewIDBox.Text & " added") Main.StatusLabel.Text = "Ordinateur ajouté avec succés dans la base de données." Main.ListAllInv() + Main.log.Info("Added computer " & NewIDBox.Text & " with success !") Me.Close() Catch ex As Exception Main.StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" + Main.log.Critical("Error has been occur when saving data to DB !") + Main.log.Critical(ex.Message) MsgBox(ex.Message) End Try End Sub diff --git a/ISEN-Repair Inventory Manager/ISEN-Repair Inventory Manager.vbproj b/ISEN-Repair Inventory Manager/ISEN-Repair Inventory Manager.vbproj index c99a6af..b8767e1 100644 --- a/ISEN-Repair Inventory Manager/ISEN-Repair Inventory Manager.vbproj +++ b/ISEN-Repair Inventory Manager/ISEN-Repair Inventory Manager.vbproj @@ -35,8 +35,8 @@ true index.htm false - 6 - 0.9.5.%2a + 3 + 0.10.1.3 false true true @@ -91,7 +91,7 @@ true - D00CE50649372742555DAC702A1327003B99D37C + 620A13A82ECD693F86DBAEDE2FA8737A6A18D351 ISEN-Repair Inventory Manager_TemporaryKey.pfx diff --git a/ISEN-Repair Inventory Manager/Logger.vb b/ISEN-Repair Inventory Manager/Logger.vb index a3eefa2..9ae62a3 100644 --- a/ISEN-Repair Inventory Manager/Logger.vb +++ b/ISEN-Repair Inventory Manager/Logger.vb @@ -3,11 +3,11 @@ Public Class Logger 'DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") - Dim logFileName As String = "logs\" & DateTime.Now.ToString("yyyy-MM-dd") & ".txt" + Dim logFileName As String = Main.localAppData & "logs\" & DateTime.Now.ToString("yyyy-MM-dd") & ".txt" Public Sub Load() - If Not My.Computer.FileSystem.DirectoryExists("logs") Then My.Computer.FileSystem.CreateDirectory("logs") - If Not My.Computer.FileSystem.FileExists(logFileName) Then File.WriteAllLines(logFileName, {"LOG FILE - " & DateTime.Now.ToString("dd/MM/yyyy"), "--------------------", "[" & DateTime.Now.ToString("HH:mm:ss") & "][INFO] Loading software"}) + If Not My.Computer.FileSystem.DirectoryExists(Main.localAppData & "logs") Then My.Computer.FileSystem.CreateDirectory(Main.localAppData & "logs") + If Not My.Computer.FileSystem.FileExists(logFileName) Then File.WriteAllLines(logFileName, {"--------------------------------------------------------------", "------------------- LOG FILE - " & DateTime.Now.ToString("dd/MM/yyyy") & " -------------------", "--------------------------------------------------------------", "[" & DateTime.Now.ToString("HH:mm:ss") & "][INFO] Init software"}) End Sub Public Sub Info(str As String) diff --git a/ISEN-Repair Inventory Manager/Main.Designer.vb b/ISEN-Repair Inventory Manager/Main.Designer.vb index c07f0b4..99b2842 100644 --- a/ISEN-Repair Inventory Manager/Main.Designer.vb +++ b/ISEN-Repair Inventory Manager/Main.Designer.vb @@ -24,8 +24,13 @@ Partial Class Main Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Main)) Me.MenuStrip1 = New System.Windows.Forms.MenuStrip() + Me.QuitterToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.AddComputerToolMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.EnleverPCsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.GénérerDesIDsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.DBToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.ImporterToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.ExporterToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.AboutToolMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.StatusStrip1 = New System.Windows.Forms.StatusStrip() Me.StatusLabel = New System.Windows.Forms.ToolStripStatusLabel() @@ -60,7 +65,8 @@ Partial Class Main Me.OSBox = New System.Windows.Forms.TextBox() Me.ArchBox = New System.Windows.Forms.TextBox() Me.EditButton = New System.Windows.Forms.Button() - Me.DBAccessToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.OpenBackupFile = New System.Windows.Forms.OpenFileDialog() + Me.SaveBackupFile = New System.Windows.Forms.SaveFileDialog() Me.MenuStrip1.SuspendLayout() Me.StatusStrip1.SuspendLayout() Me.GroupBox1.SuspendLayout() @@ -70,18 +76,30 @@ Partial Class Main ' 'MenuStrip1 ' - Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AddComputerToolMenuItem, Me.GénérerDesIDsToolStripMenuItem, Me.DBAccessToolStripMenuItem, Me.AboutToolMenuItem}) + Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.QuitterToolStripMenuItem, Me.AddComputerToolMenuItem, Me.EnleverPCsToolStripMenuItem, Me.GénérerDesIDsToolStripMenuItem, Me.DBToolStripMenuItem, Me.AboutToolMenuItem}) Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) Me.MenuStrip1.Name = "MenuStrip1" Me.MenuStrip1.Size = New System.Drawing.Size(874, 24) Me.MenuStrip1.TabIndex = 0 Me.MenuStrip1.Text = "MenuStrip1" ' + 'QuitterToolStripMenuItem + ' + Me.QuitterToolStripMenuItem.Name = "QuitterToolStripMenuItem" + Me.QuitterToolStripMenuItem.Size = New System.Drawing.Size(56, 20) + Me.QuitterToolStripMenuItem.Text = "Quitter" + ' 'AddComputerToolMenuItem ' Me.AddComputerToolMenuItem.Name = "AddComputerToolMenuItem" - Me.AddComputerToolMenuItem.Size = New System.Drawing.Size(93, 20) - Me.AddComputerToolMenuItem.Text = "Ajouter un PC" + Me.AddComputerToolMenuItem.Size = New System.Drawing.Size(81, 20) + Me.AddComputerToolMenuItem.Text = "Ajouter PCs" + ' + 'EnleverPCsToolStripMenuItem + ' + Me.EnleverPCsToolStripMenuItem.Name = "EnleverPCsToolStripMenuItem" + Me.EnleverPCsToolStripMenuItem.Size = New System.Drawing.Size(80, 20) + Me.EnleverPCsToolStripMenuItem.Text = "Enlever PCs" ' 'GénérerDesIDsToolStripMenuItem ' @@ -89,6 +107,26 @@ Partial Class Main Me.GénérerDesIDsToolStripMenuItem.Size = New System.Drawing.Size(100, 20) Me.GénérerDesIDsToolStripMenuItem.Text = "Générer des IDs" ' + 'DBToolStripMenuItem + ' + Me.DBToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ImporterToolStripMenuItem, Me.ExporterToolStripMenuItem}) + Me.DBToolStripMenuItem.Name = "DBToolStripMenuItem" + Me.DBToolStripMenuItem.Size = New System.Drawing.Size(34, 20) + Me.DBToolStripMenuItem.Text = "DB" + Me.DBToolStripMenuItem.TextAlign = System.Drawing.ContentAlignment.BottomCenter + ' + 'ImporterToolStripMenuItem + ' + Me.ImporterToolStripMenuItem.Name = "ImporterToolStripMenuItem" + Me.ImporterToolStripMenuItem.Size = New System.Drawing.Size(120, 22) + Me.ImporterToolStripMenuItem.Text = "Importer" + ' + 'ExporterToolStripMenuItem + ' + Me.ExporterToolStripMenuItem.Name = "ExporterToolStripMenuItem" + Me.ExporterToolStripMenuItem.Size = New System.Drawing.Size(120, 22) + Me.ExporterToolStripMenuItem.Text = "Exporter" + ' 'AboutToolMenuItem ' Me.AboutToolMenuItem.Name = "AboutToolMenuItem" @@ -447,11 +485,17 @@ Partial Class Main Me.EditButton.Text = "Editer le suivi" Me.EditButton.UseVisualStyleBackColor = False ' - 'DBAccessToolStripMenuItem + 'OpenBackupFile ' - Me.DBAccessToolStripMenuItem.Name = "DBAccessToolStripMenuItem" - Me.DBAccessToolStripMenuItem.Size = New System.Drawing.Size(73, 20) - Me.DBAccessToolStripMenuItem.Text = "DB Access" + Me.OpenBackupFile.DefaultExt = "sqlite" + Me.OpenBackupFile.Filter = "Fichier SQLite|*.sqlite" + Me.OpenBackupFile.Title = "Importer la DB" + ' + 'SaveBackupFile + ' + Me.SaveBackupFile.DefaultExt = "sqlite" + Me.SaveBackupFile.Filter = "Fichier SQLite|*.sqlite" + Me.SaveBackupFile.Title = "Exporter la DB" ' 'Main ' @@ -525,5 +569,11 @@ Partial Class Main Friend WithEvents IDBox As MaskedTextBox Private WithEvents AddComputerToolMenuItem As ToolStripMenuItem Friend WithEvents GénérerDesIDsToolStripMenuItem As ToolStripMenuItem - Friend WithEvents DBAccessToolStripMenuItem As ToolStripMenuItem + Friend WithEvents DBToolStripMenuItem As ToolStripMenuItem + Friend WithEvents OpenBackupFile As OpenFileDialog + Friend WithEvents SaveBackupFile As SaveFileDialog + Friend WithEvents ImporterToolStripMenuItem As ToolStripMenuItem + Friend WithEvents ExporterToolStripMenuItem As ToolStripMenuItem + Friend WithEvents QuitterToolStripMenuItem As ToolStripMenuItem + Friend WithEvents EnleverPCsToolStripMenuItem As ToolStripMenuItem End Class diff --git a/ISEN-Repair Inventory Manager/Main.resx b/ISEN-Repair Inventory Manager/Main.resx index 0c4bbcd..de66c5d 100644 --- a/ISEN-Repair Inventory Manager/Main.resx +++ b/ISEN-Repair Inventory Manager/Main.resx @@ -123,6 +123,12 @@ 132, 17 + + 249, 17 + + + 389, 17 + True diff --git a/ISEN-Repair Inventory Manager/Main.vb b/ISEN-Repair Inventory Manager/Main.vb index 45d72f1..296d4a1 100644 --- a/ISEN-Repair Inventory Manager/Main.vb +++ b/ISEN-Repair Inventory Manager/Main.vb @@ -1,16 +1,21 @@ Imports System.Data.SQLite Imports System.Text Imports System.IO +Imports System.Environment +Imports System.ComponentModel Public Class Main - Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) + 'Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Dim manualID_selected As Boolean = False Dim idList As New ArrayList Public log As New Logger + Public Shared localAppData As String = GetFolderPath(SpecialFolder.LocalApplicationData) & "\InvManager\" + Public Shared dbLocFile As String = localAppData & "db.sqlite" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load log.Load() + log.Info("Check and load of database") CheckIfFirstRun() ListAllInv() End Sub @@ -19,8 +24,8 @@ Public Class Main ''' Function to check if app is running for the first time ''' Private Sub CheckIfFirstRun() - log.Info("Check and load of database") - If Not My.Computer.FileSystem.FileExists("db.sqlite") Then + If Not My.Computer.FileSystem.DirectoryExists(localAppData) Then My.Computer.FileSystem.CreateDirectory(localAppData) + If Not My.Computer.FileSystem.FileExists(dbLocFile) Then If MsgBox("La base de données SQLite est introuvable ou inaccessible, souhaitez-vous la régénérer ?", 4161, "Base SQLite absente ou inaccessible") = 1 Then RegenerateDB() Else @@ -38,7 +43,7 @@ Public Class Main Dim dtr As SQLiteDataReader Try - Using con As New SQLiteConnection("URI=file:db.sqlite") + Using con As New SQLiteConnection("URI=file:" & dbLocFile) con.Open() Using cmd As New SQLiteCommand(con) cmd.CommandText = "SELECT * FROM computers_desc WHERE id=" & idToCheck & ";" @@ -53,7 +58,9 @@ Public Class Main Catch ex As Exception StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" - MsgBox(ex.Message) + log.Critical("Error has been occur when connect to DB !") + log.Critical(ex.Message) + MsgBox("Error ! Check log file for details.") End Try Return True @@ -143,16 +150,19 @@ Public Class Main Try StatusLabel.Text = "Reconstructions de la base SQLite..." - Using con As New SQLiteConnection("URI=file:db.sqlite") + Using con As New SQLiteConnection("URI=file:" & dbLocFile) con.Open() Dim cmd As New SQLiteCommand(genesis_seq, con) cmd.ExecuteNonQuery() con.Close() End Using StatusLabel.Text = "La base SQLite a été reconstruite avec succès !" + log.Info("Base SQLite reconstructed.") Catch ex As Exception StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" - MsgBox(ex.Message) + log.Critical("Error has been occur when reconstrut DB !") + log.Critical(ex.Message) + MsgBox("Error ! Check log file for details.") End Try End Sub @@ -168,7 +178,7 @@ Public Class Main InvList.DisplayMember = "Nom" Try StatusLabel.Text = "Récupération des données depuis la base SQLite..." - Using con As New SQLiteConnection("URI=file:db.sqlite") + Using con As New SQLiteConnection("URI=file:" & dbLocFile) con.Open() Using cmd As New SQLiteCommand(con) cmd.CommandText = "SELECT id,name FROM computers_desc;" @@ -184,7 +194,9 @@ Public Class Main StatusLabel.Text = "Récupération avec succés de la base SQLite." Catch ex As Exception StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" - MsgBox(ex.Message) + log.Critical("Error has been occur when retrieve data from DB !") + log.Critical(ex.Message) + MsgBox("Error ! Check log file for details.") End Try End Sub @@ -222,7 +234,7 @@ Public Class Main Dim dtr As SQLiteDataReader Try - Using con As New SQLiteConnection("URI=file:db.sqlite") + Using con As New SQLiteConnection("URI=file:" & dbLocFile) con.Open() Using cmd As New SQLiteCommand(con) cmd.CommandText = "SELECT * FROM computers_desc WHERE id='" & IDBox.Text & "';" @@ -257,7 +269,9 @@ Public Class Main End Using Catch ex As Exception StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" - MsgBox(ex.Message) + log.Critical("Error has been occur when retrieve data from DB !") + log.Critical(ex.Message) + MsgBox("Error ! Check log file for details.") End Try End If End Sub @@ -270,7 +284,7 @@ Public Class Main Dim dtr As SQLiteDataReader Try - Using con As New SQLiteConnection("URI=file:db.sqlite") + Using con As New SQLiteConnection("URI=file:" & dbLocFile) con.Open() Using cmd As New SQLiteCommand(con) cmd.CommandText = "SELECT * FROM computers_progress WHERE id='" & machineID & "';" @@ -326,7 +340,9 @@ Public Class Main If HWCheck.Checked And OSCheck.Checked And DrvCheck.Checked And SoftCheck.Checked And ActivateCheck.Checked Then SendOutButton.Enabled = True Else SendOutButton.Enabled = False Catch ex As Exception StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" - MsgBox(ex.Message) + log.Critical("Error has been occur when retrieve data from DB !") + log.Critical(ex.Message) + MsgBox("Error ! Check log file for details.") End Try End Sub @@ -335,7 +351,7 @@ Public Class Main Try StatusLabel.Text = "Supression d'un ordinateur de la base de données..." - Using con As New SQLiteConnection("URI=file:db.sqlite") + Using con As New SQLiteConnection("URI=file:" & dbLocFile) con.Open() Dim cmd As New SQLiteCommand(con) cmd.CommandText = "DELETE FROM computers_desc WHERE id='" & IDBox.Text & "';" @@ -345,10 +361,13 @@ Public Class Main con.Close() End Using StatusLabel.Text = "Ordinateur supprimé avec succès !" + log.Info("Delete computer " & IDBox.Text & " with success !") ListAllInv() Catch ex As Exception StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" - MsgBox(ex.Message) + log.Critical("Error has been occur when saving data to DB !") + log.Critical(ex.Message) + MsgBox("Error ! Check log file for details.") End Try End Sub @@ -374,11 +393,42 @@ Public Class Main IDBox.Text = tempStor End Sub - Private Sub DBAccessToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DBAccessToolStripMenuItem.Click - Dim p As New ProcessStartInfo - p.FileName = "explorer.exe" - p.Arguments = Directory.GetCurrentDirectory - p.UseShellExecute = False - Process.Start(p) + Private Sub ExporterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExporterToolStripMenuItem.Click + SaveBackupFile.InitialDirectory() = GetFolderPath(SpecialFolder.Desktop) + SaveBackupFile.FileName() = "invMan_" & DateTime.Now.ToString("yyyy-MM-dd_HH.mm") & ".sqlite" + SaveBackupFile.ShowDialog() + End Sub + + Private Sub SaveBackupFile_FileOk(sender As Object, e As CancelEventArgs) Handles SaveBackupFile.FileOk + Using src As FileStream = File.Open(dbLocFile, FileMode.Open) + src.CopyTo(SaveBackupFile.OpenFile) + End Using + log.Info("DB exporté avec succès") + End Sub + + Private Sub ImporterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ImporterToolStripMenuItem.Click + OpenBackupFile.InitialDirectory() = GetFolderPath(SpecialFolder.Desktop) + OpenBackupFile.ShowDialog() + End Sub + + Private Sub OpenBackupFile_FileOk(sender As Object, e As CancelEventArgs) Handles OpenBackupFile.FileOk + If My.Computer.FileSystem.FileExists(dbLocFile) Then + If MsgBox("ATTENTION ! Ceci va écraser la base de donnée existante souhaitez-vous continuer ?", 292, "Overwrite") = 7 Then Exit Sub + End If + + Using dest As FileStream = File.Open(dbLocFile, FileMode.Create) + OpenBackupFile.OpenFile.CopyTo(dest) + End Using + ListAllInv() + log.Info("DB importé avec succès") + End Sub + + Private Sub QuitterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles QuitterToolStripMenuItem.Click + If MsgBox("Souhaitez-vous faire une backup de la DB ?", 292, "Backup") = 7 Then End + + If Not My.Computer.FileSystem.DirectoryExists(localAppData & "backups") Then My.Computer.FileSystem.CreateDirectory(localAppData & "backups") + File.Copy(dbLocFile, localAppData & "backups\db_" & DateTime.Now.ToString("yyyy-MM-dd_HH.mm") & ".bck") + log.Info("Backup de la DB") + End End Sub End Class diff --git a/ISEN-Repair Inventory Manager/My Project/AssemblyInfo.vb b/ISEN-Repair Inventory Manager/My Project/AssemblyInfo.vb index 9551450..fe903aa 100644 --- a/ISEN-Repair Inventory Manager/My Project/AssemblyInfo.vb +++ b/ISEN-Repair Inventory Manager/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' en utilisant '*', comme indiqué ci-dessous : ' - - + + diff --git a/ISEN-Repair Inventory Manager/SplashScreen.vb b/ISEN-Repair Inventory Manager/SplashScreen.vb index ae195b4..13f379f 100644 --- a/ISEN-Repair Inventory Manager/SplashScreen.vb +++ b/ISEN-Repair Inventory Manager/SplashScreen.vb @@ -20,7 +20,7 @@ ' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor) - Version.Text = String.Format("Version {0}.{1}.{2}", My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.MajorRevision) + Version.Text = String.Format("Version {0}.{1}", My.Application.Info.Version.Major, My.Application.Info.Version.Minor) 'Informations de copyright Copyright.Text = My.Application.Info.Copyright