R
Rohan Danushka
Guest
Hi,
Please Help me Resolve this warning ( CA2000 and CA1305) according to FxCop
Public Shared Function GetNISTTime(ByVal host As String) As DateTime
If K9Core.CheckInternetConn = True Then
Dim timeStr As String = ""
Dim reader As New StreamReader(New TcpClient(host, 13).GetStream) 'CA2000 Warning
Try
K9Core.LastSysTime = DateTime.UtcNow()
timeStr = reader.ReadToEnd()
reader.Close()
Catch ex As SocketException
InternetTime = ex.Message
Catch ex As Exception
InternetTime = ex.Message
Throw
End Try
Dim jd As Integer = Integer.Parse(timeStr.Substring(1, 5)) 'CA1305 Warning
Dim yr As Integer = Integer.Parse(timeStr.Substring(7, 2)) 'CA1305 Warning
Dim mo As Integer = Integer.Parse(timeStr.Substring(10, 2)) 'CA1305 Warning
Dim dy As Integer = Integer.Parse(timeStr.Substring(13, 2)) 'CA1305 Warning
Dim hr As Integer = Integer.Parse(timeStr.Substring(16, 2)) 'CA1305 Warning
Dim mm As Integer = Integer.Parse(timeStr.Substring(19, 2)) 'CA1305 Warning
Dim sc As Integer = Integer.Parse(timeStr.Substring(22, 2)) 'CA1305 Warning
Dim Temp As Integer = CInt(AscW(timeStr(7)))
InternetTime = Format(Now, "yyyy-MM-dd h:mm tt")
Return New DateTime(yr + 2000, mo, dy, hr, mm, sc)
End If
Return Now
End Function
Thank You..
Rohan~
RohanD
Continue reading...
Please Help me Resolve this warning ( CA2000 and CA1305) according to FxCop
Public Shared Function GetNISTTime(ByVal host As String) As DateTime
If K9Core.CheckInternetConn = True Then
Dim timeStr As String = ""
Dim reader As New StreamReader(New TcpClient(host, 13).GetStream) 'CA2000 Warning
Try
K9Core.LastSysTime = DateTime.UtcNow()
timeStr = reader.ReadToEnd()
reader.Close()
Catch ex As SocketException
InternetTime = ex.Message
Catch ex As Exception
InternetTime = ex.Message
Throw
End Try
Dim jd As Integer = Integer.Parse(timeStr.Substring(1, 5)) 'CA1305 Warning
Dim yr As Integer = Integer.Parse(timeStr.Substring(7, 2)) 'CA1305 Warning
Dim mo As Integer = Integer.Parse(timeStr.Substring(10, 2)) 'CA1305 Warning
Dim dy As Integer = Integer.Parse(timeStr.Substring(13, 2)) 'CA1305 Warning
Dim hr As Integer = Integer.Parse(timeStr.Substring(16, 2)) 'CA1305 Warning
Dim mm As Integer = Integer.Parse(timeStr.Substring(19, 2)) 'CA1305 Warning
Dim sc As Integer = Integer.Parse(timeStr.Substring(22, 2)) 'CA1305 Warning
Dim Temp As Integer = CInt(AscW(timeStr(7)))
InternetTime = Format(Now, "yyyy-MM-dd h:mm tt")
Return New DateTime(yr + 2000, mo, dy, hr, mm, sc)
End If
Return Now
End Function
Thank You..
Rohan~
RohanD
Continue reading...