<?xml version="1.0" encoding="windows-1251"?>
<document type="SelFTrendxTest" version="0.0" xmlns:m="xTest">
     <xTest type="USER_SCRIPT" alias="EventLog Mon With T-911" 
            TitleRus="Тест контроля записей в MS Windows Event Log с отсылкой T-911"
            TitleRootRus="Тесты соблюдения политик управления ресурсами MS Windows" 
            TitleEng="MS Windows Event Log Monitoring and T-911 Sending Test" 
            TitleRootEng="MS Windows Policy Violation Tests"
            TrafficLightsName="MS Windows Event Log Monitoring Test"
            Version="1.4">
	<Files>
		<File type="conf" name="VB.WP.EventLogMonWithT911.XFiles.xml"/>
		<File type="help" name="VB.WP.EventLogMonWithT911.XFiles.chm::/VB.WP.EventLogMonWithT911.XFiles.html"/>
		<File type="dll" name="ST_SCTest.dll"/>
	</Files>
  <Keywords>
   <Keyword>Windows</Keyword>
   <Keyword>WMI</Keyword>
   <Keyword>Event Log</Keyword>
   <Keyword>ProLAN-911</Keyword>
  </Keywords>

  <xTestProps>
        <log_level_def>0</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="Servers List:">
        <resources>
           <resource_id TitleRus="Имя Windows компьютера" TitleEng="Name"></resource_id>
        </resources>

      <common_attribs TitleRus="Список параметров (общие):" TitleEng="Parameters List (common):" SubTitleRus="Параметр" SubTitleEng="Parameter">
        <!-- Type: "String", "Bool", "Integer", "Double" -->

        <Attrib Type="String" TitleRus="Пороги метрики 'Information Events' (через ;)" TitleEng="Tresholds for 'Information Events' (; separated)" Alias="Thrld.InformationEvents">"1000;1000;1000;0"</Attrib>
        <Attrib Type="String" TitleRus="Пороги метрики 'Warning Events' (через ;)" TitleEng="Tresholds for 'Warning Events' (; separated)" Alias="Thrld.WarningEvents">"1000;1000;0;0"</Attrib>
        <Attrib Type="String" TitleRus="Пороги метрики 'Error Events' (через ;)" TitleEng="Tresholds for 'Error Events' (; separated)" Alias="Thrld.ErrorEvents">"0;0;0;0"</Attrib>
        <Attrib Type="String" TitleRus="Имя или IP-адреса компьютера с коллектором сообщений 911Help" TitleEng="Name or IP-address of 911Help Collector" Alias="ConsoleAddress">"localhost"</Attrib>
        <Attrib Type="String" TitleRus="Порт службы приема сообщений 911Help" TitleEng="911Help Receiving Service Port" Alias="PortReceiving">"7002"</Attrib>
      </common_attribs>

      <resource_attribs TitleRus="Список параметров:" TitleEng="Parameters List:" SubTitleRus="Параметр" SubTitleEng="Parameter" >
            <!-- Type: "String", "Bool", "Integer", "Double" -->
        <Attrib Type="Enum" TitleRus="Тип аутентификации" TitleEng="Type of authentication" Alias="Auth">
          <Attrib_enum TitleRus="Использовать встроенную систему безопасности Windows NT" TitleEng="Use Windows NT Integrated security" Selected="Yes">"1"</Attrib_enum>
          <Attrib_enum TitleRus="Использовать заданные имя пользователя и пароль" TitleEng="Use a specific user name and password" Selected="No">"2"</Attrib_enum>
        </Attrib>
        <Attrib Type="String" TitleRus="Имя пользователя" TitleEng="Username" Alias="User">user</Attrib>
        <Attrib Type="SecureString" TitleRus="Пароль" TitleEng="Password" Alias="Pass">pass</Attrib>
        <Attrib Type="String" TitleRus="Список имен журналов (через ;)" TitleEng="Log Name List (; separated)" Alias="LogName_list">"Application;System"</Attrib>
        <Attrib Type="String" TitleRus="Список имен источников (через ;)" TitleEng="Source Name List (; separated)" Alias="Source_list">*</Attrib>
        <Attrib Type="Bool" TitleRus="Отправлять сообщения T-911 по событиям типа 'Информация'" TitleEng="Send T-911 Alarm by 'Information' Type Event" Alias="SendAlarmByInfoTypeEvent">"Yes"</Attrib>
      </resource_attribs>
    </parameters>

    <popupdisplay>
    	<!-- function: "EventCount", "Average", "Maximum", "Minimum" -->
	    <description ru="Мониторинг журналов событий Windows с отсылкой оповещений T-911" en="Windows Event Logs Monitoring and T-911 Alarms Sendind"></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

Dim g_objLocalWMIService	' Постоянный объект - локальный WMI сервис
Dim g_IsWinXP				' Тип ОС на машине (true - Windows XP и выше)

Sub OnDiscovery(ByRef ResSet)
    Dim ResCount, i, CompName, Auth, User, Pass, Unid
    Dim SLAEventName, SLAAliasName, Error, TLError, l_strTLName_ru, l_strTLName_en
    Dim l_arrThrld, l_arrSources, l_ArrLogNames
    
    On Error Resume Next
    'stop
    Err.Clear
	
    ResSet.LogMsg("*** Start Sub OnDiscovery ***")
    ResSet.SendProgressMessage("Start Script")
    ResCount=ResSet.Count
    Unid = ResSet.UnidBase
    ResSet.LogMsg("ResSet.Count: " & ResSet.Count & " ResSet.UnidBase: " & ResSet.UnidBase)
    ResSet.LogMsg("ResSet.CommonProp.Attrib ConsoleAddress: " & ResSet.CommonProp.Attrib("ConsoleAddress").Value)

    For i=0 To ResCount - 1
        Dim l_ObjWMIService, l_ObjLocator
        
        CompName=ResSet.Resource(i).Name
        ResSet.SendProgressMessage("Check: " & CompName & ". Just a second, please...")
        Auth = ResSet.Resource(i).Attrib("Auth").Value
        User = ResSet.Resource(i).Attrib("User").Value
        Pass = ResSet.Resource(i).Attrib("Pass").Value
        
        If Auth = "1" Then
            Set l_ObjWMIService = GetObject("WinMgmts:\\" & CompName & "\root\CIMV2") 
        Else
            Set l_ObjLocator = CreateObject("WbemScripting.SWbemLocator")
            Set l_ObjWMIService = l_ObjLocator.ConnectServer (CompName, "", User, Pass)
        End If
        
        If Err.Number <> 0 Then
            ResSet.ScriptError = -1
            ResSet.ScriptErrorInfo = "Ошибка при запуске теста. Нет возможности работать с устройством: '" & CompName & "'. Подробности в файле: xfiles_log.txt"
            ResSet.LogMsg ("*** Start Description Error ***")
            ResSet.LogMsg ("Computer name: " & CompName)
            ResSet.LogMsg ("Error number: " & Err.Number)
            ResSet.LogMsg ("Error Description: " & Err.Description)
            ResSet.LogMsg ("*** End Description Error ***")
            Exit Sub
        End If
        
        ' Проверить список имен источников
        l_arrSources = GetArrSplited(ResSet.Resource(i).Attrib("Source_list").Value, CompName, "Cпиcка имен источников")
        If Not IsArray(l_arrSources) Then
		        ResSet.ScriptError = 3
		        ResSet.ScriptErrorInfo = l_arrSources
		        Exit Sub
        End If
        
        ' Проверить список имен журналов
        l_ArrLogNames = GetArrSplited(ResSet.Resource(i).Attrib("LogName_list").Value, CompName, "Cпиcка имен журналов")
        If Not IsArray(l_ArrLogNames) Then
		        ResSet.ScriptError = 3
		        ResSet.ScriptErrorInfo = l_ArrLogNames
		        Exit Sub
        End If
        
        ' Availability(%)
        SLAEventName = "[" & UCase(CompName) & "] Availability(%)"
        SLAAliasName = "Availability_" &  UCase(CompName)
        Error = ResSet.EventAdd(SLAEventName, SLAAliasName, Unid)
        Unid = Unid + 1
        l_strTLName_ru = SLAEventName
        l_strTLName_en = SLAEventName
        TLError = ResSet.AddTrafficLight(SLAAliasName, l_strTLName_ru, l_strTLName_en, "Average", "<", 50, 70, 80, 99)
        
        ' Information Events
        SLAEventName = "[" & UCase(CompName) & "] Information Events"
        SLAAliasName = "InformationEvents_" &  UCase(CompName)
        Error = ResSet.EventAdd(SLAEventName, SLAAliasName, Unid)
        Unid = Unid + 1
        l_arrThrld = GetThresholdForTL(ResSet.CommonProp.Attrib("Thrld.InformationEvents").Value)
        If IsArray(l_arrThrld) Then
            l_strTLName_ru = SLAEventName
            l_strTLName_en = SLAEventName
            TLError = ResSet.AddTrafficLight(SLAAliasName, l_strTLName_ru, l_strTLName_en, "Average", ">", l_arrThrld(0), l_arrThrld(1), l_arrThrld(2), l_arrThrld(3))
        Else
		        ResSet.ScriptError = 3
		        ResSet.ScriptErrorInfo = "Пороговые значения для Thrld.InformationEvents в свойствах теста указаны не верно! Проверьте настройки и повторите запуск тестов."
		        Exit Sub
        End If
        
        ' Warning Events
        SLAEventName = "[" & UCase(CompName) & "] Warning Events"
        SLAAliasName = "WarningEvents_" &  UCase(CompName)
        Error = ResSet.EventAdd(SLAEventName, SLAAliasName, Unid)
        Unid = Unid + 1
        l_arrThrld = GetThresholdForTL(ResSet.CommonProp.Attrib("Thrld.WarningEvents").Value)
        If IsArray(l_arrThrld) Then
            l_strTLName_ru = SLAEventName
            l_strTLName_en = SLAEventName
            TLError = ResSet.AddTrafficLight(SLAAliasName, l_strTLName_ru, l_strTLName_en, "Average", ">", l_arrThrld(0), l_arrThrld(1), l_arrThrld(2), l_arrThrld(3))
        Else
		        ResSet.ScriptError = 3
		        ResSet.ScriptErrorInfo = "Пороговые значения для Thrld.WarningEvents в свойствах теста указаны не верно! Проверьте настройки и повторите запуск тестов."
		        Exit Sub
        End If
        
        ' Error Events
        SLAEventName = "[" & UCase(CompName) & "] Error Events"
        SLAAliasName = "ErrorEvents_" &  UCase(CompName)
        Error = ResSet.EventAdd(SLAEventName, SLAAliasName, Unid)
        Unid = Unid + 1
        l_arrThrld = GetThresholdForTL(ResSet.CommonProp.Attrib("Thrld.ErrorEvents").Value)
        If IsArray(l_arrThrld) Then
            l_strTLName_ru = SLAEventName
            l_strTLName_en = SLAEventName
            TLError = ResSet.AddTrafficLight(SLAAliasName, l_strTLName_ru, l_strTLName_en, "Average", ">", l_arrThrld(0), l_arrThrld(1), l_arrThrld(2), l_arrThrld(3))
        Else
		        ResSet.ScriptError = 3
		        ResSet.ScriptErrorInfo = "Пороговые значения для Thrld.ErrorEvents в свойствах теста указаны не верно! Проверьте настройки и повторите запуск тестов."
		        Exit Sub
        End If
    Next
    
    ResSet.LogMsg("*** End Sub OnDiscovery ***")
    
End Sub

Sub OnDataReceived(ByRef ResSet)
    Dim dtNowTime, ResCount, i, CompName, j
    Dim arr_objService(), l_ArrLogNames, l_strLogFileWhere, strSelect
    Dim InformationEvents, WarningEvents, ErrorEvents
    Dim l_strSLAAliasName, l_strLogMsg, Auth, User, Pass
    Dim l_arrSources, l_strSourceNameWhere, l_ToSendT911
	
    On Error Resume Next
    'stop
    dtNowTime = Now - 1.0/1140.0
	
    Err.Clear

    Set g_objLocalWMIService = GetObject("WinMgmts:\\.\root\CIMV2")
    
    g_IsWinXP = True
    If PingStatus("localhost") Then
        g_IsWinXP = True
    Else
        g_IsWinXP = False
    End If
	
    ResSet.LogMsg("*** Start Sub OnDataReceived ***")

    ResCount=ResSet.Count
    ' 0 - время последнего запроса, 1 - строка запроса для каждого компьютера
    ReDim arr_objService ((ResCount-1),1)

    For i=0 To ResCount - 1
        arr_objService(i,0) = MkDateTimeToWMI(dtNowTime)
        
        l_ArrLogNames = GetArrSplited(ResSet.Resource(i).Attrib("LogName_list").Value, CompName, "Cпиcка имен журналов")
        
        l_strLogFileWhere = ""
        If l_ArrLogNames(0) <> "*" Then
            For j = LBound(l_ArrLogNames) To UBound(l_ArrLogNames)
                If l_strLogFileWhere = "" Then
                    l_strLogFileWhere = "LogFile='" & l_ArrLogNames(j) & "'"
                Else
                    l_strLogFileWhere = l_strLogFileWhere & " or LogFile='" & l_ArrLogNames(j) & "'"
                End If
            Next
        End If

        l_arrSources = GetArrSplited(ResSet.Resource(i).Attrib("Source_list").Value, CompName, "Cпиcка имен источников")
        l_strSourceNameWhere = ""
        
        If l_arrSources(0) <> "*" Then
            For j = LBound(l_arrSources) To UBound(l_arrSources)
                If l_strSourceNameWhere = "" Then
                    l_strSourceNameWhere = "SourceName='" & l_arrSources(j) & "'"
                Else
                    l_strSourceNameWhere = l_strSourceNameWhere & " or SourceName='" & l_arrSources(j) & "'"
                End If
            Next
        End If

        strSelect = "Select Logfile, ComputerName, Type, EventType, Message, SourceName, User, TimeGenerated from Win32_NTLogEvent Where (EventType=1 or EventType=2 or EventType=3) "
        
        If l_strLogFileWhere<> "" Then
            strSelect = strSelect & " And (" & l_strLogFileWhere & ")"
        End If

        If l_strSourceNameWhere <> "" Then
            strSelect = strSelect & " And (" & l_strSourceNameWhere & ")"
        End If
        
        strSelect = strSelect & " And TimeGenerated > '"
        arr_objService(i,1) = strSelect
        
        ResSet.LogMsg ("arr_objService(i,0)='" & arr_objService(i,0) & "'")		
        ResSet.LogMsg ("arr_objService(i,1)='" & strSelect & "'")		
    Next
	
    Do While Not ResSet.StopTest
        If ResSet.IsNewSLaPeriod Then
            ResSet.LogMsg ( Timer & ": " & "Start While Loop")
            
            ResetEvents ResSet
            
            For i=0 To ResCount - 1
                Dim l_objWMIService, l_ObjLocator, colEvents, objEvent, l_objT911Alarm
                
                Err.Clear
                CompName=ResSet.Resource(i).Name
                
                InformationEvents = 0
                WarningEvents = 0
                ErrorEvents = 0
              
                If PingStatus(CompName) Then
                    l_strSLAAliasName = "Availability_" &  UCase(CompName)              
                    ResSet.Events(l_strSLAAliasName).Value = 100.0

                    Auth = ResSet.Resource(i).Attrib("Auth").Value
                    User = ResSet.Resource(i).Attrib("User").Value
                    Pass = ResSet.Resource(i).Attrib("Pass").Value
        
                    If Auth = "1" Then
                        Set l_ObjWMIService = GetObject("WinMgmts:\\" & CompName & "\root\CIMV2") 
                    Else
                        Set l_ObjLocator = CreateObject("WbemScripting.SWbemLocator")
                        Set l_ObjWMIService = l_ObjLocator.ConnectServer (CompName, "", User, Pass)
                    End If

                    strSelect = arr_objService(i,1) & arr_objService(i,0) & "'"

                    Set colEvents = l_ObjWMIService.ExecQuery (strSelect,,32)
                    
                    If Err.Number <> 0 Then
                        ResSet.LogMsg ("*** Start Description Error ***")
                        ResSet.LogMsg ("Computer name: " & CompName)
                        ResSet.LogMsg ("Error number: " & Err.Number)
                        ResSet.LogMsg ("Error Description: " & Err.Description)
                        ResSet.LogMsg ("*** End Description Error ***")
                    Else
                        For Each objEvent In colEvents
                            If (Err.Number <> 0) Then
                                Err.Clear
                                Exit For
                            End If
                            
                            l_ToSendT911 = False

                            Select Case objEvent.EventType
                                Case 3
                                    InformationEvents = InformationEvents + 1
                                    If ResSet.Resource(i).Attrib("SendAlarmByInfoTypeEvent").Value = True Then
                                        l_ToSendT911 = True
                                    End If
                                Case 2
                                    WarningEvents = WarningEvents + 1
                                    l_ToSendT911 = True
                                Case 1
                                    ErrorEvents = ErrorEvents + 1
                                    l_ToSendT911 = True
                            End Select

                            ResSet.LogMsg ("*********************")
                            ResSet.LogMsg ("Record Time: " & Now)
                            ResSet.LogMsg ("ComputerName: " & objEvent.ComputerName)
                            ResSet.LogMsg ("Type: " & objEvent.Type)
                            ResSet.LogMsg ("TimeGenerated: " & objEvent.TimeGenerated & " - " & MkDateTimeFromWMI(objEvent.TimeGenerated))
                            ResSet.LogMsg ("SourceName: " & objEvent.SourceName)
                            ResSet.LogMsg ("Message: " & objEvent.Message)
                            ResSet.LogMsg ("*********************")

                            If arr_objService(i,0) < objEvent.TimeGenerated Then
                                arr_objService(i,0) = objEvent.TimeGenerated
                            End If
                            
                            If l_ToSendT911 Then
                                ' Отправляем T-911
                                Set l_objT911Alarm = New c911Help
                                
                                Select Case objEvent.EventType
                                    Case 3
                                        l_objT911Alarm.Severity = g_SEVERITY_INFO
                                    Case 2
                                        l_objT911Alarm.Severity = g_SEVERITY_WARNING
                                    Case 1
                                        l_objT911Alarm.Severity = g_SEVERITY_ERROR
                                End Select
                                
                                l_objT911Alarm.Severity = l_objT911Alarm.Severity + g_FLAG_NO_911_MAP + g_FLAG_FROM_TEST
                                
                                l_objT911Alarm.LHAAddress = objEvent.ComputerName
                                l_objT911Alarm.ClientAddress = CompName
                                
                                If Not IsEmpty(objEvent.User) And Not IsNull(objEvent.User) Then
                                    If objEvent.User <> "" Then
                                        l_objT911Alarm.ClientAddress = l_objT911Alarm.ClientAddress & "/" & objEvent.User
                                        l_objT911Alarm.Severity = l_objT911Alarm.Severity + g_FLAG_USERNAME_IN_LH_ADDRESS
                                    End If
                                End If
                                
                                l_objT911Alarm.Source = "MS Windows Event Log Monitoring"
                                l_objT911Alarm.Reason = "Windows LogFile: '" & objEvent.Logfile & "', Event Source: '" & objEvent.SourceName & "'"
                                l_objT911Alarm.Description = MkDateTimeFromWMI(objEvent.TimeGenerated) & VbCrLf & objEvent.Message
                                l_objT911Alarm.AcceptTime = 0
                                l_objT911Alarm.CompleteTime = 0
                                l_objT911Alarm.OperationAddr = ResSet.CommonProp.Attrib("ConsoleAddress").Value
                                l_objT911Alarm.PortReceiving = ResSet.CommonProp.Attrib("PortReceiving").Value
                                

                                Call l_objT911Alarm.Send911Message (0)

                            End If
                        Next
                        
                        l_strSLAAliasName = "InformationEvents_" &  UCase(CompName)
                        ResSet.Events(l_strSLAAliasName).Value = InformationEvents
                               
                        l_strSLAAliasName = "WarningEvents_" &  UCase(CompName)
                        ResSet.Events(l_strSLAAliasName).Value = WarningEvents

                        l_strSLAAliasName = "ErrorEvents_" &  UCase(CompName)
                        ResSet.Events(l_strSLAAliasName).Value = ErrorEvents
                        
                    End If
                Else
                    '//Availability 
                    l_strSLAAliasName = "Availability_" &  UCase(CompName)
                    ResSet.Events(l_strSLAAliasName).Value = 0
                    l_strLogMsg = "OnDataReceived: " & CompName  & "Error: " &  Err.Description & "(" & Err.Number & ")"
                    ResSet.LogMsg(l_strLogMsg)
                End If
            Next

            ResSet.SendSLaEvents()
        End If
        
        ResSet.Sleep(1000)
    Loop
    
End Sub

''''''''''''''''''''''''''''''''''''''''''''''

Function MkDateTimeFromWMI( strDateTime )
    ' Convert 2002 07 15 14 23 00.000000+120) style to datetime style
    Dim dtYear, dtMonth, dtDay, tmHour, tmMin, tmSec, val
    
    dtYear  = Mid( strDateTime, 1, 4 )
    dtMonth = Mid( strDateTime, 5, 2 )
    dtDay   = Mid( strDateTime, 7, 2 )	
    tmHour  = Mid( strDateTime, 9, 2 )
    tmMin   = Mid( strDateTime, 11, 2 )
    tmSec   = Mid( strDateTime, 13, 2 )
    val     = DateSerial( dtYear,dtMonth,dtDay)
    val     = DateAdd( "h", tmHour, val )
    val     = DateAdd( "n", tmMin, val )
    val     = DateAdd( "s", tmSec, val )
    MkDateTimeFromWMI = val
End Function

''''''''''''''''''''''''''''''''''''''''''''''

Function MkDateTimeToWMI( strDateTime )
    Dim dateTime
    Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
    dateTime.SetVarDate(strDateTime)
    
    MkDateTimeToWMI=CStr(dateTime)
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function PingStatus ( strComputerName )
    ' True если компьютер отвечает на ping
    
    Dim strSelect, cPingResults, oPingResult
    
    On Error Resume Next
	
    If Not g_IsWinXP Then
        PingStatus = True
        Exit Function
    End If

    strSelect="Select StatusCode from Win32_PingStatus Where Address='" & strComputerName & "'"
    Set cPingResults = g_objLocalWMIService.ExecQuery(strSelect)
	
    For Each oPingResult In cPingResults
        If Err.Number <> 0 Then
            Err.Clear
            PingStatus = False
            Exit Function
        End If
        If oPingResult.StatusCode = 0 Then
            PingStatus = True
        Else
            PingStatus = False
        End If
    Next
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Формирование массива из элемента строки,разделенного запятой
Function GetThresholdForTL(l_ThresholdString)       
    Dim arrTL, i
    arrTL = Split(l_ThresholdString, ";")
    If UBound(arrTL) <> 3 Then 
        GetThresholdForTL = "Данные не верны, проверьте правильность введенных пороговых значений в настройках теста - 1"
        Exit Function
    End If
	
    For i = LBound(arrTL) To UBound(arrTL)
        If Not IsNumeric (Trim(arrTL(i))) Then
            GetThresholdForTL = "Данные не верны, проверьте правильность введенных пороговых значений в настройках теста - 2"
            Exit Function
        End If
    Next
	
    GetThresholdForTL = arrTL
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function GetArrSplited(SourcesString, CompName, ParameterName)
    Dim arrSources, i
    arrSources = Split(SourcesString, ";")
    
    If UBound(arrSources) < 0 Then
        GetArrSplited = "Данные не верны, проверьте правильность " & ParameterName & "  для компьютера '" & CompName & "' в настройках теста."
        Exit Function
    End If
    
    For i = LBound(arrSources) To UBound(arrSources)
        arrSources(i) = Trim(arrSources(i))
    Next

    If arrSources(0) = "*" And UBound(arrSources) > 0 Then
       arrSources = Array(0)
       arrSources(0) = "*"
    End If

    GetArrSplited = arrSources
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub ResetEvents(ByRef ResSet) 
    Dim l_iIndx
    
    For l_iIndx = 0 To ResSet.EventsCount - 1
        ResSet.Events(l_iIndx).Value = ResSet.BadValue
    Next
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>
