Advertisement
| 09.27.2008 at 05:49PM PDT, ID: 23769046 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: |
Public Class FormPrimary
Private MySettingLocation As New OleDb.OleDbConnection(My.Settings.MyConnectionString)
Private WithEvents MyExplorerWindows As New SHDocVw.ShellWindows
Private WithEvents MyBrowserExplorer As SHDocVw.ShellBrowserWindow
Private MyValidWebsites() As String = Split(My.Settings.MyAllowedWebsites, "|")
Private MyLoginUsername() As String = Split(My.User.Name, "\")
Declare Function IsIconic Lib "user32" (ByVal HWND As Integer) As Integer
Declare Function GetForegroundWindow Lib "user32" () As Integer
Declare Function GetWindowTextA Lib "user32" (ByVal HWND As Integer, ByVal Title As StringBuilder, ByVal CCH As Integer) As Integer
Private Function ValidateDomainName(ByVal MyLocationURL As String) As Boolean
For MyInteger As Integer = LBound(MyValidWebsites) To UBound(MyValidWebsites)
If MyLocationURL.Contains(MyValidWebsites(MyInteger)) = True Then
ValidateDomainName = True : Exit For
End If
Next
End Function
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerSystem.Tick
On Error Resume Next
Dim MyCheck As Boolean = False
If My.Computer.Clock.LocalTime.Date = My.Settings.MyInternetUserDate.Date.AddDays(1) Then
Me.CreateRecord(Now.Date)
Me.IconTray.Icon = My.Resources.Connected
End If
If Not MyExplorerWindows.Count > 0 Then
Me.TimerInternet.Enabled = False
End If
For Each MyCurrentExplorer As SHDocVw.ShellBrowserWindow In MyExplorerWindows
If Path.GetFileNameWithoutExtension(MyCurrentExplorer.FullName).ToLower = "iexplore" Then
If IsIconic(MyCurrentExplorer.HWND) = 0 Then
If Not Me.ValidateDomainName(MyCurrentExplorer.LocationURL) Then
MyCheck = True : Exit For
End If
End If
End If
Next
Me.TimerInternet.Enabled = MyCheck
Me.IconTray.Text = IIf(My.Settings.MyInternetTimeLeft >= 0, My.Settings.MyInternetTimeLeft, 0) & " Minutes Remaining (" & IIf(Me.TimerInternet.Enabled = True, "", "Not ") & "Tracking)"
For Each MyCurrentExplorer As SHDocVw.ShellBrowserWindow In MyExplorerWindows
If Path.GetFileNameWithoutExtension(MyCurrentExplorer.FullName).ToLower = "iexplore" Then
If GetForegroundWindow = MyCurrentExplorer.HWND Then
Dim MyFocusedString As New System.Text.StringBuilder(256)
Dim MyFocusedHeader As Integer = GetWindowTextA(GetForegroundWindow(), MyFocusedString, 256)
'If Not MyCurrentExplorer.Busy = True Then
If MyCurrentExplorer.Document.ToString = "mshtml.HTMLDocumentClass" Then
If Replace(MyFocusedString.ToString, " - Windows Internet Explorer", "") = MyCurrentExplorer.Document.Title Then
MyBrowserExplorer = MyCurrentExplorer
Exit For
End If
Else
If Replace(MyFocusedString.ToString, " - Windows Internet Explorer", "") = MyCurrentExplorer.LocationURL Then
MyBrowserExplorer = MyCurrentExplorer
Exit For
Else
Debug.WriteLine("Problem")
End If
End If
'End If
End If
End If
Next
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerInternet.Tick
My.Settings.MyInternetTimeLeft = My.Settings.MyInternetTimeLeft - 1
UpdateRecord(Now.Date)
If My.Settings.MyInternetTimeLeft = 5 Then
Me.IconTray.BalloonTipText = "You have 5 minutes of non-restricted internet use remaining."
Me.IconTray.ShowBalloonTip(5000)
End If
If My.Settings.MyInternetTimeLeft = 0 Then
Me.IconTray.BalloonTipText = "You have 0 minutes of non-restricted internet use remaining."
Me.IconTray.ShowBalloonTip(5000)
Me.IconTray.Icon = My.Resources.Disabled
End If
End Sub
Private Sub MyBrowserExplorer_BeforeNavigate2(ByVal pDisp As Object, ByRef URL As Object, ByRef Flags As Object, ByRef TargetFrameName As Object, ByRef PostData As Object, ByRef Headers As Object, ByRef Cancel As Boolean) Handles MyBrowserExplorer.BeforeNavigate2
If Me.ValidateDomainName(URL) = False And My.Settings.MyInternetTimeLeft <= 0 Then
Cancel = True
End If
End Sub
Private Sub MyBrowserExplorer_NewWindow3(ByRef ppDisp As Object, ByRef Cancel As Boolean, ByVal dwFlags As UInteger, ByVal bstrUrlContext As String, ByVal bstrUrl As String) Handles MyBrowserExplorer.NewWindow3
If Me.ValidateDomainName(bstrUrl) = False And My.Settings.MyInternetTimeLeft <= 0 Then
MyBrowserExplorer.RegisterAsBrowser = True
MyBrowserExplorer.Visible = True
ppDisp = MyBrowserExplorer
Cancel = True
End If
End Sub
Private Sub FormPrimary_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SelectRecord(Now.Date) : Me.TimerSystem.Start()
End Sub
Private Sub SelectRecord(ByVal MyRecordDate As Date)
Me.MySettingLocation.Open()
Dim MyQuery As String = "SELECT * FROM AccessEvents "
MyQuery = MyQuery & "WHERE InternetDate =#" & MyRecordDate & "# "
MyQuery = MyQuery & "AND LoginName ='" & MyLoginUsername(1) & "'"
Dim MyDataCommand As New OleDb.OleDbCommand(MyQuery, MySettingLocation)
Dim MyDataRecords As OleDb.OleDbDataReader = MyDataCommand.ExecuteReader()
If MyDataRecords.HasRows = True Then
While MyDataRecords.Read()
My.Settings.MyInternetTimeLeft = MyDataRecords("TimeRemaining")
My.Settings.MyInternetUserDate = MyDataRecords("InternetDate")
End While
Me.MySettingLocation.Close()
Me.IconTray.Icon = IIf(My.Settings.MyInternetTimeLeft <= 0, My.Resources.Disabled, My.Resources.Connected)
Me.IconTray.Text = IIf(My.Settings.MyInternetTimeLeft >= 0, My.Settings.MyInternetTimeLeft, 0) & " Minutes Remaining (" & IIf(Me.TimerInternet.Enabled = True, "", "Not ") & "Tracking)"
Else
Me.MySettingLocation.Close() : Me.CreateRecord(MyRecordDate)
End If
End Sub
Private Sub CreateRecord(ByVal MyRecordDate As Date)
Me.MySettingLocation.Open()
Dim MyQuery As String = "INSERT INTO AccessEvents (LoginName, InternetDate) "
MyQuery = MyQuery & "VALUES ('" & MyLoginUsername(1) & "', #" & MyRecordDate & "#)"
Dim MyDataCommand As New OleDb.OleDbCommand(MyQuery, MySettingLocation)
MyDataCommand.ExecuteReader() : Me.MySettingLocation.Close() : Me.SelectRecord(Now.Date)
End Sub
Private Sub UpdateRecord(ByVal MyRecordDate As Date)
Me.MySettingLocation.Open()
Dim MyQuery As String = "UPDATE AccessEvents "
MyQuery = MyQuery & "SET TimeRemaining =" & My.Settings.MyInternetTimeLeft & " "
MyQuery = MyQuery & "WHERE LoginName='" & MyLoginUsername(1) & "' "
MyQuery = MyQuery & "AND InternetDate=#" & MyRecordDate & "#"
Dim MyDataCommand As New OleDb.OleDbCommand(MyQuery, MySettingLocation)
MyDataCommand.ExecuteReader() : Me.MySettingLocation.Close()
End Sub
End Class
|
Advertisement