<?xml version="1.0" encoding="windows-1251"?>
<document type="SelFTrendxTest" version="0.0" xmlns:m="xTest">
     <xTest type="USER_SCRIPT" alias="911BHTest.BusinessApp"
            TitleRus="Базовый тест Субъективной Оценки  Качества ИТ-Сервисов"
            TitleRootRus="Поддержка технологии Красная Кнопка (ProLAN 911)"
            TitleEng="ProLAN-911 Basic Health Test for Business Application"
            TitleRootEng="ProLAN-911 Tests" 
            TrafficLightsName="ProLAN-911 Basic Health Test for Business Application"
            Version="3.5">
    <Files>
      <File type="conf" name="VB.ProLAN911BasicHealthTest.BusinessApp.xTest.xml"/>
      <File type="help" name="VB.ProLAN911BasicHealthTest.BusinessApp.xTest.chm::/VB.ProLAN911BasicHealthTest.BusinessApp.xTest.html"/>
      <File type="dll" name="ST_SCTest.dll"/>
    </Files>

       <Keywords>
         <Keyword>Красная Кнопка</Keyword>
         <Keyword>ProLAN-911</Keyword>
         <Keyword>Microsoft</Keyword>
         <Keyword>Windows</Keyword>
         <Keyword>Бизнес-приложение</Keyword>
         <Keyword>Удовлетворенность пользователей</Keyword>
       </Keywords>

       <!--
$Id: VB.ProLAN911BasicHealthTest.BusinessApp.xTest.xml,v 1.6 2010/09/16 10:28:43 bag Exp $
-->
       <xTestProps>
         <log_level_def>5</log_level_def>
         <truncate_log>1</truncate_log>
         <AverInervDuration>60</AverInervDuration>
         <discovery_func>OnDiscovery</discovery_func>
         <work_func>OnDataReceived</work_func>
       </xTestProps>

    <parameters TitleRus="Параметры:" TitleEng="Settings:">
        <resources>
            <resource_id TitleRus="Файлы Бизнес-Приложения" TitleEng="Business Application Files"></resource_id>
        </resources>
        <common_attribs TitleRus="Список параметров (общие):" TitleEng="Parameters List (common):" SubTitleRus="Параметр" SubTitleEng="Parameter">
            <Attrib Type="String" TitleRus="Название Бизнес-Приложения" TitleEng="Business Application Name" Alias="BusinessApplicationName">
                 "My Business Application"
            </Attrib>
            <Attrib Type="String" TitleRus="Строка соединения" TitleEng="Connection String" Alias="ConnectionString">
                 Provider=SQLOLEDB.1;Password=&lt;Enter Password&gt;;Persist Security Info=True;User ID=&lt;Enter UserName&gt;;Initial Catalog=&lt;Enter DB Name&gt;;Data Source=&lt;Enter SQL Server Name&gt;
            </Attrib>
            <Attrib Type="String" TitleRus="Имена или IP-адреса компьютеров с коллектором сообщений 911Help (через точку с запятой)" TitleEng="Name or IP-address of 911Help Collectors (separated by ';')" Alias="AdminConsole">
                 ""
            </Attrib>
            <Attrib Type="Integer" TitleRus="Порт службы приема сообщений 911Help" TitleEng="911Help Receiving Service Port" Alias="PortReceiving">
                 7002
            </Attrib>
        </common_attribs>
    </parameters>

    <popupdisplay>
	    <description ru="ProLAN-911 Basic Health Test For Business Application" en="ProLAN-911 Basic Health Test for Business Application"></description>
    </popupdisplay>

<Script language="VBScript">
<!--
Option Explicit

Const g_SEVERITY_INFO       = 0
Const g_SEVERITY_WARNING    = 1
Const g_SEVERITY_ERROR      = 2
Const g_FLAG_NO_LH_ADDRESS  = 4
Const g_FLAG_NO_911_MAP     = 8
Const g_FLAG_FROM_TEST      = 16
Const g_FLAG_USERNAME_IN_LH_ADDRESS = 32

Const adCmdText = 1
Const adDate = 7
Const adInteger = 3
Const adDouble = 5
Const adChar = 129
Const adParamInput = 1
Const adParamOutput = 2
Const adParamInputOutput = 3

Dim g_strDBSource, g_objConnection, g_DbAvailability
Dim g_snaCount
Dim g_ProcessNameArr, g_ConsoleArr

Sub OnDiscovery(ByRef ResSet)
    Dim l_nResCount, l_BusinessApplicationName, Unid
    Dim l_strSLAEventName, l_strSLAAliasName, l_Error, l_TLError
    Dim l_strTLName_ru, l_strTLName_en
    
    On Error Resume Next
    'stop
    Err.Clear

    ResSet.LogMsg("*** Start Sub OnDiscovery ***")
    ResSet.SendProgressMessage("Start Script")

    l_nResCount = ResSet.Count
    
    If l_nResCount < 1 Then
        ResSet.ScriptError = -1
        ResSet.ScriptErrorInfo = "Необходимо задать по крайней мере один Файл Бизнес-Приложения."
        Exit Sub
    End If
    
    l_BusinessApplicationName = Trim(ResSet.CommonProp.Attrib("BusinessApplicationName").Value)
    
    If Len(l_BusinessApplicationName) < 1 Then
        ResSet.ScriptError = -1
        ResSet.ScriptErrorInfo = "Необходимо задать название Бизнес-Приложения."
        Exit Sub
    End If

    ResSet.SendProgressMessage("Check SQL Server Connection...")

    TestSQLServerConnection(ResSet)

    If (Err.Number <> 0) Then
        ResSet.LogMsg("Failed to TestSQLServerConnection. Resource [" & ResSet.CommonProp.Attrib("ConnectionString").Value & "] "  & "Error Number: "  & CStr(Err.Number) & " Error Descr: " & Err.Description & " Err Source: " & Err.Source)
        ResSet.ScriptError = -1
        ResSet.ScriptErrorInfo = "Ошибка при подлючении к БД." & vbNewLine & "Ресурс [" & ResSet.CommonProp.Attrib("ConnectionString").Value & "]." & vbNewLine & "Error Number: "  & CStr(Err.Number) & " Error Descr: " & Err.Description & " Err Source: " & Err.Source
        Err.Clear
        Exit Sub
    End If

    ' Регистрируем метрики
    Unid = ResSet.UnidBase

    ' Доступность БД
    l_strSLAEventName = "Database Availability(%)"
    l_strSLAAliasName = "DbAvailability"
    l_Error = ResSet.EventAdd(l_strSLAEventName, l_strSLAAliasName, Unid)
    Unid = Unid + 1
    l_strTLName_ru = l_strSLAEventName
    l_strTLName_en = l_strSLAEventName
    l_TLError = ResSet.AddTrafficLight(l_strSLAAliasName, _
                    l_strTLName_ru, _
                    l_strTLName_en, _
                    "Average", "<", _
                    100, 100, 100, 100)

    If (Err.Number <> 0) Then
        ResSet.LogMsg("Failed Addint TrafficLight '" & l_strTLName_ru & "' "  & "Error Number: "  & CStr(Err.Number) & " Error Descr: " & Err.Description & " Err Source: " & Err.Source)
        ResSet.ScriptError = -1
        ResSet.ScriptErrorInfo = "Ошибка создания индикатора '" & l_strTLName_ru & "'" & vbNewLine & "Error Number: "  & CStr(Err.Number) & " Error Descr: " & Err.Description & " Err Source: " & Err.Source
        Err.Clear
        Exit Sub
    End If

    ' SAB
    l_strSLAEventName = "[" & l_BusinessApplicationName & "] Subjective Availability - B (SA-B)"
    l_strSLAAliasName = "SAB"
    l_Error = ResSet.EventAdd(l_strSLAEventName, l_strSLAAliasName, Unid)
    Unid = Unid + 1

    ' SAN
    l_strSLAEventName = "[" & l_BusinessApplicationName & "] Subjective Availability - N (SA-N)"
    l_strSLAAliasName = "SAN"
    l_Error = ResSet.EventAdd(l_strSLAEventName, l_strSLAAliasName, Unid)
    l_strTLName_ru = l_BusinessApplicationName & ".Subjective Availability - N (SA-N)"
    l_strTLName_en = l_BusinessApplicationName & ".Subjective Availability - N (SA-N)"
    l_TLError = ResSet.AddTrafficLight(l_strSLAAliasName, l_strTLName_ru, l_strTLName_en, "Average", ">", 3, 2, 1, 0)
    Unid = Unid + 1
    
    ' SAP
    l_strSLAEventName = "[" & l_BusinessApplicationName & "] Subjective Availability - P (SA-P)"
    l_strSLAAliasName = "SAP"
    l_Error = ResSet.EventAdd(l_strSLAEventName, l_strSLAAliasName, Unid)
    l_strTLName_ru = l_BusinessApplicationName & ".Subjective Availability - P (SA-P)"
    l_strTLName_en = l_BusinessApplicationName & ".Subjective Availability - P (SA-P)"
    l_TLError = ResSet.AddTrafficLight(l_strSLAAliasName, l_strTLName_ru, l_strTLName_en, "Average", ">", 30, 15, 3, 0)
    Unid = Unid + 1

    ' SPB
    l_strSLAEventName = "[" & l_BusinessApplicationName & "] Subjective Performance - B (SP-B)"
    l_strSLAAliasName = "SPB"
    l_Error = ResSet.EventAdd(l_strSLAEventName, l_strSLAAliasName, Unid)
    Unid = Unid + 1

    ' SPN
    l_strSLAEventName = "[" & l_BusinessApplicationName & "] Subjective Performance - N (SP-N)"
    l_strSLAAliasName = "SPN"
    l_Error = ResSet.EventAdd(l_strSLAEventName, l_strSLAAliasName, Unid)
    l_strTLName_ru = l_BusinessApplicationName & ".Subjective Performance - N (SP-N)"
    l_strTLName_en = l_BusinessApplicationName & ".Subjective Performance - N (SP-N)"
    l_TLError = ResSet.AddTrafficLight(l_strSLAAliasName, l_strTLName_ru, l_strTLName_en, "Average", ">", 15, 10, 5, 0)
    Unid = Unid + 1

    ' SPP
    l_strSLAEventName = "[" & l_BusinessApplicationName & "] Subjective Performance - P (SP-P)"
    l_strSLAAliasName = "SPP"
    l_Error = ResSet.EventAdd(l_strSLAEventName, l_strSLAAliasName, Unid)
    l_strTLName_ru = l_BusinessApplicationName & ".Subjective Performance - P (SP-P)"
    l_strTLName_en = l_BusinessApplicationName & ".Subjective Performance - P (SP-P)"
    l_TLError = ResSet.AddTrafficLight(l_strSLAAliasName, l_strTLName_ru, l_strTLName_en, "Average", ">", 50, 30, 15, 3)
    Unid = Unid + 1

    ' Active Users Count
    l_strSLAEventName = "[" & l_BusinessApplicationName & "] Active Users Count"
    l_strSLAAliasName = "ActiveUsersCount"
    l_Error = ResSet.EventAdd(l_strSLAEventName, l_strSLAAliasName, Unid)
    Unid = Unid + 1

    ResSet.LogMsg("*** End Sub OnDiscovery ***")
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub OnDataReceived(ByRef ResSet)
    Dim l_dtLastHelpMeMsgTime, l_dtNow, i
    
    'Stop
    On Error Resume Next

    ResSet.LogMsg("Start OnDataReceived")
    
    Redim g_ProcessNameArr(ResSet.Count - 1)
    
    For i = 0 To ResSet.Count - 1
        g_ProcessNameArr(i) = ResSet.Resource(i).Name
    Next
    
    ' Создать массив из имен консолей SLA-ON Operations
    g_ConsoleArr = Split(ResSet.CommonProp.Attrib("AdminConsole").Value, ";")
    
    For i = 0 To UBound(g_ConsoleArr)
        g_ConsoleArr(i) = Trim(g_ConsoleArr(i))
    Next

    g_strDBSource = ResSet.CommonProp.Attrib("ConnectionString").Value

    l_dtNow = Now
    l_dtLastHelpMeMsgTime = DateAdd("s", -ResSet.SLaPeriod, l_dtNow)
    
    g_snaCount = 0

    Do While Not ResSet.StopTest
        If ResSet.IsNewSLaPeriod Then
            Err.Clear

            g_DbAvailability = 0
            
            l_dtNow = Now

            ' Выполняем запрос к базе и расчеты
            RequestToDb ResSet, l_dtNow, l_dtLastHelpMeMsgTime

            If (Err.Number <> 0) Then
                ResSet.LogMsg("Failed on call RequestToDb(). Error Number: "  & CStr(Err.Number) & " Error Descr: " & Err.Description & " Err Source: " & Err.Source)
                Err.Clear
            End If
            
            Set g_objConnection = Nothing
            
            ResSet.Events("DbAvailability").Value = g_DbAvailability
            
            
            ResSet.SendSLaEvents() ' Передаем измеренные события SLA
            ResetEvents ResSet
        Else
            ResSet.Sleep 3000 ' 3 sec
        End If
    Loop
    
    ResSet.LogMsg("Exit from OnDataReceived")
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub ResetEvents(ByRef ResSet)
    Dim l_iEvCount, l_Indx

    l_iEvCount = ResSet.EventsCount
    
    For l_Indx = 0 To l_iEvCount - 1
        ResSet.Events(l_Indx).Value = ResSet.BadValue
    Next
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub TestSQLServerConnection(ByRef ResSet)
    Dim l_objConnection
    Dim l_strDBSource

    l_strDBSource = ResSet.CommonProp.Attrib("ConnectionString").Value
    ResSet.LogMsg("Testing connection for: " & l_strDBSource)

    ' Открываем соединение
    Set l_objConnection = CreateObject("ADODB.Connection")
  
    l_objConnection.ConnectionString = l_strDBSource

    ResSet.LogMsg("Opening connection to: " & l_strDBSource)
   
    l_objConnection.Open

    ResSet.LogMsg("Succeeded to open connection to: " & l_strDBSource)  

    l_objConnection.Close
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub RequestToDb(ByRef ResSet, dtNow, ByRef dtLastHelpMeMsgTime)
    Dim l_dtNewLastHelpMeMsgTime
    Dim l_objCommand, dtBegin, l_objRecordset, l_TotalActiveUserCount
    Dim l_dtReceiveTime, l_nProblemID, l_sAppProcessName, l_sProblemStatus, l_sProblemDescription
    Dim l_sDomain, l_sAccount, l_sDepName, l_sComputerName, l_nUserID, l_nComputerID, l_sAppActiveWndName, l_bAppComparedOk, i
    Dim l_SPN, l_SANna, l_SANa

    ResSet.LogMsg("RequestToDb Enter")
    
    l_dtNewLastHelpMeMsgTime = dtLastHelpMeMsgTime

    Set g_objConnection = CreateObject("ADODB.Connection")
    g_objConnection.ConnectionString = g_strDBSource
    ResSet.LogMsg("Opening connection to: " & g_strDBSource)
    g_objConnection.Open
    ResSet.LogMsg("Succeeded to open connection to: " & g_strDBSource)
    
    ' Считаем общее число активныз пользователей за последние 10 минут
    Set l_objCommand = CreateObject("ADODB.Command")
    l_objCommand.ActiveConnection = g_objConnection
    l_objCommand.CommandType = adCmdText
    l_objCommand.CommandText = "SELECT COUNT(UGTCP.nUserID) AS TOTALUSERS " & _
        "FROM UsersGlobalTotalClicksPerformance AS UGTCP, DATADESCRIPTTION AS DD " & _
        "WHERE UGTCP.nUserID >= ? AND UGTCP.nDataItemID = DD.ID AND DD.TimeEnd >= ?"

    l_objCommand.Parameters.Append l_objCommand.CreateParameter("nUserID", adInteger, adParamInput, 4, 1)
    dtBegin = DateAdd("n", -10, dtNow)
    l_objCommand.Parameters.Append l_objCommand.CreateParameter("TimeEnd", adDate, adParamInput, , dtBegin)
    l_objCommand.Prepared = True
    
    ResSet.LogMsg("Executing: " & l_objCommand.CommandText)
    Set l_objRecordset = l_objCommand.Execute(vbNull,vbNull)
    ResSet.LogMsg(l_objCommand.CommandText & " command completed")
    
    Set l_objCommand = Nothing
    
    l_TotalActiveUserCount = 0

    If Not l_objRecordset.BOF AND Not l_objRecordset.EOF Then
        l_TotalActiveUserCount = l_objRecordset.Fields(0).Value
        ResSet.LogMsg("ActiveUsersCount = " & l_TotalActiveUserCount & ".")
        ResSet.Events("ActiveUsersCount").Value = l_TotalActiveUserCount
    End If
    
    l_objRecordset.Close
    Set l_objRecordset = Nothing

    Set l_objCommand = CreateObject("ADODB.Command")
    l_objCommand.ActiveConnection = g_objConnection
    l_objCommand.CommandType = adCmdText
    l_objCommand.CommandText = "SELECT HMM.dtReceiveTime, HMM.nProblemID, APP.sAppProcessName, " & _
        "HMM.sProblemStatus, HMM.sProblemDescription, Users.sDomain, Users.sAccount, DEP.sDepName, Computers.sComputerName, " & _
        "HMM.nUserID, HMM.nComputerID, HMM.sAppActiveWndName " & _
        "FROM HelpMeMessages AS HMM, Applications AS APP, Users, Departments AS DEP, Computers " & _
        "WHERE HMM.nProblemAppID >= ? " & _
        "AND HMM.nProblemID IN (0, 1, 2) " & _
        "AND HMM.dtReceiveTime > ? " & _
        "AND APP.nAppID = HMM.nProblemAppID " & _
        "AND Users.nUserID = HMM.nUserID " & _
        "AND DEP.nDepID = Users.nDepID " & _
        "AND Computers.nComputerID = HMM.nComputerID " & _
        "ORDER BY HMM.nProblemID, HMM.nUserID, HMM.nComputerID"

    l_objCommand.Parameters.Append l_objCommand.CreateParameter("nProblemAppID", adInteger, adParamInput, 4, 1)
    l_objCommand.Parameters.Append l_objCommand.CreateParameter("dtReceiveTime", adDate, adParamInput, , l_dtNewLastHelpMeMsgTime)
    l_objCommand.Prepared = True

    ResSet.LogMsg("Executing: " & l_objCommand.CommandText)
    Set l_objRecordset = l_objCommand.Execute(vbNull,vbNull)
    ResSet.LogMsg(l_objCommand.CommandText & " command completed")
    
    Set l_objCommand = Nothing
    
    l_SPN = 0
    l_SANna = 0
    l_SANa = 0
    
    Dim l_nPrevProblemID, l_nPrevUserID, l_nPrevComputerID, l_bHandleIt, l_sBusinessApplicationName
    Dim l_objT911Alarm
    
    l_nPrevProblemID = -1
    l_nPrevUserID = 0
    l_nPrevComputerID = 0
    
    l_sBusinessApplicationName = ResSet.CommonProp.Attrib("BusinessApplicationName").Value

    If Not l_objRecordset.BOF Then
        Do While Not l_objRecordset.EOF
            l_dtReceiveTime       = l_objRecordset.Fields(0).Value
            l_nProblemID          = l_objRecordset.Fields(1).Value
            l_sAppProcessName     = l_objRecordset.Fields(2).Value
            l_sProblemStatus      = l_objRecordset.Fields(3).Value
            l_sProblemDescription = l_objRecordset.Fields(4).Value
            l_sDomain             = l_objRecordset.Fields(5).Value
            l_sAccount            = l_objRecordset.Fields(6).Value
            l_sDepName            = l_objRecordset.Fields(7).Value
            l_sComputerName       = l_objRecordset.Fields(8).Value
            l_nUserID             = l_objRecordset.Fields(9).Value
            l_nComputerID         = l_objRecordset.Fields(10).Value
            l_sAppActiveWndName   = l_objRecordset.Fields(11).Value
            
            If l_dtReceiveTime > l_dtNewLastHelpMeMsgTime Then
                l_dtNewLastHelpMeMsgTime = l_dtReceiveTime
            End If
            
            l_bAppComparedOk = False
            
            For i = 0 To UBound(g_ProcessNameArr)
                If StrComp(g_ProcessNameArr(i), l_sAppProcessName, 1) = 0 Then
                    l_bAppComparedOk = True
                    Exit For
                End If
            Next
            
            If l_bAppComparedOk = True Then
                l_bHandleIt = False
                
                If l_nProblemID <> l_nPrevProblemID Then
                    l_bHandleIt = True
                End If
                
                If l_bHandleIt = False Then
                    If l_nUserID <> l_nPrevUserID Then
                        l_bHandleIt = True
                    End If
                End If
                
                If l_bHandleIt = False Then
                    If l_nComputerID <> l_nPrevComputerID Then
                        l_bHandleIt = True
                    End If
                End If
                
                If l_bHandleIt Then
                    Select Case l_nProblemID
                        Case 0
                            ' Сервис работает слишком медленно
                            l_SPN = l_SPN + 1
                        Case 1
                            ' Сервис не доступен
                            l_SANna = l_SANna + 1
                        Case 2
                            ' Сервис доступен
                            l_SANa = l_SANa + 1
                    End Select
                    
                    If UBound(g_ConsoleArr) >= 0 Then
                        'Отправляем T-911
                        Set l_objT911Alarm = New c911Help
                        
                        Select Case l_nProblemID
                            Case 0
                                ' Сервис работает слишком медленно
                                l_objT911Alarm.Severity = g_SEVERITY_WARNING
                            Case 1
                                ' Сервис не доступен
                                l_objT911Alarm.Severity = g_SEVERITY_ERROR
                            Case 2
                                ' Сервис доступен
                                l_objT911Alarm.Severity = g_SEVERITY_INFO
                        End Select
                        
                        l_objT911Alarm.Severity = l_objT911Alarm.Severity + g_FLAG_NO_911_MAP + g_FLAG_FROM_TEST + g_FLAG_USERNAME_IN_LH_ADDRESS + g_FLAG_NO_LH_ADDRESS
                        l_objT911Alarm.Source = "SLA-ON PROBE Basic Health Test for Business Application"
                        l_objT911Alarm.Reason = l_sProblemStatus
                        
                        l_objT911Alarm.LHAAddress = l_sBusinessApplicationName
                        l_objT911Alarm.Description = l_sProblemDescription
                        l_objT911Alarm.AddInfo = "Заголовок окна приложения: " & l_sAppActiveWndName
                        l_objT911Alarm.AcceptTime = 0
                        l_objT911Alarm.CompleteTime = 0
                        l_objT911Alarm.PortReceiving = ResSet.CommonProp.Attrib("PortReceiving").Value
                        l_objT911Alarm.ClientAddress = l_sComputerName & "/" & l_sDomain & "\" & l_sAccount

                        For i = 0 To UBound(g_ConsoleArr)
                            If g_ConsoleArr(i) <> "" Then
                                l_objT911Alarm.OperationAddr = g_ConsoleArr(i)
                                Call l_objT911Alarm.Send911Message(0)
                            End If
                        Next
                        
                    End If
                End If
                
                l_nPrevProblemID = l_nProblemID
                l_nPrevUserID = l_nUserID
                l_nPrevComputerID = l_nComputerID
            End If
            
            l_objRecordset.MoveNext
        Loop
    End If
    
    dtLastHelpMeMsgTime = l_dtNewLastHelpMeMsgTime
    
    g_snaCount = g_snaCount + l_SANna - l_SANa
    
    If g_snaCount < 0 Then
        g_snaCount = 0
    End If
    
    ResSet.Events("SAN").Value = g_snaCount
    If l_SANna > 0 Then
        ResSet.Events("SAB").Value = 1
    Else
        ResSet.Events("SAB").Value = 0
    End If
    
    ResSet.Events("SPN").Value = l_SPN
    If l_SPN > 0 Then
        ResSet.Events("SPB").Value = 1
    Else
        ResSet.Events("SPB").Value = 0
    End If
    
    If l_TotalActiveUserCount > 0 Then
        ResSet.Events("SAP").Value = Round (g_snaCount * 100 / l_TotalActiveUserCount, 2)
        ResSet.Events("SPP").Value = Round (l_SPN * 100 / l_TotalActiveUserCount, 2)
    Else
        ResSet.Events("SAP").Value = 0
        ResSet.Events("SPP").Value = 0
    End If
    
    ResSet.Events("ActiveUsersCount").Value = l_TotalActiveUserCount

    g_objConnection.Close
    Set g_objConnection = Nothing
    
    g_DbAvailability = 100
    
    ResSet.LogMsg("RequestToDb Exit")
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Class c911Help
    Private l_Severity, l_Source, l_Reason, l_RecepientCode, l_LHAAddress, l_Description, l_AddInfo, l_ScreenShotsOnConnect, l_ScreenShotsDuration, l_ScreenShotsRate, l_ShowScreen, l_AcceptTime, l_CompleteTime, l_ClientAddress
    Private l_objOperCommcat, l_objLog, l_OperationAddr, l_LastAlarmID, l_PortReceiving, l_ErrNumber, l_ErrDescription
	
    Private Function GetAlarmID
        Randomize
        GetAlarmID = Int((429496720 - 999) * Rnd + 1000)
    End Function

    Public Sub Send911AddInfo
        Err.Clear
        On Error Resume Next

        Call l_objOperCommcat.OperCommcat911AddInfo ( _
            l_LastAlarmID, _
            l_AddInfo, _
            l_ClientAddress, _
            1)

        l_ErrNumber = Err.Number
        l_ErrDescription = Err.Description
    End Sub
	
    Public Function Send911Message (ByVal l_AlarmID)
        If l_AlarmID = 0 Then l_AlarmID = GetAlarmID
		
        Err.Clear
        On Error Resume Next
        
        Call l_objOperCommcat.OperCommcat911Msg ( _ 
            l_Severity, _
            l_Source, _
            l_AlarmID, _
            l_Reason, _    
            l_RecepientCode, _
            l_LHAAddress, _
            l_Description, _
            l_AddInfo, _
            l_ScreenShotsOnConnect, _
            l_ScreenShotsDuration, _
            l_ScreenShotsRate, _
            l_ShowScreen, _
            l_AcceptTime, _
            l_CompleteTime, _
            l_ClientAddress, _
            1)
		
        l_ErrNumber = Err.Number
        l_ErrDescription = Err.Description

        l_LastAlarmID = l_AlarmID
        Send911Message = l_AlarmID
    End Function
    
    Private Sub Class_Initialize   ' Setup Initialize event.
        Set l_objOperCommcat = CreateObject("PLOperCommcatRemoteComponent.PLOperCommcatRemote")

        l_OperationAddr = "localhost"
        l_Severity = 1
        l_Source = ""
        l_Reason = ""
        l_RecepientCode = 0
        l_LHAAddress = ""
        l_Description = ""
        l_AddInfo = ""
        l_ScreenShotsOnConnect = False
        l_ScreenShotsDuration = 1
        l_ScreenShotsRate = 30
        l_ShowScreen = True
        l_AcceptTime = 5
        l_CompleteTime = 10
        l_ClientAddress = ""
        l_PortReceiving = 7002
        l_ErrNumber = 0
        l_ErrDescription = ""

    End Sub

    Private Sub Class_Terminate   ' Setup Terminate event.
        Set l_objOperCommcat = Nothing
    End Sub
	
    Public Property Get PortReceiving
        PortReceiving = l_PortReceiving
    End Property
    
    Public Property Let PortReceiving(ByVal lValue)
        l_PortReceiving = lValue
        l_objOperCommcat.OperCommcatAccessorPort = l_PortReceiving
    End Property

    Public Property Get ErrDescription
        ErrDescription = l_ErrDescription
    End Property 

    Public Property Get ErrNumber
        ErrNumber = l_ErrNumber
    End Property 

    Public Property Get LastAlarmID
        LastAlarmID = l_LastAlarmID
    End Property 

    Public Property Get Severity
        Severity = l_Severity
    End Property
    
    Public Property Let Severity(ByVal lValue)
        l_Severity = lValue
    End Property

    Public Property Get Source
        Source = l_Source
    End Property
    
    Public Property Let Source(ByVal lValue)
        l_Source = lValue
    End Property

    Public Property Get Reason
        Reason = l_Reason
    End Property
    
    Public Property Let Reason(ByVal lValue)
        l_Reason = lValue
    End Property

    Public Property Get RecepientCode
        RecepientCode = l_RecepientCode
    End Property
    
    Public Property Let RecepientCode(ByVal lValue)
        l_RecepientCode = lValue
    End Property

    Public Property Get LHAAddress
        LHAAddress = l_LHAAddress
    End Property
    
    Public Property Let LHAAddress(ByVal lValue)
        l_LHAAddress = lValue
    End Property

    Public Property Get Description
        Description = l_Description
    End Property
    
    Public Property Let Description(ByVal lValue)
        l_Description = lValue
    End Property

    Public Property Get AddInfo
        AddInfo = l_AddInfo
    End Property
    
    Public Property Let AddInfo(ByVal lValue)
        l_AddInfo = lValue
    End Property

    Public Property Get ScreenShotsOnConnect
        ScreenShotsOnConnect = l_ScreenShotsOnConnect
    End Property
    
    Public Property Let ScreenShotsOnConnect(ByVal lValue)
        l_ScreenShotsOnConnect = lValue
    End Property

    Public Property Get ScreenShotsDuration
        ScreenShotsDuration = l_ScreenShotsDuration
    End Property
    
    Public Property Let ScreenShotsDuration(ByVal lValue)
        l_ScreenShotsDuration = lValue
    End Property

    Public Property Get ScreenShotsRate
        ScreenShotsRate = l_ScreenShotsRate
    End Property
    
    Public Property Let ScreenShotsRate(ByVal lValue)
        l_ScreenShotsRate = lValue
    End Property

    Public Property Get ShowScreen
        ShowScreen = l_ShowScreen
    End Property
    
    Public Property Let ShowScreen(ByVal lValue)
        l_ShowScreen = lValue
    End Property

    Public Property Get AcceptTime
        AcceptTime = l_AcceptTime
    End Property
    
    Public Property Let AcceptTime(ByVal lValue)
        l_AcceptTime = lValue
    End Property

    Public Property Get CompleteTime
        CompleteTime = l_CompleteTime
    End Property
    
    Public Property Let CompleteTime(ByVal lValue)
        l_CompleteTime = lValue
    End Property

    Public Property Get ClientAddress
        ClientAddress = l_ClientAddress
    End Property
    
    Public Property Let ClientAddress(ByVal lValue)
        l_ClientAddress = lValue
    End Property

    Public Property Get OperationAddr
        OperationAddr = l_OperationAddr
    End Property
    
    Public Property Let OperationAddr(ByVal lValue)
        l_OperationAddr = lValue
        l_objOperCommcat.OperCommcatAccessorAddress = l_OperationAddr
    End Property
End Class

-->
</Script>
    </xTest>
</document>
