284 lines
14 KiB
VB.net
284 lines
14 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Net
|
|
|
|
Public Class pcinfo
|
|
Dim lines1() As String = File.ReadAllLines(compteco)
|
|
Dim nemid = lines1(0)
|
|
Private Sub pcinfo_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Dim lines1a() As String = File.ReadAllLines(théme)
|
|
|
|
If lines1a(0) = 2 Then
|
|
Me.BackColor = Color.FromArgb(64, 64, 64)
|
|
ListBox1.BackColor = Color.FromArgb(64, 64, 64)
|
|
ListBox1.ForeColor = Color.White
|
|
DéconecterLePcToolStripMenuItem.BackColor = Color.FromArgb(64, 64, 64)
|
|
InformationDuPcToolStripMenuItem.BackColor = Color.FromArgb(64, 64, 64)
|
|
DéconecterLePcToolStripMenuItem.ForeColor = Color.White
|
|
InformationDuPcToolStripMenuItem.ForeColor = Color.White
|
|
SupprimerToolStripMenuItem.BackColor = Color.FromArgb(64, 64, 64)
|
|
SupprimerToolStripMenuItem.ForeColor = Color.White
|
|
ElseIf lines1a(0) = 3 Then
|
|
Me.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
|
|
ListBox1.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
|
|
ListBox1.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB)
|
|
DéconecterLePcToolStripMenuItem.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
|
|
InformationDuPcToolStripMenuItem.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
|
|
DéconecterLePcToolStripMenuItem.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB)
|
|
InformationDuPcToolStripMenuItem.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB)
|
|
SupprimerToolStripMenuItem.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
|
|
SupprimerToolStripMenuItem.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB)
|
|
Else
|
|
|
|
End If
|
|
|
|
Dim lines1() As String = File.ReadAllLines(compteco)
|
|
Dim nemid = lines1(0)
|
|
|
|
Try
|
|
ListBox1.Items.Clear()
|
|
Dim fwr As FtpWebRequest
|
|
fwr = FtpWebRequest.Create(ipserver & "/" & "Utilisateur" & "/" & nemid & "/pc/")
|
|
fwr.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
fwr.Method = WebRequestMethods.Ftp.ListDirectory
|
|
Dim sr As New StreamReader(fwr.GetResponse().GetResponseStream())
|
|
|
|
Dim str As String = sr.ReadLine()
|
|
While Not str Is Nothing
|
|
|
|
Directory.CreateDirectory(cozip & str)
|
|
|
|
|
|
|
|
str = sr.ReadLine()
|
|
|
|
End While
|
|
|
|
|
|
sr.Close()
|
|
|
|
For Each fichier As String In IO.Directory.GetDirectories(cozip & str)
|
|
Dim info As New IO.DirectoryInfo(fichier)
|
|
ListBox1.Items.Add(info.Name)
|
|
ListBox1.Items.Remove("index.php")
|
|
Next
|
|
|
|
For Each fichier As String In IO.Directory.GetDirectories(cozip & str)
|
|
Dim info As New IO.DirectoryInfo(fichier)
|
|
Directory.Delete(cozip & info.Name)
|
|
Next
|
|
|
|
Catch ex As Exception
|
|
Timer1.Start()
|
|
End Try
|
|
|
|
ListBox1.Items.Remove(My.Computer.Name)
|
|
ListBox1.Items.Add(My.Computer.Name & " (Cet ordinateur)")
|
|
ListBox1.SelectedItem = (My.Computer.Name & " (Cet ordinateur)")
|
|
End Sub
|
|
|
|
Private Sub pcinfo_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
|
|
ListBox1.Items.Clear()
|
|
End Sub
|
|
|
|
Private Sub DéconecterLePcToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DéconecterLePcToolStripMenuItem.Click
|
|
If ListBox1.SelectedItem = " " Then
|
|
MsgBox("Merci de sélectionner un pc", MsgBoxStyle.Information)
|
|
ElseIf ListBox1.SelectedItem = My.Computer.Name & " (Cet ordinateur)" Then
|
|
MsgBox("Impossible de déconnecter le pc actuel", MsgBoxStyle.Exclamation)
|
|
Else
|
|
Me.Enabled = False
|
|
Dim sw1 As New StreamWriter(cozip & "co.txt")
|
|
sw1.WriteLine("0")
|
|
sw1.Close()
|
|
up()
|
|
End If
|
|
End Sub
|
|
Sub et2()
|
|
Me.Enabled = True
|
|
MsgBox("Le compte se le pc: " & ListBox1.SelectedItem & " sera supprimer lors de la prochaine ouverture de lecteur média", MsgBoxStyle.Information)
|
|
Close()
|
|
End Sub
|
|
|
|
Private Sub InformationDuPcToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles InformationDuPcToolStripMenuItem.Click
|
|
If ListBox1.SelectedItem = My.Computer.Name & " (Cet ordinateur)" Then
|
|
Dim maj As New WebClient
|
|
Dim vri As String = maj.DownloadString(ipsite & "/utilisateur/" & nemid & "/pc/" & My.Computer.Name & "/info.txt")
|
|
MsgBox(vri.ToString, MsgBoxStyle.Information, "information de: " & ListBox1.SelectedItem)
|
|
Else
|
|
Dim maj2 As New WebClient
|
|
Dim vri2 As String = maj2.DownloadString(ipsite & "/utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/info.txt")
|
|
MsgBox(vri2.ToString, MsgBoxStyle.Information, "information de: " & ListBox1.SelectedItem)
|
|
End If
|
|
End Sub
|
|
Sub up()
|
|
Try
|
|
My.Computer.Network.UploadFile(cozip & "co.txt", ipserver & "/utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/co.txt")
|
|
et2()
|
|
Catch ex As Exception
|
|
Timer2.Start()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
|
Timer1.Stop()
|
|
Try
|
|
ListBox1.Items.Clear()
|
|
Dim fwr As FtpWebRequest
|
|
fwr = FtpWebRequest.Create(ipserver & "/" & "Utilisateur" & "/" & nemid & "/pc/")
|
|
fwr.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
fwr.Method = WebRequestMethods.Ftp.ListDirectory
|
|
Dim sr As New StreamReader(fwr.GetResponse().GetResponseStream())
|
|
|
|
Dim str As String = sr.ReadLine()
|
|
While Not str Is Nothing
|
|
|
|
Directory.CreateDirectory(cozip & str)
|
|
|
|
|
|
|
|
str = sr.ReadLine()
|
|
|
|
End While
|
|
|
|
|
|
sr.Close()
|
|
|
|
For Each fichier As String In IO.Directory.GetDirectories(cozip & str)
|
|
Dim info As New IO.DirectoryInfo(fichier)
|
|
ListBox1.Items.Add(info.Name)
|
|
ListBox1.Items.Remove("index.php")
|
|
Next
|
|
|
|
For Each fichier As String In IO.Directory.GetDirectories(cozip & str)
|
|
Dim info As New IO.DirectoryInfo(fichier)
|
|
Directory.Delete(cozip & info.Name)
|
|
Next
|
|
|
|
Catch ex As Exception
|
|
Timer1.Start()
|
|
End Try
|
|
|
|
Try
|
|
ListBox1.SelectedIndex = 0
|
|
If ListBox1.SelectedItem = My.Computer.Name Then
|
|
ListBox1.Items.Remove(My.Computer.Name)
|
|
ListBox1.Items.Add(My.Computer.Name & " (Cet ordinateur)")
|
|
Else
|
|
ListBox1.SelectedIndex = 1
|
|
ListBox1.Items.Remove(My.Computer.Name)
|
|
ListBox1.Items.Add(My.Computer.Name & " (Cet ordinateur)")
|
|
End If
|
|
Catch ex As Exception
|
|
ListBox1.SelectedIndex = 0
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
|
|
Timer2.Stop()
|
|
Try
|
|
My.Computer.Network.UploadFile(cozip & "co.txt", ipserver & "/utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/co.txt")
|
|
et2()
|
|
Catch ex As Exception
|
|
Timer2.Start()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub ContextMenuStrip1_Opening(sender As Object, e As CancelEventArgs) Handles ContextMenuStrip1.Opening
|
|
If ListBox1.SelectedItem = "" Then
|
|
e.Cancel = True
|
|
Else
|
|
If ListBox1.SelectedItem.ToString.Contains("(Cet ordinateur)") Then
|
|
InformationDuPcToolStripMenuItem.Visible = True
|
|
DéconecterLePcToolStripMenuItem.Visible = False
|
|
SupprimerToolStripMenuItem.Visible = False
|
|
InformationDuPcToolStripMenuItem.Text = "Information de: " & ListBox1.SelectedItem
|
|
Else
|
|
InformationDuPcToolStripMenuItem.Visible = True
|
|
DéconecterLePcToolStripMenuItem.Visible = True
|
|
SupprimerToolStripMenuItem.Visible = True
|
|
InformationDuPcToolStripMenuItem.Text = "Information de: " & ListBox1.SelectedItem
|
|
DéconecterLePcToolStripMenuItem.Text = "Déconnecter: " & ListBox1.SelectedItem
|
|
SupprimerToolStripMenuItem.Text = "Supprimer: " & ListBox1.SelectedItem & " de la liste"
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SupprimerToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SupprimerToolStripMenuItem.Click
|
|
Try
|
|
Dim ftreq2 As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/index.php")
|
|
ftreq2.Method = WebRequestMethods.Ftp.DeleteFile
|
|
ftreq2.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp2 As FtpWebResponse = ftreq2.GetResponse
|
|
|
|
Dim ftreq3 As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/info.txt")
|
|
ftreq3.Method = WebRequestMethods.Ftp.DeleteFile
|
|
ftreq3.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp3 As FtpWebResponse = ftreq3.GetResponse
|
|
|
|
Try
|
|
Dim maj As New WebClient
|
|
Dim vri As String = maj.DownloadString(ipsite & "/utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/co.txt")
|
|
Dim ftreq4 As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/co.txt")
|
|
ftreq4.Method = WebRequestMethods.Ftp.DeleteFile
|
|
ftreq4.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp4 As FtpWebResponse = ftreq4.GetResponse
|
|
|
|
Dim ftreq As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/")
|
|
ftreq.Method = WebRequestMethods.Ftp.RemoveDirectory
|
|
ftreq.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp As FtpWebResponse = ftreq.GetResponse
|
|
MsgBox("Le pc: " & ListBox1.SelectedItem & " a bien été supprimer", MsgBoxStyle.Information)
|
|
ListBox1.Items.Remove(ListBox1.SelectedItem)
|
|
Catch ex As Exception
|
|
Dim ftreq As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/")
|
|
ftreq.Method = WebRequestMethods.Ftp.RemoveDirectory
|
|
ftreq.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp As FtpWebResponse = ftreq.GetResponse
|
|
MsgBox("Le pc: " & ListBox1.SelectedItem & " a bien été supprimer", MsgBoxStyle.Information)
|
|
ListBox1.Items.Remove(ListBox1.SelectedItem)
|
|
End Try
|
|
Catch ex As Exception
|
|
Timer3.Start()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
|
|
Timer3.Stop()
|
|
Try
|
|
Dim ftreq2 As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/index.php")
|
|
ftreq2.Method = WebRequestMethods.Ftp.DeleteFile
|
|
ftreq2.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp2 As FtpWebResponse = ftreq2.GetResponse
|
|
|
|
Dim ftreq3 As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/info.txt")
|
|
ftreq3.Method = WebRequestMethods.Ftp.DeleteFile
|
|
ftreq3.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp3 As FtpWebResponse = ftreq3.GetResponse
|
|
|
|
Try
|
|
Dim maj As New WebClient
|
|
Dim vri As String = maj.DownloadString(ipsite & "/utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/co.txt")
|
|
Dim ftreq4 As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/co.txt")
|
|
ftreq4.Method = WebRequestMethods.Ftp.DeleteFile
|
|
ftreq4.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp4 As FtpWebResponse = ftreq4.GetResponse
|
|
Dim ftreq As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/")
|
|
ftreq.Method = WebRequestMethods.Ftp.RemoveDirectory
|
|
ftreq.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp As FtpWebResponse = ftreq.GetResponse
|
|
MsgBox("Le pc: " & ListBox1.SelectedItem & " a bien été supprimer", MsgBoxStyle.Information)
|
|
ListBox1.Items.Remove(ListBox1.SelectedItem)
|
|
Catch ex As Exception
|
|
Dim ftreq As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & nemid & "/pc/" & ListBox1.SelectedItem & "/")
|
|
ftreq.Method = WebRequestMethods.Ftp.RemoveDirectory
|
|
ftreq.Credentials = New NetworkCredential("yoannsafe", passftp)
|
|
Dim ftpresp As FtpWebResponse = ftreq.GetResponse
|
|
MsgBox("Le pc: " & ListBox1.SelectedItem & " a bien été supprimer", MsgBoxStyle.Information)
|
|
ListBox1.Items.Remove(ListBox1.SelectedItem)
|
|
End Try
|
|
Catch ex As Exception
|
|
Timer3.Start()
|
|
End Try
|
|
End Sub
|
|
End Class |