Imports System
Imports System.IO
Imports System.Net
Imports System.Web
Public Class CPlayerList1
Private m_Players As New Collection
Private Player As CPlayer
Public Sub New()
'empty constructor
End Sub
Public Sub LoadPlayers()
Try
Const file As String = "pathtoftp"
Dim client As New WebClient
Dim ftpReq As FtpWebRequest = _
WebRequest.Create(file)
ftpReq.Method = WebRequestMethods.Ftp.DownloadFile
ftpReq.KeepAlive = True
ftpReq.UsePassive = True
ftpReq.Credentials = New NetworkCredential( _
"nunya", "business")
Dim ftpResp As FtpWebResponse
ftpResp = ftpReq.GetResponse
Dim ftpRespStream As Stream
Dim reader As StreamReader
ftpRespStream = ftpResp.GetResponseStream
Stream.Synchronized(ftpRespStream)
reader = New IO.StreamReader(ftpRespStream, _
System.Text.Encoding.ASCII)
Do While StreamReader.Synchronized(reader).Read
Dim myPlayer As String
myPlayer = reader.ReadLine
GetNames(myPlayer)
GetKills(myPlayer)
getDeaths(myPlayer)
GetTk(myPlayer)
GetSuicides(myPlayer)
GetObjective(myPlayer)
Loop
reader.Close()
Catch ex As Exception
Dim mm As New System.Net.Mail.SmtpClient
mm.Host = "smtp.charter.net"
mm.Send("itower@chartermi.net", "itower@chartermi.net", "error", ex.Message)
End Try
End Sub
Private Sub WritePlayers(ByVal Path As String)
End Sub
Private Sub GetObjective(ByVal myObjective As String)
Dim myplayernames As String
myplayernames = getPlayersObjective(myObjective)
If myplayernames <> "" Then
Player.Objective = getPlayersObjective(myObjective)
m_Players.Add(Player) 'Add our player to our collection of players.####NOTE HERE####
End If
End Sub
Private Function getPlayersObjective(ByVal myObjective As String)
Dim reg As Regex = New Regex("Objective:+\s*\w*")
Dim m As Match = reg.Match(myObjective)
myObjective = m.Value.Replace("Objective: ", "")
Return myObjective
End Function
Private Sub GetTk(ByVal tk As String)
Dim myplayernames As String
myplayernames = GetPlayerTeamKills(tk)
If myplayernames <> "" Then
Player.TeamKills = GetPlayerTeamKills(tk)
End If
End Sub
Private Sub getDeaths(ByVal mydeaths As String)
Dim myplayernames As String
myplayernames = GetPlayerDeaths(mydeaths)
If myplayernames <> "" Then
Player.Deaths = GetPlayerDeaths(mydeaths)
End If
End Sub
Private Sub GetNames(ByVal myNames As String)
Dim myplayernames As String
myplayernames = GetPlayerNames(myNames)
If myplayernames <> "" Then
Player = New CPlayer
Player.Name = GetPlayerNames(myNames)
End If
End Sub
Private Sub GetKills(ByVal amyKills As String)
Dim myTempKills As String
myTempKills = GetPlayerKills(amyKills)
If myTempKills <> "" Then
Player.Kills = GetPlayerKills(amyKills)
End If
End Sub
Private Sub GetSuicides(ByVal mySuicides As String)
Dim myTempKills As String
myTempKills = GetPlayerSuicides(mySuicides)
If myTempKills <> "" Then
Player.Suicides = GetPlayerSuicides(mySuicides)
End If
End Sub
Public Function GetPlayerSuicides(ByVal mySuicides As String)
Dim reg As Regex = New Regex("Suicides:+\s*\w*")
Dim m As Match = reg.Match(mySuicides)
mySuicides = m.Value.Replace("Suicides: ", "")
Return mySuicides
End Function
Public Function GetPlayerDeaths(ByVal myDEaths As String) As String
Dim reg As Regex = New Regex("Deaths:+\s*\w*")
Dim m As Match = reg.Match(myDEaths)
myDEaths = m.Value.Replace("Deaths: ", "")
Return myDEaths
End Function
Public Function GetPlayerNames(ByVal myPlayer As String) As String
Dim reg As Regex = New Regex("\:+\s[a-zA-Z0-9<>?,.{}}\+_&=!@#$'%-|`*^:/;()~]+\s+\(u*")
Dim m As Match = reg.Match(myPlayer)
myPlayer = m.Value.TrimStart(": ").ToString 'changed test players
Dim temp As String = myPlayer.Replace("(u", " ")
Return temp
End Function
Public Function GetPlayerKills(ByVal myKills As String) As String
Dim reg As Regex = New Regex("]+\sKills:+\s+\w+")
Dim m As Match = reg.Match(myKills)
myKills = m.Value.TrimStart("]")
myKills = myKills.Replace("Kills: ", "")
Return myKills
End Function
Public Function GetPlayerTeamKills(ByVal myTk As String) As String
Dim reg As Regex = New Regex("m\s*\sKills:\s*\w*")
Dim m As Match = reg.Match(myTk)
Dim temp As String = m.Value.Replace("m ", "")
temp = temp.Replace("Kills:", "")
Return temp
End Function
Public Shared Function fGETDATE(ByVal myString As String) As String
Dim reg As Regex = New Regex("((?<=\[)[^\[\]]*)")
Dim m As Match = reg.Match(myString)
myString = m.Value.ToString
reg = Nothing
Return myString
End Function
Public Function Players() As Collection
Return m_Players
End Function
Public Sub RemovePlayer(ByVal index As Integer)
m_Players.Remove(index)
End Sub
Public Function GetPLAYERCount() As Integer
Return m_Players.Count
End Function
Public Function GetPLAYERObject(ByVal index As Integer) As CPlayer
Return m_Players.Item(index)
End Function
End Class