⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.asax.vb

📁 系统概要: 本系统采用VB.NET开发. 开发平台:Windows XP Professional SP2 (English Version) 开发环境:Visual Studio .NET
💻 VB
字号:
Imports System.Web
Imports System.Web.SessionState

Public Class Global
    Inherits System.Web.HttpApplication

#Region " Component Designer Generated Code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Required by the Component Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Component Designer
    'It can be modified using the Component Designer.
    'Do not modify it using the code editor.
    Friend WithEvents t As System.Timers.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.t = New System.Timers.Timer
        CType(Me.t, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.t, System.ComponentModel.ISupportInitialize).EndInit()

    End Sub

#End Region

    '应用程序启动事件
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

        '写系统启动日志
        WriteLog("Start IIS Server; Copyright (c) 2006 济南大学材料学院AutoCAD考试系统 All right reserved")

        '初始化定时器(自动备份周期)
        '-----------------------------------------------------
        '定义定时器:定时周期:=Web.config中"Time"参数 (单位:秒)
        '1000 * getParameters("Time"):将时间单位从毫秒转化为秒
        '-----------------------------------------------------
        '
        t = New System.Timers.Timer(1000 * CType(getParameters("Time"), Double))
        t.AutoReset = True
        t.Enabled = True
        AddHandler t.Elapsed, AddressOf RunTimer           '添加定时器事件

    End Sub

    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)

        '写系统停止日志
        WriteLog("Stop IIS Server; Copyright (c) 2006 济南大学材料学院AutoCAD考试系统 All right reserved")

    End Sub


    '    函数名称:RunTimer(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
    '    摘    要:定时器
    '             定时完成应用程序预定计划的事件
    '             0.按Web.config中<TIME>设置的时间(单位:秒)执行一次事件
    '             1.数据库备份
    '
    Private Sub RunTimer(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)

        If (CBool(getParameters("AUTO_BACKUP"))) Then

            Dim oBackupSQL As BackupSQL

            Try
                Common.WriteLog("Start Backup the Database...")
                oBackupSQL = New BackupSQL
                oBackupSQL.Backup()
                Common.WriteLog("Backup Database Success!")
            Catch ex As Exception
                Common.WriteLog("Occur Error on Backup Database " & ex.ToString)
                Exit Try
            End Try
        End If

    End Sub

    '    函数名称:getParameters(ByVal key As String) As String
    '    摘    要:获取Web.config中设置的应用程序key值
    '
    Private Function getParameters(ByVal key As String) As String

        Return System.Configuration.ConfigurationSettings.AppSettings(key)

    End Function

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -