Imports Rocktime Imports Rocktime.Core Partial Class Debug Inherits PageExClass Dim Version As String = "6.02.000" #Region "Stop On Error" Protected Sub btnStopOnError_Page_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStopOnError_Page.Click Config.Debug.StopOnError = Config.Debug.StopType.EndOfPage End Sub Protected Sub btnStopOnError_DB_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStopOnError_DB.Click Config.Debug.StopOnError = Config.Debug.StopType.OnDb End Sub Protected Sub btnStopOnError_First_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStopOnError_First.Click Config.Debug.StopOnError = Config.Debug.StopType.OnFirst End Sub Protected Sub btnStopOnError_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStopOnError_Off.Click Config.Debug.StopOnError = Config.Debug.StopType.No End Sub #End Region #Region "Log Mode" Protected Sub btnLogMode_Code_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogMode_Code.Click Config.Debug.LogMode = Core.WriteLogMode.Code End Sub Protected Sub btnLogMode_Raw_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogMode_Raw.Click Config.Debug.LogMode = Core.WriteLogMode.Raw End Sub Protected Sub btnLogMode_Full_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogMode_Full.Click Config.Debug.LogMode = Core.WriteLogMode.Full End Sub Protected Sub btnLogMode_User_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogMode_User.Click Config.Debug.LogMode = Core.WriteLogMode.User End Sub Protected Sub btnLogMode_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogMode_Off.Click Config.Debug.LogMode = Core.WriteLogMode.Off End Sub Private Sub SetOptionsLogMode() Select Case Config.Debug.LogMode Case Core.WriteLogMode.Off txtLogMode.BackColor = Drawing.Color.White opLogMode.Text = "Off" Case Core.WriteLogMode.Raw txtLogMode.BackColor = Drawing.Color.LightGreen opLogMode.Text = "Raw" Case Core.WriteLogMode.User txtLogMode.BackColor = Drawing.Color.LightGreen opLogMode.Text = "User" Case Core.WriteLogMode.Code txtLogMode.BackColor = Drawing.Color.LightGreen opLogMode.Text = "Code" Case Core.WriteLogMode.Full txtLogMode.BackColor = Drawing.Color.LightGreen opLogMode.Text = "Full" End Select End Sub #End Region #Region "Show" Protected Sub btnShowSQL_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowSQL_On.Click Config.Debug.ShowSQL = True End Sub Protected Sub btnShowSQL_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowSQL_Off.Click Config.Debug.ShowSQL = False End Sub Protected Sub btnShowVar_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowVar_On.Click Config.Debug.ShowVar = True End Sub Protected Sub btnShowVar_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowVar_Off.Click Config.Debug.ShowVar = False End Sub Protected Sub btnShowEmailInfo_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowEmailInfo_On.Click Config.Debug.ShowEmailInfo = True End Sub Protected Sub btnShowEmailInfo_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowEmailInfo_Off.Click Config.Debug.ShowEmailInfo = False End Sub Protected Sub btnSendViaEmail_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendViaEmail_On.Click Config.Debug.SendViaEmail = True End Sub Protected Sub btnSendViaEmail_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendViaEmail_Off.Click Config.Debug.SendViaEmail = False End Sub Protected Sub btnShowTrace_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowTrace_On.Click Config.Debug.ShowTrace = True End Sub Protected Sub btnShowTrace_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowTrace_Off.Click Config.Debug.ShowTrace = False End Sub Protected Sub btnTestMode_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTestMode_On.Click Config.Debug.TestMode = True End Sub Protected Sub btnTestMode_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTestMode_Off.Click Config.Debug.TestMode = False End Sub Private Sub SetOptionsShow() If Config.Debug.TestMode Then txtTestMode.BackColor = Drawing.Color.LightGreen opTestMode.Text = "On" Else txtTestMode.BackColor = Drawing.Color.White opTestMode.Text = "Off" End If If Config.Debug.ShowTrace Then txtShowTrace.BackColor = Drawing.Color.LightGreen opShowTrace.Text = "On" Else txtShowTrace.BackColor = Drawing.Color.White opShowTrace.Text = "Off" End If If Config.Debug.ShowSQL Then txtShowSQL.BackColor = Drawing.Color.LightGreen opShowSQL.Text = "On" Else txtShowSQL.BackColor = Drawing.Color.White opShowSQL.Text = "Off" End If If Config.Debug.ShowVar Then txtShowVar.BackColor = Drawing.Color.LightGreen opShowVar.Text = "On" Else txtShowVar.BackColor = Drawing.Color.White opShowVar.Text = "Off" End If If Config.Debug.SendViaEmail Then txtSendViaEmail.BackColor = Drawing.Color.LightGreen opSendViaEmail.Text = "On" Else txtSendViaEmail.BackColor = Drawing.Color.White opSendViaEmail.Text = "Off" End If If Config.Debug.ShowEmailInfo Then txtShowEmailInfo.BackColor = Drawing.Color.LightGreen opShowEmailInfo.Text = "On" Else txtShowEmailInfo.BackColor = Drawing.Color.White opShowEmailInfo.Text = "Off" End If End Sub #End Region #Region "Email" Protected Sub btnDebugMailServer_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDebugMailServer_On.Click Config.Debug.UseDebugMailServer = True End Sub Protected Sub btnDebugMailServer_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDebugMailServer_Off.Click Config.Debug.UseDebugMailServer = False End Sub Protected Sub btnDebugMailAddress_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDebugMailAddress_On.Click Config.Debug.UseDebugMailAddresses = True End Sub Protected Sub btnDebugMailAddress_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDebugMailAddress_Off.Click Config.Debug.UseDebugMailAddresses = False End Sub Private Sub SetOptionsMail() If Config.Debug.UseDebugMailServer Then txtDebugMailServer.BackColor = Drawing.Color.LightGreen opDebugMailServer.Text = "On" Else txtDebugMailServer.BackColor = Drawing.Color.White opDebugMailServer.Text = "Off" End If If Config.Debug.UseDebugMailAddresses Then txtDebugMailAddress.BackColor = Drawing.Color.LightGreen opDebugMailAddress.Text = "On" Else txtDebugMailAddress.BackColor = Drawing.Color.White opDebugMailAddress.Text = "Off" End If End Sub #End Region #Region "Web Config" Protected Sub btnCloseSite_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCloseSite_On.Click UpdateWC(" 0) End Function Private Sub UpdateWC(ByVal Key As String, ByVal Value As String) Dim SR As New System.IO.StreamReader(Server.MapPath("~/web.config")) Dim WCContent As String = SR.ReadToEnd SR.Close() WCContent = Core.StringFn.Replace(WCContent, Key & "=""[^""]*""", Key & "=""" & Value & """", True) Dim SW As New System.IO.StreamWriter(Server.MapPath("~/web.config"), False) SW.Write(WCContent) SW.Close() End Sub #End Region #Region "Misc Buttons" Protected Sub btnSendTestEmail_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendTestEmail.Init Trace.IsEnabled = False txtTestOutput.Text = "" End Sub Protected Sub btnResetSession_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnResetSession.Click Page.Session.Abandon() Config.Debug.Hits -= 1 PageRedirect("/debug.aspx") End Sub Protected Sub btnResetApplication_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnResetApplication.Click Page.Application.Lock() Page.Application.Clear() Page.Session.Abandon() Config.Debug.Hits = 0 Config.Debug.Sessions = 1 Config.Debug.LastNewSession = Now Config.Debug.LastTerminatedSession = Nothing Config.Debug.ApplicationRestarted = Now Config.Debug.TerminatedSessions = 0 Page.Application.UnLock() PageRedirect("/debug.aspx") End Sub Protected Sub btnStopTransfersandRedirects_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStopTransfersandRedirects_On.Click Config.Debug.StopTransfersandRedirects = True End Sub Protected Sub btnStopTransfersandRedirects_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStopTransfersandRedirects_Off.Click Config.Debug.StopTransfersandRedirects = False End Sub Protected Sub btnDebugAutoRefresh_On_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDebugAutoRefresh_On.Click Config.Debug.DebugAutoRefresh = True End Sub Protected Sub btnDebugAutoRefresh_Off_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDebugAutoRefresh_Off.Click Config.Debug.DebugAutoRefresh = False End Sub Private Sub SetOptionsMisc() If Config.Debug.StopTransfersandRedirects Then txtStopTransfersandRedirects.BackColor = Drawing.Color.LightGreen opStopTransfersandRedirects.Text = "On" Else txtStopTransfersandRedirects.BackColor = Drawing.Color.White opStopTransfersandRedirects.Text = "Off" End If If Config.Debug.DebugAutoRefresh Then txtDebugAutoRefresh.BackColor = Drawing.Color.LightGreen opDebugAutoRefresh.Text = "On" Else txtDebugAutoRefresh.BackColor = Drawing.Color.White opDebugAutoRefresh.Text = "Off" End If End Sub Protected Sub btnSendTestEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendTestEmail.Click Dim Email As New EmailClass Dim LastSetting As Boolean = Config.Debug.ShowEmailInfo Config.Debug.ShowEmailInfo = True Email.AddToAddress(Config.EMail.DebugRecipient) Email.FromAddress = Config.EMail.DefaultSiteSender Email.Subject = "Debug info message" Email.Body = "Server: " & URL.ServerVariables.HTTP_HOST & vbNewLine Email.AddBody("Time: " & Now() & vbNewLine) Email.AddBody("Test Message") Email.Send() txtTestOutput.Text = Dg.Text Config.Debug.ShowEmailInfo = LastSetting End Sub #End Region #Region "Misc" Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Page.Title = "Debug - " & Rocktime.Core.Version() & " - Debug V" & Version opInfo.Text = "Debug V" & Version & "
" & Rocktime.Core.Version Dg.RocktimeOnly() End Sub Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender SetOptions() SetStats() If Rocktime.Config.Debug.DebugAutoRefresh Then opScript.Text = "" End If End Sub Private Sub SetStats() opSessions.Text = Config.Debug.Sessions opActiveSessions.Text = Config.Debug.ActiveSessions opTeminatedSessions.Text = Config.Debug.TerminatedSessions opHits.Text = Config.Debug.Hits opLastNewSession.Text = Config.Debug.LastNewSession opLastTerminatedSession.Text = Config.Debug.LastTerminatedSession opApplicationRestarted.Text = Config.Debug.ApplicationRestarted opLastRefresh.Text = Now 'opSessionStart.Text = Config.Debug.CurrentSessionStart 'opLastRefresh.Text = Config.Debug.CurrentSessionLength End Sub Private Sub SetOptionsStopOnError() Select Case Config.Debug.StopOnError Case Config.Debug.StopType.No txtStopOnError.BackColor = Drawing.Color.White opStopOnError.Text = "Off" Case Config.Debug.StopType.EndOfPage txtStopOnError.BackColor = Drawing.Color.LightGreen opStopOnError.Text = "End Of Page" Case Config.Debug.StopType.OnDb txtStopOnError.BackColor = Drawing.Color.LightGreen opStopOnError.Text = "On DB" Case Config.Debug.StopType.OnFirst txtStopOnError.BackColor = Drawing.Color.LightGreen opStopOnError.Text = "On First" End Select End Sub Private Sub SetOptions() SetOptionsStopOnError() SetOptionsLogMode() SetOptionsShow() SetOptionsMail() SetOptionsWebConfig() SetOptionsMisc() End Sub #End Region End Class